remove sorting contacts by phone number

This commit is contained in:
tibbi 2017-12-17 23:35:12 +01:00
parent 449e487667
commit 592d4edc76
2 changed files with 8 additions and 10 deletions

View File

@ -3,7 +3,10 @@ package com.simplemobiletools.contacts.dialogs
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.SORT_BY_FIRST_NAME
import com.simplemobiletools.commons.helpers.SORT_BY_MIDDLE_NAME
import com.simplemobiletools.commons.helpers.SORT_BY_SURNAME
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.extensions.config import com.simplemobiletools.contacts.extensions.config
import kotlinx.android.synthetic.main.dialog_change_sorting.view.* import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
@ -31,8 +34,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val callback: () ->
val sortBtn = when { val sortBtn = when {
currSorting and SORT_BY_FIRST_NAME != 0 -> sortingRadio.sorting_dialog_radio_first_name currSorting and SORT_BY_FIRST_NAME != 0 -> sortingRadio.sorting_dialog_radio_first_name
currSorting and SORT_BY_MIDDLE_NAME != 0 -> sortingRadio.sorting_dialog_radio_middle_name currSorting and SORT_BY_MIDDLE_NAME != 0 -> sortingRadio.sorting_dialog_radio_middle_name
currSorting and SORT_BY_SURNAME != 0 -> sortingRadio.sorting_dialog_radio_surname else -> sortingRadio.sorting_dialog_radio_surname
else -> sortingRadio.sorting_dialog_radio_number
} }
sortBtn.isChecked = true sortBtn.isChecked = true
} }
@ -52,8 +54,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val callback: () ->
var sorting = when (sortingRadio.checkedRadioButtonId) { var sorting = when (sortingRadio.checkedRadioButtonId) {
R.id.sorting_dialog_radio_first_name -> SORT_BY_FIRST_NAME R.id.sorting_dialog_radio_first_name -> SORT_BY_FIRST_NAME
R.id.sorting_dialog_radio_middle_name -> SORT_BY_MIDDLE_NAME R.id.sorting_dialog_radio_middle_name -> SORT_BY_MIDDLE_NAME
R.id.sorting_dialog_radio_surname -> SORT_BY_SURNAME else -> SORT_BY_SURNAME
else -> SORT_BY_NUMBER
} }
if (view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) { if (view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {

View File

@ -2,7 +2,6 @@ package com.simplemobiletools.contacts.models
import com.simplemobiletools.commons.helpers.SORT_BY_FIRST_NAME import com.simplemobiletools.commons.helpers.SORT_BY_FIRST_NAME
import com.simplemobiletools.commons.helpers.SORT_BY_MIDDLE_NAME import com.simplemobiletools.commons.helpers.SORT_BY_MIDDLE_NAME
import com.simplemobiletools.commons.helpers.SORT_BY_SURNAME
import com.simplemobiletools.commons.helpers.SORT_DESCENDING import com.simplemobiletools.commons.helpers.SORT_DESCENDING
data class Contact(val id: Int, var firstName: String, var middleName: String, var surname: String, var photoUri: String, var number: String, data class Contact(val id: Int, var firstName: String, var middleName: String, var surname: String, var photoUri: String, var number: String,
@ -15,8 +14,7 @@ data class Contact(val id: Int, var firstName: String, var middleName: String, v
var result = when { var result = when {
sorting and SORT_BY_FIRST_NAME != 0 -> compareStrings(firstName, other.firstName) sorting and SORT_BY_FIRST_NAME != 0 -> compareStrings(firstName, other.firstName)
sorting and SORT_BY_MIDDLE_NAME != 0 -> compareStrings(middleName, other.middleName) sorting and SORT_BY_MIDDLE_NAME != 0 -> compareStrings(middleName, other.middleName)
sorting and SORT_BY_SURNAME != 0 -> compareStrings(surname, other.surname) else -> compareStrings(surname, other.surname)
else -> compareStrings(number, other.number)
} }
if (sorting and SORT_DESCENDING != 0) { if (sorting and SORT_DESCENDING != 0) {
@ -29,8 +27,7 @@ data class Contact(val id: Int, var firstName: String, var middleName: String, v
fun getBubbleText() = when { fun getBubbleText() = when {
sorting and SORT_BY_FIRST_NAME != 0 -> firstName sorting and SORT_BY_FIRST_NAME != 0 -> firstName
sorting and SORT_BY_MIDDLE_NAME != 0 -> middleName sorting and SORT_BY_MIDDLE_NAME != 0 -> middleName
sorting and SORT_BY_SURNAME != 0 -> surname else -> surname
else -> number
} }
fun getFullName(startWithSurname: Boolean): String { fun getFullName(startWithSurname: Boolean): String {