Widgets: Show shadow if widget is completely opaque

This commit is contained in:
2020-08-18 08:09:12 -05:00
parent 16491c142a
commit 3554895a5d
6 changed files with 6 additions and 0 deletions

View File

@@ -81,6 +81,7 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
if (manager == null) throw new RuntimeException("manager is null");
if (options == null) throw new RuntimeException("options is null");
updateDependencies(context);
context.setTheme(R.style.WidgetTheme);
BaseWidget widget = getWidgetFromId(context, widgetId);

View File

@@ -40,6 +40,7 @@ class FrequencyWidget(
val widgetView = v as GraphWidgetView
widgetView.setTitle(habit.name)
widgetView.setBackgroundAlpha(preferedBackgroundAlpha)
if (preferedBackgroundAlpha >= 255) widgetView.setShadowAlpha(0x4f)
(widgetView.dataView as FrequencyChart).apply {
setFirstWeekday(firstWeekday)
setColor(PaletteUtils.getColor(context, habit.color))

View File

@@ -41,6 +41,7 @@ class HistoryWidget(
override fun refreshData(view: View) {
val widgetView = view as GraphWidgetView
widgetView.setBackgroundAlpha(preferedBackgroundAlpha)
if (preferedBackgroundAlpha >= 255) widgetView.setShadowAlpha(0x4f)
(widgetView.dataView as HistoryChart).apply {
setFirstWeekday(firstWeekday)
setColor(PaletteUtils.getColor(context, habit.color))

View File

@@ -46,6 +46,7 @@ class ScoreWidget(
val widgetView = view as GraphWidgetView
widgetView.setBackgroundAlpha(preferedBackgroundAlpha)
if (preferedBackgroundAlpha >= 255) widgetView.setShadowAlpha(0x4f)
(widgetView.dataView as ScoreChart).apply {
setIsTransparencyEnabled(true)
setBucketSize(size)

View File

@@ -40,6 +40,7 @@ class StreakWidget(
override fun refreshData(view: View) {
val widgetView = view as GraphWidgetView
widgetView.setBackgroundAlpha(preferedBackgroundAlpha)
if (preferedBackgroundAlpha >= 255) widgetView.setShadowAlpha(0x4f)
(widgetView.dataView as StreakChart).apply {
setColor(PaletteUtils.getColor(context, habit.color))
setStreaks(habit.streaks.getBest(maxStreakCount))

View File

@@ -40,6 +40,7 @@ class TargetWidget(
override fun refreshData(view: View) {
val widgetView = view as GraphWidgetView
widgetView.setBackgroundAlpha(preferedBackgroundAlpha)
if (preferedBackgroundAlpha >= 255) widgetView.setShadowAlpha(0x4f)
val chart = (widgetView.dataView as TargetChart)
with(TargetCard.RefreshTask(context, habit, prefs.firstWeekday, chart, null)) {
onPreExecute()