diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4da5647..28bb6c4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,7 +12,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/finnmglasTheme"> + android:theme="@style/baseTheme"> necessary btn.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) } - else { - // not setting it here, unable to find a good alternative - // TODO at some point (or you do it now) - } + // not setting it in any other case (yet), unable to find a good solution } // Taken from: https://stackoverflow.com/a/33072575/12787264 diff --git a/app/src/main/java/com/finnmglas/launcher/HomeActivity.kt b/app/src/main/java/com/finnmglas/launcher/HomeActivity.kt index 537077e..1f2f956 100644 --- a/app/src/main/java/com/finnmglas/launcher/HomeActivity.kt +++ b/app/src/main/java/com/finnmglas/launcher/HomeActivity.kt @@ -16,6 +16,7 @@ import java.text.SimpleDateFormat import java.util.* import kotlin.concurrent.fixedRateTimer import kotlin.math.abs +import com.finnmglas.launcher.BuildConfig.VERSION_NAME /** * [HomeActivity] is the actual application Launcher, @@ -56,9 +57,34 @@ class HomeActivity: UIObject, AppCompatActivity(), appListViewAdapter = AppsRecyclerAdapter(this) } - // First time opening the app: show Tutorial + // First time opening the app: show Tutorial, else: check versions if (!launcherPreferences.getBoolean(PREF_STARTED, false)) startActivity(Intent(this, TutorialActivity::class.java)) + else when (launcherPreferences.getString(PREF_VERSION, "")) { + // Check versions, make sure transitions between versions go well + + VERSION_NAME -> { /* the version installed and used previously are the same */ } + "" -> { /* The version used before was pre- v1.3.0, + as version tracking started then */ + + /* + * before, the dominant and vibrant color of the `finn` and `dark` theme + * were not stored anywhere. Now they have to be stored: + * -> we just reset them using newly implemented functions + */ + when (getSavedTheme(this)) { + "finn" -> resetToDefaultTheme(this) + "dark" -> resetToDarkTheme(this) + } + + launcherPreferences.edit() + .putString(PREF_VERSION, VERSION_NAME) // save new version + .apply() + + // show the new tutorial + startActivity(Intent(this, TutorialActivity::class.java)) + } + } // Initialise layout setContentView(R.layout.home) @@ -195,19 +221,9 @@ class HomeActivity: UIObject, AppCompatActivity(), ) } 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) + // Background image was deleted or something unexpected happened + if (background == null) resetToDefaultTheme(this) - launcherPreferences.edit() - .putString(PREF_WALLPAPER, "") - .putInt(PREF_DOMINANT, dominantColor) - .putInt(PREF_VIBRANT, vibrantColor) - .apply() - - saveTheme("finn") - recreate() - } home_background_image.visibility = View.VISIBLE } else { home_background_image.visibility = View.INVISIBLE diff --git a/app/src/main/java/com/finnmglas/launcher/list/ListActivity.kt b/app/src/main/java/com/finnmglas/launcher/list/ListActivity.kt index 09150de..42a4ad7 100644 --- a/app/src/main/java/com/finnmglas/launcher/list/ListActivity.kt +++ b/app/src/main/java/com/finnmglas/launcher/list/ListActivity.kt @@ -20,7 +20,7 @@ import com.finnmglas.launcher.list.other.ListFragmentOther var intendedChoosePause = false // know when to close -// TODO: Better solution for this (used in list-fragments) +// TODO: Better solution for this intercommunication fuctionality (used in list-fragments) var intention = "view" var forApp = "" diff --git a/app/src/main/java/com/finnmglas/launcher/settings/SettingsActivity.kt b/app/src/main/java/com/finnmglas/launcher/settings/SettingsActivity.kt index da346fa..29a97b9 100644 --- a/app/src/main/java/com/finnmglas/launcher/settings/SettingsActivity.kt +++ b/app/src/main/java/com/finnmglas/launcher/settings/SettingsActivity.kt @@ -80,16 +80,7 @@ class SettingsActivity: AppCompatActivity(), UIObject { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { when (requestCode) { - REQUEST_CHOOSE_APP -> { - val value = data?.getStringExtra("value") - val forApp = data?.getStringExtra("forApp") ?: return - - launcherPreferences.edit() - .putString("action_$forApp", value.toString()) - .apply() - - loadSettings() - } + REQUEST_CHOOSE_APP -> saveListActivityChoice(data) else -> super.onActivityResult(requestCode, resultCode, data) } } diff --git a/app/src/main/java/com/finnmglas/launcher/settings/theme/SettingsFragmentTheme.kt b/app/src/main/java/com/finnmglas/launcher/settings/theme/SettingsFragmentTheme.kt index 4094423..cf68e63 100644 --- a/app/src/main/java/com/finnmglas/launcher/settings/theme/SettingsFragmentTheme.kt +++ b/app/src/main/java/com/finnmglas/launcher/settings/theme/SettingsFragmentTheme.kt @@ -123,34 +123,10 @@ class SettingsFragmentTheme : Fragment(), UIObject { override fun setOnClicks() { // Theme changing buttons settings_theme_dark_button_select.setOnClickListener { - dominantColor = resources.getColor(R.color.darkTheme_background_color) - vibrantColor = resources.getColor(R.color.darkTheme_accent_color) - - launcherPreferences.edit() - .putString(PREF_WALLPAPER, "") - .putInt(PREF_DOMINANT, dominantColor) - .putInt(PREF_VIBRANT, vibrantColor) - .apply() - - saveTheme("dark") - - intendedSettingsPause = true - activity!!.recreate() + resetToDarkTheme(activity!!) } settings_theme_finn_button_select.setOnClickListener { - dominantColor = resources.getColor(R.color.finnmglasTheme_background_color) - vibrantColor = resources.getColor(R.color.finnmglasTheme_accent_color) - - launcherPreferences.edit() - .putString(PREF_WALLPAPER, "") - .putInt(PREF_DOMINANT, dominantColor) - .putInt(PREF_VIBRANT, vibrantColor) - .apply() - - saveTheme("finn") - - intendedSettingsPause = true - activity!!.recreate() + resetToDefaultTheme(activity!!) } settings_theme_custom_button_select.setOnClickListener { intendedSettingsPause = true diff --git a/app/src/main/java/com/finnmglas/launcher/tutorial/TutorialActivity.kt b/app/src/main/java/com/finnmglas/launcher/tutorial/TutorialActivity.kt index 3042dec..c20a721 100644 --- a/app/src/main/java/com/finnmglas/launcher/tutorial/TutorialActivity.kt +++ b/app/src/main/java/com/finnmglas/launcher/tutorial/TutorialActivity.kt @@ -59,24 +59,14 @@ class TutorialActivity: AppCompatActivity(), UIObject { tutorial_close.setOnClickListener() { finish() } } - // same as in SettingsActivity; TODO: Use same function override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { when (requestCode) { - REQUEST_CHOOSE_APP -> { - val value = data?.getStringExtra("value") - val forApp = data?.getStringExtra("forApp") ?: return - - launcherPreferences.edit() - .putString("action_$forApp", value.toString()) - .apply() - - loadSettings() - } + REQUEST_CHOOSE_APP -> saveListActivityChoice(data) else -> super.onActivityResult(requestCode, resultCode, data) } } - // Prevent going back, allow if viewed again later + // Default: prevent going back, allow if viewed again later override fun onBackPressed() { if (launcherPreferences.getBoolean(PREF_STARTED, false)) super.onBackPressed() diff --git a/app/src/main/java/com/finnmglas/launcher/tutorial/tabs/TutorialFragmentFinish.kt b/app/src/main/java/com/finnmglas/launcher/tutorial/tabs/TutorialFragmentFinish.kt index 9af79ab..6d55aad 100644 --- a/app/src/main/java/com/finnmglas/launcher/tutorial/tabs/TutorialFragmentFinish.kt +++ b/app/src/main/java/com/finnmglas/launcher/tutorial/tabs/TutorialFragmentFinish.kt @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import com.finnmglas.launcher.* +import com.finnmglas.launcher.BuildConfig.VERSION_NAME import kotlinx.android.synthetic.main.tutorial_finish.* /** @@ -37,19 +38,12 @@ class TutorialFragmentFinish(): Fragment(), UIObject { tutorial_finish_button_start.setOnClickListener{ finishTutorial() } } - override fun adjustLayout() { - super.adjustLayout() - - // Different text if opened again later (from settings) - if (launcherPreferences.getBoolean(PREF_STARTED, false)) - tutorial_finish_button_start.text = "Back to Settings" - } - private fun finishTutorial() { if (!launcherPreferences.getBoolean(PREF_STARTED, false)){ launcherPreferences.edit() .putBoolean(PREF_STARTED, true) // never auto run this again .putLong(PREF_STARTED_TIME, System.currentTimeMillis() / 1000L) // record first startup timestamp + .putString(PREF_VERSION, VERSION_NAME) // save current launcher version .apply() } activity!!.finish() diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 6c2b558..478578a 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,49 +1,27 @@ - - - - - - - -