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

Commit 48319c2d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use short label, request title and request description for roles."

parents 132e9274 1f0e1257
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -685,9 +685,6 @@
    <!-- Description when an app requests to become the default call companion app. [CHAR LIMIT=60] -->
    <string name="role_call_companion_request_description"></string>

    <!-- Template for the title when an app requests to become a default application. [CHAR LIMIT=100] -->
    <string name="request_role_title">Set <xliff:g id="app_name" example="Super Duper SMS">%1$s</xliff:g> as your default <xliff:g id="role_name" example="SMS app">%2$s</xliff:g>?</string>

    <!-- Subtitle for the application that is the current default application [CHAR LIMIT=30] -->
    <string name="request_role_current_default">Current default</string>

+48 −12
Original line number Diff line number Diff line
@@ -82,7 +82,10 @@
        behavior="AssistantRoleBehavior"
        exclusive="true"
        showNone="true"
        label="@string/role_assistant_short_label">
        label="@string/role_assistant_label"
        requestDescription="@string/role_assistant_request_description"
        requestTitle="@string/role_assistant_request_title"
        shortLabel="@string/role_assistant_short_label">
        <required-components>
            <!-- Qualified components are determined int AssistantRoleBehavior. This comment here is
                 ignored and represents just a rough description
@@ -127,7 +130,10 @@
        name="android.app.role.BROWSER"
        behavior="BrowserRoleBehavior"
        exclusive="true"
        label="@string/role_browser_short_label">
        label="@string/role_browser_label"
        requestDescription="@string/role_browser_request_description"
        requestTitle="@string/role_browser_request_title"
        shortLabel="@string/role_browser_short_label">
        <!--
          ~ Required components matching is handled in BrowserRoleBehavior because it needs the
          ~ PackageManager.MATCH_ALL flag and other manual filtering, which cannot fit in our
@@ -161,7 +167,10 @@
        name="android.app.role.DIALER"
        behavior="DialerRoleBehavior"
        exclusive="true"
        label="@string/role_dialer_short_label">
        label="@string/role_dialer_label"
        requestDescription="@string/role_dialer_request_description"
        requestTitle="@string/role_dialer_request_title"
        shortLabel="@string/role_dialer_short_label">
        <required-components>
            <activity>
                <intent-filter>
@@ -217,7 +226,10 @@
        name="android.app.role.SMS"
        behavior="SmsRoleBehavior"
        exclusive="true"
        label="@string/role_sms_short_label">
        label="@string/role_sms_label"
        requestDescription="@string/role_sms_request_description"
        requestTitle="@string/role_sms_request_title"
        shortLabel="@string/role_sms_short_label">
        <required-components>
            <receiver permission="android.permission.BROADCAST_SMS">
                <intent-filter>
@@ -299,7 +311,10 @@
        name="android.app.role.EMERGENCY"
        behavior="EmergencyRoleBehavior"
        exclusive="true"
        label="@string/role_emergency_short_label"
        label="@string/role_emergency_label"
        requestDescription="@string/role_emergency_request_description"
        requestTitle="@string/role_emergency_request_title"
        shortLabel="@string/role_emergency_short_label"
        systemOnly="true">
        <required-components>
            <activity>
@@ -319,7 +334,10 @@
        name="android.app.role.HOME"
        behavior="HomeRoleBehavior"
        exclusive="true"
        label="@string/role_home_short_label">
        label="@string/role_home_label"
        requestDescription="@string/role_home_request_description"
        requestTitle="@string/role_home_request_title"
        shortLabel="@string/role_home_short_label">
        <!-- Also used by HomeRoleBehavior.getFallbackHolder(). -->
        <required-components>
            <activity>
@@ -349,7 +367,10 @@
        name="android.app.role.MUSIC"
        behavior="MusicRoleBehavior"
        exclusive="true"
        label="@string/role_music_short_label">
        label="@string/role_music_label"
        requestDescription="@string/role_music_request_description"
        requestTitle="@string/role_music_request_title"
        shortLabel="@string/role_music_short_label">
        <required-components>
            <activity>
                <intent-filter>
@@ -384,7 +405,10 @@
        name="android.app.role.GALLERY"
        behavior="GalleryRoleBehavior"
        exclusive="true"
        label="@string/role_gallery_short_label">
        label="@string/role_gallery_label"
        requestDescription="@string/role_gallery_request_description"
        requestTitle="@string/role_gallery_request_title"
        shortLabel="@string/role_gallery_short_label">
        <required-components>
            <activity>
                <intent-filter>
@@ -420,7 +444,10 @@
    <role
        name="android.app.role.CAR_MODE_DIALER"
        exclusive="true"
        label="@string/role_car_mode_dialer_short_label">
        label="@string/role_car_mode_dialer_label"
        requestDescription="@string/role_car_mode_dialer_request_description"
        requestTitle="@string/role_car_mode_dialer_request_title"
        shortLabel="@string/role_car_mode_dialer_short_label">
        <required-components>
            <service permission="android.permission.BIND_INCALL_SERVICE">
                <meta-data
@@ -439,7 +466,10 @@
    <role
        name="android.app.role.CALL_REDIRECTION"
        exclusive="true"
        label="@string/role_call_redirection_short_label">
        label="@string/role_call_redirection_label"
        requestDescription="@string/role_call_redirection_request_description"
        requestTitle="@string/role_call_redirection_request_title"
        shortLabel="@string/role_call_redirection_short_label">
        <required-components>
            <service permission="android.permission.BIND_CALL_REDIRECTION_SERVICE">
                <intent-filter>
@@ -453,7 +483,10 @@
    <role
        name="android.app.role.CALL_SCREENING"
        exclusive="true"
        label="@string/role_call_screening_short_label">
        label="@string/role_call_screening_label"
        requestDescription="@string/role_call_screening_request_description"
        requestTitle="@string/role_call_screening_request_title"
        shortLabel="@string/role_call_screening_short_label">
        <required-components>
            <service permission="android.permission.BIND_SCREENING_SERVICE">
                <intent-filter>
@@ -467,7 +500,10 @@
    <role
        name="android.app.role.CALL_COMPANION"
        exclusive="false"
        label="@string/role_call_companion_short_label">
        label="@string/role_call_companion_label"
        requestDescription="@string/role_call_companion_request_description"
        requestTitle="@string/role_call_companion_request_title"
        shortLabel="@string/role_call_companion_short_label">
        <required-components>
            <service permission="android.permission.BIND_INCALL_SERVICE">
                <meta-data
+41 −1
Original line number Diff line number Diff line
@@ -90,6 +90,26 @@ public class Role {
    @StringRes
    private final int mLabelResource;

    /**
     * The string resource for the request description of this role, shown below the selected app in
     * the request role dialog.
     */
    @StringRes
    private final int mRequestDescriptionResource;

    /**
     * The string resource for the request title of this role, shown as the title of the request
     * role dialog.
     */
    @StringRes
    private final int mRequestTitleResource;

    /**
     * The string resource for the short label of this role, currently used when in a list of roles.
     */
    @StringRes
    private final int mShortLabelResource;

    /**
     * Whether the UI for this role will show the "None" item. Only valid if this role is
     * {@link #mExclusive exclusive}, and {@link #getFallbackHolder(Context)} should also return
@@ -127,13 +147,18 @@ public class Role {
    private final List<PreferredActivity> mPreferredActivities;

    public Role(@NonNull String name, @Nullable RoleBehavior behavior, boolean exclusive,
            @StringRes int labelResource, boolean showNone, boolean systemOnly,
            @StringRes int labelResource, @StringRes int requestDescriptionResource,
            @StringRes int requestTitleResource, @StringRes int shortLabelResource,
            boolean showNone, boolean systemOnly,
            @NonNull List<RequiredComponent> requiredComponents, @NonNull List<String> permissions,
            @NonNull List<AppOp> appOps, @NonNull List<PreferredActivity> preferredActivities) {
        mName = name;
        mBehavior = behavior;
        mExclusive = exclusive;
        mLabelResource = labelResource;
        mRequestDescriptionResource = requestDescriptionResource;
        mRequestTitleResource = requestTitleResource;
        mShortLabelResource = shortLabelResource;
        mShowNone = showNone;
        mSystemOnly = systemOnly;
        mRequiredComponents = requiredComponents;
@@ -161,6 +186,21 @@ public class Role {
        return mLabelResource;
    }

    @StringRes
    public int getRequestDescriptionResource() {
        return mRequestDescriptionResource;
    }

    @StringRes
    public int getRequestTitleResource() {
        return mRequestTitleResource;
    }

    @StringRes
    public int getShortLabelResource() {
        return mShortLabelResource;
    }

    /**
     * @see #mShowNone
     */
+28 −2
Original line number Diff line number Diff line
@@ -72,8 +72,12 @@ public class Roles {
    private static final String TAG_PREFERRED_ACTIVITY = "preferred-activity";
    private static final String ATTRIBUTE_NAME = "name";
    private static final String ATTRIBUTE_BEHAVIOR = "behavior";
    private static final String ATTRIBUTE_DESCRIPTION = "description";
    private static final String ATTRIBUTE_EXCLUSIVE = "exclusive";
    private static final String ATTRIBUTE_LABEL = "label";
    private static final String ATTRIBUTE_REQUEST_TITLE = "requestTitle";
    private static final String ATTRIBUTE_REQUEST_DESCRIPTION = "requestDescription";
    private static final String ATTRIBUTE_SHORT_LABEL = "shortLabel";
    private static final String ATTRIBUTE_SHOW_NONE = "showNone";
    private static final String ATTRIBUTE_SYSTEM_ONLY = "systemOnly";
    private static final String ATTRIBUTE_PERMISSION = "permission";
@@ -318,6 +322,27 @@ public class Roles {
            return null;
        }

        Integer requestDescriptionResource = requireAttributeResourceValue(parser,
                ATTRIBUTE_REQUEST_DESCRIPTION, 0, TAG_ROLE);
        if (requestDescriptionResource == null) {
            skipCurrentTag(parser);
            return null;
        }

        Integer requestTitleResource = requireAttributeResourceValue(parser,
                ATTRIBUTE_REQUEST_TITLE, 0, TAG_ROLE);
        if (requestTitleResource == null) {
            skipCurrentTag(parser);
            return null;
        }

        Integer shortLabelResource = requireAttributeResourceValue(parser, ATTRIBUTE_SHORT_LABEL, 0,
                TAG_ROLE);
        if (shortLabelResource == null) {
            skipCurrentTag(parser);
            return null;
        }

        boolean showNone = getAttributeBooleanValue(parser, ATTRIBUTE_SHOW_NONE, false);
        if (showNone && !exclusive) {
            throwOrLogMessage("showNone=\"true\" is invalid for a non-exclusive role: " + name);
@@ -393,8 +418,9 @@ public class Roles {
        if (preferredActivities == null) {
            preferredActivities = Collections.emptyList();
        }
        return new Role(name, behavior, exclusive, labelResource, showNone, systemOnly,
                requiredComponents, permissions, appOps, preferredActivities);
        return new Role(name, behavior, exclusive, labelResource, requestDescriptionResource,
                requestTitleResource, shortLabelResource, showNone, systemOnly, requiredComponents,
                permissions, appOps, preferredActivities);
    }

    @NonNull
+1 −1
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ public class DefaultAppListFragment extends SettingsFragment
                preference = new AppIconPreference(context);
                preference.setKey(role.getName());
                preference.setIconSpaceReserved(true);
                preference.setTitle(role.getLabelResource());
                preference.setTitle(role.getShortLabelResource());
                preference.setPersistent(false);
                preference.setOnPreferenceClickListener(listener);
                preference.getExtras().putParcelable(Intent.EXTRA_USER, user);
Loading