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