Skip to content

Commit 7a8ee76

Browse files
authored
Merge pull request #1725 from Naveen3Singh/widget_improvements
Use TextClock at widgets for showing current date
2 parents 8297fb6 + 57c7eeb commit 7a8ee76

4 files changed

Lines changed: 31 additions & 24 deletions

File tree

app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetDateProvider.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import com.simplemobiletools.calendar.pro.activities.SplashActivity
1212
import com.simplemobiletools.calendar.pro.extensions.config
1313
import com.simplemobiletools.commons.extensions.applyColorFilter
1414
import com.simplemobiletools.commons.extensions.getLaunchIntent
15-
import com.simplemobiletools.commons.extensions.setText
1615

1716
class MyWidgetDateProvider : AppWidgetProvider() {
1817
private val OPEN_APP_INTENT_ID = 1
@@ -21,11 +20,8 @@ class MyWidgetDateProvider : AppWidgetProvider() {
2120
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
2221
RemoteViews(context.packageName, R.layout.widget_date).apply {
2322
applyColorFilter(R.id.widget_date_background, context.config.widgetBgColor)
24-
setText(R.id.widget_date_label, Formatter.getTodayDayNumber())
25-
setText(R.id.widget_month_label, Formatter.getCurrentMonthShort())
26-
27-
setTextColor(R.id.widget_date_label, context.config.widgetTextColor)
28-
setTextColor(R.id.widget_month_label, context.config.widgetTextColor)
23+
setTextColor(R.id.widget_date, context.config.widgetTextColor)
24+
setTextColor(R.id.widget_month, context.config.widgetTextColor)
2925

3026
setupAppOpenIntent(context, this)
3127
appWidgetManager.updateAppWidget(it, this)

app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/MyWidgetListProvider.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import com.simplemobiletools.calendar.pro.extensions.launchNewEventIntent
1616
import com.simplemobiletools.calendar.pro.extensions.widgetsDB
1717
import com.simplemobiletools.calendar.pro.services.WidgetService
1818
import com.simplemobiletools.calendar.pro.services.WidgetServiceEmpty
19-
import com.simplemobiletools.commons.extensions.*
19+
import com.simplemobiletools.commons.extensions.applyColorFilter
20+
import com.simplemobiletools.commons.extensions.getColoredBitmap
21+
import com.simplemobiletools.commons.extensions.getLaunchIntent
22+
import com.simplemobiletools.commons.extensions.setTextSize
2023
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
2124
import org.joda.time.DateTime
2225

@@ -46,9 +49,6 @@ class MyWidgetListProvider : AppWidgetProvider() {
4649
setTextSize(R.id.widget_event_list_today, fontSize)
4750
}
4851

49-
val todayText = Formatter.getLongestDate(getNowSeconds())
50-
views.setText(R.id.widget_event_list_today, todayText)
51-
5252
views.setImageViewBitmap(R.id.widget_event_new_event, context.resources.getColoredBitmap(R.drawable.ic_plus_vector, textColor))
5353
setupIntent(context, views, NEW_EVENT, R.id.widget_event_new_event)
5454
setupIntent(context, views, LAUNCH_CAL, R.id.widget_event_list_today)

app/src/main/res/layout/widget_date.xml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,37 @@
99
android:id="@+id/widget_date_background"
1010
android:layout_width="wrap_content"
1111
android:layout_height="wrap_content"
12-
android:layout_alignStart="@+id/widget_date_label"
13-
android:layout_alignTop="@+id/widget_date_label"
14-
android:layout_alignEnd="@+id/widget_date_label"
15-
android:layout_alignBottom="@+id/widget_month_label"
16-
android:src="@drawable/widget_round_background" />
12+
android:layout_alignStart="@+id/widget_date"
13+
android:layout_alignTop="@+id/widget_date"
14+
android:layout_alignEnd="@+id/widget_date"
15+
android:layout_alignBottom="@+id/widget_month"
16+
android:src="@drawable/widget_round_background"
17+
tools:ignore="ContentDescription" />
1718

18-
<TextView
19-
android:id="@+id/widget_date_label"
19+
<TextClock
20+
android:id="@+id/widget_date"
2021
android:layout_width="match_parent"
2122
android:layout_height="wrap_content"
23+
android:format12Hour="d"
24+
android:format24Hour="d"
2225
android:gravity="center"
26+
android:includeFontPadding="false"
2327
android:paddingTop="@dimen/medium_margin"
2428
android:textColor="@color/md_grey_white"
2529
android:textSize="26sp"
2630
tools:text="1" />
2731

28-
<TextView
29-
android:id="@+id/widget_month_label"
32+
<TextClock
33+
android:id="@+id/widget_month"
3034
android:layout_width="wrap_content"
3135
android:layout_height="wrap_content"
32-
android:layout_below="@+id/widget_date_label"
33-
android:layout_alignStart="@+id/widget_date_label"
34-
android:layout_alignEnd="@+id/widget_date_label"
36+
android:layout_below="@+id/widget_date"
37+
android:layout_alignStart="@+id/widget_date"
38+
android:layout_alignEnd="@+id/widget_date"
39+
android:format12Hour="MMM"
40+
android:format24Hour="MMM"
3541
android:gravity="center"
42+
android:includeFontPadding="false"
3643
android:paddingBottom="@dimen/medium_margin"
3744
android:textColor="@color/md_grey_white"
3845
android:textSize="@dimen/bigger_text_size"

app/src/main/res/layout/widget_event_list.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@
1515
android:layout_alignParentBottom="true"
1616
android:src="@drawable/widget_round_background" />
1717

18-
<TextView
18+
<TextClock
1919
android:id="@+id/widget_event_list_today"
2020
android:layout_width="match_parent"
2121
android:layout_height="wrap_content"
2222
android:layout_alignTop="@+id/widget_event_go_to_today"
2323
android:layout_alignBottom="@+id/widget_event_go_to_today"
2424
android:layout_toStartOf="@+id/widget_event_go_to_today"
2525
android:ellipsize="end"
26+
android:format12Hour="MMM d yyyy (EEEE)"
27+
android:format24Hour="MMM d yyyy (EEEE)"
2628
android:gravity="center_vertical"
29+
android:includeFontPadding="false"
2730
android:maxLines="1"
2831
android:paddingStart="@dimen/medium_margin"
32+
android:paddingTop="@dimen/medium_margin"
2933
android:paddingEnd="@dimen/medium_margin"
3034
android:textSize="@dimen/normal_text_size"
31-
tools:text="July 18" />
35+
tools:text="May 25 2022 (Wednesday)" />
3236

3337
<ImageView
3438
android:id="@+id/widget_event_go_to_today"

0 commit comments

Comments
 (0)