diff --git a/app/build.gradle b/app/build.gradle index 49afe195..8e18e6a6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,7 +43,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:4.0.14' + implementation 'com.simplemobiletools:commons:4.0.15' implementation 'me.grantland:autofittextview:0.2.1' testImplementation 'junit:junit:4.12' diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/SettingsActivity.kt index e40be61c..34a73c9f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/SettingsActivity.kt @@ -1,10 +1,12 @@ package com.simplemobiletools.calculator.activities +import android.content.Intent import android.os.Bundle import com.simplemobiletools.calculator.R import com.simplemobiletools.calculator.extensions.config import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.updateTextColors +import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS import kotlinx.android.synthetic.main.activity_settings.* import java.util.* @@ -23,6 +25,7 @@ class SettingsActivity : SimpleActivity() { setupAvoidWhatsNew() setupVibrate() setupPreventPhoneFromSleeping() + setupCustomizeWidgetColors() updateTextColors(settings_scrollview) } @@ -65,4 +68,13 @@ class SettingsActivity : SimpleActivity() { config.preventPhoneFromSleeping = settings_prevent_phone_from_sleeping.isChecked } } + + private fun setupCustomizeWidgetColors() { + settings_customize_widget_colors_holder.setOnClickListener { + Intent(this, WidgetConfigureActivity::class.java).apply { + putExtra(IS_CUSTOMIZING_COLORS, true) + startActivity(this) + } + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/WidgetConfigureActivity.kt index cd1808ac..c133cfa9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/WidgetConfigureActivity.kt @@ -16,6 +16,7 @@ import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.beVisible import com.simplemobiletools.commons.extensions.setBackgroundColor import com.simplemobiletools.commons.extensions.setFillWithStroke +import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.widget_config.* @@ -25,6 +26,7 @@ class WidgetConfigureActivity : SimpleActivity() { private var mWidgetId = 0 private var mTextColor = 0 private var mBgAlpha = 0f + private var mIsCustomizingColors = false public override fun onCreate(savedInstanceState: Bundle?) { useDynamicTheme = false @@ -33,12 +35,12 @@ class WidgetConfigureActivity : SimpleActivity() { setContentView(R.layout.widget_config) initVariables() - val extras = intent.extras - if (extras != null) - mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID) + mIsCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false + mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID - if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) + if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID && !mIsCustomizingColors) { finish() + } config_save.setOnClickListener { saveConfig() } config_bg_color.setOnClickListener { pickBackgroundColor() } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 04eb1571..3bad778d 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -33,6 +33,28 @@ + + + + + +