diff --git a/app/build.gradle b/app/build.gradle
index d30ba60..bb81e3f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -41,7 +41,7 @@ android {
}
dependencies {
- implementation 'com.simplemobiletools:commons:3.15.14'
+ implementation 'com.simplemobiletools:commons:3.15.15'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.shawnlin:number-picker:2.4.6'
diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt
index af82d80..ac091f3 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/activities/SettingsActivity.kt
@@ -82,6 +82,7 @@ class SettingsActivity : SimpleActivity() {
settings_hour_format_holder.setOnClickListener {
settings_hour_format.toggle()
config.use24HourFormat = settings_hour_format.isChecked
+ updateWidgets()
}
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/MyWidgetDateTimeProvider.kt b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/MyWidgetDateTimeProvider.kt
index a9be148..77edd0f 100644
--- a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/MyWidgetDateTimeProvider.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/MyWidgetDateTimeProvider.kt
@@ -15,6 +15,7 @@ import com.simplemobiletools.clock.extensions.getFormattedTime
import com.simplemobiletools.clock.extensions.scheduleNextWidgetUpdate
import com.simplemobiletools.commons.extensions.setBackgroundColor
import com.simplemobiletools.commons.extensions.setText
+import com.simplemobiletools.commons.extensions.setVisibleIf
import java.util.*
class MyWidgetDateTimeProvider : AppWidgetProvider() {
@@ -44,9 +45,19 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
private fun updateTexts(context: Context, views: RemoteViews) {
val calendar = Calendar.getInstance()
+ val use24HourFormat = context.config.use24HourFormat
+
+ val timeText = context.getFormattedTime(getPassedSeconds(), false, false).toString()
views.apply {
- setText(R.id.widget_time, context.getFormattedTime(getPassedSeconds(), false, false).toString())
+ if (use24HourFormat) {
+ setText(R.id.widget_time, timeText)
+ } else {
+ val timeParts = timeText.split(" ")
+ setText(R.id.widget_time, timeParts[0])
+ setText(R.id.widget_time_am_pm, " ${timeParts[1]}")
+ }
setText(R.id.widget_date, context.getFormattedDate(calendar))
+ setVisibleIf(R.id.widget_time_am_pm, !use24HourFormat)
}
}
@@ -58,6 +69,7 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
views.apply {
setBackgroundColor(R.id.widget_date_time_holder, widgetBgColor)
setTextColor(R.id.widget_time, widgetTextColor)
+ setTextColor(R.id.widget_time_am_pm, widgetTextColor)
setTextColor(R.id.widget_date, widgetTextColor)
}
}
diff --git a/app/src/main/res/layout/widget_date_time.xml b/app/src/main/res/layout/widget_date_time.xml
index eea0e5b..ea15859 100644
--- a/app/src/main/res/layout/widget_date_time.xml
+++ b/app/src/main/res/layout/widget_date_time.xml
@@ -8,13 +8,24 @@
+
+
+
+
64dp
80dp
30dp
- 110dp
+ 180dp
+ 110dp
70sp
60sp
diff --git a/app/src/main/res/xml/widget_date_time_info.xml b/app/src/main/res/xml/widget_date_time_info.xml
index 32e25ba..1b3516b 100644
--- a/app/src/main/res/xml/widget_date_time_info.xml
+++ b/app/src/main/res/xml/widget_date_time_info.xml
@@ -4,6 +4,7 @@
android:configure="com.simplemobiletools.clock.activities.WidgetDateTimeConfigureActivity"
android:initialLayout="@layout/widget_date_time"
android:minHeight="@dimen/min_widget_height"
+ android:minResizeWidth="@dimen/min_widget_resize_width"
android:minWidth="@dimen/min_widget_width"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="86400000"/>