properly handle setting default navigation bar color
This commit is contained in:
parent
4c5255ef12
commit
2a35cd1f16
6 changed files with 24 additions and 8 deletions
|
@ -112,9 +112,11 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateNavigationBarColor(color: Int = baseConfig.navigationBarColor) {
|
fun updateNavigationBarColor(color: Int = baseConfig.navigationBarColor) {
|
||||||
try {
|
if (baseConfig.navigationBarColor != INVALID_NAVIGATION_BAR_COLOR) {
|
||||||
window.navigationBarColor = color
|
try {
|
||||||
} catch (ignored: Exception) {
|
window.navigationBarColor = color
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
||||||
private var curBackgroundColor = 0
|
private var curBackgroundColor = 0
|
||||||
private var curPrimaryColor = 0
|
private var curPrimaryColor = 0
|
||||||
private var curAppIconColor = 0
|
private var curAppIconColor = 0
|
||||||
private var curNavigationBarColor = DEFAULT_NAVIGATION_BAR_COLOR
|
private var curNavigationBarColor = INVALID_NAVIGATION_BAR_COLOR
|
||||||
private var curSelectedThemeId = 0
|
private var curSelectedThemeId = 0
|
||||||
private var originalAppIconColor = 0
|
private var originalAppIconColor = 0
|
||||||
private var hasUnsavedChanges = false
|
private var hasUnsavedChanges = false
|
||||||
|
@ -43,6 +43,11 @@ class CustomizationActivity : BaseSimpleActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_customization)
|
setContentView(R.layout.activity_customization)
|
||||||
|
|
||||||
|
if (baseConfig.defaultNavigationBarColor == INVALID_NAVIGATION_BAR_COLOR) {
|
||||||
|
baseConfig.defaultNavigationBarColor = window.navigationBarColor
|
||||||
|
baseConfig.navigationBarColor = window.navigationBarColor
|
||||||
|
}
|
||||||
|
|
||||||
initColorVariables()
|
initColorVariables()
|
||||||
setupColorsPickers()
|
setupColorsPickers()
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import android.widget.ImageView
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.R
|
import com.simplemobiletools.commons.R
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.DEFAULT_NAVIGATION_BAR_COLOR
|
import com.simplemobiletools.commons.helpers.INVALID_NAVIGATION_BAR_COLOR
|
||||||
import com.simplemobiletools.commons.views.ColorPickerSquare
|
import com.simplemobiletools.commons.views.ColorPickerSquare
|
||||||
import kotlinx.android.synthetic.main.dialog_color_picker.view.*
|
import kotlinx.android.synthetic.main.dialog_color_picker.view.*
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ class ColorPickerDialog(val activity: Activity, color: Int, val removeDimmedBack
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun useDefault() {
|
private fun useDefault() {
|
||||||
callback(true, DEFAULT_NAVIGATION_BAR_COLOR)
|
callback(true, activity.baseConfig.defaultNavigationBarColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getHexCode(color: Int) = color.toHex().substring(1)
|
private fun getHexCode(color: Int) = color.toHex().substring(1)
|
||||||
|
|
|
@ -73,6 +73,10 @@ fun Activity.appLaunched(appId: String) {
|
||||||
baseConfig.wasRateUsPromptShown = true
|
baseConfig.wasRateUsPromptShown = true
|
||||||
RateUsDialog(this)
|
RateUsDialog(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (baseConfig.navigationBarColor == INVALID_NAVIGATION_BAR_COLOR) {
|
||||||
|
baseConfig.navigationBarColor = window.navigationBarColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Activity.showDonateOrUpgradeDialog() {
|
fun Activity.showDonateOrUpgradeDialog() {
|
||||||
|
|
|
@ -65,9 +65,13 @@ open class BaseConfig(val context: Context) {
|
||||||
set(primaryColor) = prefs.edit().putInt(PRIMARY_COLOR, primaryColor).apply()
|
set(primaryColor) = prefs.edit().putInt(PRIMARY_COLOR, primaryColor).apply()
|
||||||
|
|
||||||
var navigationBarColor: Int
|
var navigationBarColor: Int
|
||||||
get() = prefs.getInt(NAVIGATION_BAR_COLOR, DEFAULT_NAVIGATION_BAR_COLOR)
|
get() = prefs.getInt(NAVIGATION_BAR_COLOR, INVALID_NAVIGATION_BAR_COLOR)
|
||||||
set(navigationBarColor) = prefs.edit().putInt(NAVIGATION_BAR_COLOR, navigationBarColor).apply()
|
set(navigationBarColor) = prefs.edit().putInt(NAVIGATION_BAR_COLOR, navigationBarColor).apply()
|
||||||
|
|
||||||
|
var defaultNavigationBarColor: Int
|
||||||
|
get() = prefs.getInt(DEFAULT_NAVIGATION_BAR_COLOR, INVALID_NAVIGATION_BAR_COLOR)
|
||||||
|
set(defaultNavigationBarColor) = prefs.edit().putInt(DEFAULT_NAVIGATION_BAR_COLOR, defaultNavigationBarColor).apply()
|
||||||
|
|
||||||
var lastHandledShortcutColor: Int
|
var lastHandledShortcutColor: Int
|
||||||
get() = prefs.getInt(LAST_HANDLED_SHORTCUT_COLOR, 1)
|
get() = prefs.getInt(LAST_HANDLED_SHORTCUT_COLOR, 1)
|
||||||
set(lastHandledShortcutColor) = prefs.edit().putInt(LAST_HANDLED_SHORTCUT_COLOR, lastHandledShortcutColor).apply()
|
set(lastHandledShortcutColor) = prefs.edit().putInt(LAST_HANDLED_SHORTCUT_COLOR, lastHandledShortcutColor).apply()
|
||||||
|
|
|
@ -21,7 +21,7 @@ const val ALARM_SOUND_TYPE_ALARM = 1
|
||||||
const val ALARM_SOUND_TYPE_NOTIFICATION = 2
|
const val ALARM_SOUND_TYPE_NOTIFICATION = 2
|
||||||
const val YOUR_ALARM_SOUNDS_MIN_ID = 1000
|
const val YOUR_ALARM_SOUNDS_MIN_ID = 1000
|
||||||
const val SHOW_FAQ_BEFORE_MAIL = "show_faq_before_mail"
|
const val SHOW_FAQ_BEFORE_MAIL = "show_faq_before_mail"
|
||||||
const val DEFAULT_NAVIGATION_BAR_COLOR = -1
|
const val INVALID_NAVIGATION_BAR_COLOR = -1
|
||||||
val DEFAULT_WIDGET_BG_COLOR = Color.parseColor("#33000000")
|
val DEFAULT_WIDGET_BG_COLOR = Color.parseColor("#33000000")
|
||||||
|
|
||||||
const val HOUR_MINUTES = 60
|
const val HOUR_MINUTES = 60
|
||||||
|
@ -51,6 +51,7 @@ const val BACKGROUND_COLOR = "background_color"
|
||||||
const val PRIMARY_COLOR = "primary_color_2"
|
const val PRIMARY_COLOR = "primary_color_2"
|
||||||
const val APP_ICON_COLOR = "app_icon_color"
|
const val APP_ICON_COLOR = "app_icon_color"
|
||||||
const val NAVIGATION_BAR_COLOR = "navigation_bar_color"
|
const val NAVIGATION_BAR_COLOR = "navigation_bar_color"
|
||||||
|
const val DEFAULT_NAVIGATION_BAR_COLOR = "default_navigation_bar_color"
|
||||||
const val LAST_HANDLED_SHORTCUT_COLOR = "last_handled_shortcut_color"
|
const val LAST_HANDLED_SHORTCUT_COLOR = "last_handled_shortcut_color"
|
||||||
const val LAST_ICON_COLOR = "last_icon_color"
|
const val LAST_ICON_COLOR = "last_icon_color"
|
||||||
const val CUSTOM_TEXT_COLOR = "custom_text_color"
|
const val CUSTOM_TEXT_COLOR = "custom_text_color"
|
||||||
|
|
Loading…
Reference in a new issue