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

Commit 8af0f2f8 authored by c_yunong's avatar c_yunong Committed by Gerrit - the friendly Code Review server
Browse files

Update the customize date format

Add the feature to control the date format for customer

Change-Id: Ia9129badaac84b57d6cfde2b5d160e7a294397bb
CRs-Fixed: 1037633
parent 4404f4a2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<resources>
    <!-- custom date format or not  -->
    <bool name="config_dateformat">false</bool>

    <!-- Used in LocalePicker, default language must be contained -->
    <string name="locale_codes" translatable="false"></string>
+1 −1
Original line number Diff line number Diff line
@@ -2416,7 +2416,7 @@
  <java-symbol type="drawable" name="platlogo_m" />
  <!-- language/locale picker extention feature -->
  <java-symbol type="string" name="locale_codes" />

  <java-symbol type="bool" name="config_dateformat" />
  <java-symbol type="string" name="config_iccHotswapPromptForRestartDialogComponent" />

  <java-symbol type="string" name="config_packagedKeyboardName" />
+8 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.AttributeSet;
@@ -236,8 +237,13 @@ public class KeyguardStatusView extends GridLayout {
            final String clockView24Skel = res.getString(R.string.clock_24hr_format);
            final String key = locale.toString() + dateViewSkel + clockView12Skel + clockView24Skel;
            if (key.equals(cacheKey)) return;

            if (res.getBoolean(com.android.internal.R.bool.config_dateformat)) {
                final String dateformat = Settings.System.getString(context.getContentResolver(),
                        Settings.System.DATE_FORMAT);
                dateView = dateformat;
            } else {
                dateView = DateFormat.getBestDateTimePattern(locale, dateViewSkel);
            }

            clockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel);
            if(!context.getResources().getBoolean(R.bool.config_showAmpm)){
+9 −1
Original line number Diff line number Diff line
@@ -108,10 +108,18 @@ public class DateView extends TextView {

        mCurrentTime.setTime(System.currentTimeMillis());

        final String text = mDateFormat.format(mCurrentTime);
        final String text = getDateFormat();
        if (!text.equals(mLastText)) {
            setText(text);
            mLastText = text;
        }
    }

    private String getDateFormat() {
        if (getContext().getResources().getBoolean(com.android.internal.R.bool.config_dateformat)) {
            return android.text.format.DateFormat.getDateFormat(getContext()).format(mCurrentTime);
        } else {
            return mDateFormat.format(mCurrentTime);
        }
    }
}