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

Commit 82e036d5 authored by Christopher Tate's avatar Christopher Tate Committed by Michael Bestas
Browse files

Present the security patch date in a human-friendly format

For example, for an ISO date of 2015-08-01, this now displays
"August 1, 2015" in enUS, and "1 August 2015" in enUK, and
"2015年8月1日" in jpJP.

Bug 23358065

Change-Id: Iaa920ec88d765a222f0b589123665b689bf41978
parent f3fcb885
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.telephony.MSimTelephonyManager;
import android.text.format.DateFormat;
import android.util.Log;
import android.widget.Toast;

@@ -40,6 +41,10 @@ import com.android.settings.deviceinfo.msim.MSimStatus;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -103,6 +108,14 @@ public class DeviceInfoSettings extends RestrictedSettingsFragment {
        findPreference(KEY_FIRMWARE_VERSION).setEnabled(true);
        String patch = Build.VERSION.SECURITY_PATCH;
        if (!"".equals(patch)) {
            try {
                SimpleDateFormat template = new SimpleDateFormat("yyyy-MM-dd");
                Date patchDate = template.parse(patch);
                String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "dMMMMyyyy");
                patch = DateFormat.format(format, patchDate).toString();
            } catch (ParseException e) {
                // broken parse; fall through and use the raw string
            }
            setStringSummary(KEY_SECURITY_PATCH, patch);
        } else {
            getPreferenceScreen().removePreference(findPreference(KEY_SECURITY_PATCH));