mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-02-02 03:26:48 +01:00
add a Settings button for customizing widget colors without recreating them
This commit is contained in:
parent
2f42edd2b1
commit
9c4f4d242a
@ -1,5 +1,6 @@
|
||||
package com.simplemobiletools.clock.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
@ -7,6 +8,7 @@ import com.simplemobiletools.clock.extensions.updateWidgets
|
||||
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_ALARM_REMINDER_SECS
|
||||
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_TIMER_REMINDER_SECS
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||
import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
@ -33,6 +35,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupVibrate()
|
||||
setupTimerMaxReminder()
|
||||
setupUseTextShadow()
|
||||
setupCustomizeWidgetColors()
|
||||
updateTextColors(settings_holder)
|
||||
setupSectionColors()
|
||||
}
|
||||
@ -169,4 +172,13 @@ class SettingsActivity : SimpleActivity() {
|
||||
private fun updateTimerMaxReminderText() {
|
||||
settings_timer_max_reminder.text = formatSecondsToTimeString(config.timerMaxReminderSecs)
|
||||
}
|
||||
|
||||
private fun setupCustomizeWidgetColors() {
|
||||
settings_customize_widget_colors_holder.setOnClickListener {
|
||||
Intent(this, WidgetDateTimeConfigureActivity::class.java).apply {
|
||||
putExtra(IS_CUSTOMIZING_COLORS, true)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import com.simplemobiletools.clock.helpers.MyWidgetDateTimeProvider
|
||||
import com.simplemobiletools.clock.helpers.getPassedSeconds
|
||||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
import com.simplemobiletools.commons.extensions.adjustAlpha
|
||||
import com.simplemobiletools.commons.extensions.setFillWithStroke
|
||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||
import kotlinx.android.synthetic.main.widget_config_date_time.*
|
||||
import java.util.*
|
||||
|
||||
@ -24,6 +26,7 @@ class WidgetDateTimeConfigureActivity : SimpleActivity() {
|
||||
private var mBgColor = 0
|
||||
private var mTextColorWithoutTransparency = 0
|
||||
private var mTextColor = 0
|
||||
private var mIsCustomizingColors = false
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
useDynamicTheme = false
|
||||
@ -32,12 +35,12 @@ class WidgetDateTimeConfigureActivity : SimpleActivity() {
|
||||
setContentView(R.layout.widget_config_date_time)
|
||||
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() }
|
||||
@ -123,7 +126,7 @@ class WidgetDateTimeConfigureActivity : SimpleActivity() {
|
||||
|
||||
private fun updateColors() {
|
||||
mTextColor = mTextColorWithoutTransparency
|
||||
config_text_color.setBackgroundColor(mTextColor)
|
||||
config_text_color.setFillWithStroke(mTextColor, Color.BLACK)
|
||||
config_save.setTextColor(mTextColor)
|
||||
config_time.setTextColor(mTextColor)
|
||||
config_date.setTextColor(mTextColor)
|
||||
@ -131,7 +134,7 @@ class WidgetDateTimeConfigureActivity : SimpleActivity() {
|
||||
|
||||
private fun updateBgColor() {
|
||||
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
||||
config_bg_color.setBackgroundColor(mBgColor)
|
||||
config_bg_color.setFillWithStroke(mBgColor, Color.BLACK)
|
||||
config_save.setBackgroundColor(mBgColor)
|
||||
config_date_time_wrapper.setBackgroundColor(mBgColor)
|
||||
}
|
||||
|
@ -432,5 +432,27 @@
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/use_text_shadow"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_customize_widget_colors_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_customize_widget_colors_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/customize_widget_colors"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
@ -35,7 +35,7 @@
|
||||
tools:text="Mon, 1 January"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<Button
|
||||
<ImageView
|
||||
android:id="@+id/config_bg_color"
|
||||
android:layout_width="@dimen/widget_colorpicker_size"
|
||||
android:layout_height="@dimen/widget_colorpicker_size"
|
||||
@ -59,7 +59,7 @@
|
||||
android:paddingRight="@dimen/activity_margin"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<Button
|
||||
<ImageView
|
||||
android:id="@+id/config_text_color"
|
||||
android:layout_width="@dimen/widget_colorpicker_size"
|
||||
android:layout_height="@dimen/widget_colorpicker_size"
|
||||
|
Loading…
x
Reference in New Issue
Block a user