diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt index 6fbebc853..c5cedb415 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt @@ -122,8 +122,8 @@ class AboutActivity : BaseSimpleActivity() { setOnClickListener { val msg = "${getString(R.string.before_asking_question_read_faq)}\n\n${getString(R.string.make_sure_latest)}" - if (intent.getBooleanExtra(SHOW_FAQ_BEFORE_MAIL, false) && !baseConfig.wasBeforeAskingShown) { - baseConfig.wasBeforeAskingShown = true + if (intent.getBooleanExtra(SHOW_FAQ_BEFORE_MAIL, false) && !this@AboutActivity.baseConfig.wasBeforeAskingShown) { + this@AboutActivity.baseConfig.wasBeforeAskingShown = true ConfirmationAdvancedDialog(this@AboutActivity, msg, 0, R.string.read_faq, R.string.skip) { success -> if (success) { launchFAQActivity() @@ -184,10 +184,10 @@ class AboutActivity : BaseSimpleActivity() { about_help_us_layout.addView(this) setOnClickListener { - if (baseConfig.wasBeforeRateShown) { + if (this@AboutActivity.baseConfig.wasBeforeRateShown) { launchRateUsPrompt() } else { - baseConfig.wasBeforeRateShown = true + this@AboutActivity.baseConfig.wasBeforeRateShown = true val msg = "${getString(R.string.before_rate_read_faq)}\n\n${getString(R.string.make_sure_latest)}" ConfirmationAdvancedDialog(this@AboutActivity, msg, 0, R.string.read_faq, R.string.skip) { success -> if (success) { @@ -202,7 +202,7 @@ class AboutActivity : BaseSimpleActivity() { } private fun launchRateUsPrompt() { - if (baseConfig.wasAppRated) { + if (this.baseConfig.wasAppRated) { redirectToRateUs() } else { RateStarsDialog(this@AboutActivity) @@ -376,7 +376,7 @@ class AboutActivity : BaseSimpleActivity() { about_other_layout.addView(this) setOnClickListener { - val appId = baseConfig.appId.removeSuffix(".debug").removeSuffix(".pro").removePrefix("com.simplemobiletools.") + val appId = this@AboutActivity.baseConfig.appId.removeSuffix(".debug").removeSuffix(".pro").removePrefix("com.simplemobiletools.") val url = "https://simplemobiletools.com/privacy/$appId.txt" launchViewIntent(url) } @@ -401,7 +401,7 @@ class AboutActivity : BaseSimpleActivity() { private fun setupVersion() { var version = intent.getStringExtra(APP_VERSION_NAME) ?: "" - if (baseConfig.appId.removeSuffix(".debug").endsWith(".pro")) { + if (this.baseConfig.appId.removeSuffix(".debug").endsWith(".pro")) { version += " ${getString(R.string.pro)}" } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt index af1125c06..9415aa472 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt @@ -95,7 +95,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { super.onCreate(savedInstanceState) if (!packageName.startsWith("com.simplemobiletools.", true)) { - if ((0..50).random() == 10 || baseConfig.appRunCount % 100 == 0) { + if ((0..50).random() == 10 || this.baseConfig.appRunCount % 100 == 0) { val label = "You are using a fake version of the app. For your own safety download the original one from www.simplemobiletools.com. Thanks" ConfirmationDialog(this, label, positive = R.string.ok, negative = 0) { launchViewIntent("https://play.google.com/store/apps/dev?id=9070296388022589266") @@ -110,10 +110,10 @@ abstract class BaseSimpleActivity : AppCompatActivity() { if (useDynamicTheme) { setTheme(getThemeId(showTransparentTop = showTransparentTop)) - val backgroundColor = if (baseConfig.isUsingSystemTheme) { + val backgroundColor = if (this.baseConfig.isUsingSystemTheme) { resources.getColor(R.color.you_background_color, theme) } else { - baseConfig.backgroundColor + this.baseConfig.backgroundColor } updateBackgroundColor(backgroundColor) @@ -122,7 +122,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { if (showTransparentTop) { window.statusBarColor = Color.TRANSPARENT } else if (!isMaterialActivity) { - val color = if (baseConfig.isUsingSystemTheme) { + val color = if (this.baseConfig.isUsingSystemTheme) { resources.getColor(R.color.you_status_bar_color) } else { getProperStatusBarColor() @@ -171,7 +171,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } } - fun updateBackgroundColor(color: Int = baseConfig.backgroundColor) { + fun updateBackgroundColor(color: Int = this.baseConfig.backgroundColor) { window.decorView.setBackgroundColor(color) } @@ -382,7 +382,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } fun updateRecentsAppIcon() { - if (baseConfig.isUsingModifiedAppIcon) { + if (this.baseConfig.isUsingModifiedAppIcon) { val appIconIDs = getAppIconIDs() val currentAppIconColorIndex = getCurrentAppIconColorIndex() if (appIconIDs.size - 1 < currentAppIconColorIndex) { @@ -391,7 +391,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { val recentsIcon = BitmapFactory.decodeResource(resources, appIconIDs[currentAppIconColorIndex]) val title = getAppLauncherName() - val color = baseConfig.primaryColor + val color = this.baseConfig.primaryColor val description = ActivityManager.TaskDescription(title, recentsIcon, color) setTaskDescription(description) @@ -417,7 +417,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } private fun getCurrentAppIconColorIndex(): Int { - val appIconColor = baseConfig.appIconColor + val appIconColor = this.baseConfig.appIconColor getAppIconColors().forEachIndexed { index, color -> if (color == appIconColor) { return index @@ -483,7 +483,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } else if (requestCode == OPEN_DOCUMENT_TREE_FOR_ANDROID_DATA_OR_OBB) { if (resultCode == Activity.RESULT_OK && resultData != null && resultData.data != null) { if (isProperAndroidRoot(checkedDocumentPath, resultData.data!!)) { - if (resultData.dataString == baseConfig.OTGTreeUri || resultData.dataString == baseConfig.sdTreeUri) { + if (resultData.dataString == this.baseConfig.OTGTreeUri || resultData.dataString == this.baseConfig.sdTreeUri) { val pathToSelect = createAndroidDataOrObbPath(checkedDocumentPath) toast(getString(R.string.wrong_folder_selected, pathToSelect)) return @@ -518,7 +518,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { val isProperPartition = partition.isEmpty() || !sdOtgPattern.matcher(partition).matches() || (sdOtgPattern.matcher(partition) .matches() && resultData.dataString!!.contains(partition)) if (isProperSDRootFolder(resultData.data!!) && isProperPartition) { - if (resultData.dataString == baseConfig.OTGTreeUri) { + if (resultData.dataString == this.baseConfig.OTGTreeUri) { toast(R.string.sd_card_usb_same) return } @@ -544,13 +544,13 @@ abstract class BaseSimpleActivity : AppCompatActivity() { val isProperPartition = partition.isEmpty() || !sdOtgPattern.matcher(partition).matches() || (sdOtgPattern.matcher(partition) .matches() && resultData.dataString!!.contains(partition)) if (isProperOTGRootFolder(resultData.data!!) && isProperPartition) { - if (resultData.dataString == baseConfig.sdTreeUri) { + if (resultData.dataString == this.baseConfig.sdTreeUri) { funAfterSAFPermission?.invoke(false) toast(R.string.sd_card_usb_same) return } - baseConfig.OTGTreeUri = resultData.dataString!! - baseConfig.OTGPartition = baseConfig.OTGTreeUri.removeSuffix("%3A").substringAfterLast('/').trimEnd('/') + this.baseConfig.OTGTreeUri = resultData.dataString!! + this.baseConfig.OTGPartition = this.baseConfig.OTGTreeUri.removeSuffix("%3A").substringAfterLast('/').trimEnd('/') updateOTGPathFromPartition() val takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION @@ -588,7 +588,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { private fun saveTreeUri(resultData: Intent) { val treeUri = resultData.data - baseConfig.sdTreeUri = treeUri.toString() + this.baseConfig.sdTreeUri = treeUri.toString() val takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION applicationContext.contentResolver.takePersistableUriPermission(treeUri!!, takeFlags) @@ -633,7 +633,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { fun startCustomizationActivity() { if (!packageName.contains("slootelibomelpmis".reversed(), true)) { - if (baseConfig.appRunCount > 100) { + if (this.baseConfig.appRunCount > 100) { val label = "You are using a fake version of the app. For your own safety download the original one from www.simplemobiletools.com. Thanks" ConfirmationDialog(this, label, positive = R.string.ok, negative = 0) { launchViewIntent("https://play.google.com/store/apps/dev?id=9070296388022589266") @@ -753,7 +753,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { fun handleOTGPermission(callback: (success: Boolean) -> Unit) { hideKeyboard() - if (baseConfig.OTGTreeUri.isNotEmpty()) { + if (this.baseConfig.OTGTreeUri.isNotEmpty()) { callback(true) return } @@ -921,7 +921,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } if (!newFile.exists() && File(oldFileDirItem.path).renameTo(newFile)) { - if (!baseConfig.keepLastModified) { + if (!this.baseConfig.keepLastModified) { newFile.setLastModified(System.currentTimeMillis()) } updatedPaths.add(newFile.absolutePath) @@ -1080,8 +1080,8 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } fun checkAppOnSDCard() { - if (!baseConfig.wasAppOnSDShown && isAppInstalledOnSDCard()) { - baseConfig.wasAppOnSDShown = true + if (!this.baseConfig.wasAppOnSDShown && isAppInstalledOnSDCard()) { + this.baseConfig.wasAppOnSDShown = true ConfirmationDialog(this, "", R.string.app_on_sd_card, R.string.ok, 0) {} } } @@ -1136,7 +1136,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } private fun getExportSettingsFilename(): String { - val appName = baseConfig.appId.removeSuffix(".debug").removeSuffix(".pro").removePrefix("com.simplemobiletools.") + val appName = this.baseConfig.appId.removeSuffix(".debug").removeSuffix(".pro").removePrefix("com.simplemobiletools.") return "$appName-settings_${getCurrentFormattedDateTime()}" } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSplashActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSplashActivity.kt index c03031567..f48873e31 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSplashActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSplashActivity.kt @@ -13,16 +13,16 @@ abstract class BaseSplashActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - if (baseConfig.appSideloadingStatus == SIDELOADING_UNCHECKED) { + if (this.baseConfig.appSideloadingStatus == SIDELOADING_UNCHECKED) { if (checkAppSideloading()) { return } - } else if (baseConfig.appSideloadingStatus == SIDELOADING_TRUE) { + } else if (this.baseConfig.appSideloadingStatus == SIDELOADING_TRUE) { showSideloadingDialog() return } - baseConfig.apply { + this.baseConfig.apply { if (isUsingAutoTheme) { val isUsingSystemDarkTheme = isUsingSystemDarkTheme() isUsingSharedTheme = false @@ -31,10 +31,10 @@ abstract class BaseSplashActivity : AppCompatActivity() { } } - if (!baseConfig.isUsingAutoTheme && !baseConfig.isUsingSystemTheme && isThankYouInstalled()) { + if (!this.baseConfig.isUsingAutoTheme && !this.baseConfig.isUsingSystemTheme && isThankYouInstalled()) { getSharedTheme { if (it != null) { - baseConfig.apply { + this.baseConfig.apply { wasSharedThemeForced = true isUsingSharedTheme = true wasSharedThemeEverActivated = true @@ -45,8 +45,8 @@ abstract class BaseSplashActivity : AppCompatActivity() { accentColor = it.accentColor } - if (baseConfig.appIconColor != it.appIconColor) { - baseConfig.appIconColor = it.appIconColor + if (this.baseConfig.appIconColor != it.appIconColor) { + this.baseConfig.appIconColor = it.appIconColor checkAppIconColor() } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt index 9f9e1699c..f493c8a12 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt @@ -64,9 +64,9 @@ class CustomizationActivity : BaseSimpleActivity() { try { storedSharedTheme = getSharedThemeSync(cursorLoader) if (storedSharedTheme == null) { - baseConfig.isUsingSharedTheme = false + this.baseConfig.isUsingSharedTheme = false } else { - baseConfig.wasSharedThemeEverActivated = true + this.baseConfig.wasSharedThemeEverActivated = true } runOnUiThread { @@ -83,17 +83,17 @@ class CustomizationActivity : BaseSimpleActivity() { } } else { setupThemes() - baseConfig.isUsingSharedTheme = false + this.baseConfig.isUsingSharedTheme = false } - val textColor = if (baseConfig.isUsingSystemTheme) { + val textColor = if (this.baseConfig.isUsingSystemTheme) { getProperTextColor() } else { - baseConfig.textColor + this.baseConfig.textColor } updateLabelColors(textColor) - originalAppIconColor = baseConfig.appIconColor + originalAppIconColor = this.baseConfig.appIconColor if (resources.getBoolean(R.bool.hide_google_relations) && !isThankYou) { apply_to_all_holder.beGone() @@ -104,7 +104,7 @@ class CustomizationActivity : BaseSimpleActivity() { super.onResume() setTheme(getThemeId(getCurrentPrimaryColor())) - if (!baseConfig.isUsingSystemTheme) { + if (!this.baseConfig.isUsingSystemTheme) { updateBackgroundColor(getCurrentBackgroundColor()) updateActionbarColor(getCurrentStatusBarColor()) } @@ -199,11 +199,11 @@ class CustomizationActivity : BaseSimpleActivity() { updateAutoThemeFields() handleAccentColorLayout() customization_theme_holder.setOnClickListener { - if (baseConfig.wasAppIconCustomizationWarningShown) { + if (this.baseConfig.wasAppIconCustomizationWarningShown) { themePickerClicked() } else { ConfirmationDialog(this, "", R.string.app_icon_color_warning, R.string.ok, 0) { - baseConfig.wasAppIconCustomizationWarningShown = true + this.baseConfig.wasAppIconCustomizationWarningShown = true themePickerClicked() } } @@ -227,8 +227,8 @@ class CustomizationActivity : BaseSimpleActivity() { } updateColorTheme(it as Int, true) - if (it != THEME_CUSTOM && it != THEME_SHARED && it != THEME_AUTO && it != THEME_SYSTEM && !baseConfig.wasCustomThemeSwitchDescriptionShown) { - baseConfig.wasCustomThemeSwitchDescriptionShown = true + if (it != THEME_CUSTOM && it != THEME_SHARED && it != THEME_AUTO && it != THEME_SYSTEM && !this.baseConfig.wasCustomThemeSwitchDescriptionShown) { + this.baseConfig.wasCustomThemeSwitchDescriptionShown = true toast(R.string.changing_color_description) } @@ -249,21 +249,21 @@ class CustomizationActivity : BaseSimpleActivity() { resources.apply { if (curSelectedThemeId == THEME_CUSTOM) { if (useStored) { - curTextColor = baseConfig.customTextColor - curBackgroundColor = baseConfig.customBackgroundColor - curPrimaryColor = baseConfig.customPrimaryColor - curAccentColor = baseConfig.customAccentColor - curAppIconColor = baseConfig.customAppIconColor + curTextColor = this@CustomizationActivity.baseConfig.customTextColor + curBackgroundColor = this@CustomizationActivity.baseConfig.customBackgroundColor + curPrimaryColor = this@CustomizationActivity.baseConfig.customPrimaryColor + curAccentColor = this@CustomizationActivity.baseConfig.customAccentColor + curAppIconColor = this@CustomizationActivity.baseConfig.customAppIconColor setTheme(getThemeId(curPrimaryColor)) updateMenuItemColors(customization_toolbar.menu, curPrimaryColor) setupToolbar(customization_toolbar, NavigationIcon.Cross, curPrimaryColor) setupColorsPickers() } else { - baseConfig.customPrimaryColor = curPrimaryColor - baseConfig.customAccentColor = curAccentColor - baseConfig.customBackgroundColor = curBackgroundColor - baseConfig.customTextColor = curTextColor - baseConfig.customAppIconColor = curAppIconColor + this@CustomizationActivity.baseConfig.customPrimaryColor = curPrimaryColor + this@CustomizationActivity.baseConfig.customAccentColor = curAccentColor + this@CustomizationActivity.baseConfig.customBackgroundColor = curBackgroundColor + this@CustomizationActivity.baseConfig.customTextColor = curTextColor + this@CustomizationActivity.baseConfig.customAppIconColor = curAppIconColor } } else if (curSelectedThemeId == THEME_SHARED) { if (useStored) { @@ -326,11 +326,11 @@ class CustomizationActivity : BaseSimpleActivity() { } private fun getCurrentThemeId(): Int { - if (baseConfig.isUsingSharedTheme) { + if (this.baseConfig.isUsingSharedTheme) { return THEME_SHARED - } else if ((baseConfig.isUsingSystemTheme && !hasUnsavedChanges) || curSelectedThemeId == THEME_SYSTEM) { + } else if ((this.baseConfig.isUsingSystemTheme && !hasUnsavedChanges) || curSelectedThemeId == THEME_SYSTEM) { return THEME_SYSTEM - } else if (baseConfig.isUsingAutoTheme || curSelectedThemeId == THEME_AUTO) { + } else if (this.baseConfig.isUsingAutoTheme || curSelectedThemeId == THEME_AUTO) { return THEME_AUTO } @@ -382,7 +382,7 @@ class CustomizationActivity : BaseSimpleActivity() { private fun saveChanges(finishAfterSave: Boolean) { val didAppIconColorChange = curAppIconColor != originalAppIconColor - baseConfig.apply { + this.baseConfig.apply { textColor = curTextColor backgroundColor = curBackgroundColor primaryColor = curPrimaryColor @@ -403,10 +403,10 @@ class CustomizationActivity : BaseSimpleActivity() { } } - baseConfig.isUsingSharedTheme = curSelectedThemeId == THEME_SHARED - baseConfig.shouldUseSharedTheme = curSelectedThemeId == THEME_SHARED - baseConfig.isUsingAutoTheme = curSelectedThemeId == THEME_AUTO - baseConfig.isUsingSystemTheme = curSelectedThemeId == THEME_SYSTEM + this.baseConfig.isUsingSharedTheme = curSelectedThemeId == THEME_SHARED + this.baseConfig.shouldUseSharedTheme = curSelectedThemeId == THEME_SHARED + this.baseConfig.isUsingAutoTheme = curSelectedThemeId == THEME_AUTO + this.baseConfig.isUsingSystemTheme = curSelectedThemeId == THEME_SYSTEM hasUnsavedChanges = false if (finishAfterSave) { @@ -427,11 +427,11 @@ class CustomizationActivity : BaseSimpleActivity() { } private fun initColorVariables() { - curTextColor = baseConfig.textColor - curBackgroundColor = baseConfig.backgroundColor - curPrimaryColor = baseConfig.primaryColor - curAccentColor = baseConfig.accentColor - curAppIconColor = baseConfig.appIconColor + curTextColor = this.baseConfig.textColor + curBackgroundColor = this.baseConfig.backgroundColor + curPrimaryColor = this.baseConfig.primaryColor + curAccentColor = this.baseConfig.accentColor + curAppIconColor = this.baseConfig.appIconColor } private fun setupColorsPickers() { @@ -456,11 +456,11 @@ class CustomizationActivity : BaseSimpleActivity() { } customization_app_icon_color_holder.setOnClickListener { - if (baseConfig.wasAppIconCustomizationWarningShown) { + if (this.baseConfig.wasAppIconCustomizationWarningShown) { pickAppIconColor() } else { ConfirmationDialog(this, "", R.string.app_icon_color_warning, R.string.ok, 0) { - baseConfig.wasAppIconCustomizationWarningShown = true + this.baseConfig.wasAppIconCustomizationWarningShown = true pickAppIconColor() } } @@ -492,7 +492,7 @@ class CustomizationActivity : BaseSimpleActivity() { } private fun updateApplyToAllColors(newColor: Int) { - if (newColor == baseConfig.primaryColor && !baseConfig.isUsingSystemTheme) { + if (newColor == this.baseConfig.primaryColor && !this.baseConfig.isUsingSystemTheme) { apply_to_all.setBackgroundResource(R.drawable.button_background_rounded) } else { val applyBackground = resources.getDrawable(R.drawable.button_background_rounded, theme) as RippleDrawable @@ -541,7 +541,7 @@ class CustomizationActivity : BaseSimpleActivity() { } private fun pickPrimaryColor() { - if (!packageName.startsWith("com.simplemobiletools.", true) && baseConfig.appRunCount > 50) { + if (!packageName.startsWith("com.simplemobiletools.", true) && this.baseConfig.appRunCount > 50) { finish() return } @@ -608,7 +608,7 @@ class CustomizationActivity : BaseSimpleActivity() { predefinedThemes[THEME_SHARED] = MyTheme(getString(R.string.shared), 0, 0, 0, 0) } - baseConfig.wasSharedThemeEverActivated = true + this.baseConfig.wasSharedThemeEverActivated = true apply_to_all_holder.beGone() updateColorTheme(THEME_SHARED) saveChanges(false) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt index e582ea0d3..79de287ed 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt @@ -40,11 +40,11 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi updateTextColors(manage_blocked_numbers_wrapper) updatePlaceholderTexts() - val blockTitleRes = if (baseConfig.appId.startsWith("com.simplemobiletools.dialer")) R.string.block_unknown_calls else R.string.block_unknown_messages + val blockTitleRes = if (this.baseConfig.appId.startsWith("com.simplemobiletools.dialer")) R.string.block_unknown_calls else R.string.block_unknown_messages block_unknown.apply { setText(blockTitleRes) - isChecked = baseConfig.blockUnknownNumbers + isChecked = this@ManageBlockedNumbersActivity.baseConfig.blockUnknownNumbers if (isChecked) { maybeSetDefaultCallerIdApp() } @@ -52,7 +52,7 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi block_unknown_holder.setOnClickListener { block_unknown.toggle() - baseConfig.blockUnknownNumbers = block_unknown.isChecked + this.baseConfig.blockUnknownNumbers = block_unknown.isChecked if (block_unknown.isChecked) { maybeSetDefaultCallerIdApp() } @@ -108,7 +108,7 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi exportBlockedNumbersTo(outputStream) } else if (requestCode == REQUEST_CODE_SET_DEFAULT_CALLER_ID && resultCode != Activity.RESULT_OK) { toast(R.string.must_make_default_caller_id_app, length = Toast.LENGTH_LONG) - baseConfig.blockUnknownNumbers = false + this.baseConfig.blockUnknownNumbers = false block_unknown.isChecked = false } } @@ -215,7 +215,7 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi private fun tryExportBlockedNumbers() { if (isQPlus()) { - ExportBlockedNumbersDialog(this, baseConfig.lastBlockedNumbersExportPath, true) { file -> + ExportBlockedNumbersDialog(this, this.baseConfig.lastBlockedNumbersExportPath, true) { file -> Intent(Intent.ACTION_CREATE_DOCUMENT).apply { type = "text/plain" putExtra(Intent.EXTRA_TITLE, file.name) @@ -233,7 +233,7 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi } else { handlePermission(PERMISSION_WRITE_STORAGE) { if (it) { - ExportBlockedNumbersDialog(this, baseConfig.lastBlockedNumbersExportPath, false) { file -> + ExportBlockedNumbersDialog(this, this.baseConfig.lastBlockedNumbersExportPath, false) { file -> getFileOutputStream(file.toFileDirItem(this), true) { out -> exportBlockedNumbersTo(out) } @@ -262,7 +262,7 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi } private fun maybeSetDefaultCallerIdApp() { - if (isQPlus() && baseConfig.appId.startsWith("com.simplemobiletools.dialer")) { + if (isQPlus() && this.baseConfig.appId.startsWith("com.simplemobiletools.dialer")) { setDefaultCallerIdApp() } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity-sdk30.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity-sdk30.kt index 40a044601..b661498d0 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity-sdk30.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity-sdk30.kt @@ -36,7 +36,7 @@ fun BaseSimpleActivity.copySingleFileSdk30(source: FileDirItem, destination: Fil out?.flush() return if (source.size == copiedSize && getDoesFilePathExist(destination.path)) { - if (baseConfig.keepLastModified) { + if (this.baseConfig.keepLastModified) { copyOldLastModified(source.path, destination.path) val lastModified = File(source.path).lastModified() if (lastModified != 0L) { diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity-themes.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity-themes.kt index 4eaeb3470..653ba3b2f 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity-themes.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity-themes.kt @@ -5,16 +5,16 @@ import android.graphics.Color import com.simplemobiletools.commons.R import com.simplemobiletools.commons.helpers.DARK_GREY -fun Activity.getThemeId(color: Int = baseConfig.primaryColor, showTransparentTop: Boolean = false) = when { - baseConfig.isUsingSystemTheme -> if (isUsingSystemDarkTheme()) R.style.AppTheme_Base_System else R.style.AppTheme_Base_System_Light +fun Activity.getThemeId(color: Int = this.baseConfig.primaryColor, showTransparentTop: Boolean = false) = when { + this.baseConfig.isUsingSystemTheme -> if (isUsingSystemDarkTheme()) R.style.AppTheme_Base_System else R.style.AppTheme_Base_System_Light isBlackAndWhiteTheme() -> when { showTransparentTop -> R.style.AppTheme_BlackAndWhite_NoActionBar - baseConfig.primaryColor.getContrastColor() == DARK_GREY -> R.style.AppTheme_BlackAndWhite_DarkTextColor + this.baseConfig.primaryColor.getContrastColor() == DARK_GREY -> R.style.AppTheme_BlackAndWhite_DarkTextColor else -> R.style.AppTheme_BlackAndWhite } isWhiteTheme() -> when { showTransparentTop -> R.style.AppTheme_White_NoActionBar - baseConfig.primaryColor.getContrastColor() == Color.WHITE -> R.style.AppTheme_White_LightTextColor + this.baseConfig.primaryColor.getContrastColor() == Color.WHITE -> R.style.AppTheme_White_LightTextColor else -> R.style.AppTheme_White } showTransparentTop -> { diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt index ce2355fcc..fb9605701 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt @@ -48,47 +48,47 @@ import java.io.* import java.util.* fun Activity.appLaunched(appId: String) { - baseConfig.internalStoragePath = getInternalStoragePath() + this.baseConfig.internalStoragePath = getInternalStoragePath() updateSDCardPath() - baseConfig.appId = appId - if (baseConfig.appRunCount == 0) { - baseConfig.wasOrangeIconChecked = true + this.baseConfig.appId = appId + if (this.baseConfig.appRunCount == 0) { + this.baseConfig.wasOrangeIconChecked = true checkAppIconColor() - } else if (!baseConfig.wasOrangeIconChecked) { - baseConfig.wasOrangeIconChecked = true + } else if (!this.baseConfig.wasOrangeIconChecked) { + this.baseConfig.wasOrangeIconChecked = true val primaryColor = resources.getColor(R.color.color_primary) - if (baseConfig.appIconColor != primaryColor) { + if (this.baseConfig.appIconColor != primaryColor) { getAppIconColors().forEachIndexed { index, color -> toggleAppIconColor(appId, index, color, false) } - val defaultClassName = "${baseConfig.appId.removeSuffix(".debug")}.activities.SplashActivity" + val defaultClassName = "${this.baseConfig.appId.removeSuffix(".debug")}.activities.SplashActivity" packageManager.setComponentEnabledSetting( - ComponentName(baseConfig.appId, defaultClassName), + ComponentName(this.baseConfig.appId, defaultClassName), PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.DONT_KILL_APP ) - val orangeClassName = "${baseConfig.appId.removeSuffix(".debug")}.activities.SplashActivity.Orange" + val orangeClassName = "${this.baseConfig.appId.removeSuffix(".debug")}.activities.SplashActivity.Orange" packageManager.setComponentEnabledSetting( - ComponentName(baseConfig.appId, orangeClassName), + ComponentName(this.baseConfig.appId, orangeClassName), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP ) - baseConfig.appIconColor = primaryColor - baseConfig.lastIconColor = primaryColor + this.baseConfig.appIconColor = primaryColor + this.baseConfig.lastIconColor = primaryColor } } - baseConfig.appRunCount++ - if (baseConfig.appRunCount % 30 == 0 && !isAProApp()) { + this.baseConfig.appRunCount++ + if (this.baseConfig.appRunCount % 30 == 0 && !isAProApp()) { if (!resources.getBoolean(R.bool.hide_google_relations)) { showDonateOrUpgradeDialog() } } - if (baseConfig.appRunCount % 40 == 0 && !baseConfig.wasAppRated) { + if (this.baseConfig.appRunCount % 40 == 0 && !this.baseConfig.wasAppRated) { if (!resources.getBoolean(R.bool.hide_google_relations)) { RateStarsDialog(this) } @@ -111,7 +111,7 @@ fun Activity.isAppInstalledOnSDCard(): Boolean = try { } fun BaseSimpleActivity.isShowingSAFDialog(path: String): Boolean { - return if ((!isRPlus() && isPathOnSD(path) && !isSDCardSetAsDefaultStorage() && (baseConfig.sdTreeUri.isEmpty() || !hasProperStoredTreeUri(false)))) { + return if ((!isRPlus() && isPathOnSD(path) && !isSDCardSetAsDefaultStorage() && (this.baseConfig.sdTreeUri.isEmpty() || !hasProperStoredTreeUri(false)))) { runOnUiThread { if (!isDestroyed && !isFinishing) { WritePermissionDialog(this, Mode.SdCard) { @@ -254,7 +254,7 @@ fun BaseSimpleActivity.isShowingAndroidSAFDialog(path: String): Boolean { } fun BaseSimpleActivity.isShowingOTGDialog(path: String): Boolean { - return if (!isRPlus() && isPathOnOTG(path) && (baseConfig.OTGTreeUri.isEmpty() || !hasProperStoredTreeUri(true))) { + return if (!isRPlus() && isPathOnOTG(path) && (this.baseConfig.OTGTreeUri.isEmpty() || !hasProperStoredTreeUri(true))) { showOTGPermissionDialog(path) true } else { @@ -301,7 +301,7 @@ fun Activity.launchPurchaseThankYouIntent() { fun Activity.launchUpgradeToProIntent() { hideKeyboard() try { - launchViewIntent("market://details?id=${baseConfig.appId.removeSuffix(".debug")}.pro") + launchViewIntent("market://details?id=${this.baseConfig.appId.removeSuffix(".debug")}.pro") } catch (ignored: Exception) { launchViewIntent(getStoreUrl()) } @@ -601,19 +601,19 @@ fun Activity.tryGenericMimeType(intent: Intent, mimeType: String, uri: Uri): Boo } fun BaseSimpleActivity.checkWhatsNew(releases: List, currVersion: Int) { - if (baseConfig.lastVersion == 0) { - baseConfig.lastVersion = currVersion + if (this.baseConfig.lastVersion == 0) { + this.baseConfig.lastVersion = currVersion return } val newReleases = arrayListOf() - releases.filterTo(newReleases) { it.id > baseConfig.lastVersion } + releases.filterTo(newReleases) { it.id > this.baseConfig.lastVersion } if (newReleases.isNotEmpty()) { WhatsNewDialog(this, newReleases) } - baseConfig.lastVersion = currVersion + this.baseConfig.lastVersion = currVersion } fun BaseSimpleActivity.deleteFolders(folders: List, deleteMediaOnly: Boolean = true, callback: ((wasSuccess: Boolean) -> Unit)? = null) { @@ -626,7 +626,7 @@ fun BaseSimpleActivity.deleteFoldersBg(folders: List, deleteMediaOn var wasSuccess = false var needPermissionForPath = "" for (folder in folders) { - if (needsStupidWritePermissions(folder.path) && baseConfig.sdTreeUri.isEmpty()) { + if (needsStupidWritePermissions(folder.path) && this.baseConfig.sdTreeUri.isEmpty()) { needPermissionForPath = folder.path break } @@ -978,7 +978,7 @@ fun BaseSimpleActivity.renameFile( updateInMediaStore(oldPath, newPath) rescanPaths(arrayListOf(oldPath, newPath)) { - if (!baseConfig.keepLastModified) { + if (!this.baseConfig.keepLastModified) { updateLastModified(newPath, System.currentTimeMillis()) } deleteFromMediaStore(oldPath) @@ -1058,7 +1058,7 @@ private fun BaseSimpleActivity.renameCasually( scanPathRecursively(newPath) } } else { - if (!baseConfig.keepLastModified) { + if (!this.baseConfig.keepLastModified) { newFile.setLastModified(System.currentTimeMillis()) } updateInMediaStore(oldPath, newPath) @@ -1101,7 +1101,7 @@ private fun BaseSimpleActivity.renameCasually( if (copyTempSuccess) { contentResolver.delete(sourceUri, null) tempDestination.renameTo(File(newPath)) - if (!baseConfig.keepLastModified) { + if (!this.baseConfig.keepLastModified) { newFile.setLastModified(System.currentTimeMillis()) } updateInMediaStore(oldPath, newPath) @@ -1124,7 +1124,7 @@ private fun BaseSimpleActivity.renameCasually( ) val copySuccessful = copySingleFileSdk30(sourceFile, destinationFile) if (copySuccessful) { - if (!baseConfig.keepLastModified) { + if (!this.baseConfig.keepLastModified) { newFile.setLastModified(System.currentTimeMillis()) } contentResolver.delete(sourceUri, null) @@ -1281,7 +1281,7 @@ fun BaseSimpleActivity.getFileOutputStream(fileDirItem: FileDirItem, allowCreati fun BaseSimpleActivity.showFileCreateError(path: String) { val error = String.format(getString(R.string.could_not_create_file), path) - baseConfig.sdTreeUri = "" + this.baseConfig.sdTreeUri = "" showErrorToast(error) } @@ -1411,8 +1411,8 @@ fun Activity.showBiometricPrompt( } fun Activity.handleHiddenFolderPasswordProtection(callback: () -> Unit) { - if (baseConfig.isHiddenPasswordProtectionOn) { - SecurityDialog(this, baseConfig.hiddenPasswordHash, baseConfig.hiddenProtectionType) { _, _, success -> + if (this.baseConfig.isHiddenPasswordProtectionOn) { + SecurityDialog(this, this.baseConfig.hiddenPasswordHash, this.baseConfig.hiddenProtectionType) { _, _, success -> if (success) { callback() } @@ -1423,8 +1423,8 @@ fun Activity.handleHiddenFolderPasswordProtection(callback: () -> Unit) { } fun Activity.handleAppPasswordProtection(callback: (success: Boolean) -> Unit) { - if (baseConfig.isAppPasswordProtectionOn) { - SecurityDialog(this, baseConfig.appPasswordHash, baseConfig.appProtectionType) { _, _, success -> + if (this.baseConfig.isAppPasswordProtectionOn) { + SecurityDialog(this, this.baseConfig.appPasswordHash, this.baseConfig.appProtectionType) { _, _, success -> callback(success) } } else { @@ -1433,8 +1433,8 @@ fun Activity.handleAppPasswordProtection(callback: (success: Boolean) -> Unit) { } fun Activity.handleDeletePasswordProtection(callback: () -> Unit) { - if (baseConfig.isDeletePasswordProtectionOn) { - SecurityDialog(this, baseConfig.deletePasswordHash, baseConfig.deleteProtectionType) { _, _, success -> + if (this.baseConfig.isDeletePasswordProtectionOn) { + SecurityDialog(this, this.baseConfig.deletePasswordHash, this.baseConfig.deleteProtectionType) { _, _, success -> if (success) { callback() } @@ -1445,8 +1445,8 @@ fun Activity.handleDeletePasswordProtection(callback: () -> Unit) { } fun Activity.handleLockedFolderOpening(path: String, callback: (success: Boolean) -> Unit) { - if (baseConfig.isFolderProtected(path)) { - SecurityDialog(this, baseConfig.getFolderProtectionHash(path), baseConfig.getFolderProtectionType(path)) { _, _, success -> + if (this.baseConfig.isFolderProtected(path)) { + SecurityDialog(this, this.baseConfig.getFolderProtectionHash(path), this.baseConfig.getFolderProtectionType(path)) { _, _, success -> callback(success) } } else { @@ -1539,7 +1539,7 @@ fun Activity.setupDialogStuff( } // if we use the same primary and background color, use the text color for dialog confirmation buttons - val dialogButtonColor = if (primaryColor == baseConfig.backgroundColor) { + val dialogButtonColor = if (primaryColor == this.baseConfig.backgroundColor) { textColor } else { primaryColor @@ -1559,8 +1559,8 @@ fun Activity.setupDialogStuff( val bgDrawable = when { isBlackAndWhiteTheme() -> resources.getDrawable(R.drawable.black_dialog_background, theme) - baseConfig.isUsingSystemTheme -> resources.getDrawable(R.drawable.dialog_you_background, theme) - else -> resources.getColoredDrawableWithColor(R.drawable.dialog_bg, baseConfig.backgroundColor) + this@setupDialogStuff.baseConfig.isUsingSystemTheme -> resources.getDrawable(R.drawable.dialog_you_background, theme) + else -> resources.getColoredDrawableWithColor(R.drawable.dialog_bg, this@setupDialogStuff.baseConfig.backgroundColor) } window?.setBackgroundDrawable(bgDrawable) @@ -1569,7 +1569,7 @@ fun Activity.setupDialogStuff( } } -fun Activity.getAlertDialogBuilder() = if (baseConfig.isUsingSystemTheme) { +fun Activity.getAlertDialogBuilder() = if (this.baseConfig.isUsingSystemTheme) { MaterialAlertDialogBuilder(this) } else { AlertDialog.Builder(this) @@ -1631,7 +1631,7 @@ fun Activity.showPickSecondsDialog( TimePickerDialog( this, getTimePickerDialogTheme(), { view, hourOfDay, minute -> callback(hourOfDay * -3600 + minute * -60) }, - curSeconds / 3600, curSeconds % 3600, baseConfig.use24HourFormat + curSeconds / 3600, curSeconds % 3600, this.baseConfig.use24HourFormat ).show() } else -> { @@ -1682,13 +1682,13 @@ fun BaseSimpleActivity.getAlarmSounds(type: Int, callback: (ArrayList true SIDELOADING_FALSE -> false else -> isAppSideloaded() } - baseConfig.appSideloadingStatus = if (isSideloaded) SIDELOADING_TRUE else SIDELOADING_FALSE + this.baseConfig.appSideloadingStatus = if (isSideloaded) SIDELOADING_TRUE else SIDELOADING_FALSE if (isSideloaded) { showSideloadingDialog() } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/App.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/App.kt index 49d5d91b7..85f7b8827 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/App.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/App.kt @@ -5,7 +5,7 @@ import com.simplemobiletools.commons.helpers.isNougatPlus import java.util.* fun Application.checkUseEnglish() { - if (baseConfig.useEnglish && !isNougatPlus()) { + if (this.baseConfig.useEnglish && !isNougatPlus()) { val conf = resources.configuration conf.locale = Locale.ENGLISH resources.updateConfiguration(conf, resources.displayMetrics) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-contacts.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-contacts.kt index dc2caaf31..3771db328 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-contacts.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-contacts.kt @@ -18,14 +18,12 @@ import com.simplemobiletools.commons.models.contacts.Organization import com.simplemobiletools.commons.models.contacts.SocialAction import java.io.File -val Context.contactsConfig: ContactsConfig get() = ContactsConfig.newInstance(applicationContext) - val Context.contactsDB: ContactsDao get() = ContactsDatabase.getInstance(applicationContext).ContactsDao() val Context.groupsDB: GroupsDao get() = ContactsDatabase.getInstance(applicationContext).GroupsDao() fun Context.getEmptyContact(): Contact { - val originalContactSource = if (hasContactPermissions()) contactsConfig.lastUsedContactSource else SMT_PRIVATE + val originalContactSource = if (hasContactPermissions()) this.baseConfig.lastUsedContactSource else SMT_PRIVATE val organization = Organization("", "") return Contact( 0, "", "", "", "", "", "", "", ArrayList(), ArrayList(), ArrayList(), ArrayList(), originalContactSource, 0, 0, "", @@ -260,7 +258,7 @@ fun Context.getContactPublicUri(contact: Contact): Uri { fun Context.getVisibleContactSources(): ArrayList { val sources = getAllContactSources() - val ignoredContactSources = contactsConfig.ignoredContactSources + val ignoredContactSources = this.baseConfig.ignoredContactSources return ArrayList(sources).filter { !ignoredContactSources.contains(it.getFullIdentifier()) } .map { it.name }.toMutableList() as ArrayList } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-storage.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-storage.kt index bf5413dfb..932827409 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-storage.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-storage.kt @@ -41,7 +41,7 @@ fun Context.getSDCardPath(): String { !it.equals(getInternalStoragePath()) && !it.equals( "/storage/emulated/0", true - ) && (baseConfig.OTGPartition.isEmpty() || !it.endsWith(baseConfig.OTGPartition)) + ) && (this.baseConfig.OTGPartition.isEmpty() || !it.endsWith(this.baseConfig.OTGPartition)) } val fullSDpattern = Pattern.compile(SD_OTG_PATTERN) @@ -71,7 +71,7 @@ fun Context.getSDCardPath(): String { } val finalPath = sdCardPath.trimEnd('/') - baseConfig.sdCardPath = finalPath + this.baseConfig.sdCardPath = finalPath return finalPath } @@ -169,13 +169,13 @@ fun Context.needsStupidWritePermissions(path: String) = !isRPlus() && (isPathOnS fun Context.isSDCardSetAsDefaultStorage() = sdCardPath.isNotEmpty() && Environment.getExternalStorageDirectory().absolutePath.equals(sdCardPath, true) fun Context.hasProperStoredTreeUri(isOTG: Boolean): Boolean { - val uri = if (isOTG) baseConfig.OTGTreeUri else baseConfig.sdTreeUri + val uri = if (isOTG) this.baseConfig.OTGTreeUri else this.baseConfig.sdTreeUri val hasProperUri = contentResolver.persistedUriPermissions.any { it.uri.toString() == uri } if (!hasProperUri) { if (isOTG) { - baseConfig.OTGTreeUri = "" + this.baseConfig.OTGTreeUri = "" } else { - baseConfig.sdTreeUri = "" + this.baseConfig.sdTreeUri = "" } } return hasProperUri @@ -192,9 +192,9 @@ fun Context.hasProperStoredAndroidTreeUri(path: String): Boolean { fun Context.getAndroidTreeUri(path: String): String { return when { - isPathOnOTG(path) -> if (isAndroidDataDir(path)) baseConfig.otgAndroidDataTreeUri else baseConfig.otgAndroidObbTreeUri - isPathOnSD(path) -> if (isAndroidDataDir(path)) baseConfig.sdAndroidDataTreeUri else baseConfig.sdAndroidObbTreeUri - else -> if (isAndroidDataDir(path)) baseConfig.primaryAndroidDataTreeUri else baseConfig.primaryAndroidObbTreeUri + isPathOnOTG(path) -> if (isAndroidDataDir(path)) this.baseConfig.otgAndroidDataTreeUri else this.baseConfig.otgAndroidObbTreeUri + isPathOnSD(path) -> if (isAndroidDataDir(path)) this.baseConfig.sdAndroidDataTreeUri else this.baseConfig.sdAndroidObbTreeUri + else -> if (isAndroidDataDir(path)) this.baseConfig.primaryAndroidDataTreeUri else this.baseConfig.primaryAndroidObbTreeUri } } @@ -205,9 +205,9 @@ fun isAndroidDataDir(path: String): Boolean { fun Context.storeAndroidTreeUri(path: String, treeUri: String) { return when { - isPathOnOTG(path) -> if (isAndroidDataDir(path)) baseConfig.otgAndroidDataTreeUri = treeUri else baseConfig.otgAndroidObbTreeUri = treeUri - isPathOnSD(path) -> if (isAndroidDataDir(path)) baseConfig.sdAndroidDataTreeUri = treeUri else baseConfig.sdAndroidObbTreeUri = treeUri - else -> if (isAndroidDataDir(path)) baseConfig.primaryAndroidDataTreeUri = treeUri else baseConfig.primaryAndroidObbTreeUri = treeUri + isPathOnOTG(path) -> if (isAndroidDataDir(path)) this.baseConfig.otgAndroidDataTreeUri = treeUri else this.baseConfig.otgAndroidObbTreeUri = treeUri + isPathOnSD(path) -> if (isAndroidDataDir(path)) this.baseConfig.sdAndroidDataTreeUri = treeUri else this.baseConfig.sdAndroidObbTreeUri = treeUri + else -> if (isAndroidDataDir(path)) this.baseConfig.primaryAndroidDataTreeUri = treeUri else this.baseConfig.primaryAndroidObbTreeUri = treeUri } } @@ -282,29 +282,29 @@ fun Context.getFastDocumentFile(path: String): DocumentFile? { return getOTGFastDocumentFile(path) } - if (baseConfig.sdCardPath.isEmpty()) { + if (this.baseConfig.sdCardPath.isEmpty()) { return null } - val relativePath = Uri.encode(path.substring(baseConfig.sdCardPath.length).trim('/')) - val externalPathPart = baseConfig.sdCardPath.split("/").lastOrNull(String::isNotEmpty)?.trim('/') ?: return null - val fullUri = "${baseConfig.sdTreeUri}/document/$externalPathPart%3A$relativePath" + val relativePath = Uri.encode(path.substring(this.baseConfig.sdCardPath.length).trim('/')) + val externalPathPart = this.baseConfig.sdCardPath.split("/").lastOrNull(String::isNotEmpty)?.trim('/') ?: return null + val fullUri = "${this.baseConfig.sdTreeUri}/document/$externalPathPart%3A$relativePath" return DocumentFile.fromSingleUri(this, Uri.parse(fullUri)) } fun Context.getOTGFastDocumentFile(path: String, otgPathToUse: String? = null): DocumentFile? { - if (baseConfig.OTGTreeUri.isEmpty()) { + if (this.baseConfig.OTGTreeUri.isEmpty()) { return null } - val otgPath = otgPathToUse ?: baseConfig.OTGPath - if (baseConfig.OTGPartition.isEmpty()) { - baseConfig.OTGPartition = baseConfig.OTGTreeUri.removeSuffix("%3A").substringAfterLast('/').trimEnd('/') + val otgPath = otgPathToUse ?: this.baseConfig.OTGPath + if (this.baseConfig.OTGPartition.isEmpty()) { + this.baseConfig.OTGPartition = this.baseConfig.OTGTreeUri.removeSuffix("%3A").substringAfterLast('/').trimEnd('/') updateOTGPathFromPartition() } val relativePath = Uri.encode(path.substring(otgPath.length).trim('/')) - val fullUri = "${baseConfig.OTGTreeUri}/document/${baseConfig.OTGPartition}%3A$relativePath" + val fullUri = "${this.baseConfig.OTGTreeUri}/document/${this.baseConfig.OTGPartition}%3A$relativePath" return DocumentFile.fromSingleUri(this, Uri.parse(fullUri)) } @@ -316,7 +316,7 @@ fun Context.getDocumentFile(path: String): DocumentFile? { } return try { - val treeUri = Uri.parse(if (isOTG) baseConfig.OTGTreeUri else baseConfig.sdTreeUri) + val treeUri = Uri.parse(if (isOTG) this.baseConfig.OTGTreeUri else this.baseConfig.sdTreeUri) var document = DocumentFile.fromTreeUri(applicationContext, treeUri) val parts = relativePath.split("/").filter { it.isNotEmpty() } for (part in parts) { @@ -469,14 +469,14 @@ fun Context.updateLastModified(path: String, lastModified: Long) { fun Context.getOTGItems(path: String, shouldShowHidden: Boolean, getProperFileSize: Boolean, callback: (ArrayList) -> Unit) { val items = ArrayList() - val OTGTreeUri = baseConfig.OTGTreeUri + val OTGTreeUri = this.baseConfig.OTGTreeUri var rootUri = try { DocumentFile.fromTreeUri(applicationContext, Uri.parse(OTGTreeUri)) } catch (e: Exception) { showErrorToast(e) - baseConfig.OTGPath = "" - baseConfig.OTGTreeUri = "" - baseConfig.OTGPartition = "" + this.baseConfig.OTGPath = "" + this.baseConfig.OTGTreeUri = "" + this.baseConfig.OTGPartition = "" null } @@ -503,7 +503,7 @@ fun Context.getOTGItems(path: String, shouldShowHidden: Boolean, getProperFileSi val files = rootUri!!.listFiles().filter { it.exists() } - val basePath = "${baseConfig.OTGTreeUri}/document/${baseConfig.OTGPartition}%3A" + val basePath = "${this.baseConfig.OTGTreeUri}/document/${this.baseConfig.OTGPartition}%3A" for (file in files) { val name = file.name ?: continue if (!shouldShowHidden && name.startsWith(".")) { @@ -822,8 +822,8 @@ fun Context.trySAFFileDelete(fileDirItem: FileDirItem, allowDeleteFolder: Boolea try { fileDeleted = (document.isFile || allowDeleteFolder) && DocumentsContract.deleteDocument(applicationContext.contentResolver, document.uri) } catch (ignored: Exception) { - baseConfig.sdTreeUri = "" - baseConfig.sdCardPath = "" + this.baseConfig.sdTreeUri = "" + this.baseConfig.sdCardPath = "" } } } @@ -857,16 +857,16 @@ fun Context.getFileInputStreamSync(path: String): InputStream? { } fun Context.updateOTGPathFromPartition() { - val otgPath = "/storage/${baseConfig.OTGPartition}" - baseConfig.OTGPath = if (getOTGFastDocumentFile(otgPath, otgPath)?.exists() == true) { - "/storage/${baseConfig.OTGPartition}" + val otgPath = "/storage/${this.baseConfig.OTGPartition}" + this.baseConfig.OTGPath = if (getOTGFastDocumentFile(otgPath, otgPath)?.exists() == true) { + "/storage/${this.baseConfig.OTGPartition}" } else { - "/mnt/media_rw/${baseConfig.OTGPartition}" + "/mnt/media_rw/${this.baseConfig.OTGPartition}" } } fun Context.getDoesFilePathExist(path: String, otgPathToUse: String? = null): Boolean { - val otgPath = otgPathToUse ?: baseConfig.OTGPath + val otgPath = otgPathToUse ?: this.baseConfig.OTGPath return when { isRestrictedSAFOnlyRoot(path) -> getFastAndroidSAFDocument(path)?.exists() ?: false otgPath.isNotEmpty() && path.startsWith(otgPath) -> getOTGFastDocumentFile(path)?.exists() ?: false diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-styling.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-styling.kt index 2478fcb05..93d429ab4 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-styling.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context-styling.kt @@ -14,32 +14,32 @@ import com.simplemobiletools.commons.models.SharedTheme import com.simplemobiletools.commons.views.* // handle system default theme (Material You) specially as the color is taken from the system, not hardcoded by us -fun Context.getProperTextColor() = if (baseConfig.isUsingSystemTheme) { +fun Context.getProperTextColor() = if (this.baseConfig.isUsingSystemTheme) { resources.getColor(R.color.you_neutral_text_color, theme) } else { - baseConfig.textColor + this.baseConfig.textColor } -fun Context.getProperBackgroundColor() = if (baseConfig.isUsingSystemTheme) { +fun Context.getProperBackgroundColor() = if (this.baseConfig.isUsingSystemTheme) { resources.getColor(R.color.you_background_color, theme) } else { - baseConfig.backgroundColor + this.baseConfig.backgroundColor } fun Context.getProperPrimaryColor() = when { - baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_primary_color, theme) - isWhiteTheme() || isBlackAndWhiteTheme() -> baseConfig.accentColor - else -> baseConfig.primaryColor + this.baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_primary_color, theme) + isWhiteTheme() || isBlackAndWhiteTheme() -> this.baseConfig.accentColor + else -> this.baseConfig.primaryColor } fun Context.getProperStatusBarColor() = when { - baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_status_bar_color, theme) + this.baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_status_bar_color, theme) else -> getProperBackgroundColor() } // get the color of the statusbar with material activity, if the layout is scrolled down a bit fun Context.getColoredMaterialStatusBarColor(): Int { - return if (baseConfig.isUsingSystemTheme) { + return if (this.baseConfig.isUsingSystemTheme) { resources.getColor(R.color.you_status_bar_color, theme) } else { getProperPrimaryColor() @@ -48,13 +48,13 @@ fun Context.getColoredMaterialStatusBarColor(): Int { fun Context.updateTextColors(viewGroup: ViewGroup) { val textColor = when { - baseConfig.isUsingSystemTheme -> getProperTextColor() - else -> baseConfig.textColor + this.baseConfig.isUsingSystemTheme -> getProperTextColor() + else -> this.baseConfig.textColor } - val backgroundColor = baseConfig.backgroundColor + val backgroundColor = this.baseConfig.backgroundColor val accentColor = when { - isWhiteTheme() || isBlackAndWhiteTheme() -> baseConfig.accentColor + isWhiteTheme() || isBlackAndWhiteTheme() -> this.baseConfig.accentColor else -> getProperPrimaryColor() } @@ -76,30 +76,30 @@ fun Context.updateTextColors(viewGroup: ViewGroup) { } } -fun Context.isBlackAndWhiteTheme() = baseConfig.textColor == Color.WHITE && baseConfig.primaryColor == Color.BLACK && baseConfig.backgroundColor == Color.BLACK +fun Context.isBlackAndWhiteTheme() = this.baseConfig.textColor == Color.WHITE && this.baseConfig.primaryColor == Color.BLACK && this.baseConfig.backgroundColor == Color.BLACK -fun Context.isWhiteTheme() = baseConfig.textColor == DARK_GREY && baseConfig.primaryColor == Color.WHITE && baseConfig.backgroundColor == Color.WHITE +fun Context.isWhiteTheme() = this.baseConfig.textColor == DARK_GREY && this.baseConfig.primaryColor == Color.WHITE && this.baseConfig.backgroundColor == Color.WHITE fun Context.isUsingSystemDarkTheme() = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_YES != 0 fun Context.getTimePickerDialogTheme() = when { - baseConfig.isUsingSystemTheme -> if (isUsingSystemDarkTheme()) { + this.baseConfig.isUsingSystemTheme -> if (isUsingSystemDarkTheme()) { R.style.MyTimePickerMaterialTheme_Dark } else { R.style.MyDateTimePickerMaterialTheme } - baseConfig.backgroundColor.getContrastColor() == Color.WHITE -> R.style.MyDialogTheme_Dark + this.baseConfig.backgroundColor.getContrastColor() == Color.WHITE -> R.style.MyDialogTheme_Dark else -> R.style.MyDialogTheme } fun Context.getDatePickerDialogTheme() = when { - baseConfig.isUsingSystemTheme -> R.style.MyDateTimePickerMaterialTheme - baseConfig.backgroundColor.getContrastColor() == Color.WHITE -> R.style.MyDialogTheme_Dark + this.baseConfig.isUsingSystemTheme -> R.style.MyDateTimePickerMaterialTheme + this.baseConfig.backgroundColor.getContrastColor() == Color.WHITE -> R.style.MyDialogTheme_Dark else -> R.style.MyDialogTheme } fun Context.getPopupMenuTheme(): Int { - return if (isSPlus() && baseConfig.isUsingSystemTheme) { + return if (isSPlus() && this.baseConfig.isUsingSystemTheme) { R.style.AppTheme_YouPopupMenuStyle } else if (isWhiteTheme()) { R.style.AppTheme_PopupMenuLightStyle @@ -139,14 +139,14 @@ fun Context.getSharedThemeSync(cursorLoader: CursorLoader): SharedTheme? { } fun Context.checkAppIconColor() { - val appId = baseConfig.appId - if (appId.isNotEmpty() && baseConfig.lastIconColor != baseConfig.appIconColor) { + val appId = this.baseConfig.appId + if (appId.isNotEmpty() && this.baseConfig.lastIconColor != this.baseConfig.appIconColor) { getAppIconColors().forEachIndexed { index, color -> toggleAppIconColor(appId, index, color, false) } getAppIconColors().forEachIndexed { index, color -> - if (baseConfig.appIconColor == color) { + if (this.baseConfig.appIconColor == color) { toggleAppIconColor(appId, index, color, true) } } @@ -159,7 +159,7 @@ fun Context.toggleAppIconColor(appId: String, colorIndex: Int, color: Int, enabl try { packageManager.setComponentEnabledSetting(ComponentName(appId, className), state, PackageManager.DONT_KILL_APP) if (enable) { - baseConfig.lastIconColor = color + this.baseConfig.lastIconColor = color } } catch (e: Exception) { } @@ -169,11 +169,11 @@ fun Context.getAppIconColors() = resources.getIntArray(R.array.md_app_icon_color @SuppressLint("NewApi") fun Context.getBottomNavigationBackgroundColor(): Int { - val baseColor = baseConfig.backgroundColor + val baseColor = this.baseConfig.backgroundColor val bottomColor = when { - baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_status_bar_color, theme) + this.baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_status_bar_color, theme) baseColor == Color.WHITE -> resources.getColor(R.color.bottom_tabs_light_background) - else -> baseConfig.backgroundColor.lightenColor(4) + else -> this.baseConfig.backgroundColor.lightenColor(4) } return bottomColor } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt index d708ead69..b3ac60d14 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt @@ -95,9 +95,9 @@ fun Context.showErrorToast(exception: Exception, length: Int = Toast.LENGTH_LONG } val Context.baseConfig: BaseConfig get() = BaseConfig.newInstance(this) -val Context.sdCardPath: String get() = baseConfig.sdCardPath -val Context.internalStoragePath: String get() = baseConfig.internalStoragePath -val Context.otgPath: String get() = baseConfig.OTGPath +val Context.sdCardPath: String get() = this.baseConfig.sdCardPath +val Context.internalStoragePath: String get() = this.baseConfig.internalStoragePath +val Context.otgPath: String get() = this.baseConfig.OTGPath fun Context.isFingerPrintSensorAvailable() = Reprint.isHardwarePresent() @@ -428,10 +428,10 @@ fun Context.getCurrentFormattedDateTime(): String { fun Context.updateSDCardPath() { ensureBackgroundThread { - val oldPath = baseConfig.sdCardPath - baseConfig.sdCardPath = getSDCardPath() - if (oldPath != baseConfig.sdCardPath) { - baseConfig.sdTreeUri = "" + val oldPath = this.baseConfig.sdCardPath + this.baseConfig.sdCardPath = getSDCardPath() + if (oldPath != this.baseConfig.sdCardPath) { + this.baseConfig.sdTreeUri = "" } } } @@ -449,9 +449,9 @@ fun Context.isThankYouInstalled() = isPackageInstalled("com.simplemobiletools.th fun Context.isOrWasThankYouInstalled(): Boolean { return when { resources.getBoolean(R.bool.pretend_thank_you_installed) -> true - baseConfig.hadThankYouInstalled -> true + this.baseConfig.hadThankYouInstalled -> true isThankYouInstalled() -> { - baseConfig.hadThankYouInstalled = true + this.baseConfig.hadThankYouInstalled = true true } else -> false @@ -492,7 +492,7 @@ fun Context.getSelectedDaysString(bitMask: Int): String { val dayBits = arrayListOf(MONDAY_BIT, TUESDAY_BIT, WEDNESDAY_BIT, THURSDAY_BIT, FRIDAY_BIT, SATURDAY_BIT, SUNDAY_BIT) val weekDays = resources.getStringArray(R.array.week_days_short).toList() as ArrayList - if (baseConfig.isSundayFirst) { + if (this.baseConfig.isSundayFirst) { dayBits.moveLastItemToFront() weekDays.moveLastItemToFront() } @@ -611,7 +611,7 @@ fun Context.storeNewYourAlarmSound(resultData: Intent): AlarmSound { } val token = object : TypeToken>() {}.type - val yourAlarmSounds = Gson().fromJson>(baseConfig.yourAlarmSounds, token) + val yourAlarmSounds = Gson().fromJson>(this.baseConfig.yourAlarmSounds, token) ?: ArrayList() val newAlarmSoundId = (yourAlarmSounds.maxByOrNull { it.id }?.id ?: YOUR_ALARM_SOUNDS_MIN_ID) + 1 val newAlarmSound = AlarmSound(newAlarmSoundId, filename, uri.toString()) @@ -619,7 +619,7 @@ fun Context.storeNewYourAlarmSound(resultData: Intent): AlarmSound { yourAlarmSounds.add(newAlarmSound) } - baseConfig.yourAlarmSounds = Gson().toJson(yourAlarmSounds) + this.baseConfig.yourAlarmSounds = Gson().toJson(yourAlarmSounds) val takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION contentResolver.takePersistableUriPermission(uri, takeFlags) @@ -651,15 +651,15 @@ fun Context.saveExifRotation(exif: ExifInterface, degrees: Int) { exif.saveAttributes() } -fun Context.getLaunchIntent() = packageManager.getLaunchIntentForPackage(baseConfig.appId) +fun Context.getLaunchIntent() = packageManager.getLaunchIntentForPackage(this.baseConfig.appId) -fun Context.getCanAppBeUpgraded() = proPackages.contains(baseConfig.appId.removeSuffix(".debug").removePrefix("com.simplemobiletools.")) +fun Context.getCanAppBeUpgraded() = proPackages.contains(this.baseConfig.appId.removeSuffix(".debug").removePrefix("com.simplemobiletools.")) -fun Context.getProUrl() = "https://play.google.com/store/apps/details?id=${baseConfig.appId.removeSuffix(".debug")}.pro" +fun Context.getProUrl() = "https://play.google.com/store/apps/details?id=${this.baseConfig.appId.removeSuffix(".debug")}.pro" fun Context.getStoreUrl() = "https://play.google.com/store/apps/details?id=${packageName.removeSuffix(".debug")}" -fun Context.getTimeFormat() = if (baseConfig.use24HourFormat) TIME_FORMAT_24 else TIME_FORMAT_12 +fun Context.getTimeFormat() = if (this.baseConfig.use24HourFormat) TIME_FORMAT_24 else TIME_FORMAT_12 fun Context.getResolution(path: String): Point? { return if (path.isImageFast() || path.isImageSlow()) { @@ -856,7 +856,7 @@ fun Context.getMediaStoreLastModified(path: String): Long { fun Context.getStringsPackageName() = getString(R.string.package_name) fun Context.getFontSizeText() = getString( - when (baseConfig.fontSize) { + when (this.baseConfig.fontSize) { FONT_SIZE_SMALL -> R.string.small FONT_SIZE_MEDIUM -> R.string.medium FONT_SIZE_LARGE -> R.string.large @@ -864,7 +864,7 @@ fun Context.getFontSizeText() = getString( } ) -fun Context.getTextSize() = when (baseConfig.fontSize) { +fun Context.getTextSize() = when (this.baseConfig.fontSize) { FONT_SIZE_SMALL -> resources.getDimension(R.dimen.smaller_text_size) FONT_SIZE_MEDIUM -> resources.getDimension(R.dimen.bigger_text_size) FONT_SIZE_LARGE -> resources.getDimension(R.dimen.big_text_size) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt index 40efc9d61..8bff441b1 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt @@ -478,4 +478,72 @@ open class BaseConfig(val context: Context) { return LinkedList(prefs.getString(COLOR_PICKER_RECENT_COLORS, null)?.lines()?.map { it.toInt() } ?: defaultList) } set(recentColors) = prefs.edit().putString(COLOR_PICKER_RECENT_COLORS, recentColors.joinToString(separator = "\n")).apply() + + var ignoredContactSources: HashSet + get() = prefs.getStringSet(IGNORED_CONTACT_SOURCES, hashSetOf(".")) as HashSet + set(ignoreContactSources) = prefs.edit().remove(IGNORED_CONTACT_SOURCES).putStringSet(IGNORED_CONTACT_SOURCES, ignoreContactSources).apply() + + var showContactThumbnails: Boolean + get() = prefs.getBoolean(SHOW_CONTACT_THUMBNAILS, true) + set(showContactThumbnails) = prefs.edit().putBoolean(SHOW_CONTACT_THUMBNAILS, showContactThumbnails).apply() + + var showPhoneNumbers: Boolean + get() = prefs.getBoolean(SHOW_PHONE_NUMBERS, false) + set(showPhoneNumbers) = prefs.edit().putBoolean(SHOW_PHONE_NUMBERS, showPhoneNumbers).apply() + + var showOnlyContactsWithNumbers: Boolean + get() = prefs.getBoolean(SHOW_ONLY_CONTACTS_WITH_NUMBERS, false) + set(showOnlyContactsWithNumbers) = prefs.edit().putBoolean(SHOW_ONLY_CONTACTS_WITH_NUMBERS, showOnlyContactsWithNumbers).apply() + + var lastUsedContactSource: String + get() = prefs.getString(LAST_USED_CONTACT_SOURCE, "")!! + set(lastUsedContactSource) = prefs.edit().putString(LAST_USED_CONTACT_SOURCE, lastUsedContactSource).apply() + + var onContactClick: Int + get() = prefs.getInt(ON_CONTACT_CLICK, ON_CLICK_VIEW_CONTACT) + set(onContactClick) = prefs.edit().putInt(ON_CONTACT_CLICK, onContactClick).apply() + + var showContactFields: Int + get() = prefs.getInt( + SHOW_CONTACT_FIELDS, + SHOW_FIRST_NAME_FIELD or SHOW_SURNAME_FIELD or SHOW_PHONE_NUMBERS_FIELD or SHOW_EMAILS_FIELD or + SHOW_ADDRESSES_FIELD or SHOW_EVENTS_FIELD or SHOW_NOTES_FIELD or SHOW_GROUPS_FIELD or SHOW_CONTACT_SOURCE_FIELD + ) + set(showContactFields) = prefs.edit().putInt(SHOW_CONTACT_FIELDS, showContactFields).apply() + + var showTabs: Int + get() = prefs.getInt(SHOW_TABS, ALL_TABS_MASK) + set(showTabs) = prefs.edit().putInt(SHOW_TABS, showTabs).apply() + + var showDialpadButton: Boolean + get() = prefs.getBoolean(SHOW_DIALPAD_BUTTON, true) + set(showDialpadButton) = prefs.edit().putBoolean(SHOW_DIALPAD_BUTTON, showDialpadButton).apply() + + var wasLocalAccountInitialized: Boolean + get() = prefs.getBoolean(WAS_LOCAL_ACCOUNT_INITIALIZED, false) + set(wasLocalAccountInitialized) = prefs.edit().putBoolean(WAS_LOCAL_ACCOUNT_INITIALIZED, wasLocalAccountInitialized).apply() + + var lastExportPath: String + get() = prefs.getString(LAST_EXPORT_PATH, "")!! + set(lastExportPath) = prefs.edit().putString(LAST_EXPORT_PATH, lastExportPath).apply() + + var speedDial: String + get() = prefs.getString(SPEED_DIAL, "")!! + set(speedDial) = prefs.edit().putString(SPEED_DIAL, speedDial).apply() + + var showPrivateContacts: Boolean + get() = prefs.getBoolean(SHOW_PRIVATE_CONTACTS, true) + set(showPrivateContacts) = prefs.edit().putBoolean(SHOW_PRIVATE_CONTACTS, showPrivateContacts).apply() + + var mergeDuplicateContacts: Boolean + get() = prefs.getBoolean(MERGE_DUPLICATE_CONTACTS, true) + set(mergeDuplicateContacts) = prefs.edit().putBoolean(MERGE_DUPLICATE_CONTACTS, mergeDuplicateContacts).apply() + + var favoritesContactsOrder: String + get() = prefs.getString(FAVORITES_CONTACTS_ORDER, "")!! + set(order) = prefs.edit().putString(FAVORITES_CONTACTS_ORDER, order).apply() + + var isCustomOrderSelected: Boolean + get() = prefs.getBoolean(FAVORITES_CUSTOM_ORDER_SELECTED, false) + set(selected) = prefs.edit().putBoolean(FAVORITES_CUSTOM_ORDER_SELECTED, selected).apply() } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt index f3aa129ad..54c816dc3 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt @@ -167,6 +167,22 @@ const val START_NAME_WITH_SURNAME = "start_name_with_surname" const val FAVORITES = "favorites" const val SHOW_CALL_CONFIRMATION = "show_call_confirmation" const val COLOR_PICKER_RECENT_COLORS = "color_picker_recent_colors" +const val SHOW_CONTACT_THUMBNAILS = "show_contact_thumbnails" +const val SHOW_PHONE_NUMBERS = "show_phone_numbers" +const val SHOW_ONLY_CONTACTS_WITH_NUMBERS = "show_only_contacts_with_numbers" +const val IGNORED_CONTACT_SOURCES = "ignored_contact_sources_2" +const val LAST_USED_CONTACT_SOURCE = "last_used_contact_source" +const val ON_CONTACT_CLICK = "on_contact_click" +const val SHOW_CONTACT_FIELDS = "show_contact_fields" +const val SHOW_TABS = "show_tabs" +const val SHOW_DIALPAD_BUTTON = "show_dialpad_button" +const val SPEED_DIAL = "speed_dial" +const val LAST_EXPORT_PATH = "last_export_path" +const val WAS_LOCAL_ACCOUNT_INITIALIZED = "was_local_account_initialized" +const val SHOW_PRIVATE_CONTACTS = "show_private_contacts" +const val MERGE_DUPLICATE_CONTACTS = "merge_duplicate_contacts" +const val FAVORITES_CONTACTS_ORDER = "favorites_contacts_order" +const val FAVORITES_CUSTOM_ORDER_SELECTED = "favorites_custom_order_selected" // phone number/email types const val CELL = "CELL" @@ -534,29 +550,9 @@ fun getFilePlaceholderDrawables(context: Context): HashMap { return fileDrawables } -// contacts -// shared prefs -const val SHOW_CONTACT_THUMBNAILS = "show_contact_thumbnails" -const val SHOW_PHONE_NUMBERS = "show_phone_numbers" -const val SHOW_ONLY_CONTACTS_WITH_NUMBERS = "show_only_contacts_with_numbers" -const val IGNORED_CONTACT_SOURCES = "ignored_contact_sources_2" -const val LAST_USED_CONTACT_SOURCE = "last_used_contact_source" -const val ON_CONTACT_CLICK = "on_contact_click" -const val SHOW_CONTACT_FIELDS = "show_contact_fields" -const val SHOW_TABS = "show_tabs" -const val SHOW_DIALPAD_BUTTON = "show_dialpad_button" -const val SPEED_DIAL = "speed_dial" -const val LAST_EXPORT_PATH = "last_export_path" -const val WAS_LOCAL_ACCOUNT_INITIALIZED = "was_local_account_initialized" -const val SHOW_PRIVATE_CONTACTS = "show_private_contacts" -const val MERGE_DUPLICATE_CONTACTS = "merge_duplicate_contacts" -const val FAVORITES_CONTACTS_ORDER = "favorites_contacts_order" -const val FAVORITES_CUSTOM_ORDER_SELECTED = "favorites_custom_order_selected" - const val FIRST_CONTACT_ID = 1000000 const val DEFAULT_FILE_NAME = "contacts.vcf" - // visible fields filtering const val SHOW_PREFIX_FIELD = 1 const val SHOW_FIRST_NAME_FIELD = 2 diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/ContactsConfig.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/ContactsConfig.kt deleted file mode 100644 index 803794170..000000000 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/ContactsConfig.kt +++ /dev/null @@ -1,77 +0,0 @@ -package com.simplemobiletools.commons.helpers - -import android.content.Context - -class ContactsConfig(context: Context) : BaseConfig(context) { - companion object { - fun newInstance(context: Context) = ContactsConfig(context) - } - - var ignoredContactSources: HashSet - get() = prefs.getStringSet(IGNORED_CONTACT_SOURCES, hashSetOf(".")) as HashSet - set(ignoreContactSources) = prefs.edit().remove(IGNORED_CONTACT_SOURCES).putStringSet(IGNORED_CONTACT_SOURCES, ignoreContactSources).apply() - - var showContactThumbnails: Boolean - get() = prefs.getBoolean(SHOW_CONTACT_THUMBNAILS, true) - set(showContactThumbnails) = prefs.edit().putBoolean(SHOW_CONTACT_THUMBNAILS, showContactThumbnails).apply() - - var showPhoneNumbers: Boolean - get() = prefs.getBoolean(SHOW_PHONE_NUMBERS, false) - set(showPhoneNumbers) = prefs.edit().putBoolean(SHOW_PHONE_NUMBERS, showPhoneNumbers).apply() - - var showOnlyContactsWithNumbers: Boolean - get() = prefs.getBoolean(SHOW_ONLY_CONTACTS_WITH_NUMBERS, false) - set(showOnlyContactsWithNumbers) = prefs.edit().putBoolean(SHOW_ONLY_CONTACTS_WITH_NUMBERS, showOnlyContactsWithNumbers).apply() - - var lastUsedContactSource: String - get() = prefs.getString(LAST_USED_CONTACT_SOURCE, "")!! - set(lastUsedContactSource) = prefs.edit().putString(LAST_USED_CONTACT_SOURCE, lastUsedContactSource).apply() - - var onContactClick: Int - get() = prefs.getInt(ON_CONTACT_CLICK, ON_CLICK_VIEW_CONTACT) - set(onContactClick) = prefs.edit().putInt(ON_CONTACT_CLICK, onContactClick).apply() - - var showContactFields: Int - get() = prefs.getInt( - SHOW_CONTACT_FIELDS, - SHOW_FIRST_NAME_FIELD or SHOW_SURNAME_FIELD or SHOW_PHONE_NUMBERS_FIELD or SHOW_EMAILS_FIELD or - SHOW_ADDRESSES_FIELD or SHOW_EVENTS_FIELD or SHOW_NOTES_FIELD or SHOW_GROUPS_FIELD or SHOW_CONTACT_SOURCE_FIELD - ) - set(showContactFields) = prefs.edit().putInt(SHOW_CONTACT_FIELDS, showContactFields).apply() - - var showTabs: Int - get() = prefs.getInt(SHOW_TABS, ALL_TABS_MASK) - set(showTabs) = prefs.edit().putInt(SHOW_TABS, showTabs).apply() - - var showDialpadButton: Boolean - get() = prefs.getBoolean(SHOW_DIALPAD_BUTTON, true) - set(showDialpadButton) = prefs.edit().putBoolean(SHOW_DIALPAD_BUTTON, showDialpadButton).apply() - - var wasLocalAccountInitialized: Boolean - get() = prefs.getBoolean(WAS_LOCAL_ACCOUNT_INITIALIZED, false) - set(wasLocalAccountInitialized) = prefs.edit().putBoolean(WAS_LOCAL_ACCOUNT_INITIALIZED, wasLocalAccountInitialized).apply() - - var lastExportPath: String - get() = prefs.getString(LAST_EXPORT_PATH, "")!! - set(lastExportPath) = prefs.edit().putString(LAST_EXPORT_PATH, lastExportPath).apply() - - var speedDial: String - get() = prefs.getString(SPEED_DIAL, "")!! - set(speedDial) = prefs.edit().putString(SPEED_DIAL, speedDial).apply() - - var showPrivateContacts: Boolean - get() = prefs.getBoolean(SHOW_PRIVATE_CONTACTS, true) - set(showPrivateContacts) = prefs.edit().putBoolean(SHOW_PRIVATE_CONTACTS, showPrivateContacts).apply() - - var mergeDuplicateContacts: Boolean - get() = prefs.getBoolean(MERGE_DUPLICATE_CONTACTS, true) - set(mergeDuplicateContacts) = prefs.edit().putBoolean(MERGE_DUPLICATE_CONTACTS, mergeDuplicateContacts).apply() - - var favoritesContactsOrder: String - get() = prefs.getString(FAVORITES_CONTACTS_ORDER, "")!! - set(order) = prefs.edit().putString(FAVORITES_CONTACTS_ORDER, order).apply() - - var isCustomOrderSelected: Boolean - get() = prefs.getBoolean(FAVORITES_CUSTOM_ORDER_SELECTED, false) - set(selected) = prefs.edit().putBoolean(FAVORITES_CUSTOM_ORDER_SELECTED, selected).apply() -} diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/ContactsHelper.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/ContactsHelper.kt index 3f426d9c9..ac274d882 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/ContactsHelper.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/ContactsHelper.kt @@ -51,7 +51,7 @@ class ContactsHelper(val context: Context) { } val contactsSize = contacts.size() - val showOnlyContactsWithNumbers = context.contactsConfig.showOnlyContactsWithNumbers + val showOnlyContactsWithNumbers = context.baseConfig.showOnlyContactsWithNumbers val tempContacts = ArrayList(contactsSize) val resultContacts = ArrayList(contactsSize) @@ -65,7 +65,7 @@ class ContactsHelper(val context: Context) { contacts.valueAt(it) } - if (context.contactsConfig.mergeDuplicateContacts && ignoredContactSources.isEmpty() && !getAll) { + if (context.baseConfig.mergeDuplicateContacts && ignoredContactSources.isEmpty() && !getAll) { tempContacts.filter { displayContactSources.contains(it.source) }.groupBy { it.getNameToDisplay().toLowerCase() }.values.forEach { it -> if (it.size == 1) { resultContacts.add(it.first()) @@ -86,8 +86,8 @@ class ContactsHelper(val context: Context) { resultContacts.firstOrNull { it.contactId == key }?.groups = groups.valueAt(i) } - Contact.sorting = context.contactsConfig.sorting - Contact.startWithSurname = context.contactsConfig.startNameWithSurname + Contact.sorting = context.baseConfig.sorting + Contact.startWithSurname = context.baseConfig.startNameWithSurname resultContacts.sort() Handler(Looper.getMainLooper()).post { @@ -129,7 +129,7 @@ class ContactsHelper(val context: Context) { return } - val ignoredSources = ignoredContactSources ?: context.contactsConfig.ignoredContactSources + val ignoredSources = ignoredContactSources ?: context.baseConfig.ignoredContactSources val uri = Data.CONTENT_URI val projection = getContactProjection() @@ -792,9 +792,9 @@ class ContactsHelper(val context: Context) { return sources } - if (!context.contactsConfig.wasLocalAccountInitialized) { + if (!context.baseConfig.wasLocalAccountInitialized) { initializeLocalPhoneAccount() - context.contactsConfig.wasLocalAccountInitialized = true + context.baseConfig.wasLocalAccountInitialized = true } val accounts = AccountManager.get(context).accounts @@ -867,7 +867,7 @@ class ContactsHelper(val context: Context) { ) private fun getSortString(): String { - val sorting = context.contactsConfig.sorting + val sorting = context.baseConfig.sorting return when { sorting and SORT_BY_FIRST_NAME != 0 -> "${CommonDataKinds.StructuredName.GIVEN_NAME} COLLATE NOCASE" sorting and SORT_BY_MIDDLE_NAME != 0 -> "${CommonDataKinds.StructuredName.MIDDLE_NAME} COLLATE NOCASE" diff --git a/commons/src/main/res/values-ar/strings.xml b/commons/src/main/res/values-ar/strings.xml index 63a7e6225..fdc50624b 100644 --- a/commons/src/main/res/values-ar/strings.xml +++ b/commons/src/main/res/values-ar/strings.xml @@ -48,6 +48,7 @@ التطبيق ليس لديه إذن لبدء المكالمات الهاتفية، يرجى منحه في إعدادات الجهاز إدراج النص هنا اتصال بـ%s + تأكيد الاتصال بـ %s Zero One اثنان @@ -1229,4 +1230,4 @@ لا تنسى أنه إذا قمت بإلغاء تثبيت أي تطبيق مدفوع في غضون ساعتين ، فسيتم إسترداد أموالك تلقائياً. إذا كنت تريد إسترداد الأموال في أي وقت لاحق ، فأتصل بنا على hello@simplemobiletools.com وستحصل عليه. هذا يجعل من السهل تجربته :) مجموعة بسيطة، من تطبيقات أندرويد المفتوحة المصدر ذات الودجات القابلة للتخصيص، بدون إعلانات أو أذونات غير ضرورية. - \ No newline at end of file +