diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt index a5b52ce0..8bbd46cd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/MainActivity.kt @@ -218,7 +218,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { private fun initFragments() { viewpager.adapter = ViewPagerAdapter(this) - viewpager.setOnPageChangeListener(object : ViewPager.OnPageChangeListener { + viewpager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { override fun onPageScrollStateChanged(state: Int) { if (isSearchOpen) { getCurrentFragment().onSearchQueryChanged("") diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/ContactsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/ContactsAdapter.kt index e2514ef6..fc72ab44 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/ContactsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/ContactsAdapter.kt @@ -27,8 +27,8 @@ import com.simplemobiletools.contacts.models.Contact import kotlinx.android.synthetic.main.item_contact_with_number.view.* import java.util.* -class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList, val listener: RefreshContactsListener?, - val isFavoritesFragment: Boolean, recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) : +class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList, private val listener: RefreshContactsListener?, + private val isFavoritesFragment: Boolean, recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { private lateinit var contactDrawable: Drawable diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/FilterContactSourcesAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/FilterContactSourcesAdapter.kt index 115eee3e..05bb831a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/FilterContactSourcesAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/FilterContactSourcesAdapter.kt @@ -12,7 +12,7 @@ import com.simplemobiletools.contacts.extensions.config import kotlinx.android.synthetic.main.item_filter_contact_source.view.* import java.util.* -class FilterContactSourcesAdapter(val activity: SimpleActivity, val contactSources: List, val displayContactSources: Set) : +class FilterContactSourcesAdapter(val activity: SimpleActivity, private val contactSources: List, private val displayContactSources: Set) : RecyclerView.Adapter() { private val itemViews = SparseArray() private val selectedPositions = HashSet() @@ -66,7 +66,7 @@ class FilterContactSourcesAdapter(val activity: SimpleActivity, val contactSourc override fun getItemCount() = contactSources.size - class ViewHolder(view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity) : RecyclerView.ViewHolder(view) { + class ViewHolder(view: View, private val adapterListener: MyAdapterListener, val activity: SimpleActivity) : RecyclerView.ViewHolder(view) { fun bindView(contactSource: String): View { itemView.apply { filter_contact_source_checkbox.setColors(activity.config.textColor, activity.getAdjustedPrimaryColor(), activity.config.backgroundColor) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/SelectContactsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/SelectContactsAdapter.kt index 68145cca..cc2d5058 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/SelectContactsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/SelectContactsAdapter.kt @@ -23,8 +23,8 @@ import com.simplemobiletools.contacts.models.Contact import kotlinx.android.synthetic.main.item_add_favorite_with_number.view.* import java.util.* -class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List, val selectedContacts: ArrayList, val allowPickMultiple: Boolean, - val itemClick: ((Contact) -> Unit)? = null) : RecyclerView.Adapter() { +class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List, private val selectedContacts: ArrayList, private val allowPickMultiple: Boolean, + private val itemClick: ((Contact) -> Unit)? = null) : RecyclerView.Adapter() { private val itemViews = SparseArray() private val selectedPositions = HashSet() private val config = activity.config @@ -86,8 +86,8 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List Unit)?) : RecyclerView.ViewHolder(view) { + class ViewHolder(view: View, private val adapterListener: MyAdapterListener, val activity: SimpleActivity, private val showCheckbox: Boolean, + private val itemClick: ((Contact) -> Unit)?) : RecyclerView.ViewHolder(view) { fun bindView(contact: Contact, startNameWithSurname: Boolean, contactDrawable: Drawable, config: Config, showContactThumbnails: Boolean, smallPadding: Int, bigPadding: Int): View { itemView.apply { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/AddFavoritesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/AddFavoritesDialog.kt index 884c8be9..c846d0fc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/AddFavoritesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/AddFavoritesDialog.kt @@ -11,7 +11,7 @@ import com.simplemobiletools.contacts.helpers.ContactsHelper import com.simplemobiletools.contacts.models.Contact import kotlinx.android.synthetic.main.layout_select_contact.view.* -class AddFavoritesDialog(val activity: SimpleActivity, val callback: () -> Unit) { +class AddFavoritesDialog(val activity: SimpleActivity, private val callback: () -> Unit) { private var dialog: AlertDialog? = null private var view = activity.layoutInflater.inflate(R.layout.layout_select_contact, null) private val config = activity.config diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ChangeSortingDialog.kt index c791ca61..22a63539 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ChangeSortingDialog.kt @@ -11,7 +11,7 @@ import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.extensions.config import kotlinx.android.synthetic.main.dialog_change_sorting.view.* -class ChangeSortingDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) { +class ChangeSortingDialog(val activity: BaseSimpleActivity, private val callback: () -> Unit) { private var currSorting = 0 private var config = activity.config private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ExportContactsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ExportContactsDialog.kt index 1df75ded..494ddf1a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ExportContactsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ExportContactsDialog.kt @@ -11,7 +11,7 @@ import com.simplemobiletools.contacts.helpers.ContactsHelper import kotlinx.android.synthetic.main.dialog_export_contacts.view.* import java.io.File -class ExportContactsDialog(val activity: SimpleActivity, val path: String, val callback: (file: File, contactSources: HashSet) -> Unit) { +class ExportContactsDialog(val activity: SimpleActivity, val path: String, private val callback: (file: File, contactSources: HashSet) -> Unit) { init { val view = (activity.layoutInflater.inflate(R.layout.dialog_export_contacts, null) as ViewGroup).apply { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/FilterContactSourcesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/FilterContactSourcesDialog.kt index c3f2d5c5..6a516e01 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/FilterContactSourcesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/FilterContactSourcesDialog.kt @@ -9,7 +9,7 @@ import com.simplemobiletools.contacts.extensions.config import com.simplemobiletools.contacts.helpers.ContactsHelper import kotlinx.android.synthetic.main.dialog_filter_contact_sources.view.* -class FilterContactSourcesDialog(val activity: SimpleActivity, val callback: () -> Unit) { +class FilterContactSourcesDialog(val activity: SimpleActivity, private val callback: () -> Unit) { private var dialog: AlertDialog? = null private val view = activity.layoutInflater.inflate(R.layout.dialog_filter_contact_sources, null) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ImportContactsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ImportContactsDialog.kt index fde2a6fa..a83c9f87 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ImportContactsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/ImportContactsDialog.kt @@ -13,7 +13,7 @@ import com.simplemobiletools.contacts.helpers.VcfImporter import com.simplemobiletools.contacts.helpers.VcfImporter.ImportResult.IMPORT_FAIL import kotlinx.android.synthetic.main.dialog_import_contacts.view.* -class ImportContactsDialog(val activity: SimpleActivity, val path: String, val callback: (refreshView: Boolean) -> Unit) { +class ImportContactsDialog(val activity: SimpleActivity, val path: String, private val callback: (refreshView: Boolean) -> Unit) { init { val view = (activity.layoutInflater.inflate(R.layout.dialog_import_contacts, null) as ViewGroup).apply { import_contacts_title.text = activity.config.lastUsedContactSource diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt index 755bfa8e..9bbcb459 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt @@ -3,50 +3,50 @@ package com.simplemobiletools.contacts.helpers import android.provider.ContactsContract.CommonDataKinds // shared prefs -val CALL_CONTACT_ON_CLICK = "call_contact_on_click" -val SHOW_CONTACT_THUMBNAILS = "show_contact_thumbnails" -val SHOW_PHONE_NUMBERS = "show_phone_numbers" -val DISPLAY_CONTACT_SOURCES = "display_contact_sources" -val START_NAME_WITH_SURNAME = "start_name_with_surname" -val LAST_USED_CONTACT_SOURCE = "last_used_contact_source" -val LAST_USED_VIEW_PAGER_PAGE = "last_used_view_pager_page" +const val CALL_CONTACT_ON_CLICK = "call_contact_on_click" +const val SHOW_CONTACT_THUMBNAILS = "show_contact_thumbnails" +const val SHOW_PHONE_NUMBERS = "show_phone_numbers" +const val DISPLAY_CONTACT_SOURCES = "display_contact_sources" +const val START_NAME_WITH_SURNAME = "start_name_with_surname" +const val LAST_USED_CONTACT_SOURCE = "last_used_contact_source" +const val LAST_USED_VIEW_PAGER_PAGE = "last_used_view_pager_page" -val CONTACT_ID = "contact_id" +const val CONTACT_ID = "contact_id" // contact photo changes -val PHOTO_ADDED = 1 -val PHOTO_REMOVED = 2 -val PHOTO_CHANGED = 3 -val PHOTO_UNCHANGED = 4 +const val PHOTO_ADDED = 1 +const val PHOTO_REMOVED = 2 +const val PHOTO_CHANGED = 3 +const val PHOTO_UNCHANGED = 4 // default contact values -val DEFAULT_EMAIL_TYPE = CommonDataKinds.Email.TYPE_HOME -val DEFAULT_PHONE_NUMBER_TYPE = CommonDataKinds.Phone.TYPE_MOBILE -val DEFAULT_EVENT_TYPE = CommonDataKinds.Event.TYPE_BIRTHDAY +const val DEFAULT_EMAIL_TYPE = CommonDataKinds.Email.TYPE_HOME +const val DEFAULT_PHONE_NUMBER_TYPE = CommonDataKinds.Phone.TYPE_MOBILE +const val DEFAULT_EVENT_TYPE = CommonDataKinds.Event.TYPE_BIRTHDAY // export/import -val BEGIN_VCARD = "BEGIN:VCARD" -val END_VCARD = "END:VCARD" -val N = "N:" -val TEL = "TEL" -val BDAY = "BDAY:" -val ANNIVERSARY = "ANNIVERSARY:" -val PHOTO = "PHOTO" -val EMAIL = "EMAIL" -val ENCODING = "ENCODING" -val BASE64 = "BASE64" -val JPEG = "JPEG" -val VERSION_2_1 = "VERSION:2.1" +const val BEGIN_VCARD = "BEGIN:VCARD" +const val END_VCARD = "END:VCARD" +const val N = "N:" +const val TEL = "TEL" +const val BDAY = "BDAY:" +const val ANNIVERSARY = "ANNIVERSARY:" +const val PHOTO = "PHOTO" +const val EMAIL = "EMAIL" +const val ENCODING = "ENCODING" +const val BASE64 = "BASE64" +const val JPEG = "JPEG" +const val VERSION_2_1 = "VERSION:2.1" // phone number/email types -val CELL = "CELL" -val WORK = "WORK" -val HOME = "HOME" -val PREF = "PREF" -val MAIN = "MAIN" -val FAX = "FAX" -val WORK_FAX = "WORK;FAX" -val HOME_FAX = "HOME;FAX" -val PAGER = "PAGER" -val MOBILE = "MOBILE" -val VOICE = "VOICE" +const val CELL = "CELL" +const val WORK = "WORK" +const val HOME = "HOME" +const val PREF = "PREF" +const val MAIN = "MAIN" +const val FAX = "FAX" +const val WORK_FAX = "WORK;FAX" +const val HOME_FAX = "HOME;FAX" +const val PAGER = "PAGER" +const val MOBILE = "MOBILE" +const val VOICE = "VOICE"