Custom Theme Selection

If the custom theme is selected, the `select custom button` is not 
hidden anymore, as it is way smarter to let users change their custom 
theme.
This commit is contained in:
Finn M Glas 2020-05-23 23:07:16 +02:00
parent 03093125f7
commit ff72364983
No known key found for this signature in database
GPG key ID: 25037A2E81AB459C
6 changed files with 13 additions and 4 deletions

View file

@ -179,13 +179,15 @@ fun getSavedTheme(context : Context) : String {
return sharedPref.getString("theme", "finn").toString()
}
fun saveTheme(context : Context, themeName : String) {
fun saveTheme(context : Context, themeName : String) : String {
val sharedPref = context.getSharedPreferences(
context.getString(R.string.preference_file_key), Context.MODE_PRIVATE)
val editor: SharedPreferences.Editor = sharedPref.edit()
editor.putString("theme", themeName)
editor.apply()
return themeName
}
fun openAppSettings(pkg :String, context:Context){

View file

@ -50,6 +50,9 @@ class MainActivity : AppCompatActivity(),
currentTheme = getSavedTheme(this)
if (currentTheme == "custom" && background == null)
currentTheme = saveTheme(this, "finn")
setTheme(
when (currentTheme) {
"dark" -> R.style.darkTheme
@ -92,9 +95,8 @@ class MainActivity : AppCompatActivity(),
// TODO: do this immediately after changing preferences
if (currentTheme != getSavedTheme(this)) recreate()
if (background != null) {
if (background_image != null && getSavedTheme(this) == "custom")
background_image.setImageBitmap(background)
}
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
val timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())

View file

@ -55,7 +55,9 @@ class SettingsActivity : AppCompatActivity() {
when (getSavedTheme(container!!.context)) {
"dark" -> select_theme_dark.visibility = View.INVISIBLE
"finn" -> select_theme_finn.visibility = View.INVISIBLE
"custom" -> select_theme_custom.visibility = View.INVISIBLE
"custom" -> {
select_theme_custom.text = getString(R.string.settings_select_image)
}
}
}
}

View file

@ -34,6 +34,7 @@
<string name="settings_toast_store_not_found">PlayStore nicht gefunden</string>
<string name="settings_select_theme">Wählen</string>
<string name="settings_select_image">Bild ändern</string>
<string name="settings_footer_by">Von</string>
<string name="settings_footer_repo">https://github.com/finnmglas/Launcher#de</string>

View file

@ -34,6 +34,7 @@
<string name="settings_toast_store_not_found">Pas trouvé le PlayStore</string>
<string name="settings_select_theme">Choisir</string>
<string name="settings_select_image">Changer Image</string>
<string name="settings_footer_by">Par</string>
<string name="settings_footer_web">https://www.finnmglas.com/fr/</string>

View file

@ -42,6 +42,7 @@
<string name="settings_toast_store_not_found">PlayStore not found</string>
<string name="settings_select_theme">Select</string>
<string name="settings_select_image">Change Image</string>
<string name="settings_footer_by">By</string>
<string name="settings_footer_repo">https://github.com/finnmglas/Launcher#en</string>