diff --git a/app/build.gradle b/app/build.gradle index ecda4e89..d8fa272f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,7 +39,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.35.5' + compile 'com.simplemobiletools:commons:2.35.6' compile 'me.grantland:autofittextview:0.2.1' compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt index f3241176..2d3b260c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt @@ -9,8 +9,10 @@ import android.view.Menu import android.view.MenuItem import com.simplemobiletools.calculator.BuildConfig import com.simplemobiletools.calculator.R +import com.simplemobiletools.calculator.extensions.config import com.simplemobiletools.calculator.helpers.* import com.simplemobiletools.commons.extensions.toast +import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.helpers.LICENSE_AUTOFITTEXTVIEW import com.simplemobiletools.commons.helpers.LICENSE_ESPRESSO @@ -20,6 +22,8 @@ import kotlinx.android.synthetic.main.activity_main.* import me.grantland.widget.AutofitHelper class MainActivity : SimpleActivity(), Calculator { + private var mStoredTextColor = 0 + companion object { private lateinit var mCalc: CalculatorImpl } @@ -42,7 +46,7 @@ class MainActivity : SimpleActivity(), Calculator { btn_clear.setOnClickListener { mCalc.handleClear() } btn_clear.setOnLongClickListener { mCalc.handleReset(); true } - arrayOf(btn_decimal, btn_0, btn_1, btn_2, btn_3, btn_4, btn_5, btn_6, btn_7, btn_8, btn_9).forEach { + getButtonIds().forEach { it.setOnClickListener { mCalc.numpadClicked(it.id) } } @@ -55,6 +59,18 @@ class MainActivity : SimpleActivity(), Calculator { AutofitHelper.create(formula) } + override fun onResume() { + super.onResume() + if (mStoredTextColor != config.textColor) { + updateTextColors(calculator_holder) + } + } + + override fun onPause() { + super.onPause() + mStoredTextColor = config.textColor + } + override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu, menu) return true @@ -77,6 +93,8 @@ class MainActivity : SimpleActivity(), Calculator { startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_AUTOFITTEXTVIEW or LICENSE_ROBOLECTRIC or LICENSE_ESPRESSO, BuildConfig.VERSION_NAME) } + private fun getButtonIds() = arrayOf(btn_decimal, btn_0, btn_1, btn_2, btn_3, btn_4, btn_5, btn_6, btn_7, btn_8, btn_9) + private fun copyToClipboard(copyResult: Boolean): Boolean { var value = formula.value if (copyResult) { 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 2c323acc..50895cdd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/SettingsActivity.kt @@ -2,6 +2,7 @@ package com.simplemobiletools.calculator.activities import android.os.Bundle import com.simplemobiletools.calculator.R +import com.simplemobiletools.commons.extensions.updateTextColors import kotlinx.android.synthetic.main.activity_settings.* class SettingsActivity : SimpleActivity() { @@ -9,8 +10,13 @@ class SettingsActivity : SimpleActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_settings) + } + + override fun onResume() { + super.onResume() setupCustomizeColors() + updateTextColors(settings_scrollview) } private fun setupCustomizeColors() { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index c3667c53..5638f0f0 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,9 +6,10 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - tools:context=".activities.MainActivity"> + tools:context=".activities.MainActivity" + tools:ignore="HardcodedText"> - - -