fix: removed reference to this
when using baseConfig
This commit is contained in:
parent
b5fcc8cab0
commit
6e9dae49d5
12 changed files with 203 additions and 203 deletions
|
@ -95,7 +95,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
|
||||
super.onCreate(savedInstanceState)
|
||||
if (!packageName.startsWith("com.simplemobiletools.", true)) {
|
||||
if ((0..50).random() == 10 || this.baseConfig.appRunCount % 100 == 0) {
|
||||
if ((0..50).random() == 10 || 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 (this.baseConfig.isUsingSystemTheme) {
|
||||
val backgroundColor = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_background_color, theme)
|
||||
} else {
|
||||
this.baseConfig.backgroundColor
|
||||
baseConfig.backgroundColor
|
||||
}
|
||||
|
||||
updateBackgroundColor(backgroundColor)
|
||||
|
@ -122,7 +122,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
if (showTransparentTop) {
|
||||
window.statusBarColor = Color.TRANSPARENT
|
||||
} else if (!isMaterialActivity) {
|
||||
val color = if (this.baseConfig.isUsingSystemTheme) {
|
||||
val color = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_status_bar_color)
|
||||
} else {
|
||||
getProperStatusBarColor()
|
||||
|
@ -171,7 +171,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun updateBackgroundColor(color: Int = this.baseConfig.backgroundColor) {
|
||||
fun updateBackgroundColor(color: Int = baseConfig.backgroundColor) {
|
||||
window.decorView.setBackgroundColor(color)
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
fun updateRecentsAppIcon() {
|
||||
if (this.baseConfig.isUsingModifiedAppIcon) {
|
||||
if (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 = this.baseConfig.primaryColor
|
||||
val color = 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 = this.baseConfig.appIconColor
|
||||
val appIconColor = 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 == this.baseConfig.OTGTreeUri || resultData.dataString == this.baseConfig.sdTreeUri) {
|
||||
if (resultData.dataString == baseConfig.OTGTreeUri || resultData.dataString == 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 == this.baseConfig.OTGTreeUri) {
|
||||
if (resultData.dataString == 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 == this.baseConfig.sdTreeUri) {
|
||||
if (resultData.dataString == baseConfig.sdTreeUri) {
|
||||
funAfterSAFPermission?.invoke(false)
|
||||
toast(R.string.sd_card_usb_same)
|
||||
return
|
||||
}
|
||||
this.baseConfig.OTGTreeUri = resultData.dataString!!
|
||||
this.baseConfig.OTGPartition = this.baseConfig.OTGTreeUri.removeSuffix("%3A").substringAfterLast('/').trimEnd('/')
|
||||
baseConfig.OTGTreeUri = resultData.dataString!!
|
||||
baseConfig.OTGPartition = 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
|
||||
this.baseConfig.sdTreeUri = treeUri.toString()
|
||||
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 (this.baseConfig.appRunCount > 100) {
|
||||
if (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 (this.baseConfig.OTGTreeUri.isNotEmpty()) {
|
||||
if (baseConfig.OTGTreeUri.isNotEmpty()) {
|
||||
callback(true)
|
||||
return
|
||||
}
|
||||
|
@ -921,7 +921,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
if (!newFile.exists() && File(oldFileDirItem.path).renameTo(newFile)) {
|
||||
if (!this.baseConfig.keepLastModified) {
|
||||
if (!baseConfig.keepLastModified) {
|
||||
newFile.setLastModified(System.currentTimeMillis())
|
||||
}
|
||||
updatedPaths.add(newFile.absolutePath)
|
||||
|
@ -1080,8 +1080,8 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
fun checkAppOnSDCard() {
|
||||
if (!this.baseConfig.wasAppOnSDShown && isAppInstalledOnSDCard()) {
|
||||
this.baseConfig.wasAppOnSDShown = true
|
||||
if (!baseConfig.wasAppOnSDShown && isAppInstalledOnSDCard()) {
|
||||
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 = this.baseConfig.appId.removeSuffix(".debug").removeSuffix(".pro").removePrefix("com.simplemobiletools.")
|
||||
val appName = baseConfig.appId.removeSuffix(".debug").removeSuffix(".pro").removePrefix("com.simplemobiletools.")
|
||||
return "$appName-settings_${getCurrentFormattedDateTime()}"
|
||||
}
|
||||
|
||||
|
|
|
@ -13,16 +13,16 @@ abstract class BaseSplashActivity : AppCompatActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (this.baseConfig.appSideloadingStatus == SIDELOADING_UNCHECKED) {
|
||||
if (baseConfig.appSideloadingStatus == SIDELOADING_UNCHECKED) {
|
||||
if (checkAppSideloading()) {
|
||||
return
|
||||
}
|
||||
} else if (this.baseConfig.appSideloadingStatus == SIDELOADING_TRUE) {
|
||||
} else if (baseConfig.appSideloadingStatus == SIDELOADING_TRUE) {
|
||||
showSideloadingDialog()
|
||||
return
|
||||
}
|
||||
|
||||
this.baseConfig.apply {
|
||||
baseConfig.apply {
|
||||
if (isUsingAutoTheme) {
|
||||
val isUsingSystemDarkTheme = isUsingSystemDarkTheme()
|
||||
isUsingSharedTheme = false
|
||||
|
@ -31,10 +31,10 @@ abstract class BaseSplashActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!this.baseConfig.isUsingAutoTheme && !this.baseConfig.isUsingSystemTheme && isThankYouInstalled()) {
|
||||
if (!baseConfig.isUsingAutoTheme && !baseConfig.isUsingSystemTheme && isThankYouInstalled()) {
|
||||
getSharedTheme {
|
||||
if (it != null) {
|
||||
this.baseConfig.apply {
|
||||
baseConfig.apply {
|
||||
wasSharedThemeForced = true
|
||||
isUsingSharedTheme = true
|
||||
wasSharedThemeEverActivated = true
|
||||
|
@ -45,8 +45,8 @@ abstract class BaseSplashActivity : AppCompatActivity() {
|
|||
accentColor = it.accentColor
|
||||
}
|
||||
|
||||
if (this.baseConfig.appIconColor != it.appIconColor) {
|
||||
this.baseConfig.appIconColor = it.appIconColor
|
||||
if (baseConfig.appIconColor != it.appIconColor) {
|
||||
baseConfig.appIconColor = it.appIconColor
|
||||
checkAppIconColor()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
try {
|
||||
storedSharedTheme = getSharedThemeSync(cursorLoader)
|
||||
if (storedSharedTheme == null) {
|
||||
this.baseConfig.isUsingSharedTheme = false
|
||||
baseConfig.isUsingSharedTheme = false
|
||||
} else {
|
||||
this.baseConfig.wasSharedThemeEverActivated = true
|
||||
baseConfig.wasSharedThemeEverActivated = true
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
|
@ -83,17 +83,17 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
} else {
|
||||
setupThemes()
|
||||
this.baseConfig.isUsingSharedTheme = false
|
||||
baseConfig.isUsingSharedTheme = false
|
||||
}
|
||||
|
||||
val textColor = if (this.baseConfig.isUsingSystemTheme) {
|
||||
val textColor = if (baseConfig.isUsingSystemTheme) {
|
||||
getProperTextColor()
|
||||
} else {
|
||||
this.baseConfig.textColor
|
||||
baseConfig.textColor
|
||||
}
|
||||
|
||||
updateLabelColors(textColor)
|
||||
originalAppIconColor = this.baseConfig.appIconColor
|
||||
originalAppIconColor = 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 (!this.baseConfig.isUsingSystemTheme) {
|
||||
if (!baseConfig.isUsingSystemTheme) {
|
||||
updateBackgroundColor(getCurrentBackgroundColor())
|
||||
updateActionbarColor(getCurrentStatusBarColor())
|
||||
}
|
||||
|
@ -199,11 +199,11 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
updateAutoThemeFields()
|
||||
handleAccentColorLayout()
|
||||
customization_theme_holder.setOnClickListener {
|
||||
if (this.baseConfig.wasAppIconCustomizationWarningShown) {
|
||||
if (baseConfig.wasAppIconCustomizationWarningShown) {
|
||||
themePickerClicked()
|
||||
} else {
|
||||
ConfirmationDialog(this, "", R.string.app_icon_color_warning, R.string.ok, 0) {
|
||||
this.baseConfig.wasAppIconCustomizationWarningShown = true
|
||||
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 && !this.baseConfig.wasCustomThemeSwitchDescriptionShown) {
|
||||
this.baseConfig.wasCustomThemeSwitchDescriptionShown = true
|
||||
if (it != THEME_CUSTOM && it != THEME_SHARED && it != THEME_AUTO && it != THEME_SYSTEM && !baseConfig.wasCustomThemeSwitchDescriptionShown) {
|
||||
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 = this@CustomizationActivity.baseConfig.customTextColor
|
||||
curBackgroundColor = this@CustomizationActivity.baseConfig.customBackgroundColor
|
||||
curPrimaryColor = this@CustomizationActivity.baseConfig.customPrimaryColor
|
||||
curAccentColor = this@CustomizationActivity.baseConfig.customAccentColor
|
||||
curAppIconColor = this@CustomizationActivity.baseConfig.customAppIconColor
|
||||
curTextColor = baseConfig.customTextColor
|
||||
curBackgroundColor = baseConfig.customBackgroundColor
|
||||
curPrimaryColor = baseConfig.customPrimaryColor
|
||||
curAccentColor = baseConfig.customAccentColor
|
||||
curAppIconColor = baseConfig.customAppIconColor
|
||||
setTheme(getThemeId(curPrimaryColor))
|
||||
updateMenuItemColors(customization_toolbar.menu, curPrimaryColor)
|
||||
setupToolbar(customization_toolbar, NavigationIcon.Cross, curPrimaryColor)
|
||||
setupColorsPickers()
|
||||
} else {
|
||||
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
|
||||
baseConfig.customPrimaryColor = curPrimaryColor
|
||||
baseConfig.customAccentColor = curAccentColor
|
||||
baseConfig.customBackgroundColor = curBackgroundColor
|
||||
baseConfig.customTextColor = curTextColor
|
||||
baseConfig.customAppIconColor = curAppIconColor
|
||||
}
|
||||
} else if (curSelectedThemeId == THEME_SHARED) {
|
||||
if (useStored) {
|
||||
|
@ -326,11 +326,11 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
|
||||
private fun getCurrentThemeId(): Int {
|
||||
if (this.baseConfig.isUsingSharedTheme) {
|
||||
if (baseConfig.isUsingSharedTheme) {
|
||||
return THEME_SHARED
|
||||
} else if ((this.baseConfig.isUsingSystemTheme && !hasUnsavedChanges) || curSelectedThemeId == THEME_SYSTEM) {
|
||||
} else if ((baseConfig.isUsingSystemTheme && !hasUnsavedChanges) || curSelectedThemeId == THEME_SYSTEM) {
|
||||
return THEME_SYSTEM
|
||||
} else if (this.baseConfig.isUsingAutoTheme || curSelectedThemeId == THEME_AUTO) {
|
||||
} else if (baseConfig.isUsingAutoTheme || curSelectedThemeId == THEME_AUTO) {
|
||||
return THEME_AUTO
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
|
||||
private fun saveChanges(finishAfterSave: Boolean) {
|
||||
val didAppIconColorChange = curAppIconColor != originalAppIconColor
|
||||
this.baseConfig.apply {
|
||||
baseConfig.apply {
|
||||
textColor = curTextColor
|
||||
backgroundColor = curBackgroundColor
|
||||
primaryColor = curPrimaryColor
|
||||
|
@ -403,10 +403,10 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
this.baseConfig.isUsingSharedTheme = curSelectedThemeId == THEME_SHARED
|
||||
this.baseConfig.shouldUseSharedTheme = curSelectedThemeId == THEME_SHARED
|
||||
this.baseConfig.isUsingAutoTheme = curSelectedThemeId == THEME_AUTO
|
||||
this.baseConfig.isUsingSystemTheme = curSelectedThemeId == THEME_SYSTEM
|
||||
baseConfig.isUsingSharedTheme = curSelectedThemeId == THEME_SHARED
|
||||
baseConfig.shouldUseSharedTheme = curSelectedThemeId == THEME_SHARED
|
||||
baseConfig.isUsingAutoTheme = curSelectedThemeId == THEME_AUTO
|
||||
baseConfig.isUsingSystemTheme = curSelectedThemeId == THEME_SYSTEM
|
||||
|
||||
hasUnsavedChanges = false
|
||||
if (finishAfterSave) {
|
||||
|
@ -427,11 +427,11 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
|
||||
private fun initColorVariables() {
|
||||
curTextColor = this.baseConfig.textColor
|
||||
curBackgroundColor = this.baseConfig.backgroundColor
|
||||
curPrimaryColor = this.baseConfig.primaryColor
|
||||
curAccentColor = this.baseConfig.accentColor
|
||||
curAppIconColor = this.baseConfig.appIconColor
|
||||
curTextColor = baseConfig.textColor
|
||||
curBackgroundColor = baseConfig.backgroundColor
|
||||
curPrimaryColor = baseConfig.primaryColor
|
||||
curAccentColor = baseConfig.accentColor
|
||||
curAppIconColor = baseConfig.appIconColor
|
||||
}
|
||||
|
||||
private fun setupColorsPickers() {
|
||||
|
@ -456,11 +456,11 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
|
||||
customization_app_icon_color_holder.setOnClickListener {
|
||||
if (this.baseConfig.wasAppIconCustomizationWarningShown) {
|
||||
if (baseConfig.wasAppIconCustomizationWarningShown) {
|
||||
pickAppIconColor()
|
||||
} else {
|
||||
ConfirmationDialog(this, "", R.string.app_icon_color_warning, R.string.ok, 0) {
|
||||
this.baseConfig.wasAppIconCustomizationWarningShown = true
|
||||
baseConfig.wasAppIconCustomizationWarningShown = true
|
||||
pickAppIconColor()
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
|
||||
private fun updateApplyToAllColors(newColor: Int) {
|
||||
if (newColor == this.baseConfig.primaryColor && !this.baseConfig.isUsingSystemTheme) {
|
||||
if (newColor == baseConfig.primaryColor && !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) && this.baseConfig.appRunCount > 50) {
|
||||
if (!packageName.startsWith("com.simplemobiletools.", true) && baseConfig.appRunCount > 50) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
predefinedThemes[THEME_SHARED] = MyTheme(getString(R.string.shared), 0, 0, 0, 0)
|
||||
}
|
||||
|
||||
this.baseConfig.wasSharedThemeEverActivated = true
|
||||
baseConfig.wasSharedThemeEverActivated = true
|
||||
apply_to_all_holder.beGone()
|
||||
updateColorTheme(THEME_SHARED)
|
||||
saveChanges(false)
|
||||
|
|
|
@ -40,11 +40,11 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi
|
|||
updateTextColors(manage_blocked_numbers_wrapper)
|
||||
updatePlaceholderTexts()
|
||||
|
||||
val blockTitleRes = if (this.baseConfig.appId.startsWith("com.simplemobiletools.dialer")) R.string.block_unknown_calls else R.string.block_unknown_messages
|
||||
val blockTitleRes = if (baseConfig.appId.startsWith("com.simplemobiletools.dialer")) R.string.block_unknown_calls else R.string.block_unknown_messages
|
||||
|
||||
block_unknown.apply {
|
||||
setText(blockTitleRes)
|
||||
isChecked = this@ManageBlockedNumbersActivity.baseConfig.blockUnknownNumbers
|
||||
isChecked = baseConfig.blockUnknownNumbers
|
||||
if (isChecked) {
|
||||
maybeSetDefaultCallerIdApp()
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi
|
|||
|
||||
block_unknown_holder.setOnClickListener {
|
||||
block_unknown.toggle()
|
||||
this.baseConfig.blockUnknownNumbers = block_unknown.isChecked
|
||||
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)
|
||||
this.baseConfig.blockUnknownNumbers = false
|
||||
baseConfig.blockUnknownNumbers = false
|
||||
block_unknown.isChecked = false
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi
|
|||
|
||||
private fun tryExportBlockedNumbers() {
|
||||
if (isQPlus()) {
|
||||
ExportBlockedNumbersDialog(this, this.baseConfig.lastBlockedNumbersExportPath, true) { file ->
|
||||
ExportBlockedNumbersDialog(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, this.baseConfig.lastBlockedNumbersExportPath, false) { file ->
|
||||
ExportBlockedNumbersDialog(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() && this.baseConfig.appId.startsWith("com.simplemobiletools.dialer")) {
|
||||
if (isQPlus() && baseConfig.appId.startsWith("com.simplemobiletools.dialer")) {
|
||||
setDefaultCallerIdApp()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ fun BaseSimpleActivity.copySingleFileSdk30(source: FileDirItem, destination: Fil
|
|||
out?.flush()
|
||||
|
||||
return if (source.size == copiedSize && getDoesFilePathExist(destination.path)) {
|
||||
if (this.baseConfig.keepLastModified) {
|
||||
if (baseConfig.keepLastModified) {
|
||||
copyOldLastModified(source.path, destination.path)
|
||||
val lastModified = File(source.path).lastModified()
|
||||
if (lastModified != 0L) {
|
||||
|
|
|
@ -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 = this.baseConfig.primaryColor, showTransparentTop: Boolean = false) = when {
|
||||
this.baseConfig.isUsingSystemTheme -> if (isUsingSystemDarkTheme()) R.style.AppTheme_Base_System else R.style.AppTheme_Base_System_Light
|
||||
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
|
||||
isBlackAndWhiteTheme() -> when {
|
||||
showTransparentTop -> R.style.AppTheme_BlackAndWhite_NoActionBar
|
||||
this.baseConfig.primaryColor.getContrastColor() == DARK_GREY -> R.style.AppTheme_BlackAndWhite_DarkTextColor
|
||||
baseConfig.primaryColor.getContrastColor() == DARK_GREY -> R.style.AppTheme_BlackAndWhite_DarkTextColor
|
||||
else -> R.style.AppTheme_BlackAndWhite
|
||||
}
|
||||
isWhiteTheme() -> when {
|
||||
showTransparentTop -> R.style.AppTheme_White_NoActionBar
|
||||
this.baseConfig.primaryColor.getContrastColor() == Color.WHITE -> R.style.AppTheme_White_LightTextColor
|
||||
baseConfig.primaryColor.getContrastColor() == Color.WHITE -> R.style.AppTheme_White_LightTextColor
|
||||
else -> R.style.AppTheme_White
|
||||
}
|
||||
showTransparentTop -> {
|
||||
|
|
|
@ -48,47 +48,47 @@ import java.io.*
|
|||
import java.util.*
|
||||
|
||||
fun Activity.appLaunched(appId: String) {
|
||||
this.baseConfig.internalStoragePath = getInternalStoragePath()
|
||||
baseConfig.internalStoragePath = getInternalStoragePath()
|
||||
updateSDCardPath()
|
||||
this.baseConfig.appId = appId
|
||||
if (this.baseConfig.appRunCount == 0) {
|
||||
this.baseConfig.wasOrangeIconChecked = true
|
||||
baseConfig.appId = appId
|
||||
if (baseConfig.appRunCount == 0) {
|
||||
baseConfig.wasOrangeIconChecked = true
|
||||
checkAppIconColor()
|
||||
} else if (!this.baseConfig.wasOrangeIconChecked) {
|
||||
this.baseConfig.wasOrangeIconChecked = true
|
||||
} else if (!baseConfig.wasOrangeIconChecked) {
|
||||
baseConfig.wasOrangeIconChecked = true
|
||||
val primaryColor = resources.getColor(R.color.color_primary)
|
||||
if (this.baseConfig.appIconColor != primaryColor) {
|
||||
if (baseConfig.appIconColor != primaryColor) {
|
||||
getAppIconColors().forEachIndexed { index, color ->
|
||||
toggleAppIconColor(appId, index, color, false)
|
||||
}
|
||||
|
||||
val defaultClassName = "${this.baseConfig.appId.removeSuffix(".debug")}.activities.SplashActivity"
|
||||
val defaultClassName = "${baseConfig.appId.removeSuffix(".debug")}.activities.SplashActivity"
|
||||
packageManager.setComponentEnabledSetting(
|
||||
ComponentName(this.baseConfig.appId, defaultClassName),
|
||||
ComponentName(baseConfig.appId, defaultClassName),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
|
||||
PackageManager.DONT_KILL_APP
|
||||
)
|
||||
|
||||
val orangeClassName = "${this.baseConfig.appId.removeSuffix(".debug")}.activities.SplashActivity.Orange"
|
||||
val orangeClassName = "${baseConfig.appId.removeSuffix(".debug")}.activities.SplashActivity.Orange"
|
||||
packageManager.setComponentEnabledSetting(
|
||||
ComponentName(this.baseConfig.appId, orangeClassName),
|
||||
ComponentName(baseConfig.appId, orangeClassName),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||
PackageManager.DONT_KILL_APP
|
||||
)
|
||||
|
||||
this.baseConfig.appIconColor = primaryColor
|
||||
this.baseConfig.lastIconColor = primaryColor
|
||||
baseConfig.appIconColor = primaryColor
|
||||
baseConfig.lastIconColor = primaryColor
|
||||
}
|
||||
}
|
||||
|
||||
this.baseConfig.appRunCount++
|
||||
if (this.baseConfig.appRunCount % 30 == 0 && !isAProApp()) {
|
||||
baseConfig.appRunCount++
|
||||
if (baseConfig.appRunCount % 30 == 0 && !isAProApp()) {
|
||||
if (!resources.getBoolean(R.bool.hide_google_relations)) {
|
||||
showDonateOrUpgradeDialog()
|
||||
}
|
||||
}
|
||||
|
||||
if (this.baseConfig.appRunCount % 40 == 0 && !this.baseConfig.wasAppRated) {
|
||||
if (baseConfig.appRunCount % 40 == 0 && !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() && (this.baseConfig.sdTreeUri.isEmpty() || !hasProperStoredTreeUri(false)))) {
|
||||
return if ((!isRPlus() && isPathOnSD(path) && !isSDCardSetAsDefaultStorage() && (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) && (this.baseConfig.OTGTreeUri.isEmpty() || !hasProperStoredTreeUri(true))) {
|
||||
return if (!isRPlus() && isPathOnOTG(path) && (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=${this.baseConfig.appId.removeSuffix(".debug")}.pro")
|
||||
launchViewIntent("market://details?id=${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<Release>, currVersion: Int) {
|
||||
if (this.baseConfig.lastVersion == 0) {
|
||||
this.baseConfig.lastVersion = currVersion
|
||||
if (baseConfig.lastVersion == 0) {
|
||||
baseConfig.lastVersion = currVersion
|
||||
return
|
||||
}
|
||||
|
||||
val newReleases = arrayListOf<Release>()
|
||||
releases.filterTo(newReleases) { it.id > this.baseConfig.lastVersion }
|
||||
releases.filterTo(newReleases) { it.id > baseConfig.lastVersion }
|
||||
|
||||
if (newReleases.isNotEmpty()) {
|
||||
WhatsNewDialog(this, newReleases)
|
||||
}
|
||||
|
||||
this.baseConfig.lastVersion = currVersion
|
||||
baseConfig.lastVersion = currVersion
|
||||
}
|
||||
|
||||
fun BaseSimpleActivity.deleteFolders(folders: List<FileDirItem>, deleteMediaOnly: Boolean = true, callback: ((wasSuccess: Boolean) -> Unit)? = null) {
|
||||
|
@ -626,7 +626,7 @@ fun BaseSimpleActivity.deleteFoldersBg(folders: List<FileDirItem>, deleteMediaOn
|
|||
var wasSuccess = false
|
||||
var needPermissionForPath = ""
|
||||
for (folder in folders) {
|
||||
if (needsStupidWritePermissions(folder.path) && this.baseConfig.sdTreeUri.isEmpty()) {
|
||||
if (needsStupidWritePermissions(folder.path) && baseConfig.sdTreeUri.isEmpty()) {
|
||||
needPermissionForPath = folder.path
|
||||
break
|
||||
}
|
||||
|
@ -978,7 +978,7 @@ fun BaseSimpleActivity.renameFile(
|
|||
|
||||
updateInMediaStore(oldPath, newPath)
|
||||
rescanPaths(arrayListOf(oldPath, newPath)) {
|
||||
if (!this.baseConfig.keepLastModified) {
|
||||
if (!baseConfig.keepLastModified) {
|
||||
updateLastModified(newPath, System.currentTimeMillis())
|
||||
}
|
||||
deleteFromMediaStore(oldPath)
|
||||
|
@ -1058,7 +1058,7 @@ private fun BaseSimpleActivity.renameCasually(
|
|||
scanPathRecursively(newPath)
|
||||
}
|
||||
} else {
|
||||
if (!this.baseConfig.keepLastModified) {
|
||||
if (!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 (!this.baseConfig.keepLastModified) {
|
||||
if (!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 (!this.baseConfig.keepLastModified) {
|
||||
if (!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)
|
||||
this.baseConfig.sdTreeUri = ""
|
||||
baseConfig.sdTreeUri = ""
|
||||
showErrorToast(error)
|
||||
}
|
||||
|
||||
|
@ -1411,8 +1411,8 @@ fun Activity.showBiometricPrompt(
|
|||
}
|
||||
|
||||
fun Activity.handleHiddenFolderPasswordProtection(callback: () -> Unit) {
|
||||
if (this.baseConfig.isHiddenPasswordProtectionOn) {
|
||||
SecurityDialog(this, this.baseConfig.hiddenPasswordHash, this.baseConfig.hiddenProtectionType) { _, _, success ->
|
||||
if (baseConfig.isHiddenPasswordProtectionOn) {
|
||||
SecurityDialog(this, baseConfig.hiddenPasswordHash, baseConfig.hiddenProtectionType) { _, _, success ->
|
||||
if (success) {
|
||||
callback()
|
||||
}
|
||||
|
@ -1423,8 +1423,8 @@ fun Activity.handleHiddenFolderPasswordProtection(callback: () -> Unit) {
|
|||
}
|
||||
|
||||
fun Activity.handleAppPasswordProtection(callback: (success: Boolean) -> Unit) {
|
||||
if (this.baseConfig.isAppPasswordProtectionOn) {
|
||||
SecurityDialog(this, this.baseConfig.appPasswordHash, this.baseConfig.appProtectionType) { _, _, success ->
|
||||
if (baseConfig.isAppPasswordProtectionOn) {
|
||||
SecurityDialog(this, baseConfig.appPasswordHash, baseConfig.appProtectionType) { _, _, success ->
|
||||
callback(success)
|
||||
}
|
||||
} else {
|
||||
|
@ -1433,8 +1433,8 @@ fun Activity.handleAppPasswordProtection(callback: (success: Boolean) -> Unit) {
|
|||
}
|
||||
|
||||
fun Activity.handleDeletePasswordProtection(callback: () -> Unit) {
|
||||
if (this.baseConfig.isDeletePasswordProtectionOn) {
|
||||
SecurityDialog(this, this.baseConfig.deletePasswordHash, this.baseConfig.deleteProtectionType) { _, _, success ->
|
||||
if (baseConfig.isDeletePasswordProtectionOn) {
|
||||
SecurityDialog(this, baseConfig.deletePasswordHash, 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 (this.baseConfig.isFolderProtected(path)) {
|
||||
SecurityDialog(this, this.baseConfig.getFolderProtectionHash(path), this.baseConfig.getFolderProtectionType(path)) { _, _, success ->
|
||||
if (baseConfig.isFolderProtected(path)) {
|
||||
SecurityDialog(this, baseConfig.getFolderProtectionHash(path), 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 == this.baseConfig.backgroundColor) {
|
||||
val dialogButtonColor = if (primaryColor == baseConfig.backgroundColor) {
|
||||
textColor
|
||||
} else {
|
||||
primaryColor
|
||||
|
@ -1559,8 +1559,8 @@ fun Activity.setupDialogStuff(
|
|||
|
||||
val bgDrawable = when {
|
||||
isBlackAndWhiteTheme() -> resources.getDrawable(R.drawable.black_dialog_background, theme)
|
||||
this@setupDialogStuff.baseConfig.isUsingSystemTheme -> resources.getDrawable(R.drawable.dialog_you_background, theme)
|
||||
else -> resources.getColoredDrawableWithColor(R.drawable.dialog_bg, this@setupDialogStuff.baseConfig.backgroundColor)
|
||||
baseConfig.isUsingSystemTheme -> resources.getDrawable(R.drawable.dialog_you_background, theme)
|
||||
else -> resources.getColoredDrawableWithColor(R.drawable.dialog_bg, baseConfig.backgroundColor)
|
||||
}
|
||||
|
||||
window?.setBackgroundDrawable(bgDrawable)
|
||||
|
@ -1569,7 +1569,7 @@ fun Activity.setupDialogStuff(
|
|||
}
|
||||
}
|
||||
|
||||
fun Activity.getAlertDialogBuilder() = if (this.baseConfig.isUsingSystemTheme) {
|
||||
fun Activity.getAlertDialogBuilder() = if (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, this.baseConfig.use24HourFormat
|
||||
curSeconds / 3600, curSeconds % 3600, baseConfig.use24HourFormat
|
||||
).show()
|
||||
}
|
||||
else -> {
|
||||
|
@ -1682,13 +1682,13 @@ fun BaseSimpleActivity.getAlarmSounds(type: Int, callback: (ArrayList<AlarmSound
|
|||
}
|
||||
|
||||
fun Activity.checkAppSideloading(): Boolean {
|
||||
val isSideloaded = when (this.baseConfig.appSideloadingStatus) {
|
||||
val isSideloaded = when (baseConfig.appSideloadingStatus) {
|
||||
SIDELOADING_TRUE -> true
|
||||
SIDELOADING_FALSE -> false
|
||||
else -> isAppSideloaded()
|
||||
}
|
||||
|
||||
this.baseConfig.appSideloadingStatus = if (isSideloaded) SIDELOADING_TRUE else SIDELOADING_FALSE
|
||||
baseConfig.appSideloadingStatus = if (isSideloaded) SIDELOADING_TRUE else SIDELOADING_FALSE
|
||||
if (isSideloaded) {
|
||||
showSideloadingDialog()
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.simplemobiletools.commons.helpers.isNougatPlus
|
|||
import java.util.*
|
||||
|
||||
fun Application.checkUseEnglish() {
|
||||
if (this.baseConfig.useEnglish && !isNougatPlus()) {
|
||||
if (baseConfig.useEnglish && !isNougatPlus()) {
|
||||
val conf = resources.configuration
|
||||
conf.locale = Locale.ENGLISH
|
||||
resources.updateConfiguration(conf, resources.displayMetrics)
|
||||
|
|
|
@ -23,7 +23,7 @@ val Context.contactsDB: ContactsDao get() = ContactsDatabase.getInstance(applica
|
|||
val Context.groupsDB: GroupsDao get() = ContactsDatabase.getInstance(applicationContext).GroupsDao()
|
||||
|
||||
fun Context.getEmptyContact(): Contact {
|
||||
val originalContactSource = if (hasContactPermissions()) this.baseConfig.lastUsedContactSource else SMT_PRIVATE
|
||||
val originalContactSource = if (hasContactPermissions()) baseConfig.lastUsedContactSource else SMT_PRIVATE
|
||||
val organization = Organization("", "")
|
||||
return Contact(
|
||||
0, "", "", "", "", "", "", "", ArrayList(), ArrayList(), ArrayList(), ArrayList(), originalContactSource, 0, 0, "",
|
||||
|
@ -258,7 +258,7 @@ fun Context.getContactPublicUri(contact: Contact): Uri {
|
|||
|
||||
fun Context.getVisibleContactSources(): ArrayList<String> {
|
||||
val sources = getAllContactSources()
|
||||
val ignoredContactSources = this.baseConfig.ignoredContactSources
|
||||
val ignoredContactSources = baseConfig.ignoredContactSources
|
||||
return ArrayList(sources).filter { !ignoredContactSources.contains(it.getFullIdentifier()) }
|
||||
.map { it.name }.toMutableList() as ArrayList<String>
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ fun Context.getSDCardPath(): String {
|
|||
!it.equals(getInternalStoragePath()) && !it.equals(
|
||||
"/storage/emulated/0",
|
||||
true
|
||||
) && (this.baseConfig.OTGPartition.isEmpty() || !it.endsWith(this.baseConfig.OTGPartition))
|
||||
) && (baseConfig.OTGPartition.isEmpty() || !it.endsWith(baseConfig.OTGPartition))
|
||||
}
|
||||
|
||||
val fullSDpattern = Pattern.compile(SD_OTG_PATTERN)
|
||||
|
@ -71,7 +71,7 @@ fun Context.getSDCardPath(): String {
|
|||
}
|
||||
|
||||
val finalPath = sdCardPath.trimEnd('/')
|
||||
this.baseConfig.sdCardPath = finalPath
|
||||
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) this.baseConfig.OTGTreeUri else this.baseConfig.sdTreeUri
|
||||
val uri = if (isOTG) baseConfig.OTGTreeUri else baseConfig.sdTreeUri
|
||||
val hasProperUri = contentResolver.persistedUriPermissions.any { it.uri.toString() == uri }
|
||||
if (!hasProperUri) {
|
||||
if (isOTG) {
|
||||
this.baseConfig.OTGTreeUri = ""
|
||||
baseConfig.OTGTreeUri = ""
|
||||
} else {
|
||||
this.baseConfig.sdTreeUri = ""
|
||||
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)) 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
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,9 +205,9 @@ fun isAndroidDataDir(path: String): Boolean {
|
|||
|
||||
fun Context.storeAndroidTreeUri(path: String, treeUri: String) {
|
||||
return when {
|
||||
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
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -282,29 +282,29 @@ fun Context.getFastDocumentFile(path: String): DocumentFile? {
|
|||
return getOTGFastDocumentFile(path)
|
||||
}
|
||||
|
||||
if (this.baseConfig.sdCardPath.isEmpty()) {
|
||||
if (baseConfig.sdCardPath.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
|
||||
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"
|
||||
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"
|
||||
return DocumentFile.fromSingleUri(this, Uri.parse(fullUri))
|
||||
}
|
||||
|
||||
fun Context.getOTGFastDocumentFile(path: String, otgPathToUse: String? = null): DocumentFile? {
|
||||
if (this.baseConfig.OTGTreeUri.isEmpty()) {
|
||||
if (baseConfig.OTGTreeUri.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val otgPath = otgPathToUse ?: this.baseConfig.OTGPath
|
||||
if (this.baseConfig.OTGPartition.isEmpty()) {
|
||||
this.baseConfig.OTGPartition = this.baseConfig.OTGTreeUri.removeSuffix("%3A").substringAfterLast('/').trimEnd('/')
|
||||
val otgPath = otgPathToUse ?: baseConfig.OTGPath
|
||||
if (baseConfig.OTGPartition.isEmpty()) {
|
||||
baseConfig.OTGPartition = baseConfig.OTGTreeUri.removeSuffix("%3A").substringAfterLast('/').trimEnd('/')
|
||||
updateOTGPathFromPartition()
|
||||
}
|
||||
|
||||
val relativePath = Uri.encode(path.substring(otgPath.length).trim('/'))
|
||||
val fullUri = "${this.baseConfig.OTGTreeUri}/document/${this.baseConfig.OTGPartition}%3A$relativePath"
|
||||
val fullUri = "${baseConfig.OTGTreeUri}/document/${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) this.baseConfig.OTGTreeUri else this.baseConfig.sdTreeUri)
|
||||
val treeUri = Uri.parse(if (isOTG) baseConfig.OTGTreeUri else 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<FileDirItem>) -> Unit) {
|
||||
val items = ArrayList<FileDirItem>()
|
||||
val OTGTreeUri = this.baseConfig.OTGTreeUri
|
||||
val OTGTreeUri = baseConfig.OTGTreeUri
|
||||
var rootUri = try {
|
||||
DocumentFile.fromTreeUri(applicationContext, Uri.parse(OTGTreeUri))
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
this.baseConfig.OTGPath = ""
|
||||
this.baseConfig.OTGTreeUri = ""
|
||||
this.baseConfig.OTGPartition = ""
|
||||
baseConfig.OTGPath = ""
|
||||
baseConfig.OTGTreeUri = ""
|
||||
baseConfig.OTGPartition = ""
|
||||
null
|
||||
}
|
||||
|
||||
|
@ -503,7 +503,7 @@ fun Context.getOTGItems(path: String, shouldShowHidden: Boolean, getProperFileSi
|
|||
|
||||
val files = rootUri!!.listFiles().filter { it.exists() }
|
||||
|
||||
val basePath = "${this.baseConfig.OTGTreeUri}/document/${this.baseConfig.OTGPartition}%3A"
|
||||
val basePath = "${baseConfig.OTGTreeUri}/document/${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) {
|
||||
this.baseConfig.sdTreeUri = ""
|
||||
this.baseConfig.sdCardPath = ""
|
||||
baseConfig.sdTreeUri = ""
|
||||
baseConfig.sdCardPath = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -857,16 +857,16 @@ fun Context.getFileInputStreamSync(path: String): InputStream? {
|
|||
}
|
||||
|
||||
fun Context.updateOTGPathFromPartition() {
|
||||
val otgPath = "/storage/${this.baseConfig.OTGPartition}"
|
||||
this.baseConfig.OTGPath = if (getOTGFastDocumentFile(otgPath, otgPath)?.exists() == true) {
|
||||
"/storage/${this.baseConfig.OTGPartition}"
|
||||
val otgPath = "/storage/${baseConfig.OTGPartition}"
|
||||
baseConfig.OTGPath = if (getOTGFastDocumentFile(otgPath, otgPath)?.exists() == true) {
|
||||
"/storage/${baseConfig.OTGPartition}"
|
||||
} else {
|
||||
"/mnt/media_rw/${this.baseConfig.OTGPartition}"
|
||||
"/mnt/media_rw/${baseConfig.OTGPartition}"
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getDoesFilePathExist(path: String, otgPathToUse: String? = null): Boolean {
|
||||
val otgPath = otgPathToUse ?: this.baseConfig.OTGPath
|
||||
val otgPath = otgPathToUse ?: baseConfig.OTGPath
|
||||
return when {
|
||||
isRestrictedSAFOnlyRoot(path) -> getFastAndroidSAFDocument(path)?.exists() ?: false
|
||||
otgPath.isNotEmpty() && path.startsWith(otgPath) -> getOTGFastDocumentFile(path)?.exists() ?: false
|
||||
|
|
|
@ -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 (this.baseConfig.isUsingSystemTheme) {
|
||||
fun Context.getProperTextColor() = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_neutral_text_color, theme)
|
||||
} else {
|
||||
this.baseConfig.textColor
|
||||
baseConfig.textColor
|
||||
}
|
||||
|
||||
fun Context.getProperBackgroundColor() = if (this.baseConfig.isUsingSystemTheme) {
|
||||
fun Context.getProperBackgroundColor() = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_background_color, theme)
|
||||
} else {
|
||||
this.baseConfig.backgroundColor
|
||||
baseConfig.backgroundColor
|
||||
}
|
||||
|
||||
fun Context.getProperPrimaryColor() = when {
|
||||
this.baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_primary_color, theme)
|
||||
isWhiteTheme() || isBlackAndWhiteTheme() -> this.baseConfig.accentColor
|
||||
else -> this.baseConfig.primaryColor
|
||||
baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_primary_color, theme)
|
||||
isWhiteTheme() || isBlackAndWhiteTheme() -> baseConfig.accentColor
|
||||
else -> baseConfig.primaryColor
|
||||
}
|
||||
|
||||
fun Context.getProperStatusBarColor() = when {
|
||||
this.baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_status_bar_color, theme)
|
||||
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 (this.baseConfig.isUsingSystemTheme) {
|
||||
return if (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 {
|
||||
this.baseConfig.isUsingSystemTheme -> getProperTextColor()
|
||||
else -> this.baseConfig.textColor
|
||||
baseConfig.isUsingSystemTheme -> getProperTextColor()
|
||||
else -> baseConfig.textColor
|
||||
}
|
||||
|
||||
val backgroundColor = this.baseConfig.backgroundColor
|
||||
val backgroundColor = baseConfig.backgroundColor
|
||||
val accentColor = when {
|
||||
isWhiteTheme() || isBlackAndWhiteTheme() -> this.baseConfig.accentColor
|
||||
isWhiteTheme() || isBlackAndWhiteTheme() -> baseConfig.accentColor
|
||||
else -> getProperPrimaryColor()
|
||||
}
|
||||
|
||||
|
@ -76,30 +76,30 @@ fun Context.updateTextColors(viewGroup: ViewGroup) {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.isBlackAndWhiteTheme() = this.baseConfig.textColor == Color.WHITE && this.baseConfig.primaryColor == Color.BLACK && this.baseConfig.backgroundColor == Color.BLACK
|
||||
fun Context.isBlackAndWhiteTheme() = baseConfig.textColor == Color.WHITE && baseConfig.primaryColor == Color.BLACK && baseConfig.backgroundColor == Color.BLACK
|
||||
|
||||
fun Context.isWhiteTheme() = this.baseConfig.textColor == DARK_GREY && this.baseConfig.primaryColor == Color.WHITE && this.baseConfig.backgroundColor == Color.WHITE
|
||||
fun Context.isWhiteTheme() = baseConfig.textColor == DARK_GREY && baseConfig.primaryColor == Color.WHITE && baseConfig.backgroundColor == Color.WHITE
|
||||
|
||||
fun Context.isUsingSystemDarkTheme() = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_YES != 0
|
||||
|
||||
fun Context.getTimePickerDialogTheme() = when {
|
||||
this.baseConfig.isUsingSystemTheme -> if (isUsingSystemDarkTheme()) {
|
||||
baseConfig.isUsingSystemTheme -> if (isUsingSystemDarkTheme()) {
|
||||
R.style.MyTimePickerMaterialTheme_Dark
|
||||
} else {
|
||||
R.style.MyDateTimePickerMaterialTheme
|
||||
}
|
||||
this.baseConfig.backgroundColor.getContrastColor() == Color.WHITE -> R.style.MyDialogTheme_Dark
|
||||
baseConfig.backgroundColor.getContrastColor() == Color.WHITE -> R.style.MyDialogTheme_Dark
|
||||
else -> R.style.MyDialogTheme
|
||||
}
|
||||
|
||||
fun Context.getDatePickerDialogTheme() = when {
|
||||
this.baseConfig.isUsingSystemTheme -> R.style.MyDateTimePickerMaterialTheme
|
||||
this.baseConfig.backgroundColor.getContrastColor() == Color.WHITE -> R.style.MyDialogTheme_Dark
|
||||
baseConfig.isUsingSystemTheme -> R.style.MyDateTimePickerMaterialTheme
|
||||
baseConfig.backgroundColor.getContrastColor() == Color.WHITE -> R.style.MyDialogTheme_Dark
|
||||
else -> R.style.MyDialogTheme
|
||||
}
|
||||
|
||||
fun Context.getPopupMenuTheme(): Int {
|
||||
return if (isSPlus() && this.baseConfig.isUsingSystemTheme) {
|
||||
return if (isSPlus() && 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 = this.baseConfig.appId
|
||||
if (appId.isNotEmpty() && this.baseConfig.lastIconColor != this.baseConfig.appIconColor) {
|
||||
val appId = baseConfig.appId
|
||||
if (appId.isNotEmpty() && baseConfig.lastIconColor != baseConfig.appIconColor) {
|
||||
getAppIconColors().forEachIndexed { index, color ->
|
||||
toggleAppIconColor(appId, index, color, false)
|
||||
}
|
||||
|
||||
getAppIconColors().forEachIndexed { index, color ->
|
||||
if (this.baseConfig.appIconColor == color) {
|
||||
if (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) {
|
||||
this.baseConfig.lastIconColor = color
|
||||
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 = this.baseConfig.backgroundColor
|
||||
val baseColor = baseConfig.backgroundColor
|
||||
val bottomColor = when {
|
||||
this.baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_status_bar_color, theme)
|
||||
baseConfig.isUsingSystemTheme -> resources.getColor(R.color.you_status_bar_color, theme)
|
||||
baseColor == Color.WHITE -> resources.getColor(R.color.bottom_tabs_light_background)
|
||||
else -> this.baseConfig.backgroundColor.lightenColor(4)
|
||||
else -> baseConfig.backgroundColor.lightenColor(4)
|
||||
}
|
||||
return bottomColor
|
||||
}
|
||||
|
|
|
@ -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() = this.baseConfig.sdCardPath
|
||||
val Context.internalStoragePath: String get() = this.baseConfig.internalStoragePath
|
||||
val Context.otgPath: String get() = this.baseConfig.OTGPath
|
||||
val Context.sdCardPath: String get() = baseConfig.sdCardPath
|
||||
val Context.internalStoragePath: String get() = baseConfig.internalStoragePath
|
||||
val Context.otgPath: String get() = baseConfig.OTGPath
|
||||
|
||||
fun Context.isFingerPrintSensorAvailable() = Reprint.isHardwarePresent()
|
||||
|
||||
|
@ -428,10 +428,10 @@ fun Context.getCurrentFormattedDateTime(): String {
|
|||
|
||||
fun Context.updateSDCardPath() {
|
||||
ensureBackgroundThread {
|
||||
val oldPath = this.baseConfig.sdCardPath
|
||||
this.baseConfig.sdCardPath = getSDCardPath()
|
||||
if (oldPath != this.baseConfig.sdCardPath) {
|
||||
this.baseConfig.sdTreeUri = ""
|
||||
val oldPath = baseConfig.sdCardPath
|
||||
baseConfig.sdCardPath = getSDCardPath()
|
||||
if (oldPath != baseConfig.sdCardPath) {
|
||||
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
|
||||
this.baseConfig.hadThankYouInstalled -> true
|
||||
baseConfig.hadThankYouInstalled -> true
|
||||
isThankYouInstalled() -> {
|
||||
this.baseConfig.hadThankYouInstalled = true
|
||||
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<String>
|
||||
|
||||
if (this.baseConfig.isSundayFirst) {
|
||||
if (baseConfig.isSundayFirst) {
|
||||
dayBits.moveLastItemToFront()
|
||||
weekDays.moveLastItemToFront()
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ fun Context.storeNewYourAlarmSound(resultData: Intent): AlarmSound {
|
|||
}
|
||||
|
||||
val token = object : TypeToken<ArrayList<AlarmSound>>() {}.type
|
||||
val yourAlarmSounds = Gson().fromJson<ArrayList<AlarmSound>>(this.baseConfig.yourAlarmSounds, token)
|
||||
val yourAlarmSounds = Gson().fromJson<ArrayList<AlarmSound>>(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)
|
||||
}
|
||||
|
||||
this.baseConfig.yourAlarmSounds = Gson().toJson(yourAlarmSounds)
|
||||
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(this.baseConfig.appId)
|
||||
fun Context.getLaunchIntent() = packageManager.getLaunchIntentForPackage(baseConfig.appId)
|
||||
|
||||
fun Context.getCanAppBeUpgraded() = proPackages.contains(this.baseConfig.appId.removeSuffix(".debug").removePrefix("com.simplemobiletools."))
|
||||
fun Context.getCanAppBeUpgraded() = proPackages.contains(baseConfig.appId.removeSuffix(".debug").removePrefix("com.simplemobiletools."))
|
||||
|
||||
fun Context.getProUrl() = "https://play.google.com/store/apps/details?id=${this.baseConfig.appId.removeSuffix(".debug")}.pro"
|
||||
fun Context.getProUrl() = "https://play.google.com/store/apps/details?id=${baseConfig.appId.removeSuffix(".debug")}.pro"
|
||||
|
||||
fun Context.getStoreUrl() = "https://play.google.com/store/apps/details?id=${packageName.removeSuffix(".debug")}"
|
||||
|
||||
fun Context.getTimeFormat() = if (this.baseConfig.use24HourFormat) TIME_FORMAT_24 else TIME_FORMAT_12
|
||||
fun Context.getTimeFormat() = if (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 (this.baseConfig.fontSize) {
|
||||
when (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 (this.baseConfig.fontSize) {
|
||||
fun Context.getTextSize() = when (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)
|
||||
|
|
Loading…
Reference in a new issue