Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 962e8ea4 authored by chihhangchuang's avatar chihhangchuang
Browse files

Use the formatted time for preview clock time

Current issue: b/157440597, the AMPM field is available on the preview screen in Mandarin, even we removed it.

Screenshot of fixing:
lockscreen 12-hour: https://screenshot.googleplex.com/Ub59KfE8nzJ.png
lockscreen 24-hour: https://screenshot.googleplex.com/UiPb2Xvtxx2.png
theme preview 12-hour: https://screenshot.googleplex.com/uHMovJwu8GG.png
theme preview 24-hour: https://screenshot.googleplex.com/Kxwr6Loqy5e.png

Test: Manually
Fixes: 157440597
Change-Id: I6be7ddb5cb33ae9f5f57f4847728f3d75c5100da
parent 0b5031d8
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -46,9 +46,9 @@ import com.android.customization.model.theme.ThemeBundle;
import com.android.customization.model.theme.ThemeBundle.PreviewInfo;
import com.android.wallpaper.R;
import com.android.wallpaper.util.ScreenSizeCalculator;
import com.android.wallpaper.util.TimeTicker;
import com.android.wallpaper.util.TimeUtils;
import com.android.wallpaper.util.TimeUtils.TimeTicker;

import java.text.FieldPosition;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
@@ -293,13 +293,7 @@ class ThemeOptionPreviewer implements LifecycleObserver {
    private void updateTime() {
        Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
        if (mStatusBarClock != null) {
            StringBuffer time = new StringBuffer();
            FieldPosition amPmPosition = new FieldPosition(java.text.DateFormat.Field.AM_PM);
            DateFormat.getTimeFormat(mContext).format(calendar.getTime(), time, amPmPosition);
            if (amPmPosition.getBeginIndex() > 0) {
                time.delete(amPmPosition.getBeginIndex(), amPmPosition.getEndIndex());
            }
            mStatusBarClock.setText(time);
            mStatusBarClock.setText(TimeUtils.getFormattedTime(mContext, calendar));
        }
        if (mSmartSpaceDate != null) {
            String datePattern =