feat: visual representation of selected widget colors
This commit is contained in:
parent
fbbbf41595
commit
ea678ef55e
4 changed files with 38 additions and 37 deletions
|
@ -4,6 +4,7 @@ import android.app.Activity
|
|||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
|
@ -14,6 +15,7 @@ import ani.dantotsu.databinding.StatisticsWidgetConfigureBinding
|
|||
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.widgets.upcoming.UpcomingWidget
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import eltos.simpledialogfragment.SimpleDialog
|
||||
import eltos.simpledialogfragment.color.SimpleColorDialog
|
||||
|
||||
|
@ -59,16 +61,12 @@ class ProfileStatsConfigure : AppCompatActivity(),
|
|||
setContentView(binding.root)
|
||||
|
||||
val prefs = getSharedPreferences(ProfileStatsWidget.PREFS_NAME, Context.MODE_PRIVATE)
|
||||
|
||||
val topBackground = prefs.getInt(ProfileStatsWidget.PREF_BACKGROUND_COLOR, Color.parseColor("#80000000"))
|
||||
(binding.topBackgroundButton as MaterialButton).iconTint = ColorStateList.valueOf(topBackground)
|
||||
binding.topBackgroundButton.setOnClickListener {
|
||||
val tag = ProfileStatsWidget.PREF_BACKGROUND_COLOR
|
||||
SimpleColorDialog().title(R.string.custom_theme)
|
||||
.colorPreset(
|
||||
prefs.getInt(
|
||||
ProfileStatsWidget.PREF_BACKGROUND_COLOR,
|
||||
Color.parseColor("#80000000")
|
||||
)
|
||||
)
|
||||
.colorPreset(topBackground)
|
||||
.colors(
|
||||
this@ProfileStatsConfigure,
|
||||
SimpleColorDialog.MATERIAL_COLOR_PALLET
|
||||
|
@ -81,10 +79,12 @@ class ProfileStatsConfigure : AppCompatActivity(),
|
|||
.neg()
|
||||
.show(this@ProfileStatsConfigure, tag)
|
||||
}
|
||||
val bottomBackground = prefs.getInt(ProfileStatsWidget.PREF_BACKGROUND_FADE, Color.parseColor("#00000000"))
|
||||
(binding.bottomBackgroundButton as MaterialButton).iconTint = ColorStateList.valueOf(bottomBackground)
|
||||
binding.bottomBackgroundButton.setOnClickListener {
|
||||
val tag = ProfileStatsWidget.PREF_BACKGROUND_FADE
|
||||
SimpleColorDialog().title(R.string.custom_theme)
|
||||
.colorPreset(prefs.getInt(UpcomingWidget.PREF_BACKGROUND_FADE, Color.parseColor("#00000000")))
|
||||
.colorPreset(bottomBackground)
|
||||
.colors(
|
||||
this@ProfileStatsConfigure,
|
||||
SimpleColorDialog.MATERIAL_COLOR_PALLET
|
||||
|
@ -97,10 +97,12 @@ class ProfileStatsConfigure : AppCompatActivity(),
|
|||
.neg()
|
||||
.show(this@ProfileStatsConfigure, tag)
|
||||
}
|
||||
val titleColor = prefs.getInt(ProfileStatsWidget.PREF_TITLE_TEXT_COLOR, Color.WHITE)
|
||||
(binding.titleColorButton as MaterialButton).iconTint = ColorStateList.valueOf(titleColor)
|
||||
binding.titleColorButton.setOnClickListener {
|
||||
val tag = ProfileStatsWidget.PREF_TITLE_TEXT_COLOR
|
||||
SimpleColorDialog().title(R.string.custom_theme)
|
||||
.colorPreset(prefs.getInt(ProfileStatsWidget.PREF_TITLE_TEXT_COLOR, Color.WHITE))
|
||||
.colorPreset(titleColor)
|
||||
.colors(
|
||||
this@ProfileStatsConfigure,
|
||||
SimpleColorDialog.MATERIAL_COLOR_PALLET
|
||||
|
@ -113,10 +115,12 @@ class ProfileStatsConfigure : AppCompatActivity(),
|
|||
.neg()
|
||||
.show(this@ProfileStatsConfigure, tag)
|
||||
}
|
||||
val statsColor = prefs.getInt(ProfileStatsWidget.PREF_STATS_TEXT_COLOR, Color.WHITE)
|
||||
(binding.statsColorButton as MaterialButton).iconTint = ColorStateList.valueOf(statsColor)
|
||||
binding.statsColorButton.setOnClickListener {
|
||||
val tag = ProfileStatsWidget.PREF_STATS_TEXT_COLOR
|
||||
SimpleColorDialog().title(R.string.custom_theme)
|
||||
.colorPreset(prefs.getInt(ProfileStatsWidget.PREF_STATS_TEXT_COLOR, Color.WHITE))
|
||||
.colorPreset(statsColor)
|
||||
.colors(
|
||||
this@ProfileStatsConfigure,
|
||||
SimpleColorDialog.MATERIAL_COLOR_PALLET
|
||||
|
@ -156,8 +160,6 @@ class ProfileStatsConfigure : AppCompatActivity(),
|
|||
)
|
||||
}
|
||||
|
||||
// Possibly consider sorting the items or configuring colors
|
||||
|
||||
// If this activity was started with an intent without an app widget ID, finish with an error.
|
||||
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
|
||||
finish()
|
||||
|
|
|
@ -3,6 +3,7 @@ package ani.dantotsu.widgets.upcoming
|
|||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
|
@ -11,6 +12,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.UpcomingWidgetConfigureBinding
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import eltos.simpledialogfragment.SimpleDialog
|
||||
import eltos.simpledialogfragment.color.SimpleColorDialog
|
||||
|
||||
|
@ -46,16 +48,12 @@ class UpcomingWidgetConfigureActivity : AppCompatActivity(),
|
|||
binding = UpcomingWidgetConfigureBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
val prefs = getSharedPreferences(UpcomingWidget.PREFS_NAME, Context.MODE_PRIVATE)
|
||||
|
||||
val topBackground = prefs.getInt(UpcomingWidget.PREF_BACKGROUND_COLOR, Color.parseColor("#80000000"))
|
||||
(binding.topBackgroundButton as MaterialButton).iconTint = ColorStateList.valueOf(topBackground)
|
||||
binding.topBackgroundButton.setOnClickListener {
|
||||
val tag = UpcomingWidget.PREF_BACKGROUND_COLOR
|
||||
SimpleColorDialog().title(R.string.custom_theme)
|
||||
.colorPreset(
|
||||
prefs.getInt(
|
||||
UpcomingWidget.PREF_BACKGROUND_COLOR,
|
||||
Color.parseColor("#80000000")
|
||||
)
|
||||
)
|
||||
.colorPreset(topBackground)
|
||||
.colors(
|
||||
this@UpcomingWidgetConfigureActivity,
|
||||
SimpleColorDialog.MATERIAL_COLOR_PALLET
|
||||
|
@ -68,10 +66,12 @@ class UpcomingWidgetConfigureActivity : AppCompatActivity(),
|
|||
.neg()
|
||||
.show(this@UpcomingWidgetConfigureActivity, tag)
|
||||
}
|
||||
val bottomBackground = prefs.getInt(UpcomingWidget.PREF_BACKGROUND_FADE, Color.parseColor("#00000000"))
|
||||
(binding.bottomBackgroundButton as MaterialButton).iconTint = ColorStateList.valueOf(bottomBackground)
|
||||
binding.bottomBackgroundButton.setOnClickListener {
|
||||
val tag = UpcomingWidget.PREF_BACKGROUND_FADE
|
||||
SimpleColorDialog().title(R.string.custom_theme)
|
||||
.colorPreset(prefs.getInt(UpcomingWidget.PREF_BACKGROUND_FADE, Color.parseColor("#00000000")))
|
||||
.colorPreset(bottomBackground)
|
||||
.colors(
|
||||
this@UpcomingWidgetConfigureActivity,
|
||||
SimpleColorDialog.MATERIAL_COLOR_PALLET
|
||||
|
@ -84,10 +84,12 @@ class UpcomingWidgetConfigureActivity : AppCompatActivity(),
|
|||
.neg()
|
||||
.show(this@UpcomingWidgetConfigureActivity, tag)
|
||||
}
|
||||
val titleTextColor = prefs.getInt(UpcomingWidget.PREF_TITLE_TEXT_COLOR, Color.WHITE)
|
||||
(binding.titleColorButton as MaterialButton).iconTint = ColorStateList.valueOf(titleTextColor)
|
||||
binding.titleColorButton.setOnClickListener {
|
||||
val tag = UpcomingWidget.PREF_TITLE_TEXT_COLOR
|
||||
SimpleColorDialog().title(R.string.custom_theme)
|
||||
.colorPreset(prefs.getInt(UpcomingWidget.PREF_TITLE_TEXT_COLOR, Color.WHITE))
|
||||
.colorPreset(titleTextColor)
|
||||
.colors(
|
||||
this@UpcomingWidgetConfigureActivity,
|
||||
SimpleColorDialog.MATERIAL_COLOR_PALLET
|
||||
|
@ -99,15 +101,12 @@ class UpcomingWidgetConfigureActivity : AppCompatActivity(),
|
|||
.neg()
|
||||
.show(this@UpcomingWidgetConfigureActivity, tag)
|
||||
}
|
||||
val countdownTextColor = prefs.getInt(UpcomingWidget.PREF_COUNTDOWN_TEXT_COLOR, Color.WHITE)
|
||||
(binding.countdownColorButton as MaterialButton).iconTint = ColorStateList.valueOf(countdownTextColor)
|
||||
binding.countdownColorButton.setOnClickListener {
|
||||
val tag = UpcomingWidget.PREF_COUNTDOWN_TEXT_COLOR
|
||||
SimpleColorDialog().title(R.string.custom_theme)
|
||||
.colorPreset(
|
||||
prefs.getInt(
|
||||
UpcomingWidget.PREF_COUNTDOWN_TEXT_COLOR,
|
||||
Color.WHITE
|
||||
)
|
||||
)
|
||||
.colorPreset(countdownTextColor)
|
||||
.colors(
|
||||
this@UpcomingWidgetConfigureActivity,
|
||||
SimpleColorDialog.MATERIAL_COLOR_PALLET
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:checked="false"
|
||||
android:drawableStart="@drawable/ic_round_new_releases_24"
|
||||
android:drawableStart="@drawable/ic_palette"
|
||||
android:drawablePadding="16dp"
|
||||
android:elegantTextHeight="true"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
|
@ -52,7 +52,7 @@
|
|||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_color_picker_24"
|
||||
app:icon="@drawable/shape_corner_16dp"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
@ -76,7 +76,7 @@
|
|||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_color_picker_24"
|
||||
app:icon="@drawable/shape_corner_16dp"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
@ -100,7 +100,7 @@
|
|||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_color_picker_24"
|
||||
app:icon="@drawable/shape_corner_16dp"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
@ -124,7 +124,7 @@
|
|||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_color_picker_24"
|
||||
app:icon="@drawable/shape_corner_16dp"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:checked="false"
|
||||
android:drawableStart="@drawable/ic_round_new_releases_24"
|
||||
android:drawableStart="@drawable/ic_palette"
|
||||
android:drawablePadding="16dp"
|
||||
android:elegantTextHeight="true"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
|
@ -51,7 +51,7 @@
|
|||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_color_picker_24"
|
||||
app:icon="@drawable/shape_corner_16dp"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
@ -75,7 +75,7 @@
|
|||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_color_picker_24"
|
||||
app:icon="@drawable/shape_corner_16dp"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
@ -99,7 +99,7 @@
|
|||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_color_picker_24"
|
||||
app:icon="@drawable/shape_corner_16dp"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
@ -123,7 +123,7 @@
|
|||
android:textAllCaps="false"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
app:cornerRadius="0dp"
|
||||
app:icon="@drawable/ic_round_color_picker_24"
|
||||
app:icon="@drawable/shape_corner_16dp"
|
||||
app:iconPadding="16dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="?attr/colorPrimary" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue