mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Fix colors for themes 'finn' and 'dark'
- UIObject: Rename `setTheme` to `applyTheme` and `configure` to `adjustLayout`
This commit is contained in:
parent
840ef1f110
commit
cfa7ce5d00
10 changed files with 101 additions and 111 deletions
|
@ -32,8 +32,6 @@ import kotlin.math.abs
|
|||
class HomeActivity: UIObject, AppCompatActivity(),
|
||||
GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
|
||||
|
||||
private var currentTheme = "" // keep track of theme changes
|
||||
|
||||
private lateinit var mDetector: GestureDetectorCompat
|
||||
|
||||
// timers
|
||||
|
@ -64,8 +62,6 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
|
||||
// Initialise layout
|
||||
setContentView(R.layout.home)
|
||||
|
||||
currentTheme = getSavedTheme(this)
|
||||
}
|
||||
|
||||
override fun onStart(){
|
||||
|
@ -82,11 +78,7 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
// TODO: do this immediately after changing preferences
|
||||
if (currentTheme != getSavedTheme(this)) recreate()
|
||||
if (home_background_image != null && getSavedTheme(
|
||||
this
|
||||
) == "custom")
|
||||
if (home_background_image != null && getSavedTheme(this) == "custom")
|
||||
home_background_image.setImageBitmap(background)
|
||||
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||
|
@ -187,36 +179,52 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
return if (mDetector.onTouchEvent(event)) { false } else { super.onTouchEvent(event) }
|
||||
}
|
||||
|
||||
override fun setTheme() {
|
||||
override fun applyTheme() {
|
||||
// Start by showing the settings icon
|
||||
showSettingsIcon()
|
||||
|
||||
if (currentTheme == "custom") {
|
||||
home_settings_icon.setTextColor(vibrantColor)
|
||||
try {
|
||||
background = MediaStore.Images.Media.getBitmap(this.contentResolver, Uri.parse(
|
||||
launcherPreferences.getString("background_uri", "")))
|
||||
} catch (e: Exception) { }
|
||||
home_settings_icon.setTextColor(vibrantColor)
|
||||
home_container.setBackgroundColor(dominantColor)
|
||||
|
||||
if (background == null)
|
||||
currentTheme = saveTheme("finn")
|
||||
if (launcherPreferences.getString("background_uri", "") != "") {
|
||||
try {
|
||||
background = MediaStore.Images.Media.getBitmap(
|
||||
this.contentResolver, Uri.parse(
|
||||
launcherPreferences.getString("background_uri", "")
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) { }
|
||||
|
||||
if (background == null) { // same as in Settings - TODO make function called by both
|
||||
dominantColor = resources.getColor(R.color.finnmglasTheme_background_color)
|
||||
vibrantColor = resources.getColor(R.color.finnmglasTheme_accent_color)
|
||||
|
||||
launcherPreferences.edit()
|
||||
.putString("background_uri", "")
|
||||
.putInt("custom_dominant", dominantColor)
|
||||
.putInt("custom_vibrant", vibrantColor)
|
||||
.apply()
|
||||
|
||||
saveTheme("finn")
|
||||
recreate()
|
||||
}
|
||||
home_background_image.visibility = View.VISIBLE
|
||||
} else {
|
||||
home_background_image.visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
home_settings_icon.setOnClickListener() {
|
||||
openSettings(this)
|
||||
overridePendingTransition(R.anim.bottom_up, android.R.anim.fade_out)
|
||||
launch("launcher:settings", this, R.anim.bottom_up)
|
||||
}
|
||||
|
||||
home_date_view.setOnClickListener() {
|
||||
launch(calendarApp, this)
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
|
||||
home_time_view.setOnClickListener() {
|
||||
launch(clockApp,this)
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,13 +15,13 @@ interface UIObject {
|
|||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
|
||||
setTheme()
|
||||
applyTheme()
|
||||
setOnClicks()
|
||||
configure()
|
||||
adjustLayout()
|
||||
}
|
||||
|
||||
// Don't use actual themes, rather create them on the fly for faster theme-switching
|
||||
fun setTheme() { } // colors
|
||||
fun setOnClicks() { } // onClicks
|
||||
fun configure() { } // layoutElements
|
||||
fun applyTheme() { }
|
||||
fun setOnClicks() { }
|
||||
fun adjustLayout() { }
|
||||
}
|
|
@ -69,21 +69,19 @@ class ListActivity : AppCompatActivity(), UIObject {
|
|||
}
|
||||
}
|
||||
|
||||
override fun setTheme() {
|
||||
if (getSavedTheme(this) == "custom") {
|
||||
list_container.setBackgroundColor(dominantColor)
|
||||
list_appbar.setBackgroundColor(dominantColor)
|
||||
list_close.setTextColor(vibrantColor)
|
||||
override fun applyTheme() {
|
||||
list_container.setBackgroundColor(dominantColor)
|
||||
list_appbar.setBackgroundColor(dominantColor)
|
||||
list_close.setTextColor(vibrantColor)
|
||||
|
||||
list_tabs.setSelectedTabIndicatorColor(vibrantColor)
|
||||
}
|
||||
list_tabs.setSelectedTabIndicatorColor(vibrantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
list_close.setOnClickListener() { finish() }
|
||||
}
|
||||
|
||||
override fun configure() {
|
||||
override fun adjustLayout() {
|
||||
// get info about which action this activity is open for
|
||||
val bundle = intent.extras
|
||||
if (bundle != null) {
|
||||
|
|
|
@ -34,15 +34,13 @@ class ListFragmentApps : Fragment(), UIObject {
|
|||
super<UIObject>.onStart()
|
||||
}
|
||||
|
||||
override fun setTheme() {
|
||||
if (getSavedTheme(context!!) == "custom") {
|
||||
list_apps_container.setBackgroundColor(dominantColor)
|
||||
}
|
||||
override fun applyTheme() {
|
||||
list_apps_container.setBackgroundColor(dominantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks() { }
|
||||
|
||||
override fun configure() {
|
||||
override fun adjustLayout() {
|
||||
// set up the list / recycler
|
||||
list_apps_rview.apply {
|
||||
// improve performance (since content changes don't change the layout size)
|
||||
|
|
|
@ -75,15 +75,13 @@ class SettingsActivity: AppCompatActivity(), UIObject {
|
|||
}
|
||||
}
|
||||
|
||||
override fun setTheme() {
|
||||
if (getSavedTheme(this) == "custom") {
|
||||
settings_container.setBackgroundColor(dominantColor)
|
||||
settings_appbar.setBackgroundColor(dominantColor)
|
||||
override fun applyTheme() {
|
||||
settings_container.setBackgroundColor(dominantColor)
|
||||
settings_appbar.setBackgroundColor(dominantColor)
|
||||
|
||||
settings_system.setTextColor(vibrantColor)
|
||||
settings_close.setTextColor(vibrantColor)
|
||||
settings_tabs.setSelectedTabIndicatorColor(vibrantColor)
|
||||
}
|
||||
settings_system.setTextColor(vibrantColor)
|
||||
settings_close.setTextColor(vibrantColor)
|
||||
settings_tabs.setSelectedTabIndicatorColor(vibrantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks(){
|
||||
|
|
|
@ -52,11 +52,8 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
|||
viewHolder.removeAction.visibility = View.GONE
|
||||
viewHolder.chooseButton.visibility = View.VISIBLE
|
||||
viewHolder.chooseButton.setOnClickListener{ chooseApp(actionName.toString()) }
|
||||
if (getSavedTheme(activity) =="custom")
|
||||
setButtonColor(
|
||||
viewHolder.chooseButton,
|
||||
vibrantColor
|
||||
)
|
||||
|
||||
setButtonColor(viewHolder.chooseButton, vibrantColor)
|
||||
}
|
||||
|
||||
if (content!!.startsWith("launcher")) {
|
||||
|
@ -85,11 +82,7 @@ class ActionsRecyclerAdapter(val activity: Activity):
|
|||
viewHolder.removeAction.visibility = View.GONE
|
||||
viewHolder.chooseButton.visibility = View.VISIBLE
|
||||
viewHolder.chooseButton.setOnClickListener{ chooseApp(actionName.toString()) }
|
||||
if (getSavedTheme(activity) =="custom")
|
||||
setButtonColor(
|
||||
viewHolder.chooseButton,
|
||||
vibrantColor
|
||||
)
|
||||
setButtonColor(viewHolder.chooseButton, vibrantColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,19 +49,11 @@ class SettingsFragmentActions : Fragment(), UIObject {
|
|||
}
|
||||
}
|
||||
|
||||
override fun setTheme() {
|
||||
if (getSavedTheme(context!!) == "custom") {
|
||||
settings_actions_container.setBackgroundColor(dominantColor)
|
||||
override fun applyTheme() {
|
||||
settings_actions_container.setBackgroundColor(dominantColor)
|
||||
|
||||
setButtonColor(
|
||||
settings_actions_button_view_apps,
|
||||
vibrantColor
|
||||
)
|
||||
setButtonColor(
|
||||
settings_actions_button_install_apps,
|
||||
vibrantColor
|
||||
)
|
||||
}
|
||||
setButtonColor(settings_actions_button_view_apps, vibrantColor)
|
||||
setButtonColor(settings_actions_button_install_apps, vibrantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
|
|
|
@ -58,21 +58,18 @@ class SettingsFragmentMeta : Fragment(), UIObject {
|
|||
return intent
|
||||
}
|
||||
|
||||
override fun setTheme() {
|
||||
override fun applyTheme() {
|
||||
settings_meta_container.setBackgroundColor(dominantColor)
|
||||
|
||||
if (getSavedTheme(context!!) == "custom") {
|
||||
settings_meta_container.setBackgroundColor(dominantColor)
|
||||
setButtonColor(settings_meta_button_select_launcher, vibrantColor)
|
||||
setButtonColor(settings_meta_button_view_tutorial, vibrantColor)
|
||||
setButtonColor(settings_meta_button_reset_settings, vibrantColor)
|
||||
setButtonColor(settings_meta_button_contact, vibrantColor)
|
||||
setButtonColor(settings_meta_button_donate, vibrantColor)
|
||||
|
||||
setButtonColor(settings_meta_button_select_launcher, vibrantColor)
|
||||
setButtonColor(settings_meta_button_view_tutorial, vibrantColor)
|
||||
setButtonColor(settings_meta_button_reset_settings, vibrantColor)
|
||||
setButtonColor(settings_meta_button_contact, vibrantColor)
|
||||
setButtonColor(settings_meta_button_donate, vibrantColor)
|
||||
|
||||
settings_meta_icon_google_play.setTextColor(vibrantColor)
|
||||
settings_meta_icon_github.setTextColor(vibrantColor)
|
||||
settings_meta_icon_globe.setTextColor(vibrantColor)
|
||||
}
|
||||
settings_meta_icon_google_play.setTextColor(vibrantColor)
|
||||
settings_meta_icon_github.setTextColor(vibrantColor)
|
||||
settings_meta_icon_globe.setTextColor(vibrantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
|
|
|
@ -104,44 +104,52 @@ class SettingsFragmentTheme : Fragment(), UIObject {
|
|||
}
|
||||
}
|
||||
|
||||
override fun setTheme() {
|
||||
override fun applyTheme() {
|
||||
// Hide 'select' button for the selected theme or allow customisation
|
||||
when (getSavedTheme(context!!)) {
|
||||
"dark" -> settings_theme_dark_button_select.visibility = View.INVISIBLE
|
||||
"finn" -> settings_theme_finn_button_select.visibility = View.INVISIBLE
|
||||
"custom" -> {
|
||||
"custom" ->
|
||||
settings_theme_custom_button_select.text = getString(R.string.settings_select_image)
|
||||
settings_theme_container.setBackgroundColor(dominantColor)
|
||||
setButtonColor(
|
||||
settings_theme_finn_button_select,
|
||||
vibrantColor
|
||||
)
|
||||
setButtonColor(
|
||||
settings_theme_dark_button_select,
|
||||
vibrantColor
|
||||
)
|
||||
setButtonColor(
|
||||
settings_theme_custom_button_select,
|
||||
vibrantColor
|
||||
)
|
||||
setButtonColor(
|
||||
settings_theme_custom_button_examples,
|
||||
vibrantColor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
settings_theme_container.setBackgroundColor(dominantColor)
|
||||
setButtonColor(settings_theme_finn_button_select, vibrantColor)
|
||||
setButtonColor(settings_theme_dark_button_select, vibrantColor)
|
||||
setButtonColor(settings_theme_custom_button_select, vibrantColor)
|
||||
setButtonColor(settings_theme_custom_button_examples, vibrantColor)
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
// Theme changing buttons
|
||||
settings_theme_dark_button_select.setOnClickListener {
|
||||
intendedSettingsPause = true
|
||||
dominantColor = resources.getColor(R.color.darkTheme_background_color)
|
||||
vibrantColor = resources.getColor(R.color.darkTheme_accent_color)
|
||||
|
||||
launcherPreferences.edit()
|
||||
.putString("background_uri", "")
|
||||
.putInt("custom_dominant", dominantColor)
|
||||
.putInt("custom_vibrant", vibrantColor)
|
||||
.apply()
|
||||
|
||||
saveTheme("dark")
|
||||
|
||||
intendedSettingsPause = true
|
||||
activity!!.recreate()
|
||||
}
|
||||
settings_theme_finn_button_select.setOnClickListener {
|
||||
intendedSettingsPause = true
|
||||
dominantColor = resources.getColor(R.color.finnmglasTheme_background_color)
|
||||
vibrantColor = resources.getColor(R.color.finnmglasTheme_accent_color)
|
||||
|
||||
launcherPreferences.edit()
|
||||
.putString("background_uri", "")
|
||||
.putInt("custom_dominant", dominantColor)
|
||||
.putInt("custom_vibrant", vibrantColor)
|
||||
.apply()
|
||||
|
||||
saveTheme("finn")
|
||||
|
||||
intendedSettingsPause = true
|
||||
activity!!.recreate()
|
||||
}
|
||||
settings_theme_custom_button_select.setOnClickListener {
|
||||
|
|
|
@ -89,12 +89,10 @@ class TutorialActivity: AppCompatActivity(), UIObject {
|
|||
}
|
||||
}
|
||||
|
||||
override fun setTheme() {
|
||||
if (getSavedTheme(this) == "custom") {
|
||||
tutorial_appbar.setBackgroundColor(dominantColor)
|
||||
tutorial_container.setBackgroundColor(dominantColor)
|
||||
tutorial_close.setTextColor(vibrantColor)
|
||||
}
|
||||
override fun applyTheme() {
|
||||
tutorial_appbar.setBackgroundColor(dominantColor)
|
||||
tutorial_container.setBackgroundColor(dominantColor)
|
||||
tutorial_close.setTextColor(vibrantColor)
|
||||
|
||||
tutorial_page_hint.blink() // animate
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue