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