mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-06-05 21:49:13 +02:00
use the TextColor for setting text color
This commit is contained in:
@@ -39,7 +39,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.simplemobiletools:commons:2.35.5'
|
compile 'com.simplemobiletools:commons:2.35.6'
|
||||||
compile 'me.grantland:autofittextview:0.2.1'
|
compile 'me.grantland:autofittextview:0.2.1'
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
||||||
|
|
||||||
|
@@ -9,8 +9,10 @@ import android.view.Menu
|
|||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import com.simplemobiletools.calculator.BuildConfig
|
import com.simplemobiletools.calculator.BuildConfig
|
||||||
import com.simplemobiletools.calculator.R
|
import com.simplemobiletools.calculator.R
|
||||||
|
import com.simplemobiletools.calculator.extensions.config
|
||||||
import com.simplemobiletools.calculator.helpers.*
|
import com.simplemobiletools.calculator.helpers.*
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import com.simplemobiletools.commons.extensions.value
|
import com.simplemobiletools.commons.extensions.value
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_AUTOFITTEXTVIEW
|
import com.simplemobiletools.commons.helpers.LICENSE_AUTOFITTEXTVIEW
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_ESPRESSO
|
import com.simplemobiletools.commons.helpers.LICENSE_ESPRESSO
|
||||||
@@ -20,6 +22,8 @@ import kotlinx.android.synthetic.main.activity_main.*
|
|||||||
import me.grantland.widget.AutofitHelper
|
import me.grantland.widget.AutofitHelper
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), Calculator {
|
class MainActivity : SimpleActivity(), Calculator {
|
||||||
|
private var mStoredTextColor = 0
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private lateinit var mCalc: CalculatorImpl
|
private lateinit var mCalc: CalculatorImpl
|
||||||
}
|
}
|
||||||
@@ -42,7 +46,7 @@ class MainActivity : SimpleActivity(), Calculator {
|
|||||||
btn_clear.setOnClickListener { mCalc.handleClear() }
|
btn_clear.setOnClickListener { mCalc.handleClear() }
|
||||||
btn_clear.setOnLongClickListener { mCalc.handleReset(); true }
|
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) }
|
it.setOnClickListener { mCalc.numpadClicked(it.id) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +59,18 @@ class MainActivity : SimpleActivity(), Calculator {
|
|||||||
AutofitHelper.create(formula)
|
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 {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu, menu)
|
menuInflater.inflate(R.menu.menu, menu)
|
||||||
return true
|
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)
|
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 {
|
private fun copyToClipboard(copyResult: Boolean): Boolean {
|
||||||
var value = formula.value
|
var value = formula.value
|
||||||
if (copyResult) {
|
if (copyResult) {
|
||||||
|
@@ -2,6 +2,7 @@ package com.simplemobiletools.calculator.activities
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.simplemobiletools.calculator.R
|
import com.simplemobiletools.calculator.R
|
||||||
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
@@ -9,8 +10,13 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
setContentView(R.layout.activity_settings)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
|
||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
|
updateTextColors(settings_scrollview)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCustomizeColors() {
|
private fun setupCustomizeColors() {
|
||||||
|
@@ -6,9 +6,10 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".activities.MainActivity">
|
tools:context=".activities.MainActivity"
|
||||||
|
tools:ignore="HardcodedText">
|
||||||
|
|
||||||
<TextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/formula"
|
android:id="@+id/formula"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
android:paddingRight="@dimen/activity_margin"
|
android:paddingRight="@dimen/activity_margin"
|
||||||
android:textSize="@dimen/actionbar_text_size"/>
|
android:textSize="@dimen/actionbar_text_size"/>
|
||||||
|
|
||||||
<TextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/result"
|
android:id="@+id/result"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -39,7 +40,7 @@
|
|||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_modulo"
|
android:id="@+id/btn_modulo"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -49,7 +50,7 @@
|
|||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:textSize="@dimen/extra_big_text_size"/>
|
android:textSize="@dimen/extra_big_text_size"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_power"
|
android:id="@+id/btn_power"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -57,7 +58,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="^"/>
|
android:text="^"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_root"
|
android:id="@+id/btn_root"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -65,7 +66,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="√"/>
|
android:text="√"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_clear"
|
android:id="@+id/btn_clear"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -73,7 +74,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="C"/>
|
android:text="C"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_reset"
|
android:id="@+id/btn_reset"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -89,7 +90,7 @@
|
|||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_7"
|
android:id="@+id/btn_7"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -97,7 +98,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="7"/>
|
android:text="7"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_8"
|
android:id="@+id/btn_8"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -105,7 +106,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="8"/>
|
android:text="8"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_9"
|
android:id="@+id/btn_9"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -113,7 +114,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="9"/>
|
android:text="9"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_divide"
|
android:id="@+id/btn_divide"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -128,7 +129,7 @@
|
|||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_4"
|
android:id="@+id/btn_4"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -136,7 +137,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="4"/>
|
android:text="4"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_5"
|
android:id="@+id/btn_5"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -144,7 +145,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="5"/>
|
android:text="5"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_6"
|
android:id="@+id/btn_6"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -152,7 +153,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="6"/>
|
android:text="6"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_multiply"
|
android:id="@+id/btn_multiply"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -167,7 +168,7 @@
|
|||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_1"
|
android:id="@+id/btn_1"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -175,7 +176,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="1"/>
|
android:text="1"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_2"
|
android:id="@+id/btn_2"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -183,7 +184,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="2"/>
|
android:text="2"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_3"
|
android:id="@+id/btn_3"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -191,7 +192,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="3"/>
|
android:text="3"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_minus"
|
android:id="@+id/btn_minus"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -206,7 +207,7 @@
|
|||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_0"
|
android:id="@+id/btn_0"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -214,7 +215,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="0"/>
|
android:text="0"/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_decimal"
|
android:id="@+id/btn_decimal"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -222,7 +223,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="."/>
|
android:text="."/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_equals"
|
android:id="@+id/btn_equals"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -230,7 +231,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="="/>
|
android:text="="/>
|
||||||
|
|
||||||
<Button
|
<com.simplemobiletools.commons.views.MyButton
|
||||||
android:id="@+id/btn_plus"
|
android:id="@+id/btn_plus"
|
||||||
style="@style/MyButton"
|
style="@style/MyButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
<style name="AppTheme" parent="AppTheme.Base"/>
|
<style name="AppTheme" parent="AppTheme.Base"/>
|
||||||
|
|
||||||
<style name="MyButton" parent="Widget.AppCompat.Button">
|
<style name="MyButton" parent="Widget.AppCompat.Button">
|
||||||
<item name="android:textColor">@color/color_primary</item>
|
|
||||||
<item name="android:background">@drawable/button</item>
|
<item name="android:background">@drawable/button</item>
|
||||||
<item name="android:textSize">@dimen/button_text_size</item>
|
<item name="android:textSize">@dimen/button_text_size</item>
|
||||||
<item name="android:fontFamily">sans-serif-light</item>
|
<item name="android:fontFamily">sans-serif-light</item>
|
||||||
|
Reference in New Issue
Block a user