mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
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:
parent
03093125f7
commit
ff72364983
6 changed files with 13 additions and 4 deletions
|
@ -179,13 +179,15 @@ fun getSavedTheme(context : Context) : String {
|
||||||
return sharedPref.getString("theme", "finn").toString()
|
return sharedPref.getString("theme", "finn").toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveTheme(context : Context, themeName : String) {
|
fun saveTheme(context : Context, themeName : String) : String {
|
||||||
val sharedPref = context.getSharedPreferences(
|
val sharedPref = context.getSharedPreferences(
|
||||||
context.getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
context.getString(R.string.preference_file_key), Context.MODE_PRIVATE)
|
||||||
|
|
||||||
val editor: SharedPreferences.Editor = sharedPref.edit()
|
val editor: SharedPreferences.Editor = sharedPref.edit()
|
||||||
editor.putString("theme", themeName)
|
editor.putString("theme", themeName)
|
||||||
editor.apply()
|
editor.apply()
|
||||||
|
|
||||||
|
return themeName
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openAppSettings(pkg :String, context:Context){
|
fun openAppSettings(pkg :String, context:Context){
|
||||||
|
|
|
@ -50,6 +50,9 @@ class MainActivity : AppCompatActivity(),
|
||||||
|
|
||||||
currentTheme = getSavedTheme(this)
|
currentTheme = getSavedTheme(this)
|
||||||
|
|
||||||
|
if (currentTheme == "custom" && background == null)
|
||||||
|
currentTheme = saveTheme(this, "finn")
|
||||||
|
|
||||||
setTheme(
|
setTheme(
|
||||||
when (currentTheme) {
|
when (currentTheme) {
|
||||||
"dark" -> R.style.darkTheme
|
"dark" -> R.style.darkTheme
|
||||||
|
@ -92,9 +95,8 @@ class MainActivity : AppCompatActivity(),
|
||||||
|
|
||||||
// TODO: do this immediately after changing preferences
|
// TODO: do this immediately after changing preferences
|
||||||
if (currentTheme != getSavedTheme(this)) recreate()
|
if (currentTheme != getSavedTheme(this)) recreate()
|
||||||
if (background != null) {
|
if (background_image != null && getSavedTheme(this) == "custom")
|
||||||
background_image.setImageBitmap(background)
|
background_image.setImageBitmap(background)
|
||||||
}
|
|
||||||
|
|
||||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||||
val timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
val timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
||||||
|
|
|
@ -55,7 +55,9 @@ class SettingsActivity : AppCompatActivity() {
|
||||||
when (getSavedTheme(container!!.context)) {
|
when (getSavedTheme(container!!.context)) {
|
||||||
"dark" -> select_theme_dark.visibility = View.INVISIBLE
|
"dark" -> select_theme_dark.visibility = View.INVISIBLE
|
||||||
"finn" -> select_theme_finn.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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
<string name="settings_toast_store_not_found">PlayStore nicht gefunden</string>
|
<string name="settings_toast_store_not_found">PlayStore nicht gefunden</string>
|
||||||
|
|
||||||
<string name="settings_select_theme">Wählen</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_by">Von</string>
|
||||||
<string name="settings_footer_repo">https://github.com/finnmglas/Launcher#de</string>
|
<string name="settings_footer_repo">https://github.com/finnmglas/Launcher#de</string>
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
<string name="settings_toast_store_not_found">Pas trouvé le PlayStore</string>
|
<string name="settings_toast_store_not_found">Pas trouvé le PlayStore</string>
|
||||||
|
|
||||||
<string name="settings_select_theme">Choisir</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_by">Par</string>
|
||||||
<string name="settings_footer_web">https://www.finnmglas.com/fr/</string>
|
<string name="settings_footer_web">https://www.finnmglas.com/fr/</string>
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
<string name="settings_toast_store_not_found">PlayStore not found</string>
|
<string name="settings_toast_store_not_found">PlayStore not found</string>
|
||||||
|
|
||||||
<string name="settings_select_theme">Select</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_by">By</string>
|
||||||
<string name="settings_footer_repo">https://github.com/finnmglas/Launcher#en</string>
|
<string name="settings_footer_repo">https://github.com/finnmglas/Launcher#en</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue