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

Commit 87623c0a authored by ladios's avatar ladios
Browse files

Notification Profile: Localize default profile names

Delete "/data/system/profiles.xml" and reboot, if you need to
re-import your localized default profiles.

Change-Id: I7a0c829d66b10b779e3257d8d98fb326bca58f5c
parent ba26a4a1
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.app;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
@@ -113,8 +114,12 @@ public class NotificationGroup implements Parcelable {

    public static NotificationGroup fromXml(XmlPullParser xpp) throws XmlPullParserException,
            IOException {
        NotificationGroup notificationGroup = new NotificationGroup(xpp.getAttributeValue(null,
                "name"));
        return fromXml(xpp, null);
    }
    public static NotificationGroup fromXml(XmlPullParser xpp, Context context) throws XmlPullParserException,
            IOException {
        String attr = Profile.getAttrResString(xpp, context);
        NotificationGroup notificationGroup = new NotificationGroup(attr);
        int event = xpp.next();
        while (event != XmlPullParser.END_TAG || !xpp.getName().equals("notificationGroup")) {
            if (event == XmlPullParser.START_TAG) {
+25 −2
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.app;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.content.Context;
import android.content.res.XmlResourceParser;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
@@ -143,14 +145,35 @@ public class Profile implements Parcelable {
        builder.append("</profile>\n");
    }

    public static String getAttrResString(XmlPullParser xpp, Context context) {
        String attr = null;
        if (xpp instanceof XmlResourceParser && context != null) {
            XmlResourceParser xrp = (XmlResourceParser) xpp;
            int resId = xrp.getAttributeResourceValue(null, "name", 0);
            if (resId != 0) {
                attr = context.getResources().getString(resId);
            } else {
                attr = xrp.getAttributeValue(null, "name");
            }
        } else {
            attr = xpp.getAttributeValue(null, "name");
        }
        return attr;
    }

    public static Profile fromXml(XmlPullParser xpp) throws XmlPullParserException, IOException {
        Profile profile = new Profile(xpp.getAttributeValue(null, "name"));
        return fromXml(xpp, null);
    }

    public static Profile fromXml(XmlPullParser xpp, Context context) throws XmlPullParserException, IOException {
        String attr = getAttrResString(xpp, context);
        Profile profile = new Profile(attr);
        int event = xpp.next();
        while (event != XmlPullParser.END_TAG) {
            if (event == XmlPullParser.START_TAG) {
                String name = xpp.getName();
                if (name.equals("profileGroup")) {
                    ProfileGroup pg = ProfileGroup.fromXml(xpp);
                    ProfileGroup pg = ProfileGroup.fromXml(xpp, context);
                    profile.addProfileGroup(pg);
                }
            }
+7 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.app;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.content.Context;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Parcel;
@@ -229,9 +230,14 @@ public class ProfileGroup implements Parcelable {

    public static ProfileGroup fromXml(XmlPullParser xpp) throws XmlPullParserException,
            IOException {
        return fromXml(xpp, null);
    }
    public static ProfileGroup fromXml(XmlPullParser xpp, Context context) throws XmlPullParserException,
            IOException {
        String defaultGroup = xpp.getAttributeValue(null, "default");
        defaultGroup = defaultGroup == null ? "false" : defaultGroup;
        ProfileGroup profileGroup = new ProfileGroup(xpp.getAttributeValue(null, "name"), defaultGroup.equals("true"));
        String attr = Profile.getAttrResString(xpp, context);
        ProfileGroup profileGroup = new ProfileGroup(attr, defaultGroup.equals("true"));
        int event = xpp.next();
        while (event != XmlPullParser.END_TAG || !xpp.getName().equals("profileGroup")) {
            if (event == XmlPullParser.START_TAG) {
+14 −0
Original line number Diff line number Diff line
@@ -65,6 +65,20 @@
         could not be performed because FDN is enabled. This will be displayed in a toast. -->
    <string name="mmiFdnError" msgid="5224398216385316471">"僅限對固定撥號號碼執行此作業。"</string>

    <!-- Names of default profiles. -->
    <string name="profileNameDefault">預設</string>
    <string name="profileNameWork">工作</string>
    <string name="profileNameHome">家中</string>
    <string name="profileNameSilent">靜音</string>
    <string name="profileNameNight">深夜</string>

    <!-- Names of application groups. -->
    <string name="profileGroupPhone">電話</string>
    <string name="profileGroupCalendar">日曆</string>
    <string name="profileGroupGmail">Gmail</string>
    <string name="profileGroupEmail">電子郵件</string>
    <string name="profileGroupSMS">簡訊</string>

    <!-- Name of wildcard profile. -->
    <string name="wildcardProfile">其他</string>

+14 −0
Original line number Diff line number Diff line
@@ -64,6 +64,20 @@
         could not be performed because FDN is enabled. This will be displayed in a toast. -->
    <string name="mmiFdnError">Operation is restricted to fixed dialing numbers only.</string>

    <!-- Names of default profiles. -->
    <string name="profileNameDefault">Default</string>
    <string name="profileNameWork">Work</string>
    <string name="profileNameHome">Home</string>
    <string name="profileNameSilent">Silent</string>
    <string name="profileNameNight">Night</string>

    <!-- Names of application groups. -->
    <string name="profileGroupPhone">Phone</string>
    <string name="profileGroupCalendar">Calendar</string>
    <string name="profileGroupGmail">Gmail</string>
    <string name="profileGroupEmail">Email</string>
    <string name="profileGroupSMS">SMS</string>

    <!-- Name of wildcard profile. -->
    <string name="wildcardProfile">Other</string>

Loading