Use TextClock for date widget

This commit is contained in:
Naveen 2022-05-25 15:26:22 +05:30
parent dd218849c9
commit f32aeb80d5
2 changed files with 21 additions and 18 deletions

View file

@ -12,7 +12,6 @@ import com.simplemobiletools.calendar.pro.activities.SplashActivity
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.getLaunchIntent
import com.simplemobiletools.commons.extensions.setText
class MyWidgetDateProvider : AppWidgetProvider() {
private val OPEN_APP_INTENT_ID = 1
@ -21,11 +20,8 @@ class MyWidgetDateProvider : AppWidgetProvider() {
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
RemoteViews(context.packageName, R.layout.widget_date).apply {
applyColorFilter(R.id.widget_date_background, context.config.widgetBgColor)
setText(R.id.widget_date_label, Formatter.getTodayDayNumber())
setText(R.id.widget_month_label, Formatter.getCurrentMonthShort())
setTextColor(R.id.widget_date_label, context.config.widgetTextColor)
setTextColor(R.id.widget_month_label, context.config.widgetTextColor)
setTextColor(R.id.widget_date, context.config.widgetTextColor)
setTextColor(R.id.widget_month, context.config.widgetTextColor)
setupAppOpenIntent(context, this)
appWidgetManager.updateAppWidget(it, this)

View file

@ -9,30 +9,37 @@
android:id="@+id/widget_date_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/widget_date_label"
android:layout_alignTop="@+id/widget_date_label"
android:layout_alignEnd="@+id/widget_date_label"
android:layout_alignBottom="@+id/widget_month_label"
android:src="@drawable/widget_round_background" />
android:layout_alignStart="@+id/widget_date"
android:layout_alignTop="@+id/widget_date"
android:layout_alignEnd="@+id/widget_date"
android:layout_alignBottom="@+id/widget_month"
android:src="@drawable/widget_round_background"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/widget_date_label"
<TextClock
android:id="@+id/widget_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:format12Hour="d"
android:format24Hour="d"
android:gravity="center"
android:includeFontPadding="false"
android:paddingTop="@dimen/medium_margin"
android:textColor="@color/md_grey_white"
android:textSize="26sp"
tools:text="1" />
<TextView
android:id="@+id/widget_month_label"
<TextClock
android:id="@+id/widget_month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/widget_date_label"
android:layout_alignStart="@+id/widget_date_label"
android:layout_alignEnd="@+id/widget_date_label"
android:layout_below="@+id/widget_date"
android:layout_alignStart="@+id/widget_date"
android:layout_alignEnd="@+id/widget_date"
android:format12Hour="MMM"
android:format24Hour="MMM"
android:gravity="center"
android:includeFontPadding="false"
android:paddingBottom="@dimen/medium_margin"
android:textColor="@color/md_grey_white"
android:textSize="@dimen/bigger_text_size"