diff --git a/build.gradle b/build.gradle
index c772f496c..95a43e912 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
propMinSdkVersion = 16
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
- propVersionName = '2.41.19'
+ propVersionName = '2.42.2'
kotlin_version = '1.2.0'
support_libs = '27.0.1'
}
diff --git a/commons/src/main/AndroidManifest.xml b/commons/src/main/AndroidManifest.xml
index e47b33e90..5f8f3fb3b 100644
--- a/commons/src/main/AndroidManifest.xml
+++ b/commons/src/main/AndroidManifest.xml
@@ -1,2 +1,16 @@
-
+
+
+
+
+
+
+
+
+
+
+
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 99e958df5..01914d2aa 100644
--- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt
+++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt
@@ -1,11 +1,13 @@
package com.simplemobiletools.commons.activities
+import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.dialogs.*
import com.simplemobiletools.commons.extensions.*
+import com.simplemobiletools.commons.helpers.MyContentProvider
import com.simplemobiletools.commons.models.MyTheme
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.models.SharedTheme
@@ -85,7 +87,7 @@ class CustomizationActivity : BaseSimpleActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
- R.id.save -> saveChanges()
+ R.id.save -> saveChanges(true)
else -> return super.onOptionsItemSelected(item)
}
return true
@@ -193,7 +195,7 @@ class CustomizationActivity : BaseSimpleActivity() {
private fun promptSaveDiscard() {
ConfirmationAdvancedDialog(this, "", R.string.save_before_closing, R.string.save, R.string.discard) {
if (it) {
- saveChanges()
+ saveChanges(true)
} else {
resetColors()
finish()
@@ -201,7 +203,7 @@ class CustomizationActivity : BaseSimpleActivity() {
}
}
- private fun saveChanges() {
+ private fun saveChanges(finishAfterSave: Boolean) {
baseConfig.apply {
textColor = curTextColor
backgroundColor = curBackgroundColor
@@ -211,10 +213,16 @@ class CustomizationActivity : BaseSimpleActivity() {
if (curSelectedThemeId == THEME_SHARED) {
val newSharedTheme = SharedTheme(curTextColor, curBackgroundColor, curPrimaryColor)
updateSharedTheme(newSharedTheme)
+ Intent().apply {
+ action = MyContentProvider.SHARED_THEME_UPDATED
+ sendBroadcast(this)
+ }
}
baseConfig.isUsingSharedTheme = curSelectedThemeId == THEME_SHARED
hasUnsavedChanges = false
- finish()
+ if (finishAfterSave) {
+ finish()
+ }
}
private fun resetColors() {
@@ -308,8 +316,14 @@ class CustomizationActivity : BaseSimpleActivity() {
ConfirmationDialog(this, "", R.string.share_colors_success, R.string.ok, 0) {
baseConfig.wasSharedThemeEverActivated = true
apply_to_all_holder.beGone()
- predefinedThemes.put(THEME_SHARED, MyTheme(R.string.shared, 0, 0, 0))
updateColorTheme(THEME_SHARED)
+ saveChanges(false)
+ predefinedThemes.put(THEME_SHARED, MyTheme(R.string.shared, 0, 0, 0))
+
+ Intent().apply {
+ action = MyContentProvider.SHARED_THEME_ACTIVATED
+ sendBroadcast(this)
+ }
}
} else {
PurchaseThankYouDialog(this)
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 3e0006c36..a56bafb41 100644
--- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt
+++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt
@@ -2,8 +2,6 @@ package com.simplemobiletools.commons.extensions
import android.Manifest
import android.annotation.SuppressLint
-import android.content.ClipData
-import android.content.ClipboardManager
import android.content.ContentUris
import android.content.Context
import android.content.pm.PackageManager
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 0a30fd05e..83dd691b7 100644
--- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt
+++ b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt
@@ -116,4 +116,8 @@ open class BaseConfig(val context: Context) {
var wasCustomThemeSwitchDescriptionShown: Boolean
get() = prefs.getBoolean(WAS_CUSTOM_THEME_SWITCH_DESCRIPTION_SHOWN, false)
set(wasCustomThemeSwitchDescriptionShown) = prefs.edit().putBoolean(WAS_CUSTOM_THEME_SWITCH_DESCRIPTION_SHOWN, wasCustomThemeSwitchDescriptionShown).apply()
+
+ var wasSharedThemeForced: Boolean
+ get() = prefs.getBoolean(WAS_SHARED_THEME_FORCED, false)
+ set(wasSharedThemeForced) = prefs.edit().putBoolean(WAS_SHARED_THEME_FORCED, wasSharedThemeForced).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 fae6b5b03..d55590762 100644
--- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt
+++ b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt
@@ -32,6 +32,7 @@ val USE_ENGLISH = "use_english"
val WAS_USE_ENGLISH_TOGGLED = "was_use_english_toggled"
val WAS_SHARED_THEME_EVER_ACTIVATED = "was_shared_theme_ever_activated"
val IS_USING_SHARED_THEME = "is_using_shared_theme"
+val WAS_SHARED_THEME_FORCED = "was_shared_theme_forced"
val WAS_CUSTOM_THEME_SWITCH_DESCRIPTION_SHOWN = "was_custom_theme_switch_description_shown"
// licenses
diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/MyContentProvider.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/MyContentProvider.kt
index 9ee027c7d..9c76c2365 100644
--- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/MyContentProvider.kt
+++ b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/MyContentProvider.kt
@@ -8,6 +8,8 @@ class MyContentProvider {
companion object {
val AUTHORITY = "com.simplemobiletools.commons.provider"
val CONTENT_URI = Uri.parse("content://$AUTHORITY/themes")
+ val SHARED_THEME_ACTIVATED = "com.simplemobiletools.commons.SHARED_THEME_ACTIVATED"
+ val SHARED_THEME_UPDATED = "com.simplemobiletools.commons.SHARED_THEME_UPDATED"
val COL_ID = "_id"
val COL_TEXT_COLOR = "text_color"
diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/receivers/SharedThemeReceiver.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/receivers/SharedThemeReceiver.kt
new file mode 100644
index 000000000..65cdcfe03
--- /dev/null
+++ b/commons/src/main/kotlin/com/simplemobiletools/commons/receivers/SharedThemeReceiver.kt
@@ -0,0 +1,38 @@
+package com.simplemobiletools.commons.receivers
+
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import com.simplemobiletools.commons.extensions.baseConfig
+import com.simplemobiletools.commons.extensions.getSharedTheme
+import com.simplemobiletools.commons.helpers.MyContentProvider
+
+class SharedThemeReceiver : BroadcastReceiver() {
+ override fun onReceive(context: Context, intent: Intent) {
+ if (intent.action == MyContentProvider.SHARED_THEME_ACTIVATED) {
+ context.baseConfig.apply {
+ if (!wasSharedThemeForced) {
+ wasSharedThemeForced = true
+ isUsingSharedTheme = true
+ wasSharedThemeEverActivated = true
+
+ context.getSharedTheme {
+ textColor = it.textColor
+ backgroundColor = it.backgroundColor
+ primaryColor = it.primaryColor
+ }
+ }
+ }
+ } else if (intent.action == MyContentProvider.SHARED_THEME_UPDATED) {
+ context.baseConfig.apply {
+ if (isUsingSharedTheme) {
+ context.getSharedTheme {
+ textColor = it.textColor
+ backgroundColor = it.backgroundColor
+ primaryColor = it.primaryColor
+ }
+ }
+ }
+ }
+ }
+}