From e809269e5807b61fc395c80751cef530fef02394 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 20 May 2022 15:24:42 +0200 Subject: [PATCH] require Simple Thank You for widgets --- .../WidgetBrightDisplayConfigureActivity.kt | 19 +++++++++++++++++++ .../WidgetTorchConfigureActivity.kt | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetBrightDisplayConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetBrightDisplayConfigureActivity.kt index a762560..9b1998c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetBrightDisplayConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetBrightDisplayConfigureActivity.kt @@ -7,6 +7,7 @@ import android.graphics.Color import android.os.Bundle import android.widget.SeekBar import com.simplemobiletools.commons.dialogs.ColorPickerDialog +import com.simplemobiletools.commons.dialogs.WidgetLockedDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS import com.simplemobiletools.flashlight.R @@ -19,6 +20,7 @@ class WidgetBrightDisplayConfigureActivity : SimpleActivity() { private var mWidgetId = 0 private var mWidgetColor = 0 private var mWidgetColorWithoutTransparency = 0 + private var mWidgetLockedDialog: WidgetLockedDialog? = null public override fun onCreate(savedInstanceState: Bundle?) { useDynamicTheme = false @@ -39,6 +41,23 @@ class WidgetBrightDisplayConfigureActivity : SimpleActivity() { val primaryColor = getProperPrimaryColor() config_widget_seekbar.setColors(getProperTextColor(), primaryColor, primaryColor) + + if (!isCustomizingColors && !isOrWasThankYouInstalled()) { + mWidgetLockedDialog = WidgetLockedDialog(this) { + if (!isOrWasThankYouInstalled()) { + finish() + } + } + } + } + + override fun onResume() { + super.onResume() + window.decorView.setBackgroundColor(0) + + if (mWidgetLockedDialog != null && isOrWasThankYouInstalled()) { + mWidgetLockedDialog?.dismissDialog() + } } private fun initVariables() { diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetTorchConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetTorchConfigureActivity.kt index a6f665c..5dece9a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetTorchConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetTorchConfigureActivity.kt @@ -7,6 +7,7 @@ import android.graphics.Color import android.os.Bundle import android.widget.SeekBar import com.simplemobiletools.commons.dialogs.ColorPickerDialog +import com.simplemobiletools.commons.dialogs.WidgetLockedDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS import com.simplemobiletools.flashlight.R @@ -20,6 +21,7 @@ class WidgetTorchConfigureActivity : SimpleActivity() { private var mWidgetId = 0 private var mWidgetColor = 0 private var mWidgetColorWithoutTransparency = 0 + private var mWidgetLockedDialog: WidgetLockedDialog? = null public override fun onCreate(savedInstanceState: Bundle?) { useDynamicTheme = false @@ -40,6 +42,23 @@ class WidgetTorchConfigureActivity : SimpleActivity() { val primaryColor = getProperPrimaryColor() config_widget_seekbar.setColors(getProperTextColor(), primaryColor, primaryColor) + + if (!isCustomizingColors && !isOrWasThankYouInstalled()) { + mWidgetLockedDialog = WidgetLockedDialog(this) { + if (!isOrWasThankYouInstalled()) { + finish() + } + } + } + } + + override fun onResume() { + super.onResume() + window.decorView.setBackgroundColor(0) + + if (mWidgetLockedDialog != null && isOrWasThankYouInstalled()) { + mWidgetLockedDialog?.dismissDialog() + } } private fun initVariables() {