Merge pull request #1006 from esensar/viewbinding-migration
Migrate to viewbinding and kotlin gradle scripts
This commit is contained in:
commit
28a8a5e6ff
51 changed files with 1551 additions and 1314 deletions
|
@ -1,77 +0,0 @@
|
||||||
plugins {
|
|
||||||
id 'com.android.application'
|
|
||||||
id 'kotlin-android'
|
|
||||||
id 'kotlin-android-extensions'
|
|
||||||
id 'kotlin-kapt'
|
|
||||||
}
|
|
||||||
|
|
||||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
|
||||||
def keystoreProperties = new Properties()
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 33
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "com.simplemobiletools.contacts.pro"
|
|
||||||
minSdkVersion 23
|
|
||||||
targetSdkVersion 33
|
|
||||||
versionCode 104
|
|
||||||
versionName "6.22.4"
|
|
||||||
setProperty("archivesBaseName", "contacts")
|
|
||||||
}
|
|
||||||
|
|
||||||
signingConfigs {
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
release {
|
|
||||||
keyAlias keystoreProperties['keyAlias']
|
|
||||||
keyPassword keystoreProperties['keyPassword']
|
|
||||||
storeFile file(keystoreProperties['storeFile'])
|
|
||||||
storePassword keystoreProperties['storePassword']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
debug {
|
|
||||||
applicationIdSuffix ".debug"
|
|
||||||
}
|
|
||||||
release {
|
|
||||||
minifyEnabled true
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
if (keystorePropertiesFile.exists()) {
|
|
||||||
signingConfig signingConfigs.release
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flavorDimensions "variants"
|
|
||||||
productFlavors {
|
|
||||||
core {}
|
|
||||||
fdroid {}
|
|
||||||
prepaid {}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
|
||||||
}
|
|
||||||
|
|
||||||
lintOptions {
|
|
||||||
checkReleaseBuilds false
|
|
||||||
abortOnError false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:91763fe00f'
|
|
||||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
|
||||||
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
|
||||||
implementation 'me.grantland:autofittextview:0.2.1'
|
|
||||||
|
|
||||||
kapt "androidx.room:room-compiler:2.5.1"
|
|
||||||
implementation "androidx.room:room-runtime:2.5.1"
|
|
||||||
annotationProcessor "androidx.room:room-compiler:2.5.1"
|
|
||||||
}
|
|
98
app/build.gradle.kts
Normal file
98
app/build.gradle.kts
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
import org.jetbrains.kotlin.konan.properties.Properties
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android)
|
||||||
|
alias(libs.plugins.kotlinAndroid)
|
||||||
|
alias(libs.plugins.ksp)
|
||||||
|
}
|
||||||
|
|
||||||
|
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
|
||||||
|
val keystoreProperties = Properties()
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt()
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = libs.versions.app.version.appId.get()
|
||||||
|
minSdk = project.libs.versions.app.build.minimumSDK.get().toInt()
|
||||||
|
targetSdk = project.libs.versions.app.build.targetSDK.get().toInt()
|
||||||
|
versionName = project.libs.versions.app.version.versionName.get()
|
||||||
|
versionCode = project.libs.versions.app.version.versionCode.get().toInt()
|
||||||
|
setProperty("archivesBaseName", "contacts")
|
||||||
|
}
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
register("release") {
|
||||||
|
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||||
|
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||||
|
storeFile = file(keystoreProperties.getProperty("storeFile"))
|
||||||
|
storePassword = keystoreProperties.getProperty("storePassword")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding = true
|
||||||
|
buildConfig = true
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
applicationIdSuffix = ".debug"
|
||||||
|
}
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = true
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
signingConfig = signingConfigs.getByName("release")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flavorDimensions.add("variants")
|
||||||
|
productFlavors {
|
||||||
|
register("core")
|
||||||
|
register("fdroid")
|
||||||
|
register("prepaid")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
getByName("main").java.srcDirs("src/main/kotlin")
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get().toString())
|
||||||
|
sourceCompatibility = currentJavaVersionFromLibs
|
||||||
|
targetCompatibility = currentJavaVersionFromLibs
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile> {
|
||||||
|
kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace = libs.versions.app.version.appId.get()
|
||||||
|
|
||||||
|
lint {
|
||||||
|
checkReleaseBuilds = false
|
||||||
|
abortOnError = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.simple.tools.commons)
|
||||||
|
implementation(libs.androidx.swiperefreshlayout)
|
||||||
|
implementation(libs.autofittextview)
|
||||||
|
implementation(libs.ezvcard)
|
||||||
|
implementation(libs.indicatorfastscroll)
|
||||||
|
implementation(libs.bundles.room)
|
||||||
|
ksp(libs.androidx.room.compiler)
|
||||||
|
}
|
|
@ -11,8 +11,6 @@
|
||||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
|
||||||
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
|
|
||||||
|
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
|
|
|
@ -27,9 +27,9 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.letterBackgroundColors
|
import com.simplemobiletools.commons.helpers.letterBackgroundColors
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.extensions.shareContacts
|
import com.simplemobiletools.contacts.pro.extensions.shareContacts
|
||||||
import com.simplemobiletools.commons.models.contacts.Contact
|
|
||||||
|
|
||||||
abstract class ContactActivity : SimpleActivity() {
|
abstract class ContactActivity : SimpleActivity() {
|
||||||
protected val PICK_RINGTONE_INTENT_ID = 1500
|
protected val PICK_RINGTONE_INTENT_ID = 1500
|
||||||
|
@ -164,10 +164,10 @@ abstract class ContactActivity : SimpleActivity() {
|
||||||
} else {
|
} else {
|
||||||
getString(
|
getString(
|
||||||
when (type) {
|
when (type) {
|
||||||
Email.TYPE_HOME -> R.string.home
|
Email.TYPE_HOME -> com.simplemobiletools.commons.R.string.home
|
||||||
Email.TYPE_WORK -> R.string.work
|
Email.TYPE_WORK -> com.simplemobiletools.commons.R.string.work
|
||||||
Email.TYPE_MOBILE -> R.string.mobile
|
Email.TYPE_MOBILE -> com.simplemobiletools.commons.R.string.mobile
|
||||||
else -> R.string.other
|
else -> com.simplemobiletools.commons.R.string.other
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -179,9 +179,9 @@ abstract class ContactActivity : SimpleActivity() {
|
||||||
} else {
|
} else {
|
||||||
getString(
|
getString(
|
||||||
when (type) {
|
when (type) {
|
||||||
StructuredPostal.TYPE_HOME -> R.string.home
|
StructuredPostal.TYPE_HOME -> com.simplemobiletools.commons.R.string.home
|
||||||
StructuredPostal.TYPE_WORK -> R.string.work
|
StructuredPostal.TYPE_WORK -> com.simplemobiletools.commons.R.string.work
|
||||||
else -> R.string.other
|
else -> com.simplemobiletools.commons.R.string.other
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -207,9 +207,9 @@ abstract class ContactActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEventTextId(type: Int) = when (type) {
|
fun getEventTextId(type: Int) = when (type) {
|
||||||
Event.TYPE_ANNIVERSARY -> R.string.anniversary
|
Event.TYPE_ANNIVERSARY -> com.simplemobiletools.commons.R.string.anniversary
|
||||||
Event.TYPE_BIRTHDAY -> R.string.birthday
|
Event.TYPE_BIRTHDAY -> com.simplemobiletools.commons.R.string.birthday
|
||||||
else -> R.string.other
|
else -> com.simplemobiletools.commons.R.string.other
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getBigLetterPlaceholder(name: String): Bitmap {
|
private fun getBigLetterPlaceholder(name: String): Bitmap {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,19 +14,19 @@ import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.commons.models.contacts.Group
|
import com.simplemobiletools.commons.models.contacts.Group
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.ActivityGroupContactsBinding
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.SelectContactsDialog
|
import com.simplemobiletools.contacts.pro.dialogs.SelectContactsDialog
|
||||||
import com.simplemobiletools.contacts.pro.extensions.handleGenericContactClick
|
import com.simplemobiletools.contacts.pro.extensions.handleGenericContactClick
|
||||||
import com.simplemobiletools.contacts.pro.helpers.GROUP
|
import com.simplemobiletools.contacts.pro.helpers.GROUP
|
||||||
import com.simplemobiletools.contacts.pro.helpers.LOCATION_GROUP_CONTACTS
|
import com.simplemobiletools.contacts.pro.helpers.LOCATION_GROUP_CONTACTS
|
||||||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||||
import com.simplemobiletools.contacts.pro.interfaces.RemoveFromGroupListener
|
import com.simplemobiletools.contacts.pro.interfaces.RemoveFromGroupListener
|
||||||
import kotlinx.android.synthetic.main.activity_group_contacts.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_layout.fragment_list
|
|
||||||
|
|
||||||
class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, RefreshContactsListener {
|
class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, RefreshContactsListener {
|
||||||
private var allContacts = ArrayList<Contact>()
|
private var allContacts = ArrayList<Contact>()
|
||||||
private var groupContacts = ArrayList<Contact>()
|
private var groupContacts = ArrayList<Contact>()
|
||||||
private var wasInit = false
|
private var wasInit = false
|
||||||
|
private val binding by viewBinding(ActivityGroupContactsBinding::inflate)
|
||||||
lateinit var group: Group
|
lateinit var group: Group
|
||||||
|
|
||||||
protected val INTENT_SELECT_RINGTONE = 600
|
protected val INTENT_SELECT_RINGTONE = 600
|
||||||
|
@ -36,42 +36,42 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_group_contacts)
|
setContentView(binding.root)
|
||||||
updateTextColors(group_contacts_coordinator)
|
updateTextColors(binding.groupContactsCoordinator)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
|
|
||||||
updateMaterialActivityViews(group_contacts_coordinator, group_contacts_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
updateMaterialActivityViews(binding.groupContactsCoordinator, binding.groupContactsList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
setupMaterialScrollListener(group_contacts_list, group_contacts_toolbar)
|
setupMaterialScrollListener(binding.groupContactsList, binding.groupContactsToolbar)
|
||||||
|
|
||||||
group = intent.extras?.getSerializable(GROUP) as Group
|
group = intent.extras?.getSerializable(GROUP) as Group
|
||||||
group_contacts_toolbar.title = group.title
|
binding.groupContactsToolbar.title = group.title
|
||||||
|
|
||||||
group_contacts_fab.setOnClickListener {
|
binding.groupContactsFab.setOnClickListener {
|
||||||
if (wasInit) {
|
if (wasInit) {
|
||||||
fabClicked()
|
fabClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group_contacts_placeholder_2.setOnClickListener {
|
binding.groupContactsPlaceholder2.setOnClickListener {
|
||||||
fabClicked()
|
fabClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
val properPrimaryColor = getProperPrimaryColor()
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
group_contacts_fastscroller?.updateColors(properPrimaryColor)
|
binding.groupContactsFastscroller?.updateColors(properPrimaryColor)
|
||||||
group_contacts_placeholder_2.underlineText()
|
binding.groupContactsPlaceholder2.underlineText()
|
||||||
group_contacts_placeholder_2.setTextColor(properPrimaryColor)
|
binding.groupContactsPlaceholder2.setTextColor(properPrimaryColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
refreshContacts()
|
refreshContacts()
|
||||||
setupToolbar(group_contacts_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.groupContactsToolbar, NavigationIcon.Arrow)
|
||||||
(group_contacts_fab.layoutParams as CoordinatorLayout.LayoutParams).bottomMargin =
|
(binding.groupContactsFab.layoutParams as CoordinatorLayout.LayoutParams).bottomMargin =
|
||||||
navigationBarHeight + resources.getDimension(R.dimen.activity_margin).toInt()
|
navigationBarHeight + resources.getDimension(com.simplemobiletools.commons.R.dimen.activity_margin).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
group_contacts_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.groupContactsToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.send_sms_to_group -> sendSMSToGroup()
|
R.id.send_sms_to_group -> sendSMSToGroup()
|
||||||
R.id.send_email_to_group -> sendEmailToGroup()
|
R.id.send_email_to_group -> sendEmailToGroup()
|
||||||
|
@ -113,16 +113,16 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
|
||||||
allContacts = it
|
allContacts = it
|
||||||
|
|
||||||
groupContacts = it.filter { it.groups.map { it.id }.contains(group.id) } as ArrayList<Contact>
|
groupContacts = it.filter { it.groups.map { it.id }.contains(group.id) } as ArrayList<Contact>
|
||||||
group_contacts_placeholder_2.beVisibleIf(groupContacts.isEmpty())
|
binding.groupContactsPlaceholder2.beVisibleIf(groupContacts.isEmpty())
|
||||||
group_contacts_placeholder.beVisibleIf(groupContacts.isEmpty())
|
binding.groupContactsPlaceholder.beVisibleIf(groupContacts.isEmpty())
|
||||||
group_contacts_fastscroller.beVisibleIf(groupContacts.isNotEmpty())
|
binding.groupContactsFastscroller.beVisibleIf(groupContacts.isNotEmpty())
|
||||||
updateContacts(groupContacts)
|
updateContacts(groupContacts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendSMSToGroup() {
|
private fun sendSMSToGroup() {
|
||||||
if (groupContacts.isEmpty()) {
|
if (groupContacts.isEmpty()) {
|
||||||
toast(R.string.no_contacts_found)
|
toast(com.simplemobiletools.commons.R.string.no_contacts_found)
|
||||||
} else {
|
} else {
|
||||||
sendSMSToContacts(groupContacts)
|
sendSMSToContacts(groupContacts)
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
|
||||||
|
|
||||||
private fun sendEmailToGroup() {
|
private fun sendEmailToGroup() {
|
||||||
if (groupContacts.isEmpty()) {
|
if (groupContacts.isEmpty()) {
|
||||||
toast(R.string.no_contacts_found)
|
toast(com.simplemobiletools.commons.R.string.no_contacts_found)
|
||||||
} else {
|
} else {
|
||||||
sendEmailToContacts(groupContacts)
|
sendEmailToContacts(groupContacts)
|
||||||
}
|
}
|
||||||
|
@ -146,23 +146,23 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateContacts(contacts: ArrayList<Contact>) {
|
private fun updateContacts(contacts: ArrayList<Contact>) {
|
||||||
val currAdapter = group_contacts_list.adapter
|
val currAdapter = binding.groupContactsList.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
ContactsAdapter(
|
ContactsAdapter(
|
||||||
this,
|
this,
|
||||||
contactItems = contacts,
|
contactItems = contacts,
|
||||||
recyclerView = fragment_list,
|
recyclerView = binding.groupContactsList,
|
||||||
location = LOCATION_GROUP_CONTACTS,
|
location = LOCATION_GROUP_CONTACTS,
|
||||||
removeListener = this,
|
removeListener = this,
|
||||||
refreshListener = this
|
refreshListener = this
|
||||||
) {
|
) {
|
||||||
contactClicked(it as Contact)
|
contactClicked(it as Contact)
|
||||||
}.apply {
|
}.apply {
|
||||||
group_contacts_list.adapter = this
|
binding.groupContactsList.adapter = this
|
||||||
}
|
}
|
||||||
|
|
||||||
if (areSystemAnimationsEnabled) {
|
if (areSystemAnimationsEnabled) {
|
||||||
group_contacts_list.scheduleLayoutAnimation()
|
binding.groupContactsList.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as ContactsAdapter).updateItems(contacts)
|
(currAdapter as ContactsAdapter).updateItems(contacts)
|
||||||
|
|
|
@ -8,14 +8,14 @@ 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.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
import com.simplemobiletools.commons.databinding.BottomTablayoutItemBinding
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.contacts.*
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.adapters.ViewPagerAdapter
|
import com.simplemobiletools.contacts.pro.adapters.ViewPagerAdapter
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.ActivityInsertEditContactBinding
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.ChangeSortingDialog
|
import com.simplemobiletools.contacts.pro.dialogs.ChangeSortingDialog
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.FilterContactSourcesDialog
|
import com.simplemobiletools.contacts.pro.dialogs.FilterContactSourcesDialog
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
|
@ -24,16 +24,16 @@ import com.simplemobiletools.contacts.pro.helpers.ADD_NEW_CONTACT_NUMBER
|
||||||
import com.simplemobiletools.contacts.pro.helpers.KEY_EMAIL
|
import com.simplemobiletools.contacts.pro.helpers.KEY_EMAIL
|
||||||
import com.simplemobiletools.contacts.pro.helpers.KEY_NAME
|
import com.simplemobiletools.contacts.pro.helpers.KEY_NAME
|
||||||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||||
import kotlinx.android.synthetic.main.activity_insert_edit_contact.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_contacts.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_favorites.*
|
|
||||||
|
|
||||||
class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
private val START_INSERT_ACTIVITY = 1
|
companion object {
|
||||||
private val START_EDIT_ACTIVITY = 2
|
private const val START_INSERT_ACTIVITY = 1
|
||||||
|
private const val START_EDIT_ACTIVITY = 2
|
||||||
|
}
|
||||||
|
|
||||||
private var isSelectContactIntent = false
|
private var isSelectContactIntent = false
|
||||||
private var specialMimeType: String? = null
|
private var specialMimeType: String? = null
|
||||||
|
private val binding by viewBinding(ActivityInsertEditContactBinding::inflate)
|
||||||
|
|
||||||
private val contactsFavoritesList = arrayListOf(
|
private val contactsFavoritesList = arrayListOf(
|
||||||
TAB_CONTACTS,
|
TAB_CONTACTS,
|
||||||
|
@ -42,10 +42,10 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_insert_edit_contact)
|
setContentView(binding.root)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
isSelectContactIntent = intent.action == Intent.ACTION_PICK
|
isSelectContactIntent = intent.action == Intent.ACTION_PICK
|
||||||
updateMaterialActivityViews(insert_edit_coordinator, insert_edit_contact_holder, useTransparentNavigation = false, useTopSearchMenu = true)
|
updateMaterialActivityViews(binding.insertEditCoordinator, binding.insertEditContactHolder, useTransparentNavigation = false, useTopSearchMenu = true)
|
||||||
|
|
||||||
if (isSelectContactIntent) {
|
if (isSelectContactIntent) {
|
||||||
specialMimeType = when (intent.data) {
|
specialMimeType = when (intent.data) {
|
||||||
|
@ -55,8 +55,8 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new_contact_holder.beGoneIf(isSelectContactIntent)
|
binding.newContactHolder.beGoneIf(isSelectContactIntent)
|
||||||
select_contact_label.beGoneIf(isSelectContactIntent)
|
binding.selectContactLabel.beGoneIf(isSelectContactIntent)
|
||||||
|
|
||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
return
|
return
|
||||||
|
@ -85,21 +85,21 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
insert_edit_menu.getToolbar().inflateMenu(R.menu.menu_insert_or_edit)
|
binding.insertEditMenu.getToolbar().inflateMenu(R.menu.menu_insert_or_edit)
|
||||||
insert_edit_menu.toggleHideOnScroll(false)
|
binding.insertEditMenu.toggleHideOnScroll(false)
|
||||||
insert_edit_menu.setupMenu()
|
binding.insertEditMenu.setupMenu()
|
||||||
|
|
||||||
insert_edit_menu.onSearchClosedListener = {
|
binding.insertEditMenu.onSearchClosedListener = {
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.onSearchClosed()
|
it.onSearchClosed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
insert_edit_menu.onSearchTextChangedListener = { text ->
|
binding.insertEditMenu.onSearchTextChangedListener = { text ->
|
||||||
getCurrentFragment()?.onSearchQueryChanged(text)
|
getCurrentFragment()?.onSearchQueryChanged(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
insert_edit_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
binding.insertEditMenu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.sort -> showSortingDialog()
|
R.id.sort -> showSortingDialog()
|
||||||
R.id.filter -> showFilterDialog()
|
R.id.filter -> showFilterDialog()
|
||||||
|
@ -111,7 +111,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
private fun updateMenuColors() {
|
private fun updateMenuColors() {
|
||||||
updateStatusbarColor(getProperBackgroundColor())
|
updateStatusbarColor(getProperBackgroundColor())
|
||||||
insert_edit_menu.updateColors()
|
binding.insertEditMenu.updateColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||||
|
@ -123,99 +123,108 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (insert_edit_menu.isSearchOpen) {
|
if (binding.insertEditMenu.isSearchOpen) {
|
||||||
insert_edit_menu.closeSearch()
|
binding.insertEditMenu.closeSearch()
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initFragments() {
|
private fun initFragments() {
|
||||||
view_pager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
binding.viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||||
override fun onPageScrollStateChanged(state: Int) {}
|
override fun onPageScrollStateChanged(state: Int) {}
|
||||||
|
|
||||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
insert_edit_tabs_holder.getTabAt(position)?.select()
|
binding.insertEditTabsHolder.getTabAt(position)?.select()
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.finishActMode()
|
it.finishActMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
view_pager.onGlobalLayout {
|
binding.viewPager.onGlobalLayout {
|
||||||
refreshContacts(getTabsMask())
|
refreshContacts(getTabsMask())
|
||||||
}
|
}
|
||||||
|
|
||||||
select_contact_label?.setTextColor(getProperPrimaryColor())
|
binding.selectContactLabel.setTextColor(getProperPrimaryColor())
|
||||||
new_contact_tmb?.setImageDrawable(resources.getColoredDrawableWithColor(R.drawable.ic_add_person_vector, getProperTextColor()))
|
binding.newContactTmb.setImageDrawable(
|
||||||
new_contact_name.setTextColor(getProperTextColor())
|
resources.getColoredDrawableWithColor(
|
||||||
new_contact_holder?.setOnClickListener {
|
com.simplemobiletools.commons.R.drawable.ic_add_person_vector,
|
||||||
|
getProperTextColor()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
binding.newContactName.setTextColor(getProperTextColor())
|
||||||
|
binding.newContactHolder.setOnClickListener {
|
||||||
createNewContact()
|
createNewContact()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabs() {
|
private fun setupTabs() {
|
||||||
insert_edit_tabs_holder.removeAllTabs()
|
binding.insertEditTabsHolder.removeAllTabs()
|
||||||
contactsFavoritesList.forEachIndexed { index, value ->
|
contactsFavoritesList.forEachIndexed { index, value ->
|
||||||
if (config.showTabs and value != 0) {
|
if (config.showTabs and value != 0) {
|
||||||
insert_edit_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
|
binding.insertEditTabsHolder.newTab().setCustomView(com.simplemobiletools.commons.R.layout.bottom_tablayout_item).apply tab@{
|
||||||
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index))
|
customView?.let {
|
||||||
customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index)
|
BottomTablayoutItemBinding.bind(it)
|
||||||
insert_edit_tabs_holder.addTab(this)
|
}?.apply {
|
||||||
|
tabItemIcon.setImageDrawable(getTabIcon(index))
|
||||||
|
tabItemLabel.text = getTabLabel(index)
|
||||||
|
binding.insertEditTabsHolder.addTab(this@tab)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
insert_edit_tabs_holder.onTabSelectionChanged(
|
binding.insertEditTabsHolder.onTabSelectionChanged(
|
||||||
tabUnselectedAction = {
|
tabUnselectedAction = {
|
||||||
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
||||||
},
|
},
|
||||||
tabSelectedAction = {
|
tabSelectedAction = {
|
||||||
insert_edit_menu.closeSearch()
|
binding.insertEditMenu.closeSearch()
|
||||||
view_pager.currentItem = it.position
|
binding.viewPager.currentItem = it.position
|
||||||
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
insert_edit_tabs_holder.beGoneIf(insert_edit_tabs_holder.tabCount == 1)
|
binding.insertEditTabsHolder.beGoneIf(binding.insertEditTabsHolder.tabCount == 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCurrentFragment(): MyViewPagerFragment? {
|
private fun getCurrentFragment(): MyViewPagerFragment<*>? {
|
||||||
return if (view_pager.currentItem == 0) {
|
return if (binding.viewPager.currentItem == 0) {
|
||||||
contacts_fragment
|
findViewById(R.id.contacts_fragment)
|
||||||
} else {
|
} else {
|
||||||
favorites_fragment
|
findViewById(R.id.favorites_fragment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment)
|
private fun getAllFragments() = arrayListOf<MyViewPagerFragment<*>>(findViewById(R.id.contacts_fragment), findViewById(R.id.favorites_fragment))
|
||||||
|
|
||||||
private fun setupTabColors() {
|
private fun setupTabColors() {
|
||||||
val activeView = insert_edit_tabs_holder.getTabAt(view_pager.currentItem)?.customView
|
val activeView = binding.insertEditTabsHolder.getTabAt(binding.viewPager.currentItem)?.customView
|
||||||
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[view_pager.currentItem])
|
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[binding.viewPager.currentItem])
|
||||||
|
|
||||||
getInactiveTabIndexes(view_pager.currentItem).forEach { index ->
|
getInactiveTabIndexes(binding.viewPager.currentItem).forEach { index ->
|
||||||
val inactiveView = insert_edit_tabs_holder.getTabAt(index)?.customView
|
val inactiveView = binding.insertEditTabsHolder.getTabAt(index)?.customView
|
||||||
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
val bottomBarColor = getBottomNavigationBackgroundColor()
|
val bottomBarColor = getBottomNavigationBackgroundColor()
|
||||||
insert_edit_tabs_holder.setBackgroundColor(bottomBarColor)
|
binding.insertEditTabsHolder.setBackgroundColor(bottomBarColor)
|
||||||
updateNavigationBarColor(bottomBarColor)
|
updateNavigationBarColor(bottomBarColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until insert_edit_tabs_holder.tabCount).filter { it != activeIndex }
|
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until binding.insertEditTabsHolder.tabCount).filter { it != activeIndex }
|
||||||
|
|
||||||
private fun getSelectedTabDrawableIds() = arrayOf(
|
private fun getSelectedTabDrawableIds() = arrayOf(
|
||||||
R.drawable.ic_person_vector,
|
com.simplemobiletools.commons.R.drawable.ic_person_vector,
|
||||||
R.drawable.ic_star_vector
|
com.simplemobiletools.commons.R.drawable.ic_star_vector
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun getDeselectedTabDrawableIds() = arrayOf(
|
private fun getDeselectedTabDrawableIds() = arrayOf(
|
||||||
R.drawable.ic_person_outline_vector,
|
com.simplemobiletools.commons.R.drawable.ic_person_outline_vector,
|
||||||
R.drawable.ic_star_outline_vector
|
com.simplemobiletools.commons.R.drawable.ic_star_outline_vector
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun refreshContacts(refreshTabsMask: Int) {
|
override fun refreshContacts(refreshTabsMask: Int) {
|
||||||
|
@ -223,8 +232,8 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view_pager.adapter == null) {
|
if (binding.viewPager.adapter == null) {
|
||||||
view_pager.adapter = ViewPagerAdapter(this, contactsFavoritesList, getTabsMask())
|
binding.viewPager.adapter = ViewPagerAdapter(this, contactsFavoritesList, getTabsMask())
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactsHelper(this).getContacts {
|
ContactsHelper(this).getContacts {
|
||||||
|
@ -252,13 +261,17 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refreshTabsMask and TAB_CONTACTS != 0) {
|
if (refreshTabsMask and TAB_CONTACTS != 0) {
|
||||||
contacts_fragment?.skipHashComparing = true
|
findViewById<MyViewPagerFragment<*>>(R.id.contacts_fragment)?.apply {
|
||||||
contacts_fragment?.refreshContacts(contacts, placeholderText)
|
skipHashComparing = true
|
||||||
|
refreshContacts(contacts, placeholderText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refreshTabsMask and TAB_FAVORITES != 0) {
|
if (refreshTabsMask and TAB_FAVORITES != 0) {
|
||||||
favorites_fragment?.skipHashComparing = true
|
findViewById<MyViewPagerFragment<*>>(R.id.favorites_fragment)?.apply {
|
||||||
favorites_fragment?.refreshContacts(contacts, placeholderText)
|
skipHashComparing = true
|
||||||
|
refreshContacts(contacts, placeholderText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,6 +312,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
val contactId = ContactsHelper(this).getContactMimeTypeId(contact.id.toString(), specialMimeType!!)
|
val contactId = ContactsHelper(this).getContactMimeTypeId(contact.id.toString(), specialMimeType!!)
|
||||||
Uri.withAppendedPath(ContactsContract.Data.CONTENT_URI, contactId)
|
Uri.withAppendedPath(ContactsContract.Data.CONTENT_URI, contactId)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> getContactPublicUri(contact)
|
else -> getContactPublicUri(contact)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +341,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
try {
|
try {
|
||||||
startActivityForResult(this, START_INSERT_ACTIVITY)
|
startActivityForResult(this, START_INSERT_ACTIVITY)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
toast(R.string.no_app_found)
|
toast(com.simplemobiletools.commons.R.string.no_app_found)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -342,7 +356,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
fun showFilterDialog() {
|
fun showFilterDialog() {
|
||||||
FilterContactSourcesDialog(this) {
|
FilterContactSourcesDialog(this) {
|
||||||
contacts_fragment?.forceListRedraw = true
|
findViewById<MyViewPagerFragment<*>>(R.id.contacts_fragment)?.forceListRedraw = true
|
||||||
refreshContacts(getTabsMask())
|
refreshContacts(getTabsMask())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,10 @@ import android.graphics.drawable.Icon
|
||||||
import android.graphics.drawable.LayerDrawable
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
import com.simplemobiletools.commons.databases.ContactsDatabase
|
import com.simplemobiletools.commons.databases.ContactsDatabase
|
||||||
|
import com.simplemobiletools.commons.databinding.BottomTablayoutItemBinding
|
||||||
import com.simplemobiletools.commons.dialogs.ChangeViewTypeDialog
|
import com.simplemobiletools.commons.dialogs.ChangeViewTypeDialog
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
|
@ -28,6 +27,7 @@ import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.contacts.pro.BuildConfig
|
import com.simplemobiletools.contacts.pro.BuildConfig
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.adapters.ViewPagerAdapter
|
import com.simplemobiletools.contacts.pro.adapters.ViewPagerAdapter
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.ActivityMainBinding
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.ChangeSortingDialog
|
import com.simplemobiletools.contacts.pro.dialogs.ChangeSortingDialog
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.ExportContactsDialog
|
import com.simplemobiletools.contacts.pro.dialogs.ExportContactsDialog
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.FilterContactSourcesDialog
|
import com.simplemobiletools.contacts.pro.dialogs.FilterContactSourcesDialog
|
||||||
|
@ -40,18 +40,16 @@ import com.simplemobiletools.contacts.pro.helpers.ALL_TABS_MASK
|
||||||
import com.simplemobiletools.contacts.pro.helpers.VcfExporter
|
import com.simplemobiletools.contacts.pro.helpers.VcfExporter
|
||||||
import com.simplemobiletools.contacts.pro.helpers.tabsList
|
import com.simplemobiletools.contacts.pro.helpers.tabsList
|
||||||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_contacts.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_favorites.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_groups.*
|
|
||||||
import me.grantland.widget.AutofitHelper
|
import me.grantland.widget.AutofitHelper
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), RefreshContactsListener {
|
class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
private val PICK_IMPORT_SOURCE_INTENT = 1
|
companion object {
|
||||||
private val PICK_EXPORT_FILE_INTENT = 2
|
private const val PICK_IMPORT_SOURCE_INTENT = 1
|
||||||
|
private const val PICK_EXPORT_FILE_INTENT = 2
|
||||||
|
}
|
||||||
|
|
||||||
private var werePermissionsHandled = false
|
private var werePermissionsHandled = false
|
||||||
private var isFirstResume = true
|
private var isFirstResume = true
|
||||||
|
@ -63,22 +61,23 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
private var storedStartNameWithSurname = false
|
private var storedStartNameWithSurname = false
|
||||||
private var storedFontSize = 0
|
private var storedFontSize = 0
|
||||||
private var storedShowTabs = 0
|
private var storedShowTabs = 0
|
||||||
|
private val binding by viewBinding(ActivityMainBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(binding.root)
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
updateMaterialActivityViews(main_coordinator, main_holder, useTransparentNavigation = false, useTopSearchMenu = true)
|
updateMaterialActivityViews(binding.mainCoordinator, binding.mainHolder, useTransparentNavigation = false, useTopSearchMenu = true)
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
setupTabs()
|
setupTabs()
|
||||||
checkContactPermissions()
|
checkContactPermissions()
|
||||||
checkWhatsNewDialog()
|
checkWhatsNewDialog()
|
||||||
|
|
||||||
if (isPackageInstalled("com.simplemobiletools.contacts")) {
|
if (isPackageInstalled("com.simplemobiletools.contacts")) {
|
||||||
val dialogText = getString(R.string.upgraded_from_free_contacts, getString(R.string.phone_storage_hidden))
|
val dialogText = getString(com.simplemobiletools.commons.R.string.upgraded_from_free_contacts, getString(R.string.phone_storage_hidden))
|
||||||
ConfirmationDialog(this, dialogText, 0, R.string.ok, 0, false) {}
|
ConfirmationDialog(this, dialogText, 0, com.simplemobiletools.commons.R.string.ok, 0, false) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +118,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
val properPrimaryColor = getProperPrimaryColor()
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
main_tabs_holder.background = ColorDrawable(getProperBackgroundColor())
|
binding.mainTabsHolder.background = ColorDrawable(getProperBackgroundColor())
|
||||||
main_tabs_holder.setSelectedTabIndicatorColor(properPrimaryColor)
|
binding.mainTabsHolder.setSelectedTabIndicatorColor(properPrimaryColor)
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.setupColors(getProperTextColor(), properPrimaryColor)
|
it?.setupColors(getProperTextColor(), properPrimaryColor)
|
||||||
}
|
}
|
||||||
|
@ -130,8 +129,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
val configStartNameWithSurname = config.startNameWithSurname
|
val configStartNameWithSurname = config.startNameWithSurname
|
||||||
if (storedStartNameWithSurname != configStartNameWithSurname) {
|
if (storedStartNameWithSurname != configStartNameWithSurname) {
|
||||||
contacts_fragment?.startNameWithSurnameChanged(configStartNameWithSurname)
|
findViewById<MyViewPagerFragment<*>>(R.id.contacts_fragment)?.startNameWithSurnameChanged(configStartNameWithSurname)
|
||||||
favorites_fragment?.startNameWithSurnameChanged(configStartNameWithSurname)
|
findViewById<MyViewPagerFragment<*>>(R.id.favorites_fragment)?.startNameWithSurnameChanged(configStartNameWithSurname)
|
||||||
}
|
}
|
||||||
|
|
||||||
val configFontSize = config.fontSize
|
val configFontSize = config.fontSize
|
||||||
|
@ -142,15 +141,16 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (werePermissionsHandled && !isFirstResume) {
|
if (werePermissionsHandled && !isFirstResume) {
|
||||||
if (view_pager.adapter == null) {
|
if (binding.viewPager.adapter == null) {
|
||||||
initFragments()
|
initFragments()
|
||||||
} else {
|
} else {
|
||||||
refreshContacts(ALL_TABS_MASK)
|
refreshContacts(ALL_TABS_MASK)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val dialpadIcon = resources.getColoredDrawableWithColor(R.drawable.ic_dialpad_vector, properPrimaryColor.getContrastColor())
|
val dialpadIcon =
|
||||||
main_dialpad_button.apply {
|
resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_dialpad_vector, properPrimaryColor.getContrastColor())
|
||||||
|
binding.mainDialpadButton.apply {
|
||||||
setImageDrawable(dialpadIcon)
|
setImageDrawable(dialpadIcon)
|
||||||
background.applyColorFilter(properPrimaryColor)
|
background.applyColorFilter(properPrimaryColor)
|
||||||
beVisibleIf(config.showDialpadButton)
|
beVisibleIf(config.showDialpadButton)
|
||||||
|
@ -163,7 +163,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
config.lastUsedViewPagerPage = view_pager.currentItem
|
config.lastUsedViewPagerPage = binding.viewPager.currentItem
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
@ -188,8 +188,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
main_menu.closeSearch()
|
binding.mainMenu.closeSearch()
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
|
@ -197,32 +197,32 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
val currentFragment = getCurrentFragment()
|
val currentFragment = getCurrentFragment()
|
||||||
main_menu.getToolbar().menu.apply {
|
binding.mainMenu.getToolbar().menu.apply {
|
||||||
findItem(R.id.sort).isVisible = currentFragment != groups_fragment
|
findItem(R.id.sort).isVisible = currentFragment != findViewById(R.id.groups_fragment)
|
||||||
findItem(R.id.filter).isVisible = currentFragment != groups_fragment
|
findItem(R.id.filter).isVisible = currentFragment != findViewById(R.id.groups_fragment)
|
||||||
findItem(R.id.dialpad).isVisible = !config.showDialpadButton
|
findItem(R.id.dialpad).isVisible = !config.showDialpadButton
|
||||||
findItem(R.id.change_view_type).isVisible = currentFragment == favorites_fragment
|
findItem(R.id.change_view_type).isVisible = currentFragment == findViewById(R.id.favorites_fragment)
|
||||||
findItem(R.id.column_count).isVisible = currentFragment == favorites_fragment && config.viewType == VIEW_TYPE_GRID
|
findItem(R.id.column_count).isVisible = currentFragment == findViewById(R.id.favorites_fragment) && config.viewType == VIEW_TYPE_GRID
|
||||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
main_menu.getToolbar().inflateMenu(R.menu.menu)
|
binding.mainMenu.getToolbar().inflateMenu(R.menu.menu)
|
||||||
main_menu.toggleHideOnScroll(false)
|
binding.mainMenu.toggleHideOnScroll(false)
|
||||||
main_menu.setupMenu()
|
binding.mainMenu.setupMenu()
|
||||||
|
|
||||||
main_menu.onSearchClosedListener = {
|
binding.mainMenu.onSearchClosedListener = {
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.onSearchClosed()
|
it?.onSearchClosed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu.onSearchTextChangedListener = { text ->
|
binding.mainMenu.onSearchTextChangedListener = { text ->
|
||||||
getCurrentFragment()?.onSearchQueryChanged(text)
|
getCurrentFragment()?.onSearchQueryChanged(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
binding.mainMenu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.sort -> showSortingDialog(showCustomSorting = getCurrentFragment() is FavoritesFragment)
|
R.id.sort -> showSortingDialog(showCustomSorting = getCurrentFragment() is FavoritesFragment)
|
||||||
R.id.filter -> showFilterDialog()
|
R.id.filter -> showFilterDialog()
|
||||||
|
@ -243,14 +243,14 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
private fun changeViewType() {
|
private fun changeViewType() {
|
||||||
ChangeViewTypeDialog(this) {
|
ChangeViewTypeDialog(this) {
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
favorites_fragment?.updateFavouritesAdapter()
|
findViewById<FavoritesFragment>(R.id.favorites_fragment)?.updateFavouritesAdapter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeColumnCount() {
|
private fun changeColumnCount() {
|
||||||
val items = ArrayList<RadioItem>()
|
val items = ArrayList<RadioItem>()
|
||||||
for (i in 1..CONTACTS_GRID_MAX_COLUMNS_COUNT) {
|
for (i in 1..CONTACTS_GRID_MAX_COLUMNS_COUNT) {
|
||||||
items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i)))
|
items.add(RadioItem(i, resources.getQuantityString(com.simplemobiletools.commons.R.plurals.column_counts, i, i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentColumnCount = config.contactsGridColumnCount
|
val currentColumnCount = config.contactsGridColumnCount
|
||||||
|
@ -258,14 +258,14 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
val newColumnCount = it as Int
|
val newColumnCount = it as Int
|
||||||
if (currentColumnCount != newColumnCount) {
|
if (currentColumnCount != newColumnCount) {
|
||||||
config.contactsGridColumnCount = newColumnCount
|
config.contactsGridColumnCount = newColumnCount
|
||||||
favorites_fragment?.columnCountChanged()
|
findViewById<FavoritesFragment>(R.id.favorites_fragment)?.columnCountChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateMenuColors() {
|
private fun updateMenuColors() {
|
||||||
updateStatusbarColor(getProperBackgroundColor())
|
updateStatusbarColor(getProperBackgroundColor())
|
||||||
main_menu.updateColors()
|
binding.mainMenu.updateColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
|
@ -294,9 +294,9 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private fun getCreateNewContactShortcut(appIconColor: Int): ShortcutInfo {
|
private fun getCreateNewContactShortcut(appIconColor: Int): ShortcutInfo {
|
||||||
val newEvent = getString(R.string.create_new_contact)
|
val newEvent = getString(com.simplemobiletools.commons.R.string.create_new_contact)
|
||||||
val drawable = resources.getDrawable(R.drawable.shortcut_plus)
|
val drawable = resources.getDrawable(com.simplemobiletools.commons.R.drawable.shortcut_plus)
|
||||||
(drawable as LayerDrawable).findDrawableByLayerId(R.id.shortcut_plus_background).applyColorFilter(appIconColor)
|
(drawable as LayerDrawable).findDrawableByLayerId(com.simplemobiletools.commons.R.id.shortcut_plus_background).applyColorFilter(appIconColor)
|
||||||
val bmp = drawable.convertToBitmap()
|
val bmp = drawable.convertToBitmap()
|
||||||
|
|
||||||
val intent = Intent(this, EditContactActivity::class.java)
|
val intent = Intent(this, EditContactActivity::class.java)
|
||||||
|
@ -309,54 +309,54 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCurrentFragment(): MyViewPagerFragment? {
|
private fun getCurrentFragment(): MyViewPagerFragment<*>? {
|
||||||
val showTabs = config.showTabs
|
val showTabs = config.showTabs
|
||||||
val fragments = arrayListOf<MyViewPagerFragment>()
|
val fragments = arrayListOf<MyViewPagerFragment<*>>()
|
||||||
if (showTabs and TAB_CONTACTS != 0) {
|
if (showTabs and TAB_CONTACTS != 0) {
|
||||||
fragments.add(contacts_fragment)
|
fragments.add(findViewById(R.id.contacts_fragment))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_FAVORITES != 0) {
|
if (showTabs and TAB_FAVORITES != 0) {
|
||||||
fragments.add(favorites_fragment)
|
fragments.add(findViewById(R.id.favorites_fragment))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_GROUPS != 0) {
|
if (showTabs and TAB_GROUPS != 0) {
|
||||||
fragments.add(groups_fragment)
|
fragments.add(findViewById(R.id.groups_fragment))
|
||||||
}
|
}
|
||||||
|
|
||||||
return fragments.getOrNull(view_pager.currentItem)
|
return fragments.getOrNull(binding.viewPager.currentItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabColors() {
|
private fun setupTabColors() {
|
||||||
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
|
val activeView = binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.customView
|
||||||
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[view_pager.currentItem])
|
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[binding.viewPager.currentItem])
|
||||||
|
|
||||||
getInactiveTabIndexes(view_pager.currentItem).forEach { index ->
|
getInactiveTabIndexes(binding.viewPager.currentItem).forEach { index ->
|
||||||
val inactiveView = main_tabs_holder.getTabAt(index)?.customView
|
val inactiveView = binding.mainTabsHolder.getTabAt(index)?.customView
|
||||||
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
val bottomBarColor = getBottomNavigationBackgroundColor()
|
val bottomBarColor = getBottomNavigationBackgroundColor()
|
||||||
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
binding.mainTabsHolder.setBackgroundColor(bottomBarColor)
|
||||||
updateNavigationBarColor(bottomBarColor)
|
updateNavigationBarColor(bottomBarColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until main_tabs_holder.tabCount).filter { it != activeIndex }
|
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until binding.mainTabsHolder.tabCount).filter { it != activeIndex }
|
||||||
|
|
||||||
private fun getSelectedTabDrawableIds(): ArrayList<Int> {
|
private fun getSelectedTabDrawableIds(): ArrayList<Int> {
|
||||||
val showTabs = config.showTabs
|
val showTabs = config.showTabs
|
||||||
val icons = ArrayList<Int>()
|
val icons = ArrayList<Int>()
|
||||||
|
|
||||||
if (showTabs and TAB_CONTACTS != 0) {
|
if (showTabs and TAB_CONTACTS != 0) {
|
||||||
icons.add(R.drawable.ic_person_vector)
|
icons.add(com.simplemobiletools.commons.R.drawable.ic_person_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_FAVORITES != 0) {
|
if (showTabs and TAB_FAVORITES != 0) {
|
||||||
icons.add(R.drawable.ic_star_vector)
|
icons.add(com.simplemobiletools.commons.R.drawable.ic_star_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_GROUPS != 0) {
|
if (showTabs and TAB_GROUPS != 0) {
|
||||||
icons.add(R.drawable.ic_people_vector)
|
icons.add(com.simplemobiletools.commons.R.drawable.ic_people_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
return icons
|
return icons
|
||||||
|
@ -367,29 +367,29 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
val icons = ArrayList<Int>()
|
val icons = ArrayList<Int>()
|
||||||
|
|
||||||
if (showTabs and TAB_CONTACTS != 0) {
|
if (showTabs and TAB_CONTACTS != 0) {
|
||||||
icons.add(R.drawable.ic_person_outline_vector)
|
icons.add(com.simplemobiletools.commons.R.drawable.ic_person_outline_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_FAVORITES != 0) {
|
if (showTabs and TAB_FAVORITES != 0) {
|
||||||
icons.add(R.drawable.ic_star_outline_vector)
|
icons.add(com.simplemobiletools.commons.R.drawable.ic_star_outline_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_GROUPS != 0) {
|
if (showTabs and TAB_GROUPS != 0) {
|
||||||
icons.add(R.drawable.ic_people_outline_vector)
|
icons.add(com.simplemobiletools.commons.R.drawable.ic_people_outline_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
return icons
|
return icons
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initFragments() {
|
private fun initFragments() {
|
||||||
view_pager.offscreenPageLimit = tabsList.size - 1
|
binding.viewPager.offscreenPageLimit = tabsList.size - 1
|
||||||
view_pager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
binding.viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||||
override fun onPageScrollStateChanged(state: Int) {}
|
override fun onPageScrollStateChanged(state: Int) {}
|
||||||
|
|
||||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
main_tabs_holder.getTabAt(position)?.select()
|
binding.mainTabsHolder.getTabAt(position)?.select()
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.finishActMode()
|
it?.finishActMode()
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
view_pager.onGlobalLayout {
|
binding.viewPager.onGlobalLayout {
|
||||||
refreshContacts(ALL_TABS_MASK)
|
refreshContacts(ALL_TABS_MASK)
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
}
|
}
|
||||||
|
@ -407,36 +407,40 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
intent.data = null
|
intent.data = null
|
||||||
}
|
}
|
||||||
|
|
||||||
main_dialpad_button.setOnClickListener {
|
binding.mainDialpadButton.setOnClickListener {
|
||||||
launchDialpad()
|
launchDialpad()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabs() {
|
private fun setupTabs() {
|
||||||
main_tabs_holder.removeAllTabs()
|
binding.mainTabsHolder.removeAllTabs()
|
||||||
tabsList.forEachIndexed { index, value ->
|
tabsList.forEachIndexed { index, value ->
|
||||||
if (config.showTabs and value != 0) {
|
if (config.showTabs and value != 0) {
|
||||||
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
|
binding.mainTabsHolder.newTab().setCustomView(com.simplemobiletools.commons.R.layout.bottom_tablayout_item).apply tab@{
|
||||||
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index))
|
customView?.let {
|
||||||
customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index)
|
BottomTablayoutItemBinding.bind(it)
|
||||||
AutofitHelper.create(customView?.findViewById(R.id.tab_item_label))
|
}?.apply {
|
||||||
main_tabs_holder.addTab(this)
|
tabItemIcon.setImageDrawable(getTabIcon(index))
|
||||||
|
tabItemLabel.text = getTabLabel(index)
|
||||||
|
AutofitHelper.create(tabItemLabel)
|
||||||
|
binding.mainTabsHolder.addTab(this@tab)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_tabs_holder.onTabSelectionChanged(
|
binding.mainTabsHolder.onTabSelectionChanged(
|
||||||
tabUnselectedAction = {
|
tabUnselectedAction = {
|
||||||
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
||||||
},
|
},
|
||||||
tabSelectedAction = {
|
tabSelectedAction = {
|
||||||
main_menu.closeSearch()
|
binding.mainMenu.closeSearch()
|
||||||
view_pager.currentItem = it.position
|
binding.viewPager.currentItem = it.position
|
||||||
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
main_tabs_holder.beGoneIf(main_tabs_holder.tabCount == 1)
|
binding.mainTabsHolder.beGoneIf(binding.mainTabsHolder.tabCount == 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showSortingDialog(showCustomSorting: Boolean) {
|
private fun showSortingDialog(showCustomSorting: Boolean) {
|
||||||
|
@ -447,7 +451,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
fun showFilterDialog() {
|
fun showFilterDialog() {
|
||||||
FilterContactSourcesDialog(this) {
|
FilterContactSourcesDialog(this) {
|
||||||
contacts_fragment?.forceListRedraw = true
|
findViewById<MyViewPagerFragment<*>>(R.id.contacts_fragment)?.forceListRedraw = true
|
||||||
refreshContacts(TAB_CONTACTS or TAB_FAVORITES)
|
refreshContacts(TAB_CONTACTS or TAB_FAVORITES)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,7 +462,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
try {
|
try {
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
toast(R.string.no_app_found)
|
toast(com.simplemobiletools.commons.R.string.no_app_found)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -474,7 +478,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
try {
|
try {
|
||||||
startActivityForResult(this, PICK_IMPORT_SOURCE_INTENT)
|
startActivityForResult(this, PICK_IMPORT_SOURCE_INTENT)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
toast(R.string.system_service_disabled, Toast.LENGTH_LONG)
|
toast(com.simplemobiletools.commons.R.string.system_service_disabled, Toast.LENGTH_LONG)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -510,7 +514,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
uri.scheme == "content" -> {
|
uri.scheme == "content" -> {
|
||||||
val tempFile = getTempFile()
|
val tempFile = getTempFile()
|
||||||
if (tempFile == null) {
|
if (tempFile == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +527,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> toast(R.string.invalid_file_format)
|
|
||||||
|
else -> toast(com.simplemobiletools.commons.R.string.invalid_file_format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +545,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.no_app_found, Toast.LENGTH_LONG)
|
toast(com.simplemobiletools.commons.R.string.no_app_found, Toast.LENGTH_LONG)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -562,14 +567,14 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
private fun exportContactsTo(ignoredContactSources: HashSet<String>, outputStream: OutputStream?) {
|
private fun exportContactsTo(ignoredContactSources: HashSet<String>, outputStream: OutputStream?) {
|
||||||
ContactsHelper(this).getContacts(true, false, ignoredContactSources) { contacts ->
|
ContactsHelper(this).getContacts(true, false, ignoredContactSources) { contacts ->
|
||||||
if (contacts.isEmpty()) {
|
if (contacts.isEmpty()) {
|
||||||
toast(R.string.no_entries_for_exporting)
|
toast(com.simplemobiletools.commons.R.string.no_entries_for_exporting)
|
||||||
} else {
|
} else {
|
||||||
VcfExporter().exportContacts(this, outputStream, contacts, true) { result ->
|
VcfExporter().exportContacts(this, outputStream, contacts, true) { result ->
|
||||||
toast(
|
toast(
|
||||||
when (result) {
|
when (result) {
|
||||||
VcfExporter.ExportResult.EXPORT_OK -> R.string.exporting_successful
|
VcfExporter.ExportResult.EXPORT_OK -> com.simplemobiletools.commons.R.string.exporting_successful
|
||||||
VcfExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed
|
VcfExporter.ExportResult.EXPORT_PARTIAL -> com.simplemobiletools.commons.R.string.exporting_some_entries_failed
|
||||||
else -> R.string.exporting_failed
|
else -> com.simplemobiletools.commons.R.string.exporting_failed
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -587,13 +592,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
val faqItems = arrayListOf(
|
val faqItems = arrayListOf(
|
||||||
FAQItem(R.string.faq_1_title, R.string.faq_1_text),
|
FAQItem(R.string.faq_1_title, R.string.faq_1_text),
|
||||||
FAQItem(R.string.faq_9_title_commons, R.string.faq_9_text_commons)
|
FAQItem(com.simplemobiletools.commons.R.string.faq_9_title_commons, com.simplemobiletools.commons.R.string.faq_9_text_commons)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!resources.getBoolean(R.bool.hide_google_relations)) {
|
if (!resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)) {
|
||||||
faqItems.add(FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons))
|
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_2_title_commons, com.simplemobiletools.commons.R.string.faq_2_text_commons))
|
||||||
faqItems.add(FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons))
|
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_6_title_commons, com.simplemobiletools.commons.R.string.faq_6_text_commons))
|
||||||
faqItems.add(FAQItem(R.string.faq_7_title_commons, R.string.faq_7_text_commons))
|
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_7_title_commons, com.simplemobiletools.commons.R.string.faq_7_text_commons))
|
||||||
}
|
}
|
||||||
|
|
||||||
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
||||||
|
@ -606,9 +611,9 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
|
|
||||||
isGettingContacts = true
|
isGettingContacts = true
|
||||||
|
|
||||||
if (view_pager.adapter == null) {
|
if (binding.viewPager.adapter == null) {
|
||||||
view_pager.adapter = ViewPagerAdapter(this, tabsList, config.showTabs)
|
binding.viewPager.adapter = ViewPagerAdapter(this, tabsList, config.showTabs)
|
||||||
view_pager.currentItem = getDefaultTab()
|
binding.viewPager.currentItem = getDefaultTab()
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactsHelper(this).getContacts { contacts ->
|
ContactsHelper(this).getContacts { contacts ->
|
||||||
|
@ -618,24 +623,30 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refreshTabsMask and TAB_CONTACTS != 0) {
|
if (refreshTabsMask and TAB_CONTACTS != 0) {
|
||||||
contacts_fragment?.skipHashComparing = true
|
findViewById<MyViewPagerFragment<*>>(R.id.contacts_fragment)?.apply {
|
||||||
contacts_fragment?.refreshContacts(contacts)
|
skipHashComparing = true
|
||||||
|
refreshContacts(contacts)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refreshTabsMask and TAB_FAVORITES != 0) {
|
if (refreshTabsMask and TAB_FAVORITES != 0) {
|
||||||
favorites_fragment?.skipHashComparing = true
|
findViewById<MyViewPagerFragment<*>>(R.id.favorites_fragment)?.apply {
|
||||||
favorites_fragment?.refreshContacts(contacts)
|
skipHashComparing = true
|
||||||
|
refreshContacts(contacts)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refreshTabsMask and TAB_GROUPS != 0) {
|
if (refreshTabsMask and TAB_GROUPS != 0) {
|
||||||
if (refreshTabsMask == TAB_GROUPS) {
|
findViewById<MyViewPagerFragment<*>>(R.id.groups_fragment)?.apply {
|
||||||
groups_fragment.skipHashComparing = true
|
if (refreshTabsMask == TAB_GROUPS) {
|
||||||
|
skipHashComparing = true
|
||||||
|
}
|
||||||
|
refreshContacts(contacts)
|
||||||
}
|
}
|
||||||
groups_fragment?.refreshContacts(contacts)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
getCurrentFragment()?.onSearchQueryChanged(main_menu.getCurrentQuery())
|
getCurrentFragment()?.onSearchQueryChanged(binding.mainMenu.getCurrentQuery())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,7 +655,11 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||||
handleGenericContactClick(contact)
|
handleGenericContactClick(contact)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment)
|
private fun getAllFragments() = arrayListOf<MyViewPagerFragment<*>?>(
|
||||||
|
findViewById(R.id.contacts_fragment),
|
||||||
|
findViewById(R.id.favorites_fragment),
|
||||||
|
findViewById(R.id.groups_fragment)
|
||||||
|
)
|
||||||
|
|
||||||
private fun getDefaultTab(): Int {
|
private fun getDefaultTab(): Int {
|
||||||
val showTabsMask = config.showTabs
|
val showTabsMask = config.showTabs
|
||||||
|
|
|
@ -6,29 +6,31 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.ActivitySettingsBinding
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.ManageAutoBackupsDialog
|
import com.simplemobiletools.contacts.pro.dialogs.ManageAutoBackupsDialog
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
|
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleTabsDialog
|
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleTabsDialog
|
||||||
import com.simplemobiletools.contacts.pro.extensions.cancelScheduledAutomaticBackup
|
import com.simplemobiletools.contacts.pro.extensions.cancelScheduledAutomaticBackup
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import com.simplemobiletools.contacts.pro.extensions.scheduleNextAutomaticBackup
|
import com.simplemobiletools.contacts.pro.extensions.scheduleNextAutomaticBackup
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivitySettingsBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
setContentView(binding.root)
|
||||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||||
|
|
||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
setupManageShownContactFields()
|
setupManageShownContactFields()
|
||||||
|
@ -48,149 +50,149 @@ class SettingsActivity : SimpleActivity() {
|
||||||
setupDefaultTab()
|
setupDefaultTab()
|
||||||
setupEnableAutomaticBackups()
|
setupEnableAutomaticBackups()
|
||||||
setupManageAutomaticBackups()
|
setupManageAutomaticBackups()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(binding.settingsHolder)
|
||||||
|
|
||||||
arrayOf(
|
arrayOf(
|
||||||
settings_color_customization_section_label,
|
binding.settingsColorCustomizationSectionLabel,
|
||||||
settings_general_settings_label,
|
binding.settingsGeneralSettingsLabel,
|
||||||
settings_main_screen_label,
|
binding.settingsMainScreenLabel,
|
||||||
settings_list_view_label,
|
binding.settingsListViewLabel,
|
||||||
settings_backups_label
|
binding.settingsBackupsLabel
|
||||||
).forEach {
|
).forEach {
|
||||||
it.setTextColor(getProperPrimaryColor())
|
it.setTextColor(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCustomizeColors() {
|
private fun setupCustomizeColors() {
|
||||||
settings_color_customization_holder.setOnClickListener {
|
binding.settingsColorCustomizationHolder.setOnClickListener {
|
||||||
startCustomizationActivity()
|
startCustomizationActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageShownContactFields() {
|
private fun setupManageShownContactFields() {
|
||||||
settings_manage_contact_fields_holder.setOnClickListener {
|
binding.settingsManageContactFieldsHolder.setOnClickListener {
|
||||||
ManageVisibleFieldsDialog(this) {}
|
ManageVisibleFieldsDialog(this) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageShownTabs() {
|
private fun setupManageShownTabs() {
|
||||||
settings_manage_shown_tabs_holder.setOnClickListener {
|
binding.settingsManageShownTabsHolder.setOnClickListener {
|
||||||
ManageVisibleTabsDialog(this)
|
ManageVisibleTabsDialog(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDefaultTab() {
|
private fun setupDefaultTab() {
|
||||||
settings_default_tab.text = getDefaultTabText()
|
binding.settingsDefaultTab.text = getDefaultTabText()
|
||||||
settings_default_tab_holder.setOnClickListener {
|
binding.settingsDefaultTabHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(TAB_CONTACTS, getString(R.string.contacts_tab)),
|
RadioItem(TAB_CONTACTS, getString(com.simplemobiletools.commons.R.string.contacts_tab)),
|
||||||
RadioItem(TAB_FAVORITES, getString(R.string.favorites_tab)),
|
RadioItem(TAB_FAVORITES, getString(com.simplemobiletools.commons.R.string.favorites_tab)),
|
||||||
RadioItem(TAB_GROUPS, getString(R.string.groups_tab)),
|
RadioItem(TAB_GROUPS, getString(com.simplemobiletools.commons.R.string.groups_tab)),
|
||||||
RadioItem(TAB_LAST_USED, getString(R.string.last_used_tab))
|
RadioItem(TAB_LAST_USED, getString(com.simplemobiletools.commons.R.string.last_used_tab))
|
||||||
)
|
)
|
||||||
|
|
||||||
RadioGroupDialog(this@SettingsActivity, items, config.defaultTab) {
|
RadioGroupDialog(this@SettingsActivity, items, config.defaultTab) {
|
||||||
config.defaultTab = it as Int
|
config.defaultTab = it as Int
|
||||||
settings_default_tab.text = getDefaultTabText()
|
binding.settingsDefaultTab.text = getDefaultTabText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDefaultTabText() = getString(
|
private fun getDefaultTabText() = getString(
|
||||||
when (baseConfig.defaultTab) {
|
when (baseConfig.defaultTab) {
|
||||||
TAB_CONTACTS -> R.string.contacts_tab
|
TAB_CONTACTS -> com.simplemobiletools.commons.R.string.contacts_tab
|
||||||
TAB_FAVORITES -> R.string.favorites_tab
|
TAB_FAVORITES -> com.simplemobiletools.commons.R.string.favorites_tab
|
||||||
TAB_GROUPS -> R.string.groups_tab
|
TAB_GROUPS -> com.simplemobiletools.commons.R.string.groups_tab
|
||||||
else -> R.string.last_used_tab
|
else -> com.simplemobiletools.commons.R.string.last_used_tab
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun setupFontSize() {
|
private fun setupFontSize() {
|
||||||
settings_font_size.text = getFontSizeText()
|
binding.settingsFontSize.text = getFontSizeText()
|
||||||
settings_font_size_holder.setOnClickListener {
|
binding.settingsFontSizeHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(FONT_SIZE_SMALL, getString(R.string.small)),
|
RadioItem(FONT_SIZE_SMALL, getString(com.simplemobiletools.commons.R.string.small)),
|
||||||
RadioItem(FONT_SIZE_MEDIUM, getString(R.string.medium)),
|
RadioItem(FONT_SIZE_MEDIUM, getString(com.simplemobiletools.commons.R.string.medium)),
|
||||||
RadioItem(FONT_SIZE_LARGE, getString(R.string.large)),
|
RadioItem(FONT_SIZE_LARGE, getString(com.simplemobiletools.commons.R.string.large)),
|
||||||
RadioItem(FONT_SIZE_EXTRA_LARGE, getString(R.string.extra_large))
|
RadioItem(FONT_SIZE_EXTRA_LARGE, getString(com.simplemobiletools.commons.R.string.extra_large))
|
||||||
)
|
)
|
||||||
|
|
||||||
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
|
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
|
||||||
config.fontSize = it as Int
|
config.fontSize = it as Int
|
||||||
settings_font_size.text = getFontSizeText()
|
binding.settingsFontSize.text = getFontSizeText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUseEnglish() {
|
private fun setupUseEnglish() {
|
||||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||||
settings_use_english.isChecked = config.useEnglish
|
binding.settingsUseEnglish.isChecked = config.useEnglish
|
||||||
settings_use_english_holder.setOnClickListener {
|
binding.settingsUseEnglishHolder.setOnClickListener {
|
||||||
settings_use_english.toggle()
|
binding.settingsUseEnglish.toggle()
|
||||||
config.useEnglish = settings_use_english.isChecked
|
config.useEnglish = binding.settingsUseEnglish.isChecked
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLanguage() {
|
private fun setupLanguage() {
|
||||||
settings_language.text = Locale.getDefault().displayLanguage
|
binding.settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||||
settings_language_holder.setOnClickListener {
|
binding.settingsLanguageHolder.setOnClickListener {
|
||||||
launchChangeAppLanguageIntent()
|
launchChangeAppLanguageIntent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowContactThumbnails() {
|
private fun setupShowContactThumbnails() {
|
||||||
settings_show_contact_thumbnails.isChecked = config.showContactThumbnails
|
binding.settingsShowContactThumbnails.isChecked = config.showContactThumbnails
|
||||||
settings_show_contact_thumbnails_holder.setOnClickListener {
|
binding.settingsShowContactThumbnailsHolder.setOnClickListener {
|
||||||
settings_show_contact_thumbnails.toggle()
|
binding.settingsShowContactThumbnails.toggle()
|
||||||
config.showContactThumbnails = settings_show_contact_thumbnails.isChecked
|
config.showContactThumbnails = binding.settingsShowContactThumbnails.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowPhoneNumbers() {
|
private fun setupShowPhoneNumbers() {
|
||||||
settings_show_phone_numbers.isChecked = config.showPhoneNumbers
|
binding.settingsShowPhoneNumbers.isChecked = config.showPhoneNumbers
|
||||||
settings_show_phone_numbers_holder.setOnClickListener {
|
binding.settingsShowPhoneNumbersHolder.setOnClickListener {
|
||||||
settings_show_phone_numbers.toggle()
|
binding.settingsShowPhoneNumbers.toggle()
|
||||||
config.showPhoneNumbers = settings_show_phone_numbers.isChecked
|
config.showPhoneNumbers = binding.settingsShowPhoneNumbers.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowContactsWithNumbers() {
|
private fun setupShowContactsWithNumbers() {
|
||||||
settings_show_only_contacts_with_numbers.isChecked = config.showOnlyContactsWithNumbers
|
binding.settingsShowOnlyContactsWithNumbers.isChecked = config.showOnlyContactsWithNumbers
|
||||||
settings_show_only_contacts_with_numbers_holder.setOnClickListener {
|
binding.settingsShowOnlyContactsWithNumbersHolder.setOnClickListener {
|
||||||
settings_show_only_contacts_with_numbers.toggle()
|
binding.settingsShowOnlyContactsWithNumbers.toggle()
|
||||||
config.showOnlyContactsWithNumbers = settings_show_only_contacts_with_numbers.isChecked
|
config.showOnlyContactsWithNumbers = binding.settingsShowOnlyContactsWithNumbers.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupStartNameWithSurname() {
|
private fun setupStartNameWithSurname() {
|
||||||
settings_start_name_with_surname.isChecked = config.startNameWithSurname
|
binding.settingsStartNameWithSurname.isChecked = config.startNameWithSurname
|
||||||
settings_start_name_with_surname_holder.setOnClickListener {
|
binding.settingsStartNameWithSurnameHolder.setOnClickListener {
|
||||||
settings_start_name_with_surname.toggle()
|
binding.settingsStartNameWithSurname.toggle()
|
||||||
config.startNameWithSurname = settings_start_name_with_surname.isChecked
|
config.startNameWithSurname = binding.settingsStartNameWithSurname.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowDialpadButton() {
|
private fun setupShowDialpadButton() {
|
||||||
settings_show_dialpad_button.isChecked = config.showDialpadButton
|
binding.settingsShowDialpadButton.isChecked = config.showDialpadButton
|
||||||
settings_show_dialpad_button_holder.setOnClickListener {
|
binding.settingsShowDialpadButtonHolder.setOnClickListener {
|
||||||
settings_show_dialpad_button.toggle()
|
binding.settingsShowDialpadButton.toggle()
|
||||||
config.showDialpadButton = settings_show_dialpad_button.isChecked
|
config.showDialpadButton = binding.settingsShowDialpadButton.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowPrivateContacts() {
|
private fun setupShowPrivateContacts() {
|
||||||
settings_show_private_contacts.isChecked = config.showPrivateContacts
|
binding.settingsShowPrivateContacts.isChecked = config.showPrivateContacts
|
||||||
settings_show_private_contacts_holder.setOnClickListener {
|
binding.settingsShowPrivateContactsHolder.setOnClickListener {
|
||||||
settings_show_private_contacts.toggle()
|
binding.settingsShowPrivateContacts.toggle()
|
||||||
config.showPrivateContacts = settings_show_private_contacts.isChecked
|
config.showPrivateContacts = binding.settingsShowPrivateContacts.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOnContactClick() {
|
private fun setupOnContactClick() {
|
||||||
settings_on_contact_click.text = getOnContactClickText()
|
binding.settingsOnContactClick.text = getOnContactClickText()
|
||||||
settings_on_contact_click_holder.setOnClickListener {
|
binding.settingsOnContactClickHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(ON_CLICK_CALL_CONTACT, getString(R.string.call_contact)),
|
RadioItem(ON_CLICK_CALL_CONTACT, getString(R.string.call_contact)),
|
||||||
RadioItem(ON_CLICK_VIEW_CONTACT, getString(R.string.view_contact)),
|
RadioItem(ON_CLICK_VIEW_CONTACT, getString(R.string.view_contact)),
|
||||||
|
@ -199,7 +201,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
RadioGroupDialog(this@SettingsActivity, items, config.onContactClick) {
|
RadioGroupDialog(this@SettingsActivity, items, config.onContactClick) {
|
||||||
config.onContactClick = it as Int
|
config.onContactClick = it as Int
|
||||||
settings_on_contact_click.text = getOnContactClickText()
|
binding.settingsOnContactClick.text = getOnContactClickText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,26 +215,26 @@ class SettingsActivity : SimpleActivity() {
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun setupShowCallConfirmation() {
|
private fun setupShowCallConfirmation() {
|
||||||
settings_show_call_confirmation.isChecked = config.showCallConfirmation
|
binding.settingsShowCallConfirmation.isChecked = config.showCallConfirmation
|
||||||
settings_show_call_confirmation_holder.setOnClickListener {
|
binding.settingsShowCallConfirmationHolder.setOnClickListener {
|
||||||
settings_show_call_confirmation.toggle()
|
binding.settingsShowCallConfirmation.toggle()
|
||||||
config.showCallConfirmation = settings_show_call_confirmation.isChecked
|
config.showCallConfirmation = binding.settingsShowCallConfirmation.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupMergeDuplicateContacts() {
|
private fun setupMergeDuplicateContacts() {
|
||||||
settings_merge_duplicate_contacts.isChecked = config.mergeDuplicateContacts
|
binding.settingsMergeDuplicateContacts.isChecked = config.mergeDuplicateContacts
|
||||||
settings_merge_duplicate_contacts_holder.setOnClickListener {
|
binding.settingsMergeDuplicateContactsHolder.setOnClickListener {
|
||||||
settings_merge_duplicate_contacts.toggle()
|
binding.settingsMergeDuplicateContacts.toggle()
|
||||||
config.mergeDuplicateContacts = settings_merge_duplicate_contacts.isChecked
|
config.mergeDuplicateContacts = binding.settingsMergeDuplicateContacts.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEnableAutomaticBackups() {
|
private fun setupEnableAutomaticBackups() {
|
||||||
settings_backups_label.beVisibleIf(isRPlus())
|
binding.settingsBackupsLabel.beVisibleIf(isRPlus())
|
||||||
settings_enable_automatic_backups_holder.beVisibleIf(isRPlus())
|
binding.settingsEnableAutomaticBackupsHolder.beVisibleIf(isRPlus())
|
||||||
settings_enable_automatic_backups.isChecked = config.autoBackup
|
binding.settingsEnableAutomaticBackups.isChecked = config.autoBackup
|
||||||
settings_enable_automatic_backups_holder.setOnClickListener {
|
binding.settingsEnableAutomaticBackupsHolder.setOnClickListener {
|
||||||
val wasBackupDisabled = !config.autoBackup
|
val wasBackupDisabled = !config.autoBackup
|
||||||
if (wasBackupDisabled) {
|
if (wasBackupDisabled) {
|
||||||
ManageAutoBackupsDialog(
|
ManageAutoBackupsDialog(
|
||||||
|
@ -250,8 +252,8 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageAutomaticBackups() {
|
private fun setupManageAutomaticBackups() {
|
||||||
settings_manage_automatic_backups_holder.beVisibleIf(isRPlus() && config.autoBackup)
|
binding.settingsManageAutomaticBackupsHolder.beVisibleIf(isRPlus() && config.autoBackup)
|
||||||
settings_manage_automatic_backups_holder.setOnClickListener {
|
binding.settingsManageAutomaticBackupsHolder.setOnClickListener {
|
||||||
ManageAutoBackupsDialog(
|
ManageAutoBackupsDialog(
|
||||||
activity = this,
|
activity = this,
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
|
@ -263,7 +265,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun enableOrDisableAutomaticBackups(enable: Boolean) {
|
private fun enableOrDisableAutomaticBackups(enable: Boolean) {
|
||||||
config.autoBackup = enable
|
config.autoBackup = enable
|
||||||
settings_enable_automatic_backups.isChecked = enable
|
binding.settingsEnableAutomaticBackups.isChecked = enable
|
||||||
settings_manage_automatic_backups_holder.beVisibleIf(enable)
|
binding.settingsManageAutomaticBackupsHolder.beVisibleIf(enable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,9 @@ open class SimpleActivity : BaseSimpleActivity() {
|
||||||
|
|
||||||
protected fun getTabIcon(position: Int): Drawable {
|
protected fun getTabIcon(position: Int): Drawable {
|
||||||
val drawableId = when (position) {
|
val drawableId = when (position) {
|
||||||
LOCATION_CONTACTS_TAB -> R.drawable.ic_person_vector
|
LOCATION_CONTACTS_TAB -> com.simplemobiletools.commons.R.drawable.ic_person_vector
|
||||||
LOCATION_FAVORITES_TAB -> R.drawable.ic_star_vector
|
LOCATION_FAVORITES_TAB -> com.simplemobiletools.commons.R.drawable.ic_star_vector
|
||||||
else -> R.drawable.ic_people_vector
|
else -> com.simplemobiletools.commons.R.drawable.ic_people_vector
|
||||||
}
|
}
|
||||||
|
|
||||||
return resources.getColoredDrawableWithColor(drawableId, getProperTextColor())
|
return resources.getColoredDrawableWithColor(drawableId, getProperTextColor())
|
||||||
|
@ -75,9 +75,9 @@ open class SimpleActivity : BaseSimpleActivity() {
|
||||||
|
|
||||||
protected fun getTabLabel(position: Int): String {
|
protected fun getTabLabel(position: Int): String {
|
||||||
val stringId = when (position) {
|
val stringId = when (position) {
|
||||||
LOCATION_CONTACTS_TAB -> R.string.contacts_tab
|
LOCATION_CONTACTS_TAB -> com.simplemobiletools.commons.R.string.contacts_tab
|
||||||
LOCATION_FAVORITES_TAB -> R.string.favorites_tab
|
LOCATION_FAVORITES_TAB -> com.simplemobiletools.commons.R.string.favorites_tab
|
||||||
else -> R.string.groups_tab
|
else -> com.simplemobiletools.commons.R.string.groups_tab
|
||||||
}
|
}
|
||||||
|
|
||||||
return resources.getString(stringId)
|
return resources.getString(stringId)
|
||||||
|
|
|
@ -24,19 +24,14 @@ import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.PhoneNumber
|
import com.simplemobiletools.commons.models.PhoneNumber
|
||||||
import com.simplemobiletools.commons.models.contacts.*
|
import com.simplemobiletools.commons.models.contacts.*
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.*
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.ChooseSocialDialog
|
import com.simplemobiletools.contacts.pro.dialogs.ChooseSocialDialog
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
|
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
|
||||||
import com.simplemobiletools.contacts.pro.extensions.*
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
|
import com.simplemobiletools.contacts.pro.extensions.editContact
|
||||||
|
import com.simplemobiletools.contacts.pro.extensions.getPackageDrawable
|
||||||
|
import com.simplemobiletools.contacts.pro.extensions.startCallIntent
|
||||||
import com.simplemobiletools.contacts.pro.helpers.*
|
import com.simplemobiletools.contacts.pro.helpers.*
|
||||||
import kotlinx.android.synthetic.main.activity_view_contact.*
|
|
||||||
import kotlinx.android.synthetic.main.item_view_address.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_view_contact_source.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_view_email.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_view_event.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_view_group.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_view_im.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_view_phone_number.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_website.view.*
|
|
||||||
|
|
||||||
class ViewContactActivity : ContactActivity() {
|
class ViewContactActivity : ContactActivity() {
|
||||||
private var isViewIntent = false
|
private var isViewIntent = false
|
||||||
|
@ -47,20 +42,23 @@ class ViewContactActivity : ContactActivity() {
|
||||||
private var fullContact: Contact? = null // contact with all fields filled from duplicates
|
private var fullContact: Contact? = null // contact with all fields filled from duplicates
|
||||||
private var duplicateInitialized = false
|
private var duplicateInitialized = false
|
||||||
private val mergeDuplicate: Boolean get() = config.mergeDuplicateContacts
|
private val mergeDuplicate: Boolean get() = config.mergeDuplicateContacts
|
||||||
|
private val binding by viewBinding(ActivityViewContactBinding::inflate)
|
||||||
|
|
||||||
private val COMPARABLE_PHONE_NUMBER_LENGTH = 9
|
companion object {
|
||||||
|
private const val COMPARABLE_PHONE_NUMBER_LENGTH = 9
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
showTransparentTop = true
|
showTransparentTop = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_view_contact)
|
setContentView(binding.root)
|
||||||
|
|
||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
showFields = config.showContactFields
|
showFields = config.showContactFields
|
||||||
contact_wrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
binding.contactWrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
setupMenu()
|
setupMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +72,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
initContact()
|
initContact()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_contacts_permission)
|
toast(com.simplemobiletools.commons.R.string.no_contacts_permission)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +84,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (contact_photo_big.alpha == 1f) {
|
if (binding.contactPhotoBig.alpha == 1f) {
|
||||||
hideBigContactPhoto()
|
hideBigContactPhoto()
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
@ -94,8 +92,8 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupMenu() {
|
private fun setupMenu() {
|
||||||
(contact_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
(binding.contactAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
contact_toolbar.menu.apply {
|
binding.contactToolbar.menu.apply {
|
||||||
findItem(R.id.share).setOnMenuItemClickListener {
|
findItem(R.id.share).setOnMenuItemClickListener {
|
||||||
if (fullContact != null) {
|
if (fullContact != null) {
|
||||||
shareContact(fullContact!!)
|
shareContact(fullContact!!)
|
||||||
|
@ -131,7 +129,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_toolbar.setNavigationOnClickListener {
|
binding.contactToolbar.setNavigationOnClickListener {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +171,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
|
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
if (!wasEditLaunched) {
|
if (!wasEditLaunched) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
finish()
|
finish()
|
||||||
} else {
|
} else {
|
||||||
|
@ -197,54 +195,55 @@ class ViewContactActivity : ContactActivity() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_scrollview.beVisible()
|
binding.contactScrollview.beVisible()
|
||||||
setupViewContact()
|
setupViewContact()
|
||||||
contact_send_sms.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
binding.contactSendSms.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
||||||
contact_start_call.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
binding.contactStartCall.beVisibleIf(contact!!.phoneNumbers.isNotEmpty())
|
||||||
contact_send_email.beVisibleIf(contact!!.emails.isNotEmpty())
|
binding.contactSendEmail.beVisibleIf(contact!!.emails.isNotEmpty())
|
||||||
|
|
||||||
if (contact!!.photoUri.isEmpty() && contact!!.photo == null) {
|
if (contact!!.photoUri.isEmpty() && contact!!.photo == null) {
|
||||||
showPhotoPlaceholder(contact_photo)
|
showPhotoPlaceholder(binding.contactPhoto)
|
||||||
contact_photo_bottom_shadow.beGone()
|
binding.contactPhotoBottomShadow.beGone()
|
||||||
} else {
|
} else {
|
||||||
updateContactPhoto(contact!!.photoUri, contact_photo, contact_photo_bottom_shadow, contact!!.photo)
|
updateContactPhoto(contact!!.photoUri, binding.contactPhoto, binding.contactPhotoBottomShadow, contact!!.photo)
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.transform(FitCenter(), RoundedCorners(resources.getDimension(R.dimen.normal_margin).toInt()))
|
.transform(FitCenter(), RoundedCorners(resources.getDimension(com.simplemobiletools.commons.R.dimen.normal_margin).toInt()))
|
||||||
|
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.load(contact!!.photo ?: currentContactPhotoPath)
|
.load(contact!!.photo ?: currentContactPhotoPath)
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.into(contact_photo_big)
|
.into(binding.contactPhotoBig)
|
||||||
|
|
||||||
contact_photo.setOnClickListener {
|
binding.contactPhoto.setOnClickListener {
|
||||||
contact_photo_big.alpha = 0f
|
binding.contactPhotoBig.alpha = 0f
|
||||||
contact_photo_big.beVisible()
|
binding.contactPhotoBig.beVisible()
|
||||||
contact_photo_big.animate().alpha(1f).start()
|
binding.contactPhotoBig.animate().alpha(1f).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_photo_big.setOnClickListener {
|
binding.contactPhotoBig.setOnClickListener {
|
||||||
hideBigContactPhoto()
|
hideBigContactPhoto()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val textColor = getProperTextColor()
|
val textColor = getProperTextColor()
|
||||||
arrayOf(
|
arrayOf(
|
||||||
contact_name_image, contact_numbers_image, contact_emails_image, contact_addresses_image, contact_ims_image, contact_events_image,
|
binding.contactNameImage, binding.contactNumbersImage, binding.contactEmailsImage, binding.contactAddressesImage, binding.contactImsImage,
|
||||||
contact_source_image, contact_notes_image, contact_ringtone_image, contact_organization_image, contact_websites_image, contact_groups_image
|
binding.contactEventsImage, binding.contactSourceImage, binding.contactNotesImage, binding.contactRingtoneImage, binding.contactOrganizationImage,
|
||||||
|
binding.contactWebsitesImage, binding.contactGroupsImage
|
||||||
).forEach {
|
).forEach {
|
||||||
it.applyColorFilter(textColor)
|
it.applyColorFilter(textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_send_sms.setOnClickListener { trySendSMS() }
|
binding.contactSendSms.setOnClickListener { trySendSMS() }
|
||||||
contact_start_call.setOnClickListener { tryInitiateCall(contact!!) { startCallIntent(it) } }
|
binding.contactStartCall.setOnClickListener { tryInitiateCall(contact!!) { startCallIntent(it) } }
|
||||||
contact_send_email.setOnClickListener { trySendEmail() }
|
binding.contactSendEmail.setOnClickListener { trySendEmail() }
|
||||||
|
|
||||||
contact_send_sms.setOnLongClickListener { toast(R.string.send_sms); true; }
|
binding.contactSendSms.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.send_sms); true; }
|
||||||
contact_start_call.setOnLongClickListener { toast(R.string.call_contact); true; }
|
binding.contactStartCall.setOnLongClickListener { toast(R.string.call_contact); true; }
|
||||||
contact_send_email.setOnLongClickListener { toast(R.string.send_email); true; }
|
binding.contactSendEmail.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.send_email); true; }
|
||||||
|
|
||||||
updateTextColors(contact_scrollview)
|
updateTextColors(binding.contactScrollview)
|
||||||
contact_toolbar.menu.findItem(R.id.open_with).isVisible = contact?.isPrivate() == false
|
binding.contactToolbar.menu.findItem(R.id.open_with).isVisible = contact?.isPrivate() == false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViewContact() {
|
private fun setupViewContact() {
|
||||||
|
@ -281,7 +280,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
setupNotes()
|
setupNotes()
|
||||||
setupRingtone()
|
setupRingtone()
|
||||||
setupOrganization()
|
setupOrganization()
|
||||||
updateTextColors(contact_scrollview)
|
updateTextColors(binding.contactScrollview)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchEditContact(contact: Contact) {
|
private fun launchEditContact(contact: Contact) {
|
||||||
|
@ -298,7 +297,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFavorite() {
|
private fun setupFavorite() {
|
||||||
contact_toggle_favorite.apply {
|
binding.contactToggleFavorite.apply {
|
||||||
beVisible()
|
beVisible()
|
||||||
tag = contact!!.starred
|
tag = contact!!.starred
|
||||||
setImageDrawable(getStarDrawable(tag == 1))
|
setImageDrawable(getStarDrawable(tag == 1))
|
||||||
|
@ -331,10 +330,10 @@ class ViewContactActivity : ContactActivity() {
|
||||||
val showNameFields = showFields and SHOW_PREFIX_FIELD != 0 || showFields and SHOW_FIRST_NAME_FIELD != 0 || showFields and SHOW_MIDDLE_NAME_FIELD != 0 ||
|
val showNameFields = showFields and SHOW_PREFIX_FIELD != 0 || showFields and SHOW_FIRST_NAME_FIELD != 0 || showFields and SHOW_MIDDLE_NAME_FIELD != 0 ||
|
||||||
showFields and SHOW_SURNAME_FIELD != 0 || showFields and SHOW_SUFFIX_FIELD != 0
|
showFields and SHOW_SURNAME_FIELD != 0 || showFields and SHOW_SUFFIX_FIELD != 0
|
||||||
|
|
||||||
contact_name.text = displayName
|
binding.contactName.text = displayName
|
||||||
contact_name.copyOnLongClick(displayName)
|
binding.contactName.copyOnLongClick(displayName)
|
||||||
contact_name.beVisibleIf(displayName.isNotEmpty() && !contact!!.isABusinessContact() && showNameFields)
|
binding.contactName.beVisibleIf(displayName.isNotEmpty() && !contact!!.isABusinessContact() && showNameFields)
|
||||||
contact_name_image.beInvisibleIf(contact_name.isGone())
|
binding.contactNameImage.beInvisibleIf(binding.contactName.isGone())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPhoneNumbers() {
|
private fun setupPhoneNumbers() {
|
||||||
|
@ -377,17 +376,17 @@ class ViewContactActivity : ContactActivity() {
|
||||||
|
|
||||||
phoneNumbers = phoneNumbers.sortedBy { it.type }.toMutableSet() as LinkedHashSet<PhoneNumber>
|
phoneNumbers = phoneNumbers.sortedBy { it.type }.toMutableSet() as LinkedHashSet<PhoneNumber>
|
||||||
fullContact!!.phoneNumbers = phoneNumbers.toMutableList() as ArrayList<PhoneNumber>
|
fullContact!!.phoneNumbers = phoneNumbers.toMutableList() as ArrayList<PhoneNumber>
|
||||||
contact_numbers_holder.removeAllViews()
|
binding.contactNumbersHolder.removeAllViews()
|
||||||
|
|
||||||
if (phoneNumbers.isNotEmpty() && showFields and SHOW_PHONE_NUMBERS_FIELD != 0) {
|
if (phoneNumbers.isNotEmpty() && showFields and SHOW_PHONE_NUMBERS_FIELD != 0) {
|
||||||
phoneNumbers.forEach { phoneNumber ->
|
phoneNumbers.forEach { phoneNumber ->
|
||||||
layoutInflater.inflate(R.layout.item_view_phone_number, contact_numbers_holder, false).apply {
|
ItemViewPhoneNumberBinding.inflate(layoutInflater, binding.contactNumbersHolder, false).apply {
|
||||||
contact_numbers_holder.addView(this)
|
binding.contactNumbersHolder.addView(root)
|
||||||
contact_number.text = phoneNumber.value
|
contactNumber.text = phoneNumber.value
|
||||||
contact_number_type.text = getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)
|
contactNumberType.text = getPhoneNumberTypeText(phoneNumber.type, phoneNumber.label)
|
||||||
copyOnLongClick(phoneNumber.value)
|
root.copyOnLongClick(phoneNumber.value)
|
||||||
|
|
||||||
setOnClickListener {
|
root.setOnClickListener {
|
||||||
if (config.showCallConfirmation) {
|
if (config.showCallConfirmation) {
|
||||||
CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) {
|
CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) {
|
||||||
startCallIntent(phoneNumber.value)
|
startCallIntent(phoneNumber.value)
|
||||||
|
@ -397,46 +396,46 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_number_holder.default_toggle_icon.isVisible = phoneNumber.isPrimary
|
defaultToggleIcon.isVisible = phoneNumber.isPrimary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contact_numbers_image.beVisible()
|
binding.contactNumbersImage.beVisible()
|
||||||
contact_numbers_holder.beVisible()
|
binding.contactNumbersHolder.beVisible()
|
||||||
} else {
|
} else {
|
||||||
contact_numbers_image.beGone()
|
binding.contactNumbersImage.beGone()
|
||||||
contact_numbers_holder.beGone()
|
binding.contactNumbersHolder.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the Call and SMS buttons are visible if any phone number is shown
|
// make sure the Call and SMS buttons are visible if any phone number is shown
|
||||||
if (phoneNumbers.isNotEmpty()) {
|
if (phoneNumbers.isNotEmpty()) {
|
||||||
contact_send_sms.beVisible()
|
binding.contactSendSms.beVisible()
|
||||||
contact_start_call.beVisible()
|
binding.contactStartCall.beVisible()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// a contact cannot have different emails per contact source. Such contacts are handled as separate ones, not duplicates of each other
|
// a contact cannot have different emails per contact source. Such contacts are handled as separate ones, not duplicates of each other
|
||||||
private fun setupEmails() {
|
private fun setupEmails() {
|
||||||
contact_emails_holder.removeAllViews()
|
binding.contactEmailsHolder.removeAllViews()
|
||||||
val emails = contact!!.emails
|
val emails = contact!!.emails
|
||||||
if (emails.isNotEmpty() && showFields and SHOW_EMAILS_FIELD != 0) {
|
if (emails.isNotEmpty() && showFields and SHOW_EMAILS_FIELD != 0) {
|
||||||
emails.forEach {
|
emails.forEach {
|
||||||
layoutInflater.inflate(R.layout.item_view_email, contact_emails_holder, false).apply {
|
ItemViewEmailBinding.inflate(layoutInflater, binding.contactEmailsHolder, false).apply {
|
||||||
val email = it
|
val email = it
|
||||||
contact_emails_holder.addView(this)
|
binding.contactEmailsHolder.addView(root)
|
||||||
contact_email.text = email.value
|
contactEmail.text = email.value
|
||||||
contact_email_type.text = getEmailTypeText(email.type, email.label)
|
contactEmailType.text = getEmailTypeText(email.type, email.label)
|
||||||
copyOnLongClick(email.value)
|
root.copyOnLongClick(email.value)
|
||||||
|
|
||||||
setOnClickListener {
|
root.setOnClickListener {
|
||||||
sendEmailIntent(email.value)
|
sendEmailIntent(email.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contact_emails_image.beVisible()
|
binding.contactEmailsImage.beVisible()
|
||||||
contact_emails_holder.beVisible()
|
binding.contactEmailsHolder.beVisible()
|
||||||
} else {
|
} else {
|
||||||
contact_emails_image.beGone()
|
binding.contactEmailsImage.beGone()
|
||||||
contact_emails_holder.beGone()
|
binding.contactEmailsHolder.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,27 +450,27 @@ class ViewContactActivity : ContactActivity() {
|
||||||
|
|
||||||
addresses = addresses.sortedBy { it.type }.toMutableSet() as LinkedHashSet<Address>
|
addresses = addresses.sortedBy { it.type }.toMutableSet() as LinkedHashSet<Address>
|
||||||
fullContact!!.addresses = addresses.toMutableList() as ArrayList<Address>
|
fullContact!!.addresses = addresses.toMutableList() as ArrayList<Address>
|
||||||
contact_addresses_holder.removeAllViews()
|
binding.contactAddressesHolder.removeAllViews()
|
||||||
|
|
||||||
if (addresses.isNotEmpty() && showFields and SHOW_ADDRESSES_FIELD != 0) {
|
if (addresses.isNotEmpty() && showFields and SHOW_ADDRESSES_FIELD != 0) {
|
||||||
addresses.forEach {
|
addresses.forEach {
|
||||||
layoutInflater.inflate(R.layout.item_view_address, contact_addresses_holder, false).apply {
|
ItemViewAddressBinding.inflate(layoutInflater, binding.contactAddressesHolder, false).apply {
|
||||||
val address = it
|
val address = it
|
||||||
contact_addresses_holder.addView(this)
|
binding.contactAddressesHolder.addView(root)
|
||||||
contact_address.text = address.value
|
contactAddress.text = address.value
|
||||||
contact_address_type.text = getAddressTypeText(address.type, address.label)
|
contactAddressType.text = getAddressTypeText(address.type, address.label)
|
||||||
copyOnLongClick(address.value)
|
root.copyOnLongClick(address.value)
|
||||||
|
|
||||||
setOnClickListener {
|
root.setOnClickListener {
|
||||||
sendAddressIntent(address.value)
|
sendAddressIntent(address.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contact_addresses_image.beVisible()
|
binding.contactAddressesImage.beVisible()
|
||||||
contact_addresses_holder.beVisible()
|
binding.contactAddressesHolder.beVisible()
|
||||||
} else {
|
} else {
|
||||||
contact_addresses_image.beGone()
|
binding.contactAddressesImage.beGone()
|
||||||
contact_addresses_holder.beGone()
|
binding.contactAddressesHolder.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,23 +485,23 @@ class ViewContactActivity : ContactActivity() {
|
||||||
|
|
||||||
IMs = IMs.sortedBy { it.type }.toMutableSet() as LinkedHashSet<IM>
|
IMs = IMs.sortedBy { it.type }.toMutableSet() as LinkedHashSet<IM>
|
||||||
fullContact!!.IMs = IMs.toMutableList() as ArrayList<IM>
|
fullContact!!.IMs = IMs.toMutableList() as ArrayList<IM>
|
||||||
contact_ims_holder.removeAllViews()
|
binding.contactImsHolder.removeAllViews()
|
||||||
|
|
||||||
if (IMs.isNotEmpty() && showFields and SHOW_IMS_FIELD != 0) {
|
if (IMs.isNotEmpty() && showFields and SHOW_IMS_FIELD != 0) {
|
||||||
IMs.forEach {
|
IMs.forEach {
|
||||||
layoutInflater.inflate(R.layout.item_view_im, contact_ims_holder, false).apply {
|
ItemViewImBinding.inflate(layoutInflater, binding.contactImsHolder, false).apply {
|
||||||
val IM = it
|
val IM = it
|
||||||
contact_ims_holder.addView(this)
|
binding.contactImsHolder.addView(root)
|
||||||
contact_im.text = IM.value
|
contactIm.text = IM.value
|
||||||
contact_im_type.text = getIMTypeText(IM.type, IM.label)
|
contactImType.text = getIMTypeText(IM.type, IM.label)
|
||||||
copyOnLongClick(IM.value)
|
root.copyOnLongClick(IM.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contact_ims_image.beVisible()
|
binding.contactImsImage.beVisible()
|
||||||
contact_ims_holder.beVisible()
|
binding.contactImsHolder.beVisible()
|
||||||
} else {
|
} else {
|
||||||
contact_ims_image.beGone()
|
binding.contactImsImage.beGone()
|
||||||
contact_ims_holder.beGone()
|
binding.contactImsHolder.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,22 +516,22 @@ class ViewContactActivity : ContactActivity() {
|
||||||
|
|
||||||
events = events.sortedBy { it.type }.toMutableSet() as LinkedHashSet<Event>
|
events = events.sortedBy { it.type }.toMutableSet() as LinkedHashSet<Event>
|
||||||
fullContact!!.events = events.toMutableList() as ArrayList<Event>
|
fullContact!!.events = events.toMutableList() as ArrayList<Event>
|
||||||
contact_events_holder.removeAllViews()
|
binding.contactEventsHolder.removeAllViews()
|
||||||
|
|
||||||
if (events.isNotEmpty() && showFields and SHOW_EVENTS_FIELD != 0) {
|
if (events.isNotEmpty() && showFields and SHOW_EVENTS_FIELD != 0) {
|
||||||
events.forEach {
|
events.forEach {
|
||||||
layoutInflater.inflate(R.layout.item_view_event, contact_events_holder, false).apply {
|
ItemViewEventBinding.inflate(layoutInflater, binding.contactEventsHolder, false).apply {
|
||||||
contact_events_holder.addView(this)
|
binding.contactEventsHolder.addView(root)
|
||||||
it.value.getDateTimeFromDateString(true, contact_event)
|
it.value.getDateTimeFromDateString(true, contactEvent)
|
||||||
contact_event_type.setText(getEventTextId(it.type))
|
contactEventType.setText(getEventTextId(it.type))
|
||||||
copyOnLongClick(it.value)
|
root.copyOnLongClick(it.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contact_events_image.beVisible()
|
binding.contactEventsImage.beVisible()
|
||||||
contact_events_holder.beVisible()
|
binding.contactEventsHolder.beVisible()
|
||||||
} else {
|
} else {
|
||||||
contact_events_image.beGone()
|
binding.contactEventsImage.beGone()
|
||||||
contact_events_holder.beGone()
|
binding.contactEventsHolder.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,26 +546,26 @@ class ViewContactActivity : ContactActivity() {
|
||||||
|
|
||||||
websites = websites.sorted().toMutableSet() as LinkedHashSet<String>
|
websites = websites.sorted().toMutableSet() as LinkedHashSet<String>
|
||||||
fullContact!!.websites = websites.toMutableList() as ArrayList<String>
|
fullContact!!.websites = websites.toMutableList() as ArrayList<String>
|
||||||
contact_websites_holder.removeAllViews()
|
binding.contactWebsitesHolder.removeAllViews()
|
||||||
|
|
||||||
if (websites.isNotEmpty() && showFields and SHOW_WEBSITES_FIELD != 0) {
|
if (websites.isNotEmpty() && showFields and SHOW_WEBSITES_FIELD != 0) {
|
||||||
websites.forEach {
|
websites.forEach {
|
||||||
val url = it
|
val url = it
|
||||||
layoutInflater.inflate(R.layout.item_website, contact_websites_holder, false).apply {
|
ItemWebsiteBinding.inflate(layoutInflater, binding.contactWebsitesHolder, false).apply {
|
||||||
contact_websites_holder.addView(this)
|
binding.contactWebsitesHolder.addView(root)
|
||||||
contact_website.text = url
|
contactWebsite.text = url
|
||||||
copyOnLongClick(url)
|
root.copyOnLongClick(url)
|
||||||
|
|
||||||
setOnClickListener {
|
root.setOnClickListener {
|
||||||
openWebsiteIntent(url)
|
openWebsiteIntent(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contact_websites_image.beVisible()
|
binding.contactWebsitesImage.beVisible()
|
||||||
contact_websites_holder.beVisible()
|
binding.contactWebsitesHolder.beVisible()
|
||||||
} else {
|
} else {
|
||||||
contact_websites_image.beGone()
|
binding.contactWebsitesImage.beGone()
|
||||||
contact_websites_holder.beGone()
|
binding.contactWebsitesHolder.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,27 +580,27 @@ class ViewContactActivity : ContactActivity() {
|
||||||
|
|
||||||
groups = groups.sortedBy { it.title }.toMutableSet() as LinkedHashSet<Group>
|
groups = groups.sortedBy { it.title }.toMutableSet() as LinkedHashSet<Group>
|
||||||
fullContact!!.groups = groups.toMutableList() as ArrayList<Group>
|
fullContact!!.groups = groups.toMutableList() as ArrayList<Group>
|
||||||
contact_groups_holder.removeAllViews()
|
binding.contactGroupsHolder.removeAllViews()
|
||||||
|
|
||||||
if (groups.isNotEmpty() && showFields and SHOW_GROUPS_FIELD != 0) {
|
if (groups.isNotEmpty() && showFields and SHOW_GROUPS_FIELD != 0) {
|
||||||
groups.forEach {
|
groups.forEach {
|
||||||
layoutInflater.inflate(R.layout.item_view_group, contact_groups_holder, false).apply {
|
ItemViewGroupBinding.inflate(layoutInflater, binding.contactGroupsHolder, false).apply {
|
||||||
val group = it
|
val group = it
|
||||||
contact_groups_holder.addView(this)
|
binding.contactGroupsHolder.addView(root)
|
||||||
contact_group.text = group.title
|
contactGroup.text = group.title
|
||||||
copyOnLongClick(group.title)
|
root.copyOnLongClick(group.title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contact_groups_image.beVisible()
|
binding.contactGroupsImage.beVisible()
|
||||||
contact_groups_holder.beVisible()
|
binding.contactGroupsHolder.beVisible()
|
||||||
} else {
|
} else {
|
||||||
contact_groups_image.beGone()
|
binding.contactGroupsImage.beGone()
|
||||||
contact_groups_holder.beGone()
|
binding.contactGroupsHolder.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupContactSources() {
|
private fun setupContactSources() {
|
||||||
contact_sources_holder.removeAllViews()
|
binding.contactSourcesHolder.removeAllViews()
|
||||||
if (showFields and SHOW_CONTACT_SOURCE_FIELD != 0) {
|
if (showFields and SHOW_CONTACT_SOURCE_FIELD != 0) {
|
||||||
var sources = HashMap<Contact, String>()
|
var sources = HashMap<Contact, String>()
|
||||||
sources[contact!!] = getPublicContactSourceSync(contact!!.source, contactSources)
|
sources[contact!!] = getPublicContactSourceSync(contact!!.source, contactSources)
|
||||||
|
@ -617,101 +616,101 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for ((key, value) in sources) {
|
for ((key, value) in sources) {
|
||||||
layoutInflater.inflate(R.layout.item_view_contact_source, contact_sources_holder, false).apply {
|
ItemViewContactSourceBinding.inflate(layoutInflater, binding.contactSourcesHolder, false).apply {
|
||||||
contact_source.text = if (value == "") getString(R.string.phone_storage) else value
|
contactSource.text = if (value == "") getString(R.string.phone_storage) else value
|
||||||
contact_source.copyOnLongClick(value)
|
contactSource.copyOnLongClick(value)
|
||||||
contact_sources_holder.addView(this)
|
binding.contactSourcesHolder.addView(root)
|
||||||
|
|
||||||
contact_source.setOnClickListener {
|
contactSource.setOnClickListener {
|
||||||
launchEditContact(key)
|
launchEditContact(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.toLowerCase() == WHATSAPP) {
|
if (value.toLowerCase() == WHATSAPP) {
|
||||||
contact_source_image.setImageDrawable(getPackageDrawable(WHATSAPP_PACKAGE))
|
contactSourceImage.setImageDrawable(getPackageDrawable(WHATSAPP_PACKAGE))
|
||||||
contact_source_image.beVisible()
|
contactSourceImage.beVisible()
|
||||||
contact_source_image.setOnClickListener {
|
contactSourceImage.setOnClickListener {
|
||||||
showSocialActions(key.id)
|
showSocialActions(key.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.toLowerCase() == SIGNAL) {
|
if (value.toLowerCase() == SIGNAL) {
|
||||||
contact_source_image.setImageDrawable(getPackageDrawable(SIGNAL_PACKAGE))
|
contactSourceImage.setImageDrawable(getPackageDrawable(SIGNAL_PACKAGE))
|
||||||
contact_source_image.beVisible()
|
contactSourceImage.beVisible()
|
||||||
contact_source_image.setOnClickListener {
|
contactSourceImage.setOnClickListener {
|
||||||
showSocialActions(key.id)
|
showSocialActions(key.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.toLowerCase() == VIBER) {
|
if (value.toLowerCase() == VIBER) {
|
||||||
contact_source_image.setImageDrawable(getPackageDrawable(VIBER_PACKAGE))
|
contactSourceImage.setImageDrawable(getPackageDrawable(VIBER_PACKAGE))
|
||||||
contact_source_image.beVisible()
|
contactSourceImage.beVisible()
|
||||||
contact_source_image.setOnClickListener {
|
contactSourceImage.setOnClickListener {
|
||||||
showSocialActions(key.id)
|
showSocialActions(key.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.toLowerCase() == TELEGRAM) {
|
if (value.toLowerCase() == TELEGRAM) {
|
||||||
contact_source_image.setImageDrawable(getPackageDrawable(TELEGRAM_PACKAGE))
|
contactSourceImage.setImageDrawable(getPackageDrawable(TELEGRAM_PACKAGE))
|
||||||
contact_source_image.beVisible()
|
contactSourceImage.beVisible()
|
||||||
contact_source_image.setOnClickListener {
|
contactSourceImage.setOnClickListener {
|
||||||
showSocialActions(key.id)
|
showSocialActions(key.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.toLowerCase() == THREEMA) {
|
if (value.toLowerCase() == THREEMA) {
|
||||||
contact_source_image.setImageDrawable(getPackageDrawable(THREEMA_PACKAGE))
|
contactSourceImage.setImageDrawable(getPackageDrawable(THREEMA_PACKAGE))
|
||||||
contact_source_image.beVisible()
|
contactSourceImage.beVisible()
|
||||||
contact_source_image.setOnClickListener {
|
contactSourceImage.setOnClickListener {
|
||||||
showSocialActions(key.id)
|
showSocialActions(key.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_source_image.beVisible()
|
binding.contactSourceImage.beVisible()
|
||||||
contact_sources_holder.beVisible()
|
binding.contactSourcesHolder.beVisible()
|
||||||
} else {
|
} else {
|
||||||
contact_source_image.beGone()
|
binding.contactSourceImage.beGone()
|
||||||
contact_sources_holder.beGone()
|
binding.contactSourcesHolder.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupNotes() {
|
private fun setupNotes() {
|
||||||
val notes = contact!!.notes
|
val notes = contact!!.notes
|
||||||
if (notes.isNotEmpty() && showFields and SHOW_NOTES_FIELD != 0) {
|
if (notes.isNotEmpty() && showFields and SHOW_NOTES_FIELD != 0) {
|
||||||
contact_notes.text = notes
|
binding.contactNotes.text = notes
|
||||||
contact_notes_image.beVisible()
|
binding.contactNotesImage.beVisible()
|
||||||
contact_notes.beVisible()
|
binding.contactNotes.beVisible()
|
||||||
contact_notes.copyOnLongClick(notes)
|
binding.contactNotes.copyOnLongClick(notes)
|
||||||
} else {
|
} else {
|
||||||
contact_notes_image.beGone()
|
binding.contactNotesImage.beGone()
|
||||||
contact_notes.beGone()
|
binding.contactNotes.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupRingtone() {
|
private fun setupRingtone() {
|
||||||
if (showFields and SHOW_RINGTONE_FIELD != 0) {
|
if (showFields and SHOW_RINGTONE_FIELD != 0) {
|
||||||
contact_ringtone_image.beVisible()
|
binding.contactRingtoneImage.beVisible()
|
||||||
contact_ringtone.beVisible()
|
binding.contactRingtone.beVisible()
|
||||||
|
|
||||||
val ringtone = contact!!.ringtone
|
val ringtone = contact!!.ringtone
|
||||||
if (ringtone?.isEmpty() == true) {
|
if (ringtone?.isEmpty() == true) {
|
||||||
contact_ringtone.text = getString(R.string.no_sound)
|
binding.contactRingtone.text = getString(com.simplemobiletools.commons.R.string.no_sound)
|
||||||
} else if (ringtone?.isNotEmpty() == true && ringtone != getDefaultRingtoneUri().toString()) {
|
} else if (ringtone?.isNotEmpty() == true && ringtone != getDefaultRingtoneUri().toString()) {
|
||||||
if (ringtone == SILENT) {
|
if (ringtone == SILENT) {
|
||||||
contact_ringtone.text = getString(R.string.no_sound)
|
binding.contactRingtone.text = getString(com.simplemobiletools.commons.R.string.no_sound)
|
||||||
} else {
|
} else {
|
||||||
systemRingtoneSelected(Uri.parse(ringtone))
|
systemRingtoneSelected(Uri.parse(ringtone))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contact_ringtone_image.beGone()
|
binding.contactRingtoneImage.beGone()
|
||||||
contact_ringtone.beGone()
|
binding.contactRingtone.beGone()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_ringtone.copyOnLongClick(contact_ringtone.text.toString())
|
binding.contactRingtone.copyOnLongClick(binding.contactRingtone.text.toString())
|
||||||
|
|
||||||
contact_ringtone.setOnClickListener {
|
binding.contactRingtone.setOnClickListener {
|
||||||
val ringtonePickerIntent = getRingtonePickerIntent()
|
val ringtonePickerIntent = getRingtonePickerIntent()
|
||||||
try {
|
try {
|
||||||
startActivityForResult(ringtonePickerIntent, INTENT_SELECT_RINGTONE)
|
startActivityForResult(ringtonePickerIntent, INTENT_SELECT_RINGTONE)
|
||||||
|
@ -724,7 +723,7 @@ class ViewContactActivity : ContactActivity() {
|
||||||
RingtoneManager.TYPE_RINGTONE,
|
RingtoneManager.TYPE_RINGTONE,
|
||||||
true,
|
true,
|
||||||
onAlarmPicked = {
|
onAlarmPicked = {
|
||||||
contact_ringtone.text = it?.title
|
binding.contactRingtone.text = it?.title
|
||||||
ringtoneUpdated(it?.uri)
|
ringtoneUpdated(it?.uri)
|
||||||
},
|
},
|
||||||
onAlarmSoundDeleted = {}
|
onAlarmSoundDeleted = {}
|
||||||
|
@ -732,29 +731,32 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contact_ringtone_image.beGone()
|
binding.contactRingtoneImage.beGone()
|
||||||
contact_ringtone.beGone()
|
binding.contactRingtone.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOrganization() {
|
private fun setupOrganization() {
|
||||||
val organization = contact!!.organization
|
val organization = contact!!.organization
|
||||||
if (organization.isNotEmpty() && showFields and SHOW_ORGANIZATION_FIELD != 0) {
|
if (organization.isNotEmpty() && showFields and SHOW_ORGANIZATION_FIELD != 0) {
|
||||||
contact_organization_company.text = organization.company
|
binding.contactOrganizationCompany.text = organization.company
|
||||||
contact_organization_job_position.text = organization.jobPosition
|
binding.contactOrganizationJobPosition.text = organization.jobPosition
|
||||||
contact_organization_image.beGoneIf(organization.isEmpty())
|
binding.contactOrganizationImage.beGoneIf(organization.isEmpty())
|
||||||
contact_organization_company.beGoneIf(organization.company.isEmpty())
|
binding.contactOrganizationCompany.beGoneIf(organization.company.isEmpty())
|
||||||
contact_organization_job_position.beGoneIf(organization.jobPosition.isEmpty())
|
binding.contactOrganizationJobPosition.beGoneIf(organization.jobPosition.isEmpty())
|
||||||
contact_organization_company.copyOnLongClick(contact_organization_company.value)
|
binding.contactOrganizationCompany.copyOnLongClick(binding.contactOrganizationCompany.value)
|
||||||
contact_organization_job_position.copyOnLongClick(contact_organization_job_position.value)
|
binding.contactOrganizationJobPosition.copyOnLongClick(binding.contactOrganizationJobPosition.value)
|
||||||
|
|
||||||
if (organization.company.isEmpty() && organization.jobPosition.isNotEmpty()) {
|
if (organization.company.isEmpty() && organization.jobPosition.isNotEmpty()) {
|
||||||
(contact_organization_image.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ALIGN_TOP, contact_organization_job_position.id)
|
(binding.contactOrganizationImage.layoutParams as RelativeLayout.LayoutParams).addRule(
|
||||||
|
RelativeLayout.ALIGN_TOP,
|
||||||
|
binding.contactOrganizationJobPosition.id
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contact_organization_image.beGone()
|
binding.contactOrganizationImage.beGone()
|
||||||
contact_organization_company.beGone()
|
binding.contactOrganizationCompany.beGone()
|
||||||
contact_organization_job_position.beGone()
|
binding.contactOrganizationJobPosition.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,11 +777,11 @@ class ViewContactActivity : ContactActivity() {
|
||||||
if (success) {
|
if (success) {
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_phone_call_permission)
|
toast(com.simplemobiletools.commons.R.string.no_phone_call_permission)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
toast(R.string.no_app_found)
|
toast(com.simplemobiletools.commons.R.string.no_app_found)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -791,13 +793,13 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun customRingtoneSelected(ringtonePath: String) {
|
override fun customRingtoneSelected(ringtonePath: String) {
|
||||||
contact_ringtone.text = ringtonePath.getFilenameFromPath()
|
binding.contactRingtone.text = ringtonePath.getFilenameFromPath()
|
||||||
ringtoneUpdated(ringtonePath)
|
ringtoneUpdated(ringtonePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun systemRingtoneSelected(uri: Uri?) {
|
override fun systemRingtoneSelected(uri: Uri?) {
|
||||||
val contactRingtone = RingtoneManager.getRingtone(this, uri)
|
val contactRingtone = RingtoneManager.getRingtone(this, uri)
|
||||||
contact_ringtone.text = contactRingtone.getTitle(this)
|
binding.contactRingtone.text = contactRingtone.getTitle(this)
|
||||||
ringtoneUpdated(uri?.toString() ?: "")
|
ringtoneUpdated(uri?.toString() ?: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,13 +835,13 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteContactFromAllSources() {
|
private fun deleteContactFromAllSources() {
|
||||||
val addition = if (contact_sources_holder.childCount > 1) {
|
val addition = if (binding.contactSourcesHolder.childCount > 1) {
|
||||||
"\n\n${getString(R.string.delete_from_all_sources)}"
|
"\n\n${getString(R.string.delete_from_all_sources)}"
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
val message = "${getString(R.string.proceed_with_deletion)}$addition"
|
val message = "${getString(com.simplemobiletools.commons.R.string.proceed_with_deletion)}$addition"
|
||||||
ConfirmationDialog(this, message) {
|
ConfirmationDialog(this, message) {
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
ContactsHelper(this).deleteContact(contact!!, true) {
|
ContactsHelper(this).deleteContact(contact!!, true) {
|
||||||
|
@ -849,10 +851,11 @@ class ViewContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getStarDrawable(on: Boolean) = resources.getDrawable(if (on) R.drawable.ic_star_vector else R.drawable.ic_star_outline_vector)
|
private fun getStarDrawable(on: Boolean) =
|
||||||
|
resources.getDrawable(if (on) com.simplemobiletools.commons.R.drawable.ic_star_vector else com.simplemobiletools.commons.R.drawable.ic_star_outline_vector)
|
||||||
|
|
||||||
private fun hideBigContactPhoto() {
|
private fun hideBigContactPhoto() {
|
||||||
contact_photo_big.animate().alpha(0f).withEndAction { contact_photo_big.beGone() }.start()
|
binding.contactPhotoBig.animate().alpha(0f).withEndAction { binding.contactPhotoBig.beGone() }.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun View.copyOnLongClick(value: String) {
|
private fun View.copyOnLongClick(value: String) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.simplemobiletools.contacts.pro.adapters
|
package com.simplemobiletools.contacts.pro.adapters
|
||||||
|
|
||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
|
@ -16,11 +15,8 @@ import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.normalizeString
|
import com.simplemobiletools.commons.extensions.normalizeString
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
import com.simplemobiletools.commons.models.contacts.Contact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.contacts.pro.R
|
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import kotlinx.android.synthetic.main.item_autocomplete_name_number.view.item_autocomplete_image
|
import com.simplemobiletools.contacts.pro.databinding.ItemAutocompleteNameNumberBinding
|
||||||
import kotlinx.android.synthetic.main.item_autocomplete_name_number.view.item_autocomplete_name
|
|
||||||
import kotlinx.android.synthetic.main.item_autocomplete_name_number.view.item_autocomplete_number
|
|
||||||
|
|
||||||
class AutoCompleteTextViewAdapter(
|
class AutoCompleteTextViewAdapter(
|
||||||
val activity: SimpleActivity,
|
val activity: SimpleActivity,
|
||||||
|
@ -34,23 +30,23 @@ class AutoCompleteTextViewAdapter(
|
||||||
var listItem = convertView
|
var listItem = convertView
|
||||||
val nameToUse = contact.getNameToDisplay()
|
val nameToUse = contact.getNameToDisplay()
|
||||||
if (listItem == null || listItem.tag != nameToUse.isNotEmpty()) {
|
if (listItem == null || listItem.tag != nameToUse.isNotEmpty()) {
|
||||||
listItem = LayoutInflater.from(activity).inflate(R.layout.item_autocomplete_name_number, parent, false)
|
listItem = ItemAutocompleteNameNumberBinding.inflate(activity.layoutInflater, parent, false).root
|
||||||
}
|
}
|
||||||
|
|
||||||
val placeholder = BitmapDrawable(activity.resources, SimpleContactsHelper(context).getContactLetterIcon(nameToUse))
|
val placeholder = BitmapDrawable(activity.resources, SimpleContactsHelper(context).getContactLetterIcon(nameToUse))
|
||||||
listItem!!.apply {
|
ItemAutocompleteNameNumberBinding.bind(listItem).apply {
|
||||||
setBackgroundColor(context.getProperBackgroundColor())
|
root.setBackgroundColor(context.getProperBackgroundColor())
|
||||||
item_autocomplete_name.setTextColor(context.getProperTextColor())
|
itemAutocompleteName.setTextColor(context.getProperTextColor())
|
||||||
item_autocomplete_number.setTextColor(context.getProperTextColor())
|
itemAutocompleteNumber.setTextColor(context.getProperTextColor())
|
||||||
|
|
||||||
tag = nameToUse.isNotEmpty()
|
root.tag = nameToUse.isNotEmpty()
|
||||||
item_autocomplete_name.text = nameToUse
|
itemAutocompleteName.text = nameToUse
|
||||||
contact.phoneNumbers.apply {
|
contact.phoneNumbers.apply {
|
||||||
val phoneNumber = firstOrNull { it.isPrimary }?.normalizedNumber ?: firstOrNull()?.normalizedNumber
|
val phoneNumber = firstOrNull { it.isPrimary }?.normalizedNumber ?: firstOrNull()?.normalizedNumber
|
||||||
if (phoneNumber.isNullOrEmpty()) {
|
if (phoneNumber.isNullOrEmpty()) {
|
||||||
item_autocomplete_number.beGone()
|
itemAutocompleteNumber.beGone()
|
||||||
} else {
|
} else {
|
||||||
item_autocomplete_number.text = phoneNumber
|
itemAutocompleteNumber.text = phoneNumber
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +61,7 @@ class AutoCompleteTextViewAdapter(
|
||||||
.placeholder(placeholder)
|
.placeholder(placeholder)
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.apply(RequestOptions.circleCropTransform())
|
.apply(RequestOptions.circleCropTransform())
|
||||||
.into(item_autocomplete_image)
|
.into(itemAutocompleteImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
return listItem
|
return listItem
|
||||||
|
|
|
@ -146,10 +146,11 @@ class ContactsAdapter(
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val layout = when (viewType) {
|
val layout = when (viewType) {
|
||||||
VIEW_TYPE_GRID -> {
|
VIEW_TYPE_GRID -> {
|
||||||
if (showPhoneNumbers) R.layout.item_contact_with_number_grid else R.layout.item_contact_without_number_grid
|
if (showPhoneNumbers) com.simplemobiletools.commons.R.layout.item_contact_with_number_grid else com.simplemobiletools.commons.R.layout.item_contact_without_number_grid
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
|
if (showPhoneNumbers) com.simplemobiletools.commons.R.layout.item_contact_with_number else com.simplemobiletools.commons.R.layout.item_contact_without_number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return createViewHolder(layout, parent)
|
return createViewHolder(layout, parent)
|
||||||
|
@ -194,10 +195,10 @@ class ContactsAdapter(
|
||||||
val items = if (itemsCnt == 1) {
|
val items = if (itemsCnt == 1) {
|
||||||
"\"${getSelectedItems().first().getNameToDisplay()}\""
|
"\"${getSelectedItems().first().getNameToDisplay()}\""
|
||||||
} else {
|
} else {
|
||||||
resources.getQuantityString(R.plurals.delete_contacts, itemsCnt, itemsCnt)
|
resources.getQuantityString(com.simplemobiletools.commons.R.plurals.delete_contacts, itemsCnt, itemsCnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
val baseString = R.string.deletion_confirmation
|
val baseString = com.simplemobiletools.commons.R.string.deletion_confirmation
|
||||||
val question = String.format(resources.getString(baseString), items)
|
val question = String.format(resources.getString(baseString), items)
|
||||||
|
|
||||||
ConfirmationDialog(activity, question) {
|
ConfirmationDialog(activity, question) {
|
||||||
|
@ -345,7 +346,7 @@ class ContactsAdapter(
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.error(placeholderImage)
|
.error(placeholderImage)
|
||||||
|
|
||||||
val size = activity.resources.getDimension(R.dimen.shortcut_size).toInt()
|
val size = activity.resources.getDimension(com.simplemobiletools.commons.R.dimen.shortcut_size).toInt()
|
||||||
val itemToLoad: Any? = if (contact.photoUri.isNotEmpty()) {
|
val itemToLoad: Any? = if (contact.photoUri.isNotEmpty()) {
|
||||||
contact.photoUri
|
contact.photoUri
|
||||||
} else {
|
} else {
|
||||||
|
@ -377,16 +378,16 @@ class ContactsAdapter(
|
||||||
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) {
|
||||||
Glide.with(activity).clear(holder.itemView.findViewById<ImageView>(R.id.item_contact_image))
|
Glide.with(activity).clear(holder.itemView.findViewById<ImageView>(com.simplemobiletools.commons.R.id.item_contact_image))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, contact: Contact, holder: ViewHolder) {
|
private fun setupView(view: View, contact: Contact, holder: ViewHolder) {
|
||||||
view.apply {
|
view.apply {
|
||||||
setupViewBackground(activity)
|
setupViewBackground(activity)
|
||||||
findViewById<ConstraintLayout>(R.id.item_contact_frame)?.isSelected = selectedKeys.contains(contact.id)
|
findViewById<ConstraintLayout>(com.simplemobiletools.commons.R.id.item_contact_frame)?.isSelected = selectedKeys.contains(contact.id)
|
||||||
val fullName = contact.getNameToDisplay()
|
val fullName = contact.getNameToDisplay()
|
||||||
findViewById<TextView>(R.id.item_contact_name).text = if (textToHighlight.isEmpty()) fullName else {
|
findViewById<TextView>(com.simplemobiletools.commons.R.id.item_contact_name).text = if (textToHighlight.isEmpty()) fullName else {
|
||||||
if (fullName.contains(textToHighlight, true)) {
|
if (fullName.contains(textToHighlight, true)) {
|
||||||
fullName.highlightTextPart(textToHighlight, properPrimaryColor)
|
fullName.highlightTextPart(textToHighlight, properPrimaryColor)
|
||||||
} else {
|
} else {
|
||||||
|
@ -394,12 +395,12 @@ class ContactsAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
findViewById<TextView>(R.id.item_contact_name).apply {
|
findViewById<TextView>(com.simplemobiletools.commons.R.id.item_contact_name).apply {
|
||||||
setTextColor(textColor)
|
setTextColor(textColor)
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (findViewById<TextView>(R.id.item_contact_number) != null) {
|
if (findViewById<TextView>(com.simplemobiletools.commons.R.id.item_contact_number) != null) {
|
||||||
val phoneNumberToUse = if (textToHighlight.isEmpty()) {
|
val phoneNumberToUse = if (textToHighlight.isEmpty()) {
|
||||||
contact.phoneNumbers.firstOrNull()
|
contact.phoneNumbers.firstOrNull()
|
||||||
} else {
|
} else {
|
||||||
|
@ -407,19 +408,19 @@ class ContactsAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
val numberText = phoneNumberToUse?.value ?: ""
|
val numberText = phoneNumberToUse?.value ?: ""
|
||||||
findViewById<TextView>(R.id.item_contact_number).apply {
|
findViewById<TextView>(com.simplemobiletools.commons.R.id.item_contact_number).apply {
|
||||||
text = if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, properPrimaryColor, false, true)
|
text = if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, properPrimaryColor, false, true)
|
||||||
setTextColor(textColor)
|
setTextColor(textColor)
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
findViewById<TextView>(R.id.item_contact_image).beVisibleIf(showContactThumbnails)
|
findViewById<TextView>(com.simplemobiletools.commons.R.id.item_contact_image).beVisibleIf(showContactThumbnails)
|
||||||
|
|
||||||
if (showContactThumbnails) {
|
if (showContactThumbnails) {
|
||||||
val placeholderImage = BitmapDrawable(resources, SimpleContactsHelper(context).getContactLetterIcon(fullName))
|
val placeholderImage = BitmapDrawable(resources, SimpleContactsHelper(context).getContactLetterIcon(fullName))
|
||||||
if (contact.photoUri.isEmpty() && contact.photo == null) {
|
if (contact.photoUri.isEmpty() && contact.photo == null) {
|
||||||
findViewById<ImageView>(R.id.item_contact_image).setImageDrawable(placeholderImage)
|
findViewById<ImageView>(com.simplemobiletools.commons.R.id.item_contact_image).setImageDrawable(placeholderImage)
|
||||||
} else {
|
} else {
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.signature(ObjectKey(contact.getSignatureKey()))
|
.signature(ObjectKey(contact.getSignatureKey()))
|
||||||
|
@ -437,11 +438,11 @@ class ContactsAdapter(
|
||||||
.load(itemToLoad)
|
.load(itemToLoad)
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.apply(RequestOptions.circleCropTransform())
|
.apply(RequestOptions.circleCropTransform())
|
||||||
.into(findViewById(R.id.item_contact_image))
|
.into(findViewById(com.simplemobiletools.commons.R.id.item_contact_image))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val dragIcon = findViewById<ImageView>(R.id.drag_handle_icon)
|
val dragIcon = findViewById<ImageView>(com.simplemobiletools.commons.R.id.drag_handle_icon)
|
||||||
if (enableDrag && textToHighlight.isEmpty()) {
|
if (enableDrag && textToHighlight.isEmpty()) {
|
||||||
dragIcon.apply {
|
dragIcon.apply {
|
||||||
beVisibleIf(selectedKeys.isNotEmpty())
|
beVisibleIf(selectedKeys.isNotEmpty())
|
||||||
|
|
|
@ -8,9 +8,8 @@ import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.helpers.SMT_PRIVATE
|
import com.simplemobiletools.commons.helpers.SMT_PRIVATE
|
||||||
import com.simplemobiletools.commons.models.contacts.ContactSource
|
import com.simplemobiletools.commons.models.contacts.ContactSource
|
||||||
import com.simplemobiletools.contacts.pro.R
|
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import kotlinx.android.synthetic.main.item_filter_contact_source.view.*
|
import com.simplemobiletools.contacts.pro.databinding.ItemFilterContactSourceBinding
|
||||||
|
|
||||||
class FilterContactSourcesAdapter(
|
class FilterContactSourcesAdapter(
|
||||||
val activity: SimpleActivity,
|
val activity: SimpleActivity,
|
||||||
|
@ -45,8 +44,7 @@ class FilterContactSourcesAdapter(
|
||||||
fun getSelectedContactSources() = contactSources.filter { selectedKeys.contains(it.hashCode()) }
|
fun getSelectedContactSources() = contactSources.filter { selectedKeys.contains(it.hashCode()) }
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.item_filter_contact_source, parent, false)
|
return ViewHolder(ItemFilterContactSourceBinding.inflate(activity.layoutInflater, parent, false).root)
|
||||||
return ViewHolder(view)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
@ -59,13 +57,13 @@ class FilterContactSourcesAdapter(
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
fun bindView(contactSource: ContactSource): View {
|
fun bindView(contactSource: ContactSource): View {
|
||||||
val isSelected = selectedKeys.contains(contactSource.hashCode())
|
val isSelected = selectedKeys.contains(contactSource.hashCode())
|
||||||
itemView.apply {
|
ItemFilterContactSourceBinding.bind(itemView).apply {
|
||||||
filter_contact_source_checkbox.isChecked = isSelected
|
filterContactSourceCheckbox.isChecked = isSelected
|
||||||
filter_contact_source_checkbox.setColors(activity.getProperTextColor(), activity.getProperPrimaryColor(), activity.getProperBackgroundColor())
|
filterContactSourceCheckbox.setColors(activity.getProperTextColor(), activity.getProperPrimaryColor(), activity.getProperBackgroundColor())
|
||||||
val countText = if (contactSource.count >= 0) " (${contactSource.count})" else ""
|
val countText = if (contactSource.count >= 0) " (${contactSource.count})" else ""
|
||||||
val displayName = "${contactSource.publicName}$countText"
|
val displayName = "${contactSource.publicName}$countText"
|
||||||
filter_contact_source_checkbox.text = displayName
|
filterContactSourceCheckbox.text = displayName
|
||||||
filter_contact_source_holder.setOnClickListener { viewClicked(!isSelected, contactSource) }
|
filterContactSourceHolder.setOnClickListener { viewClicked(!isSelected, contactSource) }
|
||||||
}
|
}
|
||||||
|
|
||||||
return itemView
|
return itemView
|
||||||
|
|
|
@ -7,20 +7,22 @@ import android.view.ViewGroup
|
||||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.commons.extensions.getTextSize
|
||||||
|
import com.simplemobiletools.commons.extensions.groupsDB
|
||||||
|
import com.simplemobiletools.commons.extensions.highlightTextPart
|
||||||
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.TAB_GROUPS
|
import com.simplemobiletools.commons.helpers.TAB_GROUPS
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
|
import com.simplemobiletools.commons.models.contacts.Group
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.ItemGroupBinding
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.RenameGroupDialog
|
import com.simplemobiletools.contacts.pro.dialogs.RenameGroupDialog
|
||||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
|
||||||
import com.simplemobiletools.commons.models.contacts.Group
|
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||||
import kotlinx.android.synthetic.main.item_group.view.*
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class GroupsAdapter(
|
class GroupsAdapter(
|
||||||
activity: SimpleActivity, var groups: ArrayList<Group>, val refreshListener: RefreshContactsListener?, recyclerView: MyRecyclerView,
|
activity: SimpleActivity, var groups: ArrayList<Group>, val refreshListener: RefreshContactsListener?, recyclerView: MyRecyclerView,
|
||||||
|
@ -67,7 +69,9 @@ class GroupsAdapter(
|
||||||
|
|
||||||
override fun onActionModeDestroyed() {}
|
override fun onActionModeDestroyed() {}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_group, parent)
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return createViewHolder(ItemGroupBinding.inflate(layoutInflater, parent, false).root)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val group = groups[position]
|
val group = groups[position]
|
||||||
|
@ -110,7 +114,7 @@ class GroupsAdapter(
|
||||||
resources.getQuantityString(R.plurals.delete_groups, itemsCnt, itemsCnt)
|
resources.getQuantityString(R.plurals.delete_groups, itemsCnt, itemsCnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
val baseString = R.string.deletion_confirmation
|
val baseString = com.simplemobiletools.commons.R.string.deletion_confirmation
|
||||||
val question = String.format(resources.getString(baseString), items)
|
val question = String.format(resources.getString(baseString), items)
|
||||||
|
|
||||||
ConfirmationDialog(activity, question) {
|
ConfirmationDialog(activity, question) {
|
||||||
|
@ -149,8 +153,8 @@ class GroupsAdapter(
|
||||||
private fun getSelectedItems() = groups.filter { selectedKeys.contains(it.id?.toInt()) } as ArrayList<Group>
|
private fun getSelectedItems() = groups.filter { selectedKeys.contains(it.id?.toInt()) } as ArrayList<Group>
|
||||||
|
|
||||||
private fun setupView(view: View, group: Group) {
|
private fun setupView(view: View, group: Group) {
|
||||||
view.apply {
|
ItemGroupBinding.bind(view).apply {
|
||||||
group_frame?.isSelected = selectedKeys.contains(group.id!!.toInt())
|
groupFrame.isSelected = selectedKeys.contains(group.id!!.toInt())
|
||||||
val titleWithCnt = "${group.title} (${group.contactsCount})"
|
val titleWithCnt = "${group.title} (${group.contactsCount})"
|
||||||
val groupTitle = if (textToHighlight.isEmpty()) {
|
val groupTitle = if (textToHighlight.isEmpty()) {
|
||||||
titleWithCnt
|
titleWithCnt
|
||||||
|
@ -158,15 +162,15 @@ class GroupsAdapter(
|
||||||
titleWithCnt.highlightTextPart(textToHighlight, properPrimaryColor)
|
titleWithCnt.highlightTextPart(textToHighlight, properPrimaryColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
group_name.apply {
|
groupName.apply {
|
||||||
setTextColor(textColor)
|
setTextColor(textColor)
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
text = groupTitle
|
text = groupTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
group_tmb.beVisibleIf(showContactThumbnails)
|
groupTmb.beVisibleIf(showContactThumbnails)
|
||||||
if (showContactThumbnails) {
|
if (showContactThumbnails) {
|
||||||
group_tmb.setImageDrawable(SimpleContactsHelper(activity).getColoredGroupIcon(group.title))
|
groupTmb.setImageDrawable(SimpleContactsHelper(activity).getColoredGroupIcon(group.title))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,21 +3,26 @@ package com.simplemobiletools.contacts.pro.adapters
|
||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.util.SparseArray
|
import android.util.SparseArray
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.signature.ObjectKey
|
import com.bumptech.glide.signature.ObjectKey
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
import com.simplemobiletools.commons.models.contacts.*
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
|
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.contacts.pro.R
|
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.ItemAddFavoriteWithNumberBinding
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.ItemAddFavoriteWithoutNumberBinding
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.item_add_favorite_with_number.view.*
|
|
||||||
|
|
||||||
class SelectContactsAdapter(
|
class SelectContactsAdapter(
|
||||||
val activity: SimpleActivity, var contacts: ArrayList<Contact>, private val selectedContacts: ArrayList<Contact>, private val allowPickMultiple: Boolean,
|
val activity: SimpleActivity, var contacts: ArrayList<Contact>, private val selectedContacts: ArrayList<Contact>, private val allowPickMultiple: Boolean,
|
||||||
|
@ -32,7 +37,7 @@ class SelectContactsAdapter(
|
||||||
|
|
||||||
private val showContactThumbnails = config.showContactThumbnails
|
private val showContactThumbnails = config.showContactThumbnails
|
||||||
private val showPhoneNumbers = config.showPhoneNumbers
|
private val showPhoneNumbers = config.showPhoneNumbers
|
||||||
private val itemLayout = if (showPhoneNumbers) R.layout.item_add_favorite_with_number else R.layout.item_add_favorite_without_number
|
private val itemBindingClass = if (showPhoneNumbers) Binding.WithNumber else Binding.WithoutNumber
|
||||||
private var textToHighlight = ""
|
private var textToHighlight = ""
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -56,7 +61,7 @@ class SelectContactsAdapter(
|
||||||
selectedPositions.remove(pos)
|
selectedPositions.remove(pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemViews[pos]?.contact_checkbox?.isChecked = select
|
itemBindingClass.bind(itemViews[pos]).contactCheckbox.isChecked = select
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSelectedItemsSet(): HashSet<Contact> {
|
fun getSelectedItemsSet(): HashSet<Contact> {
|
||||||
|
@ -66,8 +71,8 @@ class SelectContactsAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val view = activity.layoutInflater.inflate(itemLayout, parent, false)
|
val binding = itemBindingClass.inflate(activity.layoutInflater, parent, false)
|
||||||
return ViewHolder(view)
|
return ViewHolder(binding.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
@ -81,19 +86,19 @@ class SelectContactsAdapter(
|
||||||
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) {
|
||||||
Glide.with(activity).clear(holder.itemView.contact_tmb)
|
Glide.with(activity).clear(itemBindingClass.bind(holder.itemView).contactTmb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
fun bindView(contact: Contact): View {
|
fun bindView(contact: Contact): View {
|
||||||
itemView.apply {
|
itemBindingClass.bind(itemView).apply {
|
||||||
contact_checkbox.beVisibleIf(allowPickMultiple)
|
contactCheckbox.beVisibleIf(allowPickMultiple)
|
||||||
contact_checkbox.setColors(context.getProperTextColor(), context.getProperPrimaryColor(), context.getProperBackgroundColor())
|
contactCheckbox.setColors(root.context.getProperTextColor(), root.context.getProperPrimaryColor(), root.context.getProperBackgroundColor())
|
||||||
val textColor = context.getProperTextColor()
|
val textColor = root.context.getProperTextColor()
|
||||||
|
|
||||||
val fullName = contact.getNameToDisplay()
|
val fullName = contact.getNameToDisplay()
|
||||||
contact_name.text = if (textToHighlight.isEmpty()) fullName else {
|
contactName.text = if (textToHighlight.isEmpty()) fullName else {
|
||||||
if (fullName.contains(textToHighlight, true)) {
|
if (fullName.contains(textToHighlight, true)) {
|
||||||
fullName.highlightTextPart(textToHighlight, adjustedPrimaryColor)
|
fullName.highlightTextPart(textToHighlight, adjustedPrimaryColor)
|
||||||
} else {
|
} else {
|
||||||
|
@ -101,10 +106,10 @@ class SelectContactsAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_name.setTextColor(textColor)
|
contactName.setTextColor(textColor)
|
||||||
contact_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
contactName.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
|
|
||||||
if (contact_number != null) {
|
contactNumber?.apply {
|
||||||
val phoneNumberToUse = if (textToHighlight.isEmpty()) {
|
val phoneNumberToUse = if (textToHighlight.isEmpty()) {
|
||||||
contact.phoneNumbers.firstOrNull()
|
contact.phoneNumbers.firstOrNull()
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,21 +117,20 @@ class SelectContactsAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
val numberText = phoneNumberToUse?.value ?: ""
|
val numberText = phoneNumberToUse?.value ?: ""
|
||||||
contact_number.text =
|
text = if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, adjustedPrimaryColor, false, true)
|
||||||
if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, adjustedPrimaryColor, false, true)
|
setTextColor(textColor)
|
||||||
contact_number.setTextColor(textColor)
|
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
contact_number.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_frame.setOnClickListener {
|
root.setOnClickListener {
|
||||||
if (itemClick != null) {
|
if (itemClick != null) {
|
||||||
itemClick.invoke(contact)
|
itemClick.invoke(contact)
|
||||||
} else {
|
} else {
|
||||||
viewClicked(!contact_checkbox.isChecked)
|
viewClicked(!contactCheckbox.isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_tmb.beVisibleIf(showContactThumbnails)
|
contactTmb.beVisibleIf(showContactThumbnails)
|
||||||
|
|
||||||
if (showContactThumbnails) {
|
if (showContactThumbnails) {
|
||||||
val avatarName = when {
|
val avatarName = when {
|
||||||
|
@ -135,10 +139,10 @@ class SelectContactsAdapter(
|
||||||
else -> contact.firstName
|
else -> contact.firstName
|
||||||
}
|
}
|
||||||
|
|
||||||
val placeholderImage = BitmapDrawable(resources, SimpleContactsHelper(context).getContactLetterIcon(avatarName))
|
val placeholderImage = BitmapDrawable(root.resources, SimpleContactsHelper(root.context).getContactLetterIcon(avatarName))
|
||||||
|
|
||||||
if (contact.photoUri.isEmpty() && contact.photo == null) {
|
if (contact.photoUri.isEmpty() && contact.photo == null) {
|
||||||
contact_tmb.setImageDrawable(placeholderImage)
|
contactTmb.setImageDrawable(placeholderImage)
|
||||||
} else {
|
} else {
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.signature(ObjectKey(contact.getSignatureKey()))
|
.signature(ObjectKey(contact.getSignatureKey()))
|
||||||
|
@ -156,7 +160,7 @@ class SelectContactsAdapter(
|
||||||
.load(itemToLoad)
|
.load(itemToLoad)
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.apply(RequestOptions.circleCropTransform())
|
.apply(RequestOptions.circleCropTransform())
|
||||||
.into(contact_tmb)
|
.into(contactTmb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,4 +172,54 @@ class SelectContactsAdapter(
|
||||||
toggleItemSelection(select, adapterPosition)
|
toggleItemSelection(select, adapterPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sealed interface Binding {
|
||||||
|
|
||||||
|
fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemAddFavoriteBinding
|
||||||
|
fun bind(view: View): ItemAddFavoriteBinding
|
||||||
|
|
||||||
|
|
||||||
|
data object WithNumber : Binding {
|
||||||
|
override fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemAddFavoriteBinding {
|
||||||
|
return ItemAddFavoriteWithNumberBindingAdapter(ItemAddFavoriteWithNumberBinding.inflate(layoutInflater, viewGroup, attachToRoot))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bind(view: View): ItemAddFavoriteBinding {
|
||||||
|
return ItemAddFavoriteWithNumberBindingAdapter(ItemAddFavoriteWithNumberBinding.bind(view))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data object WithoutNumber : Binding {
|
||||||
|
override fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemAddFavoriteBinding {
|
||||||
|
return ItemAddFavoriteWithoutNumberBindingAdapter(ItemAddFavoriteWithoutNumberBinding.inflate(layoutInflater, viewGroup, attachToRoot))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bind(view: View): ItemAddFavoriteBinding {
|
||||||
|
return ItemAddFavoriteWithoutNumberBindingAdapter(ItemAddFavoriteWithoutNumberBinding.bind(view))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface ItemAddFavoriteBinding : ViewBinding {
|
||||||
|
val contactName: TextView
|
||||||
|
val contactNumber: TextView?
|
||||||
|
val contactTmb: ImageView
|
||||||
|
val contactCheckbox: MyAppCompatCheckbox
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ItemAddFavoriteWithoutNumberBindingAdapter(val binding: ItemAddFavoriteWithoutNumberBinding) : ItemAddFavoriteBinding {
|
||||||
|
override val contactName: TextView = binding.contactName
|
||||||
|
override val contactNumber: TextView? = null
|
||||||
|
override val contactTmb: ImageView = binding.contactTmb
|
||||||
|
override val contactCheckbox: MyAppCompatCheckbox = binding.contactCheckbox
|
||||||
|
override fun getRoot(): View = binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ItemAddFavoriteWithNumberBindingAdapter(val binding: ItemAddFavoriteWithNumberBinding) : ItemAddFavoriteBinding {
|
||||||
|
override val contactName: TextView = binding.contactName
|
||||||
|
override val contactNumber: TextView = binding.contactNumber
|
||||||
|
override val contactTmb: ImageView = binding.contactTmb
|
||||||
|
override val contactCheckbox: MyAppCompatCheckbox = binding.contactCheckbox
|
||||||
|
override fun getRoot(): View = binding.root
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ViewPagerAdapter(val activity: SimpleActivity, val currTabsList: ArrayList
|
||||||
val view = activity.layoutInflater.inflate(layout, container, false)
|
val view = activity.layoutInflater.inflate(layout, container, false)
|
||||||
container.addView(view)
|
container.addView(view)
|
||||||
|
|
||||||
(view as MyViewPagerFragment).apply {
|
(view as MyViewPagerFragment<*>).apply {
|
||||||
setupFragment(activity)
|
setupFragment(activity)
|
||||||
setupColors(activity.getProperTextColor(), activity.getProperPrimaryColor())
|
setupColors(activity.getProperTextColor(), activity.getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import android.database.Cursor
|
||||||
import android.database.MatrixCursor
|
import android.database.MatrixCursor
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
|
||||||
import com.simplemobiletools.commons.helpers.LocalContactsHelper
|
import com.simplemobiletools.commons.helpers.LocalContactsHelper
|
||||||
|
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
|
|
||||||
class MyContactsContentProvider : ContentProvider() {
|
class MyContactsContentProvider : ContentProvider() {
|
||||||
|
|
|
@ -6,20 +6,20 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.DialogChangeSortingBinding
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
|
||||||
|
|
||||||
class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCustomSorting: Boolean = false, private val callback: () -> Unit) {
|
class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCustomSorting: Boolean = false, private val callback: () -> Unit) {
|
||||||
private var currSorting = 0
|
private var currSorting = 0
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
|
private val binding = DialogChangeSortingBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.sort_by)
|
||||||
}
|
}
|
||||||
|
|
||||||
currSorting = if (showCustomSorting && config.isCustomOrderSelected) {
|
currSorting = if (showCustomSorting && config.isCustomOrderSelected) {
|
||||||
|
@ -33,42 +33,41 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCust
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSortRadio() {
|
private fun setupSortRadio() {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
val sortingRadio = binding.sortingDialogRadioSorting
|
||||||
|
|
||||||
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
|
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
|
||||||
val isCustomSorting = checkedId == sortingRadio.sorting_dialog_radio_custom.id
|
val isCustomSorting = checkedId == binding.sortingDialogRadioCustom.id
|
||||||
view.sorting_dialog_radio_order.beGoneIf(isCustomSorting)
|
binding.sortingDialogRadioOrder.beGoneIf(isCustomSorting)
|
||||||
view.divider.beGoneIf(isCustomSorting)
|
binding.divider.beGoneIf(isCustomSorting)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 -> binding.sortingDialogRadioFirstName
|
||||||
currSorting and SORT_BY_MIDDLE_NAME != 0 -> sortingRadio.sorting_dialog_radio_middle_name
|
currSorting and SORT_BY_MIDDLE_NAME != 0 -> binding.sortingDialogRadioMiddleName
|
||||||
currSorting and SORT_BY_SURNAME != 0 -> sortingRadio.sorting_dialog_radio_surname
|
currSorting and SORT_BY_SURNAME != 0 -> binding.sortingDialogRadioSurname
|
||||||
currSorting and SORT_BY_FULL_NAME != 0 -> sortingRadio.sorting_dialog_radio_full_name
|
currSorting and SORT_BY_FULL_NAME != 0 -> binding.sortingDialogRadioFullName
|
||||||
currSorting and SORT_BY_CUSTOM != 0 -> sortingRadio.sorting_dialog_radio_custom
|
currSorting and SORT_BY_CUSTOM != 0 -> binding.sortingDialogRadioCustom
|
||||||
else -> sortingRadio.sorting_dialog_radio_date_created
|
else -> binding.sortingDialogRadioDateCreated
|
||||||
}
|
}
|
||||||
sortBtn.isChecked = true
|
sortBtn.isChecked = true
|
||||||
|
|
||||||
if (showCustomSorting) {
|
if (showCustomSorting) {
|
||||||
sortingRadio.sorting_dialog_radio_custom.isChecked = config.isCustomOrderSelected
|
binding.sortingDialogRadioCustom.isChecked = config.isCustomOrderSelected
|
||||||
}
|
}
|
||||||
view.sorting_dialog_radio_custom.beGoneIf(!showCustomSorting)
|
binding.sortingDialogRadioCustom.beGoneIf(!showCustomSorting)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOrderRadio() {
|
private fun setupOrderRadio() {
|
||||||
val orderRadio = view.sorting_dialog_radio_order
|
var orderBtn = binding.sortingDialogRadioAscending
|
||||||
var orderBtn = orderRadio.sorting_dialog_radio_ascending
|
|
||||||
|
|
||||||
if (currSorting and SORT_DESCENDING != 0) {
|
if (currSorting and SORT_DESCENDING != 0) {
|
||||||
orderBtn = orderRadio.sorting_dialog_radio_descending
|
orderBtn = binding.sortingDialogRadioDescending
|
||||||
}
|
}
|
||||||
orderBtn.isChecked = true
|
orderBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
val sortingRadio = binding.sortingDialogRadioSorting
|
||||||
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
|
||||||
|
@ -78,7 +77,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCust
|
||||||
else -> SORT_BY_DATE_CREATED
|
else -> SORT_BY_DATE_CREATED
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sorting != SORT_BY_CUSTOM && view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {
|
if (sorting != SORT_BY_CUSTOM && binding.sortingDialogRadioOrder.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {
|
||||||
sorting = sorting or SORT_DESCENDING
|
sorting = sorting or SORT_DESCENDING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,46 +3,44 @@ package com.simplemobiletools.contacts.pro.dialogs
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.RadioGroup
|
import android.widget.RadioGroup
|
||||||
import android.widget.RelativeLayout
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.extensions.beGone
|
import com.simplemobiletools.commons.extensions.beGone
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.models.contacts.SocialAction
|
import com.simplemobiletools.commons.models.contacts.SocialAction
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.databinding.DialogChooseSocialBinding
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.ItemChooseSocialBinding
|
||||||
import com.simplemobiletools.contacts.pro.extensions.getPackageDrawable
|
import com.simplemobiletools.contacts.pro.extensions.getPackageDrawable
|
||||||
import kotlinx.android.synthetic.main.dialog_choose_social.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_choose_social.view.*
|
|
||||||
|
|
||||||
class ChooseSocialDialog(val activity: Activity, actions: ArrayList<SocialAction>, val callback: (action: SocialAction) -> Unit) {
|
class ChooseSocialDialog(val activity: Activity, actions: ArrayList<SocialAction>, val callback: (action: SocialAction) -> Unit) {
|
||||||
private lateinit var dialog: AlertDialog
|
private lateinit var dialog: AlertDialog
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_choose_social, null)
|
val binding = DialogChooseSocialBinding.inflate(activity.layoutInflater)
|
||||||
actions.sortBy { it.type }
|
actions.sortBy { it.type }
|
||||||
actions.forEach { action ->
|
actions.forEach { action ->
|
||||||
val item = (activity.layoutInflater.inflate(R.layout.item_choose_social, null) as RelativeLayout).apply {
|
val item = ItemChooseSocialBinding.inflate(activity.layoutInflater).apply {
|
||||||
item_social_label.text = action.label
|
itemSocialLabel.text = action.label
|
||||||
setOnClickListener {
|
root.setOnClickListener {
|
||||||
callback(action)
|
callback(action)
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
val drawable = activity.getPackageDrawable(action.packageName)
|
val drawable = activity.getPackageDrawable(action.packageName)
|
||||||
if (drawable == null) {
|
if (drawable == null) {
|
||||||
item_social_image.beGone()
|
itemSocialImage.beGone()
|
||||||
} else {
|
} else {
|
||||||
item_social_image.setImageDrawable(drawable)
|
itemSocialImage.setImageDrawable(drawable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view.dialog_choose_social.addView(item, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
|
binding.dialogChooseSocial.addView(item.root, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
|
||||||
}
|
}
|
||||||
|
|
||||||
val builder = activity.getAlertDialogBuilder()
|
val builder = activity.getAlertDialogBuilder()
|
||||||
|
|
||||||
builder.apply {
|
builder.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
dialog = alertDialog
|
dialog = alertDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,22 +11,22 @@ import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.models.contacts.ContactSource
|
import com.simplemobiletools.commons.models.contacts.ContactSource
|
||||||
import com.simplemobiletools.commons.models.contacts.Group
|
import com.simplemobiletools.commons.models.contacts.Group
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_create_new_group.view.*
|
import com.simplemobiletools.contacts.pro.databinding.DialogCreateNewGroupBinding
|
||||||
|
|
||||||
class CreateNewGroupDialog(val activity: BaseSimpleActivity, val callback: (newGroup: Group) -> Unit) {
|
class CreateNewGroupDialog(val activity: BaseSimpleActivity, val callback: (newGroup: Group) -> Unit) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_create_new_group, null)
|
val binding = DialogCreateNewGroupBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.create_new_group) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.create_new_group) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.group_name)
|
alertDialog.showKeyboard(binding.groupName)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
||||||
val name = view.group_name.value
|
val name = binding.groupName.value
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
activity.toast(R.string.empty_name)
|
activity.toast(com.simplemobiletools.commons.R.string.empty_name)
|
||||||
return@OnClickListener
|
return@OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,23 +3,22 @@ package com.simplemobiletools.contacts.pro.dialogs
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.databinding.DialogCustomLabelBinding
|
||||||
import kotlinx.android.synthetic.main.dialog_custom_label.view.*
|
|
||||||
|
|
||||||
class CustomLabelDialog(val activity: BaseSimpleActivity, val callback: (label: String) -> Unit) {
|
class CustomLabelDialog(val activity: BaseSimpleActivity, val callback: (label: String) -> Unit) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_custom_label, null)
|
val binding = DialogCustomLabelBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.label) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.label) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.custom_label_edittext)
|
alertDialog.showKeyboard(binding.customLabelEdittext)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val label = view.custom_label_edittext.value
|
val label = binding.customLabelEdittext.value
|
||||||
if (label.isEmpty()) {
|
if (label.isEmpty()) {
|
||||||
activity.toast(R.string.empty_name)
|
activity.toast(com.simplemobiletools.commons.R.string.empty_name)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class DateTimePatternInfoDialog(activity: BaseSimpleActivity) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.datetime_pattern_info_layout, null)
|
val view = activity.layoutInflater.inflate(R.layout.datetime_pattern_info_layout, null)
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { _, _ -> { } }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { _, _ -> { } }
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(view, this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
package com.simplemobiletools.contacts.pro.dialogs
|
package com.simplemobiletools.contacts.pro.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.models.contacts.*
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
|
import com.simplemobiletools.commons.models.contacts.ContactSource
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.contacts.pro.adapters.FilterContactSourcesAdapter
|
import com.simplemobiletools.contacts.pro.adapters.FilterContactSourcesAdapter
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.DialogExportContactsBinding
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_export_contacts.view.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class ExportContactsDialog(
|
class ExportContactsDialog(
|
||||||
|
@ -27,17 +26,17 @@ class ExportContactsDialog(
|
||||||
private var isContactsReady = false
|
private var isContactsReady = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_export_contacts, null) as ViewGroup).apply {
|
val binding = DialogExportContactsBinding.inflate(activity.layoutInflater).apply {
|
||||||
export_contacts_folder.setText(activity.humanizePath(realPath))
|
exportContactsFolder.setText(activity.humanizePath(realPath))
|
||||||
export_contacts_filename.setText("contacts_${activity.getCurrentFormattedDateTime()}")
|
exportContactsFilename.setText("contacts_${activity.getCurrentFormattedDateTime()}")
|
||||||
|
|
||||||
if (hidePath) {
|
if (hidePath) {
|
||||||
export_contacts_folder_hint.beGone()
|
exportContactsFolderHint.beGone()
|
||||||
} else {
|
} else {
|
||||||
export_contacts_folder.setOnClickListener {
|
exportContactsFolder.setOnClickListener {
|
||||||
activity.hideKeyboard(export_contacts_filename)
|
activity.hideKeyboard(exportContactsFilename)
|
||||||
FilePickerDialog(activity, realPath, false, showFAB = true) {
|
FilePickerDialog(activity, realPath, false, showFAB = true) {
|
||||||
export_contacts_folder.setText(activity.humanizePath(it))
|
exportContactsFolder.setText(activity.humanizePath(it))
|
||||||
realPath = it
|
realPath = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,29 +56,29 @@ class ExportContactsDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.export_contacts) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.export_contacts) { alertDialog ->
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
if (view.export_contacts_list.adapter == null || ignoreClicks) {
|
if (binding.exportContactsList.adapter == null || ignoreClicks) {
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
val filename = view.export_contacts_filename.value
|
val filename = binding.exportContactsFilename.value
|
||||||
when {
|
when {
|
||||||
filename.isEmpty() -> activity.toast(R.string.empty_name)
|
filename.isEmpty() -> activity.toast(com.simplemobiletools.commons.R.string.empty_name)
|
||||||
filename.isAValidFilename() -> {
|
filename.isAValidFilename() -> {
|
||||||
val file = File(realPath, "$filename.vcf")
|
val file = File(realPath, "$filename.vcf")
|
||||||
if (!hidePath && file.exists()) {
|
if (!hidePath && file.exists()) {
|
||||||
activity.toast(R.string.name_taken)
|
activity.toast(com.simplemobiletools.commons.R.string.name_taken)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
ignoreClicks = true
|
ignoreClicks = true
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
activity.config.lastExportPath = file.absolutePath.getParentPath()
|
activity.config.lastExportPath = file.absolutePath.getParentPath()
|
||||||
val selectedSources = (view.export_contacts_list.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
|
val selectedSources = (binding.exportContactsList.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
|
||||||
val ignoredSources = contactSources
|
val ignoredSources = contactSources
|
||||||
.filter { !selectedSources.contains(it) }
|
.filter { !selectedSources.contains(it) }
|
||||||
.map { it.getFullIdentifier() }
|
.map { it.getFullIdentifier() }
|
||||||
|
@ -88,14 +87,15 @@ class ExportContactsDialog(
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> activity.toast(R.string.invalid_name)
|
|
||||||
|
else -> activity.toast(com.simplemobiletools.commons.R.string.invalid_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processDataIfReady(view: View) {
|
private fun processDataIfReady(binding: DialogExportContactsBinding) {
|
||||||
if (!isContactSourcesReady || !isContactsReady) {
|
if (!isContactSourcesReady || !isContactsReady) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ class ExportContactsDialog(
|
||||||
contactSources.addAll(contactSourcesWithCount)
|
contactSources.addAll(contactSourcesWithCount)
|
||||||
|
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
view.export_contacts_list.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, activity.getVisibleContactSources())
|
binding.exportContactsList.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, activity.getVisibleContactSources())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,20 @@ package com.simplemobiletools.contacts.pro.dialogs
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
|
import com.simplemobiletools.commons.extensions.getVisibleContactSources
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.SMT_PRIVATE
|
import com.simplemobiletools.commons.helpers.SMT_PRIVATE
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
|
import com.simplemobiletools.commons.models.contacts.ContactSource
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.contacts.pro.adapters.FilterContactSourcesAdapter
|
import com.simplemobiletools.contacts.pro.adapters.FilterContactSourcesAdapter
|
||||||
import com.simplemobiletools.commons.extensions.getVisibleContactSources
|
import com.simplemobiletools.contacts.pro.databinding.DialogFilterContactSourcesBinding
|
||||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
|
||||||
import com.simplemobiletools.commons.models.contacts.*
|
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_filter_contact_sources.view.*
|
|
||||||
|
|
||||||
class FilterContactSourcesDialog(val activity: SimpleActivity, private val callback: () -> Unit) {
|
class FilterContactSourcesDialog(val activity: SimpleActivity, private val callback: () -> Unit) {
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_filter_contact_sources, null)
|
private val binding = DialogFilterContactSourcesBinding.inflate(activity.layoutInflater)
|
||||||
private var contactSources = ArrayList<ContactSource>()
|
private var contactSources = ArrayList<ContactSource>()
|
||||||
private var contacts = ArrayList<Contact>()
|
private var contacts = ArrayList<Contact>()
|
||||||
private var isContactSourcesReady = false
|
private var isContactSourcesReady = false
|
||||||
|
@ -55,14 +55,14 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
|
||||||
|
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
val selectedSources = activity.getVisibleContactSources()
|
val selectedSources = activity.getVisibleContactSources()
|
||||||
view.filter_contact_sources_list.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedSources)
|
binding.filterContactSourcesList.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedSources)
|
||||||
|
|
||||||
if (dialog == null) {
|
if (dialog == null) {
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmContactSources() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialogInterface, i -> confirmContactSources() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
dialog = alertDialog
|
dialog = alertDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun confirmContactSources() {
|
private fun confirmContactSources() {
|
||||||
val selectedContactSources = (view.filter_contact_sources_list.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
|
val selectedContactSources = (binding.filterContactSourcesList.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
|
||||||
val ignoredContactSources = contactSources.filter { !selectedContactSources.contains(it) }.map {
|
val ignoredContactSources = contactSources.filter { !selectedContactSources.contains(it) }.map {
|
||||||
if (it.type == SMT_PRIVATE) SMT_PRIVATE else it.getFullIdentifier()
|
if (it.type == SMT_PRIVATE) SMT_PRIVATE else it.getFullIdentifier()
|
||||||
}.toHashSet()
|
}.toHashSet()
|
||||||
|
|
|
@ -1,64 +1,66 @@
|
||||||
package com.simplemobiletools.contacts.pro.dialogs
|
package com.simplemobiletools.contacts.pro.dialogs
|
||||||
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
|
import com.simplemobiletools.commons.extensions.getPublicContactSource
|
||||||
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.SMT_PRIVATE
|
import com.simplemobiletools.commons.helpers.SMT_PRIVATE
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.DialogImportContactsBinding
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import com.simplemobiletools.contacts.pro.extensions.showContactSourcePicker
|
import com.simplemobiletools.contacts.pro.extensions.showContactSourcePicker
|
||||||
import com.simplemobiletools.contacts.pro.helpers.VcfImporter
|
import com.simplemobiletools.contacts.pro.helpers.VcfImporter
|
||||||
import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_FAIL
|
import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_FAIL
|
||||||
import kotlinx.android.synthetic.main.dialog_import_contacts.view.*
|
|
||||||
|
|
||||||
class ImportContactsDialog(val activity: SimpleActivity, val path: String, private val callback: (refreshView: Boolean) -> Unit) {
|
class ImportContactsDialog(val activity: SimpleActivity, val path: String, private val callback: (refreshView: Boolean) -> Unit) {
|
||||||
private var targetContactSource = ""
|
private var targetContactSource = ""
|
||||||
private var ignoreClicks = false
|
private var ignoreClicks = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_import_contacts, null) as ViewGroup).apply {
|
val binding = DialogImportContactsBinding.inflate(activity.layoutInflater).apply {
|
||||||
targetContactSource = activity.config.lastUsedContactSource
|
targetContactSource = activity.config.lastUsedContactSource
|
||||||
activity.getPublicContactSource(targetContactSource) {
|
activity.getPublicContactSource(targetContactSource) {
|
||||||
import_contacts_title.setText(it)
|
importContactsTitle.setText(it)
|
||||||
if (it.isEmpty()) {
|
if (it.isEmpty()) {
|
||||||
ContactsHelper(activity).getContactSources {
|
ContactsHelper(activity).getContactSources {
|
||||||
val localSource = it.firstOrNull { it.name == SMT_PRIVATE }
|
val localSource = it.firstOrNull { it.name == SMT_PRIVATE }
|
||||||
if (localSource != null) {
|
if (localSource != null) {
|
||||||
targetContactSource = localSource.name
|
targetContactSource = localSource.name
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
import_contacts_title.setText(localSource.publicName)
|
importContactsTitle.setText(localSource.publicName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
import_contacts_title.setOnClickListener {
|
importContactsTitle.setOnClickListener {
|
||||||
activity.showContactSourcePicker(targetContactSource) {
|
activity.showContactSourcePicker(targetContactSource) {
|
||||||
targetContactSource = if (it == activity.getString(R.string.phone_storage_hidden)) SMT_PRIVATE else it
|
targetContactSource = if (it == activity.getString(R.string.phone_storage_hidden)) SMT_PRIVATE else it
|
||||||
activity.getPublicContactSource(it) {
|
activity.getPublicContactSource(it) {
|
||||||
val title = if (it == "") activity.getString(R.string.phone_storage) else it
|
val title = if (it == "") activity.getString(R.string.phone_storage) else it
|
||||||
import_contacts_title.setText(title)
|
importContactsTitle.setText(title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.import_contacts) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.import_contacts) { alertDialog ->
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
if (ignoreClicks) {
|
if (ignoreClicks) {
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
ignoreClicks = true
|
ignoreClicks = true
|
||||||
activity.toast(R.string.importing)
|
activity.toast(com.simplemobiletools.commons.R.string.importing)
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val result = VcfImporter(activity).importContacts(path, targetContactSource)
|
val result = VcfImporter(activity).importContacts(path, targetContactSource)
|
||||||
handleParseResult(result)
|
handleParseResult(result)
|
||||||
|
@ -72,9 +74,9 @@ class ImportContactsDialog(val activity: SimpleActivity, val path: String, priva
|
||||||
private fun handleParseResult(result: VcfImporter.ImportResult) {
|
private fun handleParseResult(result: VcfImporter.ImportResult) {
|
||||||
activity.toast(
|
activity.toast(
|
||||||
when (result) {
|
when (result) {
|
||||||
VcfImporter.ImportResult.IMPORT_OK -> R.string.importing_successful
|
VcfImporter.ImportResult.IMPORT_OK -> com.simplemobiletools.commons.R.string.importing_successful
|
||||||
VcfImporter.ImportResult.IMPORT_PARTIAL -> R.string.importing_some_entries_failed
|
VcfImporter.ImportResult.IMPORT_PARTIAL -> com.simplemobiletools.commons.R.string.importing_some_entries_failed
|
||||||
else -> R.string.importing_failed
|
else -> com.simplemobiletools.commons.R.string.importing_failed
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
callback(result != IMPORT_FAIL)
|
callback(result != IMPORT_FAIL)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package com.simplemobiletools.contacts.pro.dialogs
|
package com.simplemobiletools.contacts.pro.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
@ -12,15 +10,12 @@ import com.simplemobiletools.commons.models.contacts.ContactSource
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.contacts.pro.adapters.FilterContactSourcesAdapter
|
import com.simplemobiletools.contacts.pro.adapters.FilterContactSourcesAdapter
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.DialogManageAutomaticBackupsBinding
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_manage_automatic_backups.view.backup_contact_sources_list
|
|
||||||
import kotlinx.android.synthetic.main.dialog_manage_automatic_backups.view.backup_contacts_filename
|
|
||||||
import kotlinx.android.synthetic.main.dialog_manage_automatic_backups.view.backup_contacts_filename_hint
|
|
||||||
import kotlinx.android.synthetic.main.dialog_manage_automatic_backups.view.backup_contacts_folder
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: () -> Unit) {
|
class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: () -> Unit) {
|
||||||
private val view = (activity.layoutInflater.inflate(R.layout.dialog_manage_automatic_backups, null) as ViewGroup)
|
private val binding = DialogManageAutomaticBackupsBinding.inflate(activity.layoutInflater)
|
||||||
private val config = activity.config
|
private val config = activity.config
|
||||||
private var backupFolder = config.autoBackupFolder
|
private var backupFolder = config.autoBackupFolder
|
||||||
private var contactSources = mutableListOf<ContactSource>()
|
private var contactSources = mutableListOf<ContactSource>()
|
||||||
|
@ -30,23 +25,23 @@ class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: (
|
||||||
private var isContactsReady = false
|
private var isContactsReady = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view.apply {
|
binding.apply {
|
||||||
backup_contacts_folder.setText(activity.humanizePath(backupFolder))
|
backupContactsFolder.setText(activity.humanizePath(backupFolder))
|
||||||
val filename = config.autoBackupFilename.ifEmpty {
|
val filename = config.autoBackupFilename.ifEmpty {
|
||||||
"${activity.getString(R.string.contacts)}_%Y%M%D_%h%m%s"
|
"${activity.getString(R.string.contacts)}_%Y%M%D_%h%m%s"
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_contacts_filename.setText(filename)
|
backupContactsFilename.setText(filename)
|
||||||
backup_contacts_filename_hint.setEndIconOnClickListener {
|
backupContactsFilenameHint.setEndIconOnClickListener {
|
||||||
DateTimePatternInfoDialog(activity)
|
DateTimePatternInfoDialog(activity)
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_contacts_filename_hint.setEndIconOnLongClickListener {
|
backupContactsFilenameHint.setEndIconOnLongClickListener {
|
||||||
DateTimePatternInfoDialog(activity)
|
DateTimePatternInfoDialog(activity)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_contacts_folder.setOnClickListener {
|
backupContactsFolder.setOnClickListener {
|
||||||
selectBackupFolder()
|
selectBackupFolder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,27 +59,27 @@ class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: (
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.manage_automatic_backups) { dialog ->
|
activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.manage_automatic_backups) { dialog ->
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
if (view.backup_contact_sources_list.adapter == null) {
|
if (binding.backupContactSourcesList.adapter == null) {
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
val filename = view.backup_contacts_filename.value
|
val filename = binding.backupContactsFilename.value
|
||||||
when {
|
when {
|
||||||
filename.isEmpty() -> activity.toast(R.string.empty_name)
|
filename.isEmpty() -> activity.toast(com.simplemobiletools.commons.R.string.empty_name)
|
||||||
filename.isAValidFilename() -> {
|
filename.isAValidFilename() -> {
|
||||||
val file = File(backupFolder, "$filename.vcf")
|
val file = File(backupFolder, "$filename.vcf")
|
||||||
if (file.exists() && !file.canWrite()) {
|
if (file.exists() && !file.canWrite()) {
|
||||||
activity.toast(R.string.name_taken)
|
activity.toast(com.simplemobiletools.commons.R.string.name_taken)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
val selectedSources = (view.backup_contact_sources_list.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
|
val selectedSources = (binding.backupContactSourcesList.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
|
||||||
if (selectedSources.isEmpty()) {
|
if (selectedSources.isEmpty()) {
|
||||||
activity.toast(R.string.no_entries_for_exporting)
|
activity.toast(com.simplemobiletools.commons.R.string.no_entries_for_exporting)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,14 +99,14 @@ class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> activity.toast(R.string.invalid_name)
|
else -> activity.toast(com.simplemobiletools.commons.R.string.invalid_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processDataIfReady(view: View) {
|
private fun processDataIfReady(binding: DialogManageAutomaticBackupsBinding) {
|
||||||
if (!isContactSourcesReady || !isContactsReady) {
|
if (!isContactSourcesReady || !isContactsReady) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -130,12 +125,12 @@ class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: (
|
||||||
contactSources.addAll(contactSourcesWithCount)
|
contactSources.addAll(contactSourcesWithCount)
|
||||||
|
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
view.backup_contact_sources_list.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedContactSources.toList())
|
binding.backupContactSourcesList.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedContactSources.toList())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun selectBackupFolder() {
|
private fun selectBackupFolder() {
|
||||||
activity.hideKeyboard(view.backup_contacts_filename)
|
activity.hideKeyboard(binding.backupContactsFilename)
|
||||||
FilePickerDialog(activity, backupFolder, false, showFAB = true) { path ->
|
FilePickerDialog(activity, backupFolder, false, showFAB = true) { path ->
|
||||||
activity.handleSAFDialog(path) { grantedSAF ->
|
activity.handleSAFDialog(path) { grantedSAF ->
|
||||||
if (!grantedSAF) {
|
if (!grantedSAF) {
|
||||||
|
@ -148,7 +143,7 @@ class ManageAutoBackupsDialog(private val activity: SimpleActivity, onSuccess: (
|
||||||
}
|
}
|
||||||
|
|
||||||
backupFolder = path
|
backupFolder = path
|
||||||
view.backup_contacts_folder.setText(activity.humanizePath(path))
|
binding.backupContactsFolder.setText(activity.humanizePath(path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package com.simplemobiletools.contacts.pro.dialogs
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.commons.helpers.*
|
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
|
|
||||||
class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback: (hasSomethingChanged: Boolean) -> Unit) {
|
class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback: (hasSomethingChanged: Boolean) -> Unit) {
|
||||||
|
@ -39,8 +39,8 @@ class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback:
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(view, this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(view, this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,21 +4,20 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.helpers.isSPlus
|
import com.simplemobiletools.commons.helpers.isSPlus
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.databinding.DialogDatePickerBinding
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_date_picker.view.*
|
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import java.util.*
|
import java.util.Calendar
|
||||||
|
|
||||||
class MyDatePickerDialog(val activity: BaseSimpleActivity, val defaultDate: String, val callback: (dateTag: String) -> Unit) {
|
class MyDatePickerDialog(val activity: BaseSimpleActivity, val defaultDate: String, val callback: (dateTag: String) -> Unit) {
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_date_picker, null)
|
private val binding = DialogDatePickerBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
val today = Calendar.getInstance()
|
val today = Calendar.getInstance()
|
||||||
var year = today.get(Calendar.YEAR)
|
var year = today.get(Calendar.YEAR)
|
||||||
var month = today.get(Calendar.MONTH)
|
var month = today.get(Calendar.MONTH)
|
||||||
|
@ -26,7 +25,7 @@ class MyDatePickerDialog(val activity: BaseSimpleActivity, val defaultDate: Stri
|
||||||
|
|
||||||
if (defaultDate.isNotEmpty()) {
|
if (defaultDate.isNotEmpty()) {
|
||||||
val ignoreYear = defaultDate.startsWith("-")
|
val ignoreYear = defaultDate.startsWith("-")
|
||||||
view.hide_year.isChecked = ignoreYear
|
binding.hideYear.isChecked = ignoreYear
|
||||||
|
|
||||||
if (ignoreYear) {
|
if (ignoreYear) {
|
||||||
month = defaultDate.substring(2, 4).toInt() - 1
|
month = defaultDate.substring(2, 4).toInt() - 1
|
||||||
|
@ -39,23 +38,23 @@ class MyDatePickerDialog(val activity: BaseSimpleActivity, val defaultDate: Stri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.config.isUsingSystemTheme && isSPlus()) {
|
if (activity.config.isUsingSystemTheme && isSPlus()) {
|
||||||
val dialogBackgroundColor = activity.getColor(R.color.you_dialog_background_color)
|
val dialogBackgroundColor = activity.getColor(com.simplemobiletools.commons.R.color.you_dialog_background_color)
|
||||||
view.dialog_holder.setBackgroundColor(dialogBackgroundColor)
|
binding.dialogHolder.setBackgroundColor(dialogBackgroundColor)
|
||||||
view.date_picker.setBackgroundColor(dialogBackgroundColor)
|
binding.datePicker.setBackgroundColor(dialogBackgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
view.date_picker.updateDate(year, month, day)
|
binding.datePicker.updateDate(year, month, day)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val year = view.date_picker.year
|
val year = binding.datePicker.year
|
||||||
val month = view.date_picker.month + 1
|
val month = binding.datePicker.month + 1
|
||||||
val day = view.date_picker.dayOfMonth
|
val day = binding.datePicker.dayOfMonth
|
||||||
val date = DateTime().withDate(year, month, day).withTimeAtStartOfDay()
|
val date = DateTime().withDate(year, month, day).withTimeAtStartOfDay()
|
||||||
|
|
||||||
val tag = if (view.hide_year.isChecked) {
|
val tag = if (binding.hideYear.isChecked) {
|
||||||
date.toString("--MM-dd")
|
date.toString("--MM-dd")
|
||||||
} else {
|
} else {
|
||||||
date.toString("yyyy-MM-dd")
|
date.toString("yyyy-MM-dd")
|
||||||
|
|
|
@ -6,30 +6,29 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.models.contacts.Group
|
import com.simplemobiletools.commons.models.contacts.Group
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.databinding.DialogRenameGroupBinding
|
||||||
import kotlinx.android.synthetic.main.dialog_rename_group.view.*
|
|
||||||
|
|
||||||
class RenameGroupDialog(val activity: BaseSimpleActivity, val group: Group, val callback: () -> Unit) {
|
class RenameGroupDialog(val activity: BaseSimpleActivity, val group: Group, val callback: () -> Unit) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_rename_group, null).apply {
|
val binding = DialogRenameGroupBinding.inflate(activity.layoutInflater).apply {
|
||||||
rename_group_title.setText(group.title)
|
renameGroupTitle.setText(group.title)
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.rename) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.rename) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.rename_group_title)
|
alertDialog.showKeyboard(binding.renameGroupTitle)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val newTitle = view.rename_group_title.value
|
val newTitle = binding.renameGroupTitle.value
|
||||||
if (newTitle.isEmpty()) {
|
if (newTitle.isEmpty()) {
|
||||||
activity.toast(R.string.empty_name)
|
activity.toast(com.simplemobiletools.commons.R.string.empty_name)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newTitle.isAValidFilename()) {
|
if (!newTitle.isAValidFilename()) {
|
||||||
activity.toast(R.string.invalid_name)
|
activity.toast(com.simplemobiletools.commons.R.string.invalid_name)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,18 @@ import androidx.appcompat.app.AlertDialog
|
||||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.contacts.pro.adapters.SelectContactsAdapter
|
import com.simplemobiletools.contacts.pro.adapters.SelectContactsAdapter
|
||||||
import com.simplemobiletools.commons.models.contacts.*
|
import com.simplemobiletools.contacts.pro.databinding.DialogSelectContactBinding
|
||||||
import kotlinx.android.synthetic.main.dialog_select_contact.view.*
|
import java.util.Locale
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class SelectContactsDialog(
|
class SelectContactsDialog(
|
||||||
val activity: SimpleActivity, initialContacts: ArrayList<Contact>, val allowSelectMultiple: Boolean, val showOnlyContactsWithNumber: Boolean,
|
val activity: SimpleActivity, initialContacts: ArrayList<Contact>, val allowSelectMultiple: Boolean, val showOnlyContactsWithNumber: Boolean,
|
||||||
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.dialog_select_contact, null)
|
private val binding = DialogSelectContactBinding.inflate(activity.layoutInflater)
|
||||||
private var initiallySelectedContacts = ArrayList<Contact>()
|
private var initiallySelectedContacts = ArrayList<Contact>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -42,30 +41,30 @@ class SelectContactsDialog(
|
||||||
dialog!!.dismiss()
|
dialog!!.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
view.apply {
|
binding.apply {
|
||||||
select_contact_list.adapter = SelectContactsAdapter(
|
selectContactList.adapter = SelectContactsAdapter(
|
||||||
activity, allContacts, initiallySelectedContacts, allowSelectMultiple,
|
activity, allContacts, initiallySelectedContacts, allowSelectMultiple,
|
||||||
select_contact_list, contactClickCallback
|
selectContactList, contactClickCallback
|
||||||
)
|
)
|
||||||
|
|
||||||
if (context.areSystemAnimationsEnabled) {
|
if (root.context.areSystemAnimationsEnabled) {
|
||||||
select_contact_list.scheduleLayoutAnimation()
|
selectContactList.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
select_contact_list.beVisibleIf(allContacts.isNotEmpty())
|
selectContactList.beVisibleIf(allContacts.isNotEmpty())
|
||||||
select_contact_placeholder.beVisibleIf(allContacts.isEmpty())
|
selectContactPlaceholder.beVisibleIf(allContacts.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
setupFastscroller(allContacts)
|
setupFastscroller(allContacts)
|
||||||
|
|
||||||
val builder = activity.getAlertDialogBuilder()
|
val builder = activity.getAlertDialogBuilder()
|
||||||
if (allowSelectMultiple) {
|
if (allowSelectMultiple) {
|
||||||
builder.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
builder.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
}
|
}
|
||||||
builder.setNegativeButton(R.string.cancel, null)
|
builder.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
|
|
||||||
builder.apply {
|
builder.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
dialog = alertDialog
|
dialog = alertDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +72,7 @@ class SelectContactsDialog(
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val adapter = view?.select_contact_list?.adapter as? SelectContactsAdapter
|
val adapter = binding.selectContactList.adapter as? SelectContactsAdapter
|
||||||
val selectedContacts = adapter?.getSelectedItemsSet()?.toList() ?: ArrayList()
|
val selectedContacts = adapter?.getSelectedItemsSet()?.toList() ?: ArrayList()
|
||||||
|
|
||||||
val newlySelectedContacts = selectedContacts.filter { !initiallySelectedContacts.contains(it) } as ArrayList
|
val newlySelectedContacts = selectedContacts.filter { !initiallySelectedContacts.contains(it) } as ArrayList
|
||||||
|
@ -84,16 +83,16 @@ class SelectContactsDialog(
|
||||||
|
|
||||||
private fun setupFastscroller(allContacts: ArrayList<Contact>) {
|
private fun setupFastscroller(allContacts: ArrayList<Contact>) {
|
||||||
val adjustedPrimaryColor = activity.getProperPrimaryColor()
|
val adjustedPrimaryColor = activity.getProperPrimaryColor()
|
||||||
view.apply {
|
binding.apply {
|
||||||
letter_fastscroller?.textColor = context.getProperTextColor().getColorStateList()
|
letterFastscroller.textColor = root.context.getProperTextColor().getColorStateList()
|
||||||
letter_fastscroller?.pressedTextColor = adjustedPrimaryColor
|
letterFastscroller.pressedTextColor = adjustedPrimaryColor
|
||||||
letter_fastscroller_thumb?.fontSize = context.getTextSize()
|
letterFastscrollerThumb.fontSize = root.context.getTextSize()
|
||||||
letter_fastscroller_thumb?.textColor = adjustedPrimaryColor.getContrastColor()
|
letterFastscrollerThumb.textColor = adjustedPrimaryColor.getContrastColor()
|
||||||
letter_fastscroller_thumb?.thumbColor = adjustedPrimaryColor.getColorStateList()
|
letterFastscrollerThumb.thumbColor = adjustedPrimaryColor.getColorStateList()
|
||||||
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
letterFastscrollerThumb.setupWithFastScroller(letterFastscroller)
|
||||||
}
|
}
|
||||||
|
|
||||||
view.letter_fastscroller.setupWithRecyclerView(view.select_contact_list, { position ->
|
binding.letterFastscroller.setupWithRecyclerView(binding.selectContactList, { position ->
|
||||||
try {
|
try {
|
||||||
val name = allContacts[position].getNameToDisplay()
|
val name = allContacts[position].getNameToDisplay()
|
||||||
val character = if (name.isNotEmpty()) name.substring(0, 1) else ""
|
val character = if (name.isNotEmpty()) name.substring(0, 1) else ""
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.simplemobiletools.contacts.pro.dialogs
|
package com.simplemobiletools.contacts.pro.dialogs
|
||||||
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
|
@ -8,12 +7,12 @@ import com.simplemobiletools.commons.models.contacts.Group
|
||||||
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import kotlinx.android.synthetic.main.dialog_select_groups.view.*
|
import com.simplemobiletools.contacts.pro.databinding.DialogSelectGroupsBinding
|
||||||
import kotlinx.android.synthetic.main.item_checkbox.view.*
|
import com.simplemobiletools.contacts.pro.databinding.ItemCheckboxBinding
|
||||||
import kotlinx.android.synthetic.main.item_textview.view.*
|
import com.simplemobiletools.contacts.pro.databinding.ItemTextviewBinding
|
||||||
|
|
||||||
class SelectGroupsDialog(val activity: SimpleActivity, val selectedGroups: ArrayList<Group>, val callback: (newGroups: ArrayList<Group>) -> Unit) {
|
class SelectGroupsDialog(val activity: SimpleActivity, val selectedGroups: ArrayList<Group>, val callback: (newGroups: ArrayList<Group>) -> Unit) {
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_select_groups, null) as ViewGroup
|
private val binding = DialogSelectGroupsBinding.inflate(activity.layoutInflater)
|
||||||
private val checkboxes = ArrayList<MyAppCompatCheckbox>()
|
private val checkboxes = ArrayList<MyAppCompatCheckbox>()
|
||||||
private var groups = ArrayList<Group>()
|
private var groups = ArrayList<Group>()
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
|
@ -35,44 +34,44 @@ class SelectGroupsDialog(val activity: SimpleActivity, val selectedGroups: Array
|
||||||
addCreateNewGroupButton()
|
addCreateNewGroupButton()
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
dialog = alertDialog
|
dialog = alertDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addGroupCheckbox(group: Group) {
|
private fun addGroupCheckbox(group: Group) {
|
||||||
activity.layoutInflater.inflate(R.layout.item_checkbox, null, false).apply {
|
ItemCheckboxBinding.inflate(activity.layoutInflater, null, false).apply {
|
||||||
checkboxes.add(item_checkbox)
|
checkboxes.add(itemCheckbox)
|
||||||
item_checkbox_holder.setOnClickListener {
|
itemCheckboxHolder.setOnClickListener {
|
||||||
item_checkbox.toggle()
|
itemCheckbox.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
item_checkbox.apply {
|
itemCheckbox.apply {
|
||||||
isChecked = selectedGroups.contains(group)
|
isChecked = selectedGroups.contains(group)
|
||||||
text = group.title
|
text = group.title
|
||||||
tag = group.id
|
tag = group.id
|
||||||
setColors(activity.getProperTextColor(), activity.getProperPrimaryColor(), activity.getProperBackgroundColor())
|
setColors(activity.getProperTextColor(), activity.getProperPrimaryColor(), activity.getProperBackgroundColor())
|
||||||
}
|
}
|
||||||
view.dialog_groups_holder.addView(this)
|
binding.dialogGroupsHolder.addView(this.root)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addCreateNewGroupButton() {
|
private fun addCreateNewGroupButton() {
|
||||||
val newGroup = Group(0, activity.getString(R.string.create_new_group))
|
val newGroup = Group(0, activity.getString(R.string.create_new_group))
|
||||||
activity.layoutInflater.inflate(R.layout.item_textview, null, false).item_textview.apply {
|
ItemTextviewBinding.inflate(activity.layoutInflater, null, false).itemTextview.apply {
|
||||||
text = newGroup.title
|
text = newGroup.title
|
||||||
tag = newGroup.id
|
tag = newGroup.id
|
||||||
setTextColor(activity.getProperTextColor())
|
setTextColor(activity.getProperTextColor())
|
||||||
view.dialog_groups_holder.addView(this)
|
binding.dialogGroupsHolder.addView(this)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
CreateNewGroupDialog(activity) {
|
CreateNewGroupDialog(activity) {
|
||||||
selectedGroups.add(it)
|
selectedGroups.add(it)
|
||||||
groups.add(it)
|
groups.add(it)
|
||||||
view.dialog_groups_holder.removeViewAt(view.dialog_groups_holder.childCount - 1)
|
binding.dialogGroupsHolder.removeViewAt(binding.dialogGroupsHolder.childCount - 1)
|
||||||
addGroupCheckbox(it)
|
addGroupCheckbox(it)
|
||||||
addCreateNewGroupButton()
|
addCreateNewGroupButton()
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
|
||||||
|
|
||||||
val file = getTempFile(filename)
|
val file = getTempFile(filename)
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ fun SimpleActivity.callContact(contact: Contact) {
|
||||||
if (contact.phoneNumbers.isNotEmpty()) {
|
if (contact.phoneNumbers.isNotEmpty()) {
|
||||||
tryInitiateCall(contact) { startCallIntent(it) }
|
tryInitiateCall(contact) { startCallIntent(it) }
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_phone_number_found)
|
toast(com.simplemobiletools.commons.R.string.no_phone_number_found)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ fun Context.scheduleNextAutomaticBackup() {
|
||||||
val pendingIntent = getAutomaticBackupIntent()
|
val pendingIntent = getAutomaticBackupIntent()
|
||||||
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||||
try {
|
try {
|
||||||
AlarmManagerCompat.setExactAndAllowWhileIdle(alarmManager, AlarmManager.RTC_WAKEUP, backupAtMillis, pendingIntent)
|
AlarmManagerCompat.setAndAllowWhileIdle(alarmManager, AlarmManager.RTC_WAKEUP, backupAtMillis, pendingIntent)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ fun Context.backupContacts() {
|
||||||
val config = config
|
val config = config
|
||||||
ContactsHelper(this).getContactsToExport(selectedContactSources = config.autoBackupContactSources) { contactsToBackup ->
|
ContactsHelper(this).getContactsToExport(selectedContactSources = config.autoBackupContactSources) { contactsToBackup ->
|
||||||
if (contactsToBackup.isEmpty()) {
|
if (contactsToBackup.isEmpty()) {
|
||||||
toast(R.string.no_entries_for_exporting)
|
toast(com.simplemobiletools.commons.R.string.no_entries_for_exporting)
|
||||||
config.lastAutoBackupTime = DateTime.now().millis
|
config.lastAutoBackupTime = DateTime.now().millis
|
||||||
scheduleNextAutomaticBackup()
|
scheduleNextAutomaticBackup()
|
||||||
return@getContactsToExport
|
return@getContactsToExport
|
||||||
|
@ -136,8 +136,8 @@ fun Context.backupContacts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
when (exportResult) {
|
when (exportResult) {
|
||||||
ExportResult.EXPORT_OK -> toast(R.string.exporting_successful)
|
ExportResult.EXPORT_OK -> toast(com.simplemobiletools.commons.R.string.exporting_successful)
|
||||||
else -> toast(R.string.exporting_failed)
|
else -> toast(com.simplemobiletools.commons.R.string.exporting_failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.lastAutoBackupTime = DateTime.now().millis
|
config.lastAutoBackupTime = DateTime.now().millis
|
||||||
|
|
|
@ -11,12 +11,22 @@ import com.simplemobiletools.contacts.pro.activities.InsertOrEditContactActivity
|
||||||
import com.simplemobiletools.contacts.pro.activities.MainActivity
|
import com.simplemobiletools.contacts.pro.activities.MainActivity
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.FragmentContactsBinding
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.FragmentLettersLayoutBinding
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import com.simplemobiletools.contacts.pro.helpers.LOCATION_CONTACTS_TAB
|
import com.simplemobiletools.contacts.pro.helpers.LOCATION_CONTACTS_TAB
|
||||||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||||
import kotlinx.android.synthetic.main.fragment_layout.view.fragment_list
|
|
||||||
|
|
||||||
class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment<MyViewPagerFragment.LetterLayout>(context, attributeSet) {
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentContactsBinding
|
||||||
|
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
binding = FragmentContactsBinding.bind(this)
|
||||||
|
innerBinding = LetterLayout(FragmentLettersLayoutBinding.bind(binding.root))
|
||||||
|
}
|
||||||
|
|
||||||
override fun fabClicked() {
|
override fun fabClicked() {
|
||||||
activity?.hideKeyboard()
|
activity?.hideKeyboard()
|
||||||
Intent(context, EditContactActivity::class.java).apply {
|
Intent(context, EditContactActivity::class.java).apply {
|
||||||
|
@ -34,7 +44,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
||||||
|
|
||||||
fun setupContactsAdapter(contacts: List<Contact>) {
|
fun setupContactsAdapter(contacts: List<Contact>) {
|
||||||
setupViewVisibility(contacts.isNotEmpty())
|
setupViewVisibility(contacts.isNotEmpty())
|
||||||
val currAdapter = fragment_list.adapter
|
val currAdapter = innerBinding.fragmentList.adapter
|
||||||
|
|
||||||
if (currAdapter == null || forceListRedraw) {
|
if (currAdapter == null || forceListRedraw) {
|
||||||
forceListRedraw = false
|
forceListRedraw = false
|
||||||
|
@ -46,16 +56,16 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
||||||
refreshListener = activity as RefreshContactsListener,
|
refreshListener = activity as RefreshContactsListener,
|
||||||
location = location,
|
location = location,
|
||||||
removeListener = null,
|
removeListener = null,
|
||||||
recyclerView = fragment_list,
|
recyclerView = innerBinding.fragmentList,
|
||||||
enableDrag = false,
|
enableDrag = false,
|
||||||
) {
|
) {
|
||||||
(activity as RefreshContactsListener).contactClicked(it as Contact)
|
(activity as RefreshContactsListener).contactClicked(it as Contact)
|
||||||
}.apply {
|
}.apply {
|
||||||
fragment_list.adapter = this
|
innerBinding.fragmentList.adapter = this
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.areSystemAnimationsEnabled) {
|
if (context.areSystemAnimationsEnabled) {
|
||||||
fragment_list.scheduleLayoutAnimation()
|
innerBinding.fragmentList.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as ContactsAdapter).apply {
|
(currAdapter as ContactsAdapter).apply {
|
||||||
|
|
|
@ -17,17 +17,23 @@ import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.contacts.pro.activities.MainActivity
|
import com.simplemobiletools.contacts.pro.activities.MainActivity
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.FragmentFavoritesBinding
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.FragmentLettersLayoutBinding
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.SelectContactsDialog
|
import com.simplemobiletools.contacts.pro.dialogs.SelectContactsDialog
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import com.simplemobiletools.contacts.pro.helpers.LOCATION_FAVORITES_TAB
|
import com.simplemobiletools.contacts.pro.helpers.LOCATION_FAVORITES_TAB
|
||||||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||||
import kotlinx.android.synthetic.main.dialog_select_contact.view.letter_fastscroller
|
|
||||||
import kotlinx.android.synthetic.main.fragment_favorites.view.favorites_fragment
|
|
||||||
import kotlinx.android.synthetic.main.fragment_layout.view.fragment_list
|
|
||||||
|
|
||||||
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment<MyViewPagerFragment.LetterLayout>(context, attributeSet) {
|
||||||
private var favouriteContacts = listOf<Contact>()
|
private var favouriteContacts = listOf<Contact>()
|
||||||
private var zoomListener: MyRecyclerView.MyZoomListener? = null
|
private var zoomListener: MyRecyclerView.MyZoomListener? = null
|
||||||
|
private lateinit var binding: FragmentFavoritesBinding
|
||||||
|
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
binding = FragmentFavoritesBinding.bind(this)
|
||||||
|
innerBinding = LetterLayout(FragmentLettersLayoutBinding.bind(binding.root))
|
||||||
|
}
|
||||||
|
|
||||||
override fun fabClicked() {
|
override fun fabClicked() {
|
||||||
finishActMode()
|
finishActMode()
|
||||||
|
@ -38,7 +44,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
||||||
showAddFavoritesDialog()
|
showAddFavoritesDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRecyclerAdapter() = fragment_list.adapter as? ContactsAdapter
|
private fun getRecyclerAdapter() = innerBinding.fragmentList.adapter as? ContactsAdapter
|
||||||
|
|
||||||
private fun showAddFavoritesDialog() {
|
private fun showAddFavoritesDialog() {
|
||||||
SelectContactsDialog(activity!!, allContacts, true, false) { addedContacts, removedContacts ->
|
SelectContactsDialog(activity!!, allContacts, true, false) { addedContacts, removedContacts ->
|
||||||
|
@ -71,15 +77,15 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
||||||
location = location,
|
location = location,
|
||||||
viewType = viewType,
|
viewType = viewType,
|
||||||
removeListener = null,
|
removeListener = null,
|
||||||
recyclerView = fragment_list,
|
recyclerView = innerBinding.fragmentList,
|
||||||
enableDrag = true,
|
enableDrag = true,
|
||||||
) {
|
) {
|
||||||
(activity as RefreshContactsListener).contactClicked(it as Contact)
|
(activity as RefreshContactsListener).contactClicked(it as Contact)
|
||||||
}.apply {
|
}.apply {
|
||||||
fragment_list.adapter = this
|
innerBinding.fragmentList.adapter = this
|
||||||
setupZoomListener(zoomListener)
|
setupZoomListener(zoomListener)
|
||||||
onDragEndListener = {
|
onDragEndListener = {
|
||||||
val adapter = fragment_list?.adapter
|
val adapter = innerBinding.fragmentList.adapter
|
||||||
if (adapter is ContactsAdapter) {
|
if (adapter is ContactsAdapter) {
|
||||||
val items = adapter.contactItems
|
val items = adapter.contactItems
|
||||||
saveCustomOrderToPrefs(items)
|
saveCustomOrderToPrefs(items)
|
||||||
|
@ -89,7 +95,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.areSystemAnimationsEnabled) {
|
if (context.areSystemAnimationsEnabled) {
|
||||||
fragment_list.scheduleLayoutAnimation()
|
innerBinding.fragmentList.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
currAdapter.apply {
|
currAdapter.apply {
|
||||||
|
@ -110,17 +116,17 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
||||||
val spanCount = context.config.contactsGridColumnCount
|
val spanCount = context.config.contactsGridColumnCount
|
||||||
|
|
||||||
if (viewType == VIEW_TYPE_GRID) {
|
if (viewType == VIEW_TYPE_GRID) {
|
||||||
favorites_fragment.letter_fastscroller.beGone()
|
innerBinding.letterFastscroller.beGone()
|
||||||
fragment_list.layoutManager = MyGridLayoutManager(context, spanCount)
|
innerBinding.fragmentList.layoutManager = MyGridLayoutManager(context, spanCount)
|
||||||
} else {
|
} else {
|
||||||
favorites_fragment.letter_fastscroller.beVisible()
|
innerBinding.letterFastscroller.beVisible()
|
||||||
fragment_list.layoutManager = MyLinearLayoutManager(context)
|
innerBinding.fragmentList.layoutManager = MyLinearLayoutManager(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initZoomListener(viewType: Int) {
|
private fun initZoomListener(viewType: Int) {
|
||||||
if (viewType == VIEW_TYPE_GRID) {
|
if (viewType == VIEW_TYPE_GRID) {
|
||||||
val layoutManager = fragment_list.layoutManager as MyGridLayoutManager
|
val layoutManager = innerBinding.fragmentList.layoutManager as MyGridLayoutManager
|
||||||
zoomListener = object : MyRecyclerView.MyZoomListener {
|
zoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
if (layoutManager.spanCount > 1) {
|
if (layoutManager.spanCount > 1) {
|
||||||
|
@ -156,7 +162,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
||||||
}
|
}
|
||||||
|
|
||||||
fun columnCountChanged() {
|
fun columnCountChanged() {
|
||||||
(fragment_list.layoutManager as? MyGridLayoutManager)?.spanCount = context!!.config.contactsGridColumnCount
|
(innerBinding.fragmentList.layoutManager as? MyGridLayoutManager)?.spanCount = context!!.config.contactsGridColumnCount
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
notifyItemRangeChanged(0, favouriteContacts.size)
|
notifyItemRangeChanged(0, favouriteContacts.size)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,20 @@ import android.util.AttributeSet
|
||||||
import com.simplemobiletools.commons.helpers.TAB_GROUPS
|
import com.simplemobiletools.commons.helpers.TAB_GROUPS
|
||||||
import com.simplemobiletools.contacts.pro.activities.MainActivity
|
import com.simplemobiletools.contacts.pro.activities.MainActivity
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.FragmentGroupsBinding
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.FragmentLayoutBinding
|
||||||
import com.simplemobiletools.contacts.pro.dialogs.CreateNewGroupDialog
|
import com.simplemobiletools.contacts.pro.dialogs.CreateNewGroupDialog
|
||||||
|
|
||||||
class GroupsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
class GroupsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment<MyViewPagerFragment.FragmentLayout>(context, attributeSet) {
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentGroupsBinding
|
||||||
|
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
binding = FragmentGroupsBinding.bind(this)
|
||||||
|
innerBinding = FragmentLayout(FragmentLayoutBinding.bind(binding.root))
|
||||||
|
}
|
||||||
|
|
||||||
override fun fabClicked() {
|
override fun fabClicked() {
|
||||||
finishActMode()
|
finishActMode()
|
||||||
showNewGroupsDialog()
|
showNewGroupsDialog()
|
||||||
|
|
|
@ -4,13 +4,20 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.RelativeLayout
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
|
import com.reddit.indicatorfastscroll.FastScrollerThumbView
|
||||||
|
import com.reddit.indicatorfastscroll.FastScrollerView
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.contacts.Contact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.commons.models.contacts.Group
|
import com.simplemobiletools.commons.models.contacts.Group
|
||||||
|
import com.simplemobiletools.commons.views.MyFloatingActionButton
|
||||||
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
|
import com.simplemobiletools.commons.views.MyTextView
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.activities.GroupContactsActivity
|
import com.simplemobiletools.contacts.pro.activities.GroupContactsActivity
|
||||||
import com.simplemobiletools.contacts.pro.activities.InsertOrEditContactActivity
|
import com.simplemobiletools.contacts.pro.activities.InsertOrEditContactActivity
|
||||||
|
@ -18,20 +25,18 @@ import com.simplemobiletools.contacts.pro.activities.MainActivity
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
|
||||||
import com.simplemobiletools.contacts.pro.adapters.GroupsAdapter
|
import com.simplemobiletools.contacts.pro.adapters.GroupsAdapter
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.FragmentLayoutBinding
|
||||||
|
import com.simplemobiletools.contacts.pro.databinding.FragmentLettersLayoutBinding
|
||||||
import com.simplemobiletools.contacts.pro.extensions.config
|
import com.simplemobiletools.contacts.pro.extensions.config
|
||||||
import com.simplemobiletools.contacts.pro.helpers.AVOID_CHANGING_TEXT_TAG
|
import com.simplemobiletools.contacts.pro.helpers.AVOID_CHANGING_TEXT_TAG
|
||||||
import com.simplemobiletools.contacts.pro.helpers.AVOID_CHANGING_VISIBILITY_TAG
|
import com.simplemobiletools.contacts.pro.helpers.AVOID_CHANGING_VISIBILITY_TAG
|
||||||
import com.simplemobiletools.contacts.pro.helpers.Config
|
import com.simplemobiletools.contacts.pro.helpers.Config
|
||||||
import com.simplemobiletools.contacts.pro.helpers.GROUP
|
import com.simplemobiletools.contacts.pro.helpers.GROUP
|
||||||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||||
import kotlinx.android.synthetic.main.dialog_select_contact.view.letter_fastscroller
|
|
||||||
import kotlinx.android.synthetic.main.fragment_contacts.view.contacts_fragment
|
|
||||||
import kotlinx.android.synthetic.main.fragment_favorites.view.favorites_fragment
|
|
||||||
import kotlinx.android.synthetic.main.fragment_layout.view.*
|
|
||||||
import kotlinx.android.synthetic.main.fragment_letters_layout.view.letter_fastscroller_thumb
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet) {
|
abstract class MyViewPagerFragment<Binding : MyViewPagerFragment.InnerBinding>(context: Context, attributeSet: AttributeSet) :
|
||||||
|
CoordinatorLayout(context, attributeSet) {
|
||||||
protected var activity: SimpleActivity? = null
|
protected var activity: SimpleActivity? = null
|
||||||
protected var allContacts = ArrayList<Contact>()
|
protected var allContacts = ArrayList<Contact>()
|
||||||
|
|
||||||
|
@ -39,6 +44,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
private var contactsIgnoringSearch = listOf<Contact>()
|
private var contactsIgnoringSearch = listOf<Contact>()
|
||||||
private var groupsIgnoringSearch = listOf<Group>()
|
private var groupsIgnoringSearch = listOf<Group>()
|
||||||
private lateinit var config: Config
|
private lateinit var config: Config
|
||||||
|
protected lateinit var innerBinding: Binding
|
||||||
|
|
||||||
var skipHashComparing = false
|
var skipHashComparing = false
|
||||||
var forceListRedraw = false
|
var forceListRedraw = false
|
||||||
|
@ -47,59 +53,59 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
config = activity.config
|
config = activity.config
|
||||||
if (this.activity == null) {
|
if (this.activity == null) {
|
||||||
this.activity = activity
|
this.activity = activity
|
||||||
fragment_fab?.beGoneIf(activity is InsertOrEditContactActivity)
|
innerBinding.fragmentFab.beGoneIf(activity is InsertOrEditContactActivity)
|
||||||
fragment_fab?.setOnClickListener {
|
innerBinding.fragmentFab.setOnClickListener {
|
||||||
fabClicked()
|
fabClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment_placeholder_2?.setOnClickListener {
|
innerBinding.fragmentPlaceholder2.setOnClickListener {
|
||||||
placeholderClicked()
|
placeholderClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment_placeholder_2?.underlineText()
|
innerBinding.fragmentPlaceholder2.underlineText()
|
||||||
|
|
||||||
when {
|
when (this) {
|
||||||
this is ContactsFragment -> {
|
is ContactsFragment -> {
|
||||||
fragment_fab.contentDescription = activity.getString(R.string.create_new_contact)
|
innerBinding.fragmentFab.contentDescription = activity.getString(com.simplemobiletools.commons.R.string.create_new_contact)
|
||||||
}
|
}
|
||||||
|
|
||||||
this is FavoritesFragment -> {
|
is FavoritesFragment -> {
|
||||||
fragment_placeholder.text = activity.getString(R.string.no_favorites)
|
innerBinding.fragmentPlaceholder.text = activity.getString(R.string.no_favorites)
|
||||||
fragment_placeholder_2.text = activity.getString(R.string.add_favorites)
|
innerBinding.fragmentPlaceholder2.text = activity.getString(com.simplemobiletools.commons.R.string.add_favorites)
|
||||||
fragment_fab.contentDescription = activity.getString(R.string.add_favorites)
|
innerBinding.fragmentFab.contentDescription = activity.getString(com.simplemobiletools.commons.R.string.add_favorites)
|
||||||
}
|
}
|
||||||
|
|
||||||
this is GroupsFragment -> {
|
is GroupsFragment -> {
|
||||||
fragment_placeholder.text = activity.getString(R.string.no_group_created)
|
innerBinding.fragmentPlaceholder.text = activity.getString(R.string.no_group_created)
|
||||||
fragment_placeholder_2.text = activity.getString(R.string.create_group)
|
innerBinding.fragmentPlaceholder2.text = activity.getString(R.string.create_group)
|
||||||
fragment_fab.contentDescription = activity.getString(R.string.create_group)
|
innerBinding.fragmentFab.contentDescription = activity.getString(R.string.create_group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
||||||
when {
|
when (this) {
|
||||||
this is GroupsFragment -> (fragment_list.adapter as? GroupsAdapter)?.updateTextColor(textColor)
|
is GroupsFragment -> (innerBinding.fragmentList.adapter as? GroupsAdapter)?.updateTextColor(textColor)
|
||||||
else -> (fragment_list.adapter as? ContactsAdapter)?.apply {
|
else -> (innerBinding.fragmentList.adapter as? ContactsAdapter)?.apply {
|
||||||
updateTextColor(textColor)
|
updateTextColor(textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.updateTextColors(fragment_wrapper.parent as ViewGroup)
|
context.updateTextColors(innerBinding.fragmentWrapper.parent as ViewGroup)
|
||||||
fragment_fastscroller?.updateColors(adjustedPrimaryColor)
|
innerBinding.fragmentFastscroller?.updateColors(adjustedPrimaryColor)
|
||||||
fragment_placeholder_2?.setTextColor(adjustedPrimaryColor)
|
innerBinding.fragmentPlaceholder2.setTextColor(adjustedPrimaryColor)
|
||||||
|
|
||||||
letter_fastscroller?.textColor = textColor.getColorStateList()
|
innerBinding.letterFastscroller?.textColor = textColor.getColorStateList()
|
||||||
letter_fastscroller?.pressedTextColor = adjustedPrimaryColor
|
innerBinding.letterFastscroller?.pressedTextColor = adjustedPrimaryColor
|
||||||
letter_fastscroller_thumb?.fontSize = context.getTextSize()
|
innerBinding.letterFastscrollerThumb?.fontSize = context.getTextSize()
|
||||||
letter_fastscroller_thumb?.textColor = adjustedPrimaryColor.getContrastColor()
|
innerBinding.letterFastscrollerThumb?.textColor = adjustedPrimaryColor.getContrastColor()
|
||||||
letter_fastscroller_thumb?.thumbColor = adjustedPrimaryColor.getColorStateList()
|
innerBinding.letterFastscrollerThumb?.thumbColor = adjustedPrimaryColor.getColorStateList()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startNameWithSurnameChanged(startNameWithSurname: Boolean) {
|
fun startNameWithSurnameChanged(startNameWithSurname: Boolean) {
|
||||||
if (this !is GroupsFragment) {
|
if (this !is GroupsFragment) {
|
||||||
(fragment_list.adapter as? ContactsAdapter)?.apply {
|
(innerBinding.fragmentList.adapter as? ContactsAdapter)?.apply {
|
||||||
config.sorting = if (startNameWithSurname) SORT_BY_SURNAME else SORT_BY_FIRST_NAME
|
config.sorting = if (startNameWithSurname) SORT_BY_SURNAME else SORT_BY_FIRST_NAME
|
||||||
(this@MyViewPagerFragment.activity!! as MainActivity).refreshContacts(TAB_CONTACTS or TAB_FAVORITES)
|
(this@MyViewPagerFragment.activity!! as MainActivity).refreshContacts(TAB_CONTACTS or TAB_FAVORITES)
|
||||||
}
|
}
|
||||||
|
@ -150,10 +156,10 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
setupContacts(filtered)
|
setupContacts(filtered)
|
||||||
|
|
||||||
if (placeholderText != null) {
|
if (placeholderText != null) {
|
||||||
fragment_placeholder.text = placeholderText
|
innerBinding.fragmentPlaceholder.text = placeholderText
|
||||||
fragment_placeholder.tag = AVOID_CHANGING_TEXT_TAG
|
innerBinding.fragmentPlaceholder.tag = AVOID_CHANGING_TEXT_TAG
|
||||||
fragment_placeholder_2.beGone()
|
innerBinding.fragmentPlaceholder2.beGone()
|
||||||
fragment_placeholder_2.tag = AVOID_CHANGING_VISIBILITY_TAG
|
innerBinding.fragmentPlaceholder2.tag = AVOID_CHANGING_VISIBILITY_TAG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,22 +183,22 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
when (this) {
|
when (this) {
|
||||||
is GroupsFragment -> {
|
is GroupsFragment -> {
|
||||||
setupGroupsAdapter(contacts) {
|
setupGroupsAdapter(contacts) {
|
||||||
groupsIgnoringSearch = (fragment_list?.adapter as? GroupsAdapter)?.groups ?: ArrayList()
|
groupsIgnoringSearch = (innerBinding.fragmentList.adapter as? GroupsAdapter)?.groups ?: ArrayList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is FavoritesFragment -> {
|
is FavoritesFragment -> {
|
||||||
favorites_fragment.setupContactsFavoritesAdapter(contacts)
|
setupContactsFavoritesAdapter(contacts)
|
||||||
contactsIgnoringSearch = (fragment_list?.adapter as? ContactsAdapter)?.contactItems ?: listOf()
|
contactsIgnoringSearch = (innerBinding.fragmentList.adapter as? ContactsAdapter)?.contactItems ?: listOf()
|
||||||
setupLetterFastscroller(contacts)
|
setupLetterFastscroller(contacts)
|
||||||
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
innerBinding.letterFastscrollerThumb.setupWithFastScroller(innerBinding.letterFastscroller)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
is ContactsFragment -> {
|
||||||
contacts_fragment.setupContactsAdapter(contacts)
|
setupContactsAdapter(contacts)
|
||||||
contactsIgnoringSearch = (fragment_list?.adapter as? ContactsAdapter)?.contactItems ?: ArrayList()
|
contactsIgnoringSearch = (innerBinding.fragmentList.adapter as? ContactsAdapter)?.contactItems ?: ArrayList()
|
||||||
setupLetterFastscroller(contacts)
|
setupLetterFastscroller(contacts)
|
||||||
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
innerBinding.letterFastscrollerThumb.setupWithFastScroller(innerBinding.letterFastscroller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,24 +216,24 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
|
|
||||||
storedGroups = storedGroups.asSequence().sortedWith(compareBy { it.title.toLowerCase().normalizeString() }).toMutableList() as ArrayList<Group>
|
storedGroups = storedGroups.asSequence().sortedWith(compareBy { it.title.toLowerCase().normalizeString() }).toMutableList() as ArrayList<Group>
|
||||||
|
|
||||||
fragment_placeholder_2.beVisibleIf(storedGroups.isEmpty())
|
innerBinding.fragmentPlaceholder2.beVisibleIf(storedGroups.isEmpty())
|
||||||
fragment_placeholder.beVisibleIf(storedGroups.isEmpty())
|
innerBinding.fragmentPlaceholder.beVisibleIf(storedGroups.isEmpty())
|
||||||
fragment_fastscroller.beVisibleIf(storedGroups.isNotEmpty())
|
innerBinding.letterFastscroller?.beVisibleIf(storedGroups.isNotEmpty())
|
||||||
|
|
||||||
val currAdapter = fragment_list.adapter
|
val currAdapter = innerBinding.fragmentList.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
GroupsAdapter(activity as SimpleActivity, storedGroups, activity as RefreshContactsListener, fragment_list) {
|
GroupsAdapter(activity as SimpleActivity, storedGroups, activity as RefreshContactsListener, innerBinding.fragmentList) {
|
||||||
activity?.hideKeyboard()
|
activity?.hideKeyboard()
|
||||||
Intent(activity, GroupContactsActivity::class.java).apply {
|
Intent(activity, GroupContactsActivity::class.java).apply {
|
||||||
putExtra(GROUP, it as Group)
|
putExtra(GROUP, it as Group)
|
||||||
activity!!.startActivity(this)
|
activity!!.startActivity(this)
|
||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
fragment_list.adapter = this
|
innerBinding.fragmentList.adapter = this
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.areSystemAnimationsEnabled) {
|
if (context.areSystemAnimationsEnabled) {
|
||||||
fragment_list.scheduleLayoutAnimation()
|
innerBinding.fragmentList.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as GroupsAdapter).apply {
|
(currAdapter as GroupsAdapter).apply {
|
||||||
|
@ -242,12 +248,12 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
|
|
||||||
fun showContactThumbnailsChanged(showThumbnails: Boolean) {
|
fun showContactThumbnailsChanged(showThumbnails: Boolean) {
|
||||||
if (this is GroupsFragment) {
|
if (this is GroupsFragment) {
|
||||||
(fragment_list.adapter as? GroupsAdapter)?.apply {
|
(innerBinding.fragmentList.adapter as? GroupsAdapter)?.apply {
|
||||||
showContactThumbnails = showThumbnails
|
showContactThumbnails = showThumbnails
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(fragment_list.adapter as? ContactsAdapter)?.apply {
|
(innerBinding.fragmentList.adapter as? ContactsAdapter)?.apply {
|
||||||
showContactThumbnails = showThumbnails
|
showContactThumbnails = showThumbnails
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
@ -256,7 +262,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
|
|
||||||
fun setupLetterFastscroller(contacts: List<Contact>) {
|
fun setupLetterFastscroller(contacts: List<Contact>) {
|
||||||
val sorting = context.config.sorting
|
val sorting = context.config.sorting
|
||||||
letter_fastscroller.setupWithRecyclerView(fragment_list, { position ->
|
innerBinding.letterFastscroller?.setupWithRecyclerView(innerBinding.fragmentList, { position ->
|
||||||
try {
|
try {
|
||||||
val contact = contacts[position]
|
val contact = contacts[position]
|
||||||
var name = when {
|
var name = when {
|
||||||
|
@ -282,12 +288,12 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
|
|
||||||
fun fontSizeChanged() {
|
fun fontSizeChanged() {
|
||||||
if (this is GroupsFragment) {
|
if (this is GroupsFragment) {
|
||||||
(fragment_list.adapter as? GroupsAdapter)?.apply {
|
(innerBinding.fragmentList.adapter as? GroupsAdapter)?.apply {
|
||||||
fontSize = activity.getTextSize()
|
fontSize = activity.getTextSize()
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(fragment_list.adapter as? ContactsAdapter)?.apply {
|
(innerBinding.fragmentList.adapter as? ContactsAdapter)?.apply {
|
||||||
fontSize = activity.getTextSize()
|
fontSize = activity.getTextSize()
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
@ -295,11 +301,11 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun finishActMode() {
|
fun finishActMode() {
|
||||||
(fragment_list.adapter as? MyRecyclerViewAdapter)?.finishActMode()
|
(innerBinding.fragmentList.adapter as? MyRecyclerViewAdapter)?.finishActMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSearchQueryChanged(text: String) {
|
fun onSearchQueryChanged(text: String) {
|
||||||
val adapter = fragment_list.adapter
|
val adapter = innerBinding.fragmentList.adapter
|
||||||
if (adapter is ContactsAdapter) {
|
if (adapter is ContactsAdapter) {
|
||||||
val shouldNormalize = text.normalizeString() == text
|
val shouldNormalize = text.normalizeString() == text
|
||||||
val filtered = contactsIgnoringSearch.filter {
|
val filtered = contactsIgnoringSearch.filter {
|
||||||
|
@ -324,12 +330,12 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filtered.isEmpty() && this@MyViewPagerFragment is FavoritesFragment) {
|
if (filtered.isEmpty() && this@MyViewPagerFragment is FavoritesFragment) {
|
||||||
if (fragment_placeholder.tag != AVOID_CHANGING_TEXT_TAG) {
|
if (innerBinding.fragmentPlaceholder.tag != AVOID_CHANGING_TEXT_TAG) {
|
||||||
fragment_placeholder.text = activity?.getString(R.string.no_contacts_found)
|
innerBinding.fragmentPlaceholder.text = activity?.getString(com.simplemobiletools.commons.R.string.no_contacts_found)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment_placeholder.beVisibleIf(filtered.isEmpty())
|
innerBinding.fragmentPlaceholder.beVisibleIf(filtered.isEmpty())
|
||||||
(adapter as? ContactsAdapter)?.updateItems(filtered, text.normalizeString())
|
(adapter as? ContactsAdapter)?.updateItems(filtered, text.normalizeString())
|
||||||
setupLetterFastscroller(filtered)
|
setupLetterFastscroller(filtered)
|
||||||
} else if (adapter is GroupsAdapter) {
|
} else if (adapter is GroupsAdapter) {
|
||||||
|
@ -338,39 +344,72 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||||
} as ArrayList
|
} as ArrayList
|
||||||
|
|
||||||
if (filtered.isEmpty()) {
|
if (filtered.isEmpty()) {
|
||||||
fragment_placeholder.text = activity?.getString(R.string.no_items_found)
|
innerBinding.fragmentPlaceholder.text = activity?.getString(com.simplemobiletools.commons.R.string.no_items_found)
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment_placeholder.beVisibleIf(filtered.isEmpty())
|
innerBinding.fragmentPlaceholder.beVisibleIf(filtered.isEmpty())
|
||||||
(adapter as? GroupsAdapter)?.updateItems(filtered, text)
|
(adapter as? GroupsAdapter)?.updateItems(filtered, text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSearchClosed() {
|
fun onSearchClosed() {
|
||||||
if (fragment_list.adapter is ContactsAdapter) {
|
if (innerBinding.fragmentList.adapter is ContactsAdapter) {
|
||||||
(fragment_list.adapter as? ContactsAdapter)?.updateItems(contactsIgnoringSearch)
|
(innerBinding.fragmentList.adapter as? ContactsAdapter)?.updateItems(contactsIgnoringSearch)
|
||||||
setupLetterFastscroller(contactsIgnoringSearch)
|
setupLetterFastscroller(contactsIgnoringSearch)
|
||||||
setupViewVisibility(contactsIgnoringSearch.isNotEmpty())
|
setupViewVisibility(contactsIgnoringSearch.isNotEmpty())
|
||||||
} else if (fragment_list.adapter is GroupsAdapter) {
|
} else if (innerBinding.fragmentList.adapter is GroupsAdapter) {
|
||||||
(fragment_list.adapter as? GroupsAdapter)?.updateItems(ArrayList(groupsIgnoringSearch))
|
(innerBinding.fragmentList.adapter as? GroupsAdapter)?.updateItems(ArrayList(groupsIgnoringSearch))
|
||||||
setupViewVisibility(groupsIgnoringSearch.isNotEmpty())
|
setupViewVisibility(groupsIgnoringSearch.isNotEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this is FavoritesFragment && fragment_placeholder.tag != AVOID_CHANGING_TEXT_TAG) {
|
if (this is FavoritesFragment && innerBinding.fragmentPlaceholder.tag != AVOID_CHANGING_TEXT_TAG) {
|
||||||
fragment_placeholder.text = activity?.getString(R.string.no_favorites)
|
innerBinding.fragmentPlaceholder.text = activity?.getString(R.string.no_favorites)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setupViewVisibility(hasItemsToShow: Boolean) {
|
fun setupViewVisibility(hasItemsToShow: Boolean) {
|
||||||
if (fragment_placeholder_2.tag != AVOID_CHANGING_VISIBILITY_TAG) {
|
if (innerBinding.fragmentPlaceholder2.tag != AVOID_CHANGING_VISIBILITY_TAG) {
|
||||||
fragment_placeholder_2?.beVisibleIf(!hasItemsToShow)
|
innerBinding.fragmentPlaceholder2.beVisibleIf(!hasItemsToShow)
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment_placeholder?.beVisibleIf(!hasItemsToShow)
|
innerBinding.fragmentPlaceholder.beVisibleIf(!hasItemsToShow)
|
||||||
fragment_list.beVisibleIf(hasItemsToShow)
|
innerBinding.fragmentList.beVisibleIf(hasItemsToShow)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun fabClicked()
|
abstract fun fabClicked()
|
||||||
|
|
||||||
abstract fun placeholderClicked()
|
abstract fun placeholderClicked()
|
||||||
|
|
||||||
|
interface InnerBinding {
|
||||||
|
val fragmentList: MyRecyclerView
|
||||||
|
val fragmentPlaceholder: MyTextView
|
||||||
|
val fragmentPlaceholder2: MyTextView
|
||||||
|
val fragmentFab: MyFloatingActionButton
|
||||||
|
val fragmentWrapper: RelativeLayout
|
||||||
|
val letterFastscroller: FastScrollerView?
|
||||||
|
val letterFastscrollerThumb: FastScrollerThumbView?
|
||||||
|
val fragmentFastscroller: RecyclerViewFastScroller?
|
||||||
|
}
|
||||||
|
|
||||||
|
class LetterLayout(val binding: FragmentLettersLayoutBinding) : InnerBinding {
|
||||||
|
override val fragmentList: MyRecyclerView = binding.fragmentList
|
||||||
|
override val fragmentPlaceholder: MyTextView = binding.fragmentPlaceholder
|
||||||
|
override val fragmentPlaceholder2: MyTextView = binding.fragmentPlaceholder2
|
||||||
|
override val fragmentFab: MyFloatingActionButton = binding.fragmentFab
|
||||||
|
override val fragmentWrapper: RelativeLayout = binding.fragmentWrapper
|
||||||
|
override val letterFastscroller: FastScrollerView = binding.letterFastscroller
|
||||||
|
override val letterFastscrollerThumb: FastScrollerThumbView = binding.letterFastscrollerThumb
|
||||||
|
override val fragmentFastscroller: RecyclerViewFastScroller? = null
|
||||||
|
}
|
||||||
|
|
||||||
|
class FragmentLayout(val binding: FragmentLayoutBinding) : InnerBinding {
|
||||||
|
override val fragmentList: MyRecyclerView = binding.fragmentList
|
||||||
|
override val fragmentPlaceholder: MyTextView = binding.fragmentPlaceholder
|
||||||
|
override val fragmentPlaceholder2: MyTextView = binding.fragmentPlaceholder2
|
||||||
|
override val fragmentFab: MyFloatingActionButton = binding.fragmentFab
|
||||||
|
override val fragmentWrapper: RelativeLayout = binding.fragmentWrapper
|
||||||
|
override val letterFastscroller: FastScrollerView? = null
|
||||||
|
override val letterFastscrollerThumb: FastScrollerThumbView? = null
|
||||||
|
override val fragmentFastscroller: RecyclerViewFastScroller = binding.fragmentFastscroller
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
|
|
||||||
var autoBackupContactSources: Set<String>
|
var autoBackupContactSources: Set<String>
|
||||||
get() = prefs.getStringSet(AUTO_BACKUP_CONTACT_SOURCES, setOf())!!
|
get() = prefs.getStringSet(AUTO_BACKUP_CONTACT_SOURCES, setOf())!!
|
||||||
set(autoBackupContactSources) = prefs.edit().remove(AUTO_BACKUP_CONTACT_SOURCES).putStringSet(AUTO_BACKUP_CONTACT_SOURCES, autoBackupContactSources).apply()
|
set(autoBackupContactSources) = prefs.edit().remove(AUTO_BACKUP_CONTACT_SOURCES).putStringSet(AUTO_BACKUP_CONTACT_SOURCES, autoBackupContactSources)
|
||||||
|
.apply()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import com.simplemobiletools.commons.extensions.getDateTimeFromDateString
|
||||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.models.contacts.Contact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.contacts.pro.R
|
|
||||||
import com.simplemobiletools.contacts.pro.helpers.VcfExporter.ExportResult.EXPORT_FAIL
|
import com.simplemobiletools.contacts.pro.helpers.VcfExporter.ExportResult.EXPORT_FAIL
|
||||||
import ezvcard.Ezvcard
|
import ezvcard.Ezvcard
|
||||||
import ezvcard.VCard
|
import ezvcard.VCard
|
||||||
|
@ -21,7 +20,7 @@ import ezvcard.VCardVersion
|
||||||
import ezvcard.parameter.ImageType
|
import ezvcard.parameter.ImageType
|
||||||
import ezvcard.property.*
|
import ezvcard.property.*
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
import java.util.*
|
import java.util.Calendar
|
||||||
|
|
||||||
class VcfExporter {
|
class VcfExporter {
|
||||||
enum class ExportResult {
|
enum class ExportResult {
|
||||||
|
@ -46,7 +45,7 @@ class VcfExporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showExportingToast) {
|
if (showExportingToast) {
|
||||||
activity.toast(R.string.exporting)
|
activity.toast(com.simplemobiletools.commons.R.string.exporting)
|
||||||
}
|
}
|
||||||
|
|
||||||
val cards = ArrayList<VCard>()
|
val cards = ArrayList<VCard>()
|
||||||
|
|
|
@ -7,16 +7,16 @@ import android.provider.ContactsContract.CommonDataKinds.Im
|
||||||
import android.provider.ContactsContract.CommonDataKinds.Phone
|
import android.provider.ContactsContract.CommonDataKinds.Phone
|
||||||
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal
|
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import com.simplemobiletools.commons.extensions.getCachePhoto
|
||||||
import com.simplemobiletools.commons.extensions.groupsDB
|
import com.simplemobiletools.commons.extensions.groupsDB
|
||||||
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
|
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
|
||||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||||
import com.simplemobiletools.commons.extensions.getCachePhoto
|
|
||||||
import com.simplemobiletools.contacts.pro.extensions.getCachePhotoUri
|
|
||||||
import com.simplemobiletools.commons.helpers.ContactsHelper
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.DEFAULT_MIMETYPE
|
import com.simplemobiletools.commons.helpers.DEFAULT_MIMETYPE
|
||||||
import com.simplemobiletools.commons.models.PhoneNumber
|
import com.simplemobiletools.commons.models.PhoneNumber
|
||||||
import com.simplemobiletools.commons.models.contacts.*
|
import com.simplemobiletools.commons.models.contacts.*
|
||||||
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.contacts.pro.extensions.getCachePhotoUri
|
||||||
import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_FAIL
|
import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_FAIL
|
||||||
import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_OK
|
import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_OK
|
||||||
import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_PARTIAL
|
import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_PARTIAL
|
||||||
|
@ -26,7 +26,7 @@ import ezvcard.util.PartialDate
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.net.URLDecoder
|
import java.net.URLDecoder
|
||||||
import java.util.*
|
import java.util.Date
|
||||||
|
|
||||||
class VcfImporter(val activity: SimpleActivity) {
|
class VcfImporter(val activity: SimpleActivity) {
|
||||||
enum class ImportResult {
|
enum class ImportResult {
|
||||||
|
@ -261,6 +261,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
||||||
Phone.TYPE_HOME
|
Phone.TYPE_HOME
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WORK -> {
|
WORK -> {
|
||||||
if (subtype?.toUpperCase() == FAX) {
|
if (subtype?.toUpperCase() == FAX) {
|
||||||
Phone.TYPE_FAX_WORK
|
Phone.TYPE_FAX_WORK
|
||||||
|
@ -268,6 +269,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
||||||
Phone.TYPE_WORK
|
Phone.TYPE_WORK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MAIN -> Phone.TYPE_MAIN
|
MAIN -> Phone.TYPE_MAIN
|
||||||
WORK_FAX -> Phone.TYPE_FAX_WORK
|
WORK_FAX -> Phone.TYPE_FAX_WORK
|
||||||
HOME_FAX -> Phone.TYPE_FAX_HOME
|
HOME_FAX -> Phone.TYPE_FAX_HOME
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.simplemobiletools.contacts.pro.interfaces
|
package com.simplemobiletools.contacts.pro.interfaces
|
||||||
|
|
||||||
import com.simplemobiletools.commons.models.contacts.*
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
|
|
||||||
interface RefreshContactsListener {
|
interface RefreshContactsListener {
|
||||||
fun refreshContacts(refreshTabsMask: Int)
|
fun refreshContacts(refreshTabsMask: Int)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.simplemobiletools.contacts.pro.interfaces
|
package com.simplemobiletools.contacts.pro.interfaces
|
||||||
|
|
||||||
import com.simplemobiletools.commons.models.contacts.*
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
|
|
||||||
interface RemoveFromGroupListener {
|
interface RemoveFromGroupListener {
|
||||||
fun removeFromGroup(contacts: ArrayList<Contact>)
|
fun removeFromGroup(contacts: ArrayList<Contact>)
|
||||||
|
|
30
build.gradle
30
build.gradle
|
@ -1,30 +0,0 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
ext.kotlin_version = '1.7.10'
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
|
||||||
// in the individual module build.gradle files
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
maven { url 'https://jitpack.io' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task clean(type: Delete) {
|
|
||||||
delete rootProject.buildDir
|
|
||||||
}
|
|
5
build.gradle.kts
Normal file
5
build.gradle.kts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android).apply(false)
|
||||||
|
alias(libs.plugins.kotlinAndroid).apply(false)
|
||||||
|
alias(libs.plugins.ksp).apply(false)
|
||||||
|
}
|
|
@ -1,2 +1,3 @@
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
|
|
53
gradle/libs.versions.toml
Normal file
53
gradle/libs.versions.toml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
[versions]
|
||||||
|
#jetbrains
|
||||||
|
kotlin = "1.9.0"
|
||||||
|
#KSP
|
||||||
|
ksp = "1.9.0-1.0.12"
|
||||||
|
#AndroidX
|
||||||
|
androidx-swiperefreshlayout = "1.1.0"
|
||||||
|
#AutoFitTextView
|
||||||
|
autofittextview = "0.2.1"
|
||||||
|
#EzVCard
|
||||||
|
ezvcard = "0.11.3"
|
||||||
|
#IndicatorFastScroll
|
||||||
|
indicatorfastscroll = "4524cd0b61"
|
||||||
|
#Room
|
||||||
|
room = "2.6.0-alpha02"
|
||||||
|
#Simple tools
|
||||||
|
simple-commons = "d1629c7f1a"
|
||||||
|
#Gradle
|
||||||
|
gradlePlugins-agp = "8.1.0"
|
||||||
|
#build
|
||||||
|
app-build-compileSDKVersion = "34"
|
||||||
|
app-build-targetSDK = "34"
|
||||||
|
app-build-minimumSDK = "23"
|
||||||
|
app-build-javaVersion = "VERSION_17"
|
||||||
|
app-build-kotlinJVMTarget = "17"
|
||||||
|
#versioning
|
||||||
|
app-version-appId = "com.simplemobiletools.contacts.pro"
|
||||||
|
app-version-versionCode = "104"
|
||||||
|
app-version-versionName = "6.22.4"
|
||||||
|
[libraries]
|
||||||
|
#AndroidX
|
||||||
|
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "androidx-swiperefreshlayout" }
|
||||||
|
#AutoFitTextView
|
||||||
|
autofittextview = { module = "me.grantland:autofittextview", version.ref = "autofittextview" }
|
||||||
|
#EzVcard
|
||||||
|
ezvcard = { module = "com.googlecode.ez-vcard:ez-vcard", version.ref = "ezvcard" }
|
||||||
|
#IndicatorFastScroll
|
||||||
|
indicatorfastscroll = { module = "com.github.tibbi:IndicatorFastScroll", version.ref = "indicatorfastscroll" }
|
||||||
|
#Room
|
||||||
|
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
|
||||||
|
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
|
||||||
|
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
|
||||||
|
#Simple Mobile Tools
|
||||||
|
simple-tools-commons = { module = "com.github.SimpleMobileTools:Simple-Commons", version.ref = "simple-commons" }
|
||||||
|
[bundles]
|
||||||
|
room = [
|
||||||
|
"androidx-room-ktx",
|
||||||
|
"androidx-room-runtime",
|
||||||
|
]
|
||||||
|
[plugins]
|
||||||
|
android = { id = "com.android.application", version.ref = "gradlePlugins-agp" }
|
||||||
|
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
include ':app'
|
|
16
settings.gradle.kts
Normal file
16
settings.gradle.kts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
maven { setUrl("https://jitpack.io") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
include(":app")
|
Loading…
Reference in a new issue