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

Commit 82bf2153 authored by Daniel Olusakin's avatar Daniel Olusakin Committed by Android (Google) Code Review
Browse files

Merge "Update label loading logic to use intent-filter as sublabel for apps...

Merge "Update label loading logic to use intent-filter as sublabel for apps holding the right permission"
parents 1bb48d23 eb109bbd
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -838,6 +838,12 @@ public class ResolverListAdapter extends BaseAdapter {
            // check if subLabel matches label before final display
            return mRi.loadLabel(mPm).toString();
        }

        @Override
        String getAppLabelForSubstitutePermission() {
            // Will default to app name if no activity label set
            return mRi.getComponentInfo().loadLabel(mPm).toString();
        }
    }

    /**
@@ -877,6 +883,11 @@ public class ResolverListAdapter extends BaseAdapter {
            // matches label before final display
            return (String) mActivityInfo.loadLabel(mPm);
        }

        @Override
        String getAppLabelForSubstitutePermission() {
            return getAppSubLabelInternal();
        }
    }

    /**
@@ -889,6 +900,7 @@ public class ResolverListAdapter extends BaseAdapter {
    private abstract static class TargetPresentationGetter {
        @Nullable abstract Drawable getIconSubstituteInternal();
        @Nullable abstract String getAppSubLabelInternal();
        @Nullable abstract String getAppLabelForSubstitutePermission();

        private Context mCtx;
        private final int mIconDpi;
@@ -940,9 +952,10 @@ public class ResolverListAdapter extends BaseAdapter {

        public String getLabel() {
            String label = null;
            // Apps with the substitute permission will always show the sublabel as their label
            // Apps with the substitute permission will always show the activity label as the
            // app label if provided
            if (mHasSubstitutePermission) {
                label = getAppSubLabelInternal();
                label = getAppLabelForSubstitutePermission();
            }

            if (label == null) {
@@ -953,8 +966,17 @@ public class ResolverListAdapter extends BaseAdapter {
        }

        public String getSubLabel() {
            // Apps with the substitute permission will never have a sublabel
            if (mHasSubstitutePermission) return null;
            // Apps with the substitute permission will always show the resolve info label as the
            // sublabel if provided
            if (mHasSubstitutePermission){
                String appSubLabel = getAppSubLabelInternal();
                // Use the resolve info label as sublabel if it is set
                if(!TextUtils.isEmpty(appSubLabel)
                    && !TextUtils.equals(appSubLabel, getLabel())){
                    return appSubLabel;
                }
                return null;
            }
            return getAppSubLabelInternal();
        }

+4 −4
Original line number Diff line number Diff line
@@ -384,10 +384,10 @@ public class ResolverActivityTest {
        info = createPackageManagerMockedInfo(true);
        pg = new ResolveInfoPresentationGetter(
                info.ctx, 0, info.resolveInfo);
        assertThat("With override permission label should match resolve info label if set",
                pg.getLabel().equals(info.setResolveInfoLabel));
        assertThat("With override permission sublabel should be empty",
                TextUtils.isEmpty(pg.getSubLabel()));
        assertThat("With override permission label should match activity label if set",
                pg.getLabel().equals(info.setActivityLabel));
        assertThat("With override permission the sublabel should be the resolve info label",
                pg.getSubLabel().equals(info.setResolveInfoLabel));
    }

    @Test