mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
some minor code cleanup
This commit is contained in:
@ -8,7 +8,6 @@ import android.os.Bundle
|
|||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import android.provider.ContactsContract.CommonDataKinds.Email
|
import android.provider.ContactsContract.CommonDataKinds.Email
|
||||||
import android.provider.ContactsContract.CommonDataKinds.Phone
|
import android.provider.ContactsContract.CommonDataKinds.Phone
|
||||||
import android.view.MenuItem
|
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
@ -35,8 +34,6 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
private val START_INSERT_ACTIVITY = 1
|
private val START_INSERT_ACTIVITY = 1
|
||||||
private val START_EDIT_ACTIVITY = 2
|
private val START_EDIT_ACTIVITY = 2
|
||||||
|
|
||||||
private var isSearchOpen = false
|
|
||||||
private var searchMenuItem: MenuItem? = null
|
|
||||||
private var isSelectContactIntent = false
|
private var isSelectContactIntent = false
|
||||||
private var specialMimeType: String? = null
|
private var specialMimeType: String? = null
|
||||||
|
|
||||||
@ -89,11 +86,6 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
setupTabColors()
|
setupTabColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
|
||||||
super.onStop()
|
|
||||||
searchMenuItem?.collapseActionView()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
insert_edit_menu.getToolbar().inflateMenu(R.menu.menu_insert_or_edit)
|
insert_edit_menu.getToolbar().inflateMenu(R.menu.menu_insert_or_edit)
|
||||||
insert_edit_menu.toggleHideOnScroll(false)
|
insert_edit_menu.toggleHideOnScroll(false)
|
||||||
@ -344,15 +336,6 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun closeSearch() {
|
|
||||||
if (isSearchOpen) {
|
|
||||||
getAllFragments().forEach {
|
|
||||||
it?.onSearchQueryChanged("")
|
|
||||||
}
|
|
||||||
searchMenuItem?.collapseActionView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showSortingDialog() {
|
private fun showSortingDialog() {
|
||||||
ChangeSortingDialog(this) {
|
ChangeSortingDialog(this) {
|
||||||
refreshContacts(getTabsMask())
|
refreshContacts(getTabsMask())
|
||||||
|
@ -513,7 +513,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
try {
|
try {
|
||||||
startActivityForResult(this, PICK_EXPORT_FILE_INTENT)
|
startActivityForResult(this, PICK_EXPORT_FILE_INTENT)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
toast(R.string.system_service_disabled, Toast.LENGTH_LONG)
|
toast(R.string.no_app_found, Toast.LENGTH_LONG)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ class ContactsAdapter(
|
|||||||
private val enableDrag: Boolean = false,
|
private val enableDrag: Boolean = false,
|
||||||
itemClick: (Any) -> Unit
|
itemClick: (Any) -> Unit
|
||||||
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate, ItemTouchHelperContract {
|
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate, ItemTouchHelperContract {
|
||||||
|
|
||||||
private val NEW_GROUP_ID = -1
|
private val NEW_GROUP_ID = -1
|
||||||
|
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
@ -64,12 +65,11 @@ class ContactsAdapter(
|
|||||||
var showContactThumbnails = config.showContactThumbnails
|
var showContactThumbnails = config.showContactThumbnails
|
||||||
var showPhoneNumbers = config.showPhoneNumbers
|
var showPhoneNumbers = config.showPhoneNumbers
|
||||||
var fontSize = activity.getTextSize()
|
var fontSize = activity.getTextSize()
|
||||||
|
var onDragEndListener: (() -> Unit)? = null
|
||||||
|
|
||||||
private val itemLayout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
|
private val itemLayout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
|
||||||
|
|
||||||
private var touchHelper: ItemTouchHelper? = null
|
private var touchHelper: ItemTouchHelper? = null
|
||||||
private var startReorderDragListener: StartReorderDragListener? = null
|
private var startReorderDragListener: StartReorderDragListener? = null
|
||||||
var onDragEndListener: (() -> Unit)? = null
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupDragListener(true)
|
setupDragListener(true)
|
||||||
|
@ -78,17 +78,6 @@ class SelectContactsAdapter(
|
|||||||
|
|
||||||
override fun getItemCount() = contacts.size
|
override fun getItemCount() = contacts.size
|
||||||
|
|
||||||
fun updateItems(newItems: ArrayList<Contact>, highlightText: String = "") {
|
|
||||||
if (newItems.hashCode() != contacts.hashCode()) {
|
|
||||||
contacts = newItems.clone() as ArrayList<Contact>
|
|
||||||
textToHighlight = highlightText
|
|
||||||
notifyDataSetChanged()
|
|
||||||
} else if (textToHighlight != highlightText) {
|
|
||||||
textToHighlight = highlightText
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewRecycled(holder: ViewHolder) {
|
override fun onViewRecycled(holder: ViewHolder) {
|
||||||
super.onViewRecycled(holder)
|
super.onViewRecycled(holder)
|
||||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||||
|
@ -35,7 +35,6 @@ class ExportContactsDialog(
|
|||||||
|
|
||||||
if (hidePath) {
|
if (hidePath) {
|
||||||
export_contacts_folder_hint.beGone()
|
export_contacts_folder_hint.beGone()
|
||||||
export_contacts_folder.beGone()
|
|
||||||
} else {
|
} else {
|
||||||
export_contacts_folder.setOnClickListener {
|
export_contacts_folder.setOnClickListener {
|
||||||
activity.hideKeyboard(export_contacts_filename)
|
activity.hideKeyboard(export_contacts_filename)
|
||||||
|
@ -9,7 +9,7 @@ import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
|||||||
import com.simplemobiletools.contacts.pro.adapters.SelectContactsAdapter
|
import com.simplemobiletools.contacts.pro.adapters.SelectContactsAdapter
|
||||||
import com.simplemobiletools.contacts.pro.extensions.getVisibleContactSources
|
import com.simplemobiletools.contacts.pro.extensions.getVisibleContactSources
|
||||||
import com.simplemobiletools.contacts.pro.models.Contact
|
import com.simplemobiletools.contacts.pro.models.Contact
|
||||||
import kotlinx.android.synthetic.main.layout_select_contact.view.*
|
import kotlinx.android.synthetic.main.dialog_select_contact.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class SelectContactsDialog(
|
class SelectContactsDialog(
|
||||||
@ -17,7 +17,7 @@ class SelectContactsDialog(
|
|||||||
selectContacts: ArrayList<Contact>? = null, val callback: (addedContacts: ArrayList<Contact>, removedContacts: ArrayList<Contact>) -> Unit
|
selectContacts: ArrayList<Contact>? = null, val callback: (addedContacts: ArrayList<Contact>, removedContacts: ArrayList<Contact>) -> Unit
|
||||||
) {
|
) {
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.layout_select_contact, null)
|
private var view = activity.layoutInflater.inflate(R.layout.dialog_select_contact, null)
|
||||||
private var initiallySelectedContacts = ArrayList<Contact>()
|
private var initiallySelectedContacts = ArrayList<Contact>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
Reference in New Issue
Block a user