From 2420b7261dd5291f7f1903d378cf064778d16be4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 6 Nov 2017 20:34:36 +0100 Subject: [PATCH] adding an option to hide the launcher icon --- app/build.gradle | 8 ++++---- .../thankyou/activities/SettingsActivity.kt | 17 ++++++++++++++++ .../thankyou/extensions/Context.kt | 6 ++++++ .../thankyou/helpers/Config.kt | 20 +++++-------------- .../thankyou/helpers/Constants.kt | 4 +--- app/src/main/res/layout/activity_settings.xml | 20 +++++++++++++++++++ app/src/main/res/values-de/strings.xml | 3 +++ app/src/main/res/values-es/strings.xml | 3 +++ app/src/main/res/values-hi-rIN/strings.xml | 3 +++ app/src/main/res/values-hu/strings.xml | 3 +++ app/src/main/res/values-it/strings.xml | 3 +++ app/src/main/res/values-ja/strings.xml | 3 +++ app/src/main/res/values-lt/strings.xml | 3 +++ app/src/main/res/values-pl/strings.xml | 3 +++ app/src/main/res/values-pt-rPT/strings.xml | 3 +++ app/src/main/res/values-ru/strings.xml | 3 +++ app/src/main/res/values-sk/strings.xml | 3 +++ app/src/main/res/values-sv/strings.xml | 3 +++ app/src/main/res/values-zh/strings.xml | 3 +++ app/src/main/res/values/strings.xml | 3 +++ 20 files changed, 95 insertions(+), 22 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/thankyou/extensions/Context.kt diff --git a/app/build.gradle b/app/build.gradle index df164ed..b959e2d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,13 +3,13 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 25 - buildToolsVersion "25.0.3" + compileSdkVersion 26 + buildToolsVersion "26.0.2" defaultConfig { applicationId "com.simplemobiletools.thankyou" minSdkVersion 16 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 2 versionName "2.0.0" } @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.32.0' + compile 'com.simplemobiletools:commons:2.36.0' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/app/src/main/kotlin/com/simplemobiletools/thankyou/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/thankyou/activities/SettingsActivity.kt index 8c3ee6b..730cac7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/thankyou/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/thankyou/activities/SettingsActivity.kt @@ -1,9 +1,12 @@ package com.simplemobiletools.thankyou.activities +import android.content.ComponentName +import android.content.pm.PackageManager import android.os.Bundle import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.thankyou.R +import com.simplemobiletools.thankyou.extensions.config import kotlinx.android.synthetic.main.activity_settings.* class SettingsActivity : BaseSimpleActivity() { @@ -15,7 +18,9 @@ class SettingsActivity : BaseSimpleActivity() { override fun onResume() { super.onResume() + setupCustomizeColors() + setupHideLauncherIcon() updateTextColors(settings_holder) } @@ -24,4 +29,16 @@ class SettingsActivity : BaseSimpleActivity() { startCustomizationActivity() } } + + private fun setupHideLauncherIcon() { + settings_hide_launcher_icon.isChecked = config.hideLauncherIcon + settings_hide_launcher_icon_holder.setOnClickListener { + settings_hide_launcher_icon.toggle() + config.hideLauncherIcon = settings_hide_launcher_icon.isChecked + + val componentName = ComponentName(this, MainActivity::class.java) + val state = if (config.hideLauncherIcon) PackageManager.COMPONENT_ENABLED_STATE_DISABLED else PackageManager.COMPONENT_ENABLED_STATE_ENABLED + packageManager.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP) + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/thankyou/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/thankyou/extensions/Context.kt new file mode 100644 index 0000000..2a4d993 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/thankyou/extensions/Context.kt @@ -0,0 +1,6 @@ +package com.simplemobiletools.thankyou.extensions + +import android.content.Context +import com.simplemobiletools.thankyou.helpers.Config + +val Context.config: Config get() = Config.newInstance(this) diff --git a/app/src/main/kotlin/com/simplemobiletools/thankyou/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/thankyou/helpers/Config.kt index 59e0a79..acbdac9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/thankyou/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/thankyou/helpers/Config.kt @@ -1,24 +1,14 @@ package com.simplemobiletools.thankyou.helpers import android.content.Context -import android.content.SharedPreferences - -class Config(context: Context) { - private val mPrefs: SharedPreferences +import com.simplemobiletools.commons.helpers.BaseConfig +class Config(context: Context) : BaseConfig(context) { companion object { fun newInstance(context: Context) = Config(context) } - init { - mPrefs = context.getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE) - } - - var isFirstRun: Boolean - get() = mPrefs.getBoolean(IS_FIRST_RUN, true) - set(firstRun) = mPrefs.edit().putBoolean(IS_FIRST_RUN, firstRun).apply() - - var isDarkTheme: Boolean - get() = mPrefs.getBoolean(IS_DARK_THEME, false) - set(isDarkTheme) = mPrefs.edit().putBoolean(IS_DARK_THEME, isDarkTheme).apply() + var hideLauncherIcon: Boolean + get() = prefs.getBoolean(HIDE_LAUNCHER_ICON, false) + set(hideLauncherIcon) = prefs.edit().putBoolean(HIDE_LAUNCHER_ICON, hideLauncherIcon).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/thankyou/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/thankyou/helpers/Constants.kt index 1b14b37..fce9bb2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/thankyou/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/thankyou/helpers/Constants.kt @@ -1,6 +1,4 @@ package com.simplemobiletools.thankyou.helpers // Shared Preferences -val PREFS_KEY = "Thank You" -val IS_FIRST_RUN = "is_first_run" -val IS_DARK_THEME = "is_dark_theme" +val HIDE_LAUNCHER_ICON = "hide_launcher_icon" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 11a4618..c066226 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -29,5 +29,25 @@ android:text="@string/customize_colors"/> + + + + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 6eba1f0..721f249 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -3,6 +3,9 @@ Dankeschön Danke für deine Unterstützung!\nSchreibe uns doch an \n hello@simplemobiletools.com,\n wir hören dein Feedback und deine Vorschläge sehr gerne.\n\n(Bitte lasse diese App für mindestens einen Tag installiert, um eine automatische Rückerstattung zu unterbinden.) + + Hide the launcher icon + Eine kostenpflichtige App für alle, die uns unterstützen wollen. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index b235e9c..f72f784 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -3,6 +3,9 @@ Thank You Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-hi-rIN/strings.xml b/app/src/main/res/values-hi-rIN/strings.xml index b235e9c..f72f784 100644 --- a/app/src/main/res/values-hi-rIN/strings.xml +++ b/app/src/main/res/values-hi-rIN/strings.xml @@ -3,6 +3,9 @@ Thank You Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index b235e9c..f72f784 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -3,6 +3,9 @@ Thank You Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index b235e9c..f72f784 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -3,6 +3,9 @@ Thank You Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index f3734e6..d0830a6 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -3,6 +3,9 @@ Thank You Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index b235e9c..f72f784 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -3,6 +3,9 @@ Thank You Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index ddd6753..a33148f 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -3,6 +3,9 @@ Simple Thank You Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 583c1d5..e03c2cf 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -3,6 +3,9 @@ Obrigado Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 112a1d4..a5e0548 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -3,6 +3,9 @@ Спасибо Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 49eee4d..7c402ef 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -3,6 +3,9 @@ Ďakujem Ďakujem za našu podporu!\nNapíšte nám na \n hello@simplemobiletools.com,\n chceme počuť každú spätnú väzbu a odporúčania.\n\n(Prosím ponechajte si aplikáciu nainštalovanú aspoň 1 deň, predídete tak automatickému vráteniu peňazí) + + Skryť spúšťaciu ikonku + Platená aplikácia pre ľudí, ktorí nás chcú podporiť, veľa zatiaľ toho nerobí. diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index dc01a19..0d4705f 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -3,6 +3,9 @@ Tack Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index b235e9c..f72f784 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -3,6 +3,9 @@ Thank You Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b235e9c..f72f784 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,6 +3,9 @@ Thank You Thank you for supporting us!\nDrop us a line at \n hello@simplemobiletools.com,\n we\'d love to hear all your feedback and suggestions.\n\n(Please keep the app installed at least for a day, to avoid getting automatically refunded) + + Hide the launcher icon + A paid app for people who want to support us, not doing much yet.