mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-03-01 09:47:49 +01:00
cleaning up some widget config code
This commit is contained in:
parent
98a578ca6d
commit
fc373024bf
@ -21,12 +21,11 @@ import kotlinx.android.synthetic.main.activity_main.*
|
|||||||
import kotlinx.android.synthetic.main.widget_config.*
|
import kotlinx.android.synthetic.main.widget_config.*
|
||||||
|
|
||||||
class WidgetConfigureActivity : SimpleActivity() {
|
class WidgetConfigureActivity : SimpleActivity() {
|
||||||
private var mBgColor = 0
|
|
||||||
private var mBgColorWithoutTransparency = 0
|
|
||||||
private var mWidgetId = 0
|
|
||||||
private var mTextColor = 0
|
|
||||||
private var mBgAlpha = 0f
|
private var mBgAlpha = 0f
|
||||||
private var mIsCustomizingColors = false
|
private var mWidgetId = 0
|
||||||
|
private var mBgColor = 0
|
||||||
|
private var mTextColor = 0
|
||||||
|
private var mBgColorWithoutTransparency = 0
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
useDynamicTheme = false
|
useDynamicTheme = false
|
||||||
@ -35,7 +34,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||||||
setContentView(R.layout.widget_config)
|
setContentView(R.layout.widget_config)
|
||||||
initVariables()
|
initVariables()
|
||||||
|
|
||||||
mIsCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
|
val mIsCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
|
||||||
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
|
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
|
||||||
|
|
||||||
if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID && !mIsCustomizingColors) {
|
if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID && !mIsCustomizingColors) {
|
||||||
@ -49,12 +48,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun initVariables() {
|
private fun initVariables() {
|
||||||
mBgColor = config.widgetBgColor
|
mBgColor = config.widgetBgColor
|
||||||
if (mBgColor == 1) {
|
|
||||||
mBgColor = Color.BLACK
|
|
||||||
mBgAlpha = .2f
|
|
||||||
} else {
|
|
||||||
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
|
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
|
||||||
}
|
|
||||||
|
|
||||||
btn_reset.beVisible()
|
btn_reset.beVisible()
|
||||||
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
||||||
@ -102,8 +96,8 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||||||
private fun updateBackgroundColor() {
|
private fun updateBackgroundColor() {
|
||||||
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
||||||
config_calc.setBackgroundColor(mBgColor)
|
config_calc.setBackgroundColor(mBgColor)
|
||||||
config_bg_color.setFillWithStroke(mBgColor, Color.BLACK)
|
|
||||||
config_save.setBackgroundColor(mBgColor)
|
config_save.setBackgroundColor(mBgColor)
|
||||||
|
config_bg_color.setFillWithStroke(mBgColor, Color.BLACK)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTextColor() {
|
private fun updateTextColor() {
|
||||||
@ -145,12 +139,8 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||||||
updateBackgroundColor()
|
updateBackgroundColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
override fun onStartTrackingTouch(seekBar: SeekBar) {}
|
||||||
|
|
||||||
}
|
override fun onStopTrackingTouch(seekBar: SeekBar) {}
|
||||||
|
|
||||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,6 @@ class MyWidgetProvider : AppWidgetProvider(), Calculator {
|
|||||||
setupIntent(context, views, PERCENT, R.id.btn_percent)
|
setupIntent(context, views, PERCENT, R.id.btn_percent)
|
||||||
setupIntent(context, views, POWER, R.id.btn_power)
|
setupIntent(context, views, POWER, R.id.btn_power)
|
||||||
setupIntent(context, views, ROOT, R.id.btn_root)
|
setupIntent(context, views, ROOT, R.id.btn_root)
|
||||||
setupIntent(context, views, FACTORIAL, R.id.btn_factorial )
|
|
||||||
setupIntent(context, views, CLEAR, R.id.btn_clear)
|
setupIntent(context, views, CLEAR, R.id.btn_clear)
|
||||||
setupIntent(context, views, RESET, R.id.btn_reset)
|
setupIntent(context, views, RESET, R.id.btn_reset)
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ class MyWidgetProvider : AppWidgetProvider(), Calculator {
|
|||||||
|
|
||||||
private fun updateTextColors(views: RemoteViews, color: Int) {
|
private fun updateTextColors(views: RemoteViews, color: Int) {
|
||||||
val viewIds = intArrayOf(R.id.formula, R.id.result, R.id.btn_0, R.id.btn_1, R.id.btn_2, R.id.btn_3, R.id.btn_4, R.id.btn_5, R.id.btn_6,
|
val viewIds = intArrayOf(R.id.formula, R.id.result, R.id.btn_0, R.id.btn_1, R.id.btn_2, R.id.btn_3, R.id.btn_4, R.id.btn_5, R.id.btn_6,
|
||||||
R.id.btn_7, R.id.btn_8, R.id.btn_9, R.id.btn_percent, R.id.btn_power, R.id.btn_root, R.id.btn_factorial, R.id.btn_clear, R.id.btn_reset, R.id.btn_divide,
|
R.id.btn_7, R.id.btn_8, R.id.btn_9, R.id.btn_percent, R.id.btn_power, R.id.btn_root, R.id.btn_clear, R.id.btn_reset, R.id.btn_divide,
|
||||||
R.id.btn_multiply, R.id.btn_minus, R.id.btn_plus, R.id.btn_decimal, R.id.btn_equals)
|
R.id.btn_multiply, R.id.btn_minus, R.id.btn_plus, R.id.btn_decimal, R.id.btn_equals)
|
||||||
|
|
||||||
for (i in viewIds) {
|
for (i in viewIds) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user