diff --git a/app/src/main/kotlin/org/fossify/clock/extensions/Context.kt b/app/src/main/kotlin/org/fossify/clock/extensions/Context.kt index de931273..d0c16c32 100644 --- a/app/src/main/kotlin/org/fossify/clock/extensions/Context.kt +++ b/app/src/main/kotlin/org/fossify/clock/extensions/Context.kt @@ -113,7 +113,12 @@ fun Context.getFormattedDate(calendar: Calendar): String { val dayString = resources.getStringArray(org.fossify.commons.R.array.week_days_short)[dayOfWeek] val monthString = resources.getStringArray(org.fossify.commons.R.array.months)[month] - return "$dayString, $dayOfMonth $monthString" + + return formatDateString(monthString, dayOfMonth, dayString) +} + +private fun Context.formatDateString(month: String, day: Int, weekday: String): String { + return getString(R.string.date_format_md, weekday, day, month) } fun Context.getEditedTimeZonesMap(): HashMap { diff --git a/app/src/main/kotlin/org/fossify/clock/views/MyTextClock.kt b/app/src/main/kotlin/org/fossify/clock/views/MyTextClock.kt index 63477eb7..d35ef7a3 100644 --- a/app/src/main/kotlin/org/fossify/clock/views/MyTextClock.kt +++ b/app/src/main/kotlin/org/fossify/clock/views/MyTextClock.kt @@ -7,9 +7,13 @@ import android.text.style.RelativeSizeSpan import android.util.AttributeSet import android.widget.TextClock import androidx.annotation.AttrRes +import org.fossify.clock.R import org.fossify.clock.extensions.config +import org.fossify.clock.extensions.getFormattedDate import org.fossify.commons.extensions.applyFontToTextView import java.text.DateFormatSymbols +import java.util.Calendar +import androidx.core.content.withStyledAttributes private const val AM_PM_SCALE = 0.4f @@ -21,6 +25,12 @@ class MyTextClock @JvmOverloads constructor( init { if (!isInEditMode) context.applyFontToTextView(this) + + attrs?.let { + context.withStyledAttributes(it, R.styleable.MyTextClock, defStyleAttr, 0) { + useLocalizedDateFormat = getBoolean(R.styleable.MyTextClock_useLocalizedDateFormat, false) + } + } } private val amPmStrings by lazy { @@ -30,6 +40,7 @@ class MyTextClock @JvmOverloads constructor( } private var reenter = false + private var useLocalizedDateFormat = false override fun setText(text: CharSequence?, type: BufferType?) { if (reenter) { @@ -37,11 +48,21 @@ class MyTextClock @JvmOverloads constructor( return } + if (useLocalizedDateFormat) { + val formattedDate = context.getFormattedDate(Calendar.getInstance()) + super.setText(formattedDate, type) + return + } + if (context.config.use24HourFormat || text.isNullOrEmpty()) { super.setText(text, type) return } + setTextWithAmPmScaled(text, type); + } + + private fun setTextWithAmPmScaled(text: CharSequence?, type: BufferType?) { val full = text.toString() var amPmPosition = -1 var amPmString: String? = null diff --git a/app/src/main/res/layout/fragment_clock.xml b/app/src/main/res/layout/fragment_clock.xml index b6affe50..6900a9ef 100644 --- a/app/src/main/res/layout/fragment_clock.xml +++ b/app/src/main/res/layout/fragment_clock.xml @@ -33,10 +33,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/clock_time" - android:format12Hour="EEE, d MMM" - android:format24Hour="EEE, d MMM" android:gravity="center_horizontal" android:textSize="@dimen/big_text_size" + app:useLocalizedDateFormat="true" tools:text="Mon, 1 January" /> リマインダーの最大再生時間 時間切れ 時計と日付 + %3$s%2$d日(%1$s) 文字に影を付ける 右にスワイプして終了、または左にスワイプしてスヌーズ。 作成順 diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 2add7b78..f00d27f7 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -8,6 +8,7 @@ 알림 최대 지속시간 시간 만료 시계 및 날짜 + %3$s %2$d일 %1$s 텍스트 그림자 사용 생성된 순서 아날로그 시계 diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index f3e1ddc5..48f02b8b 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -14,6 +14,7 @@ 最长提醒持续时间 时间结束 时钟和日期 + %3$s%2$d日 %1$s 使用文字阴影 向右滑动可关闭,向左滑动可暂停。 创建顺序 diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml new file mode 100644 index 00000000..ccdc3bf4 --- /dev/null +++ b/app/src/main/res/values/attrs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b129f5c3..754c1d41 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,6 +14,7 @@ Max reminder duration Time expired Clock and date + %1$s, %2$d %3$s Use text shadow Swipe right to Dismiss, or left to Snooze. Creation order