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

Commit 59e99fc2 authored by Joel Galenson's avatar Joel Galenson
Browse files

Show correctly-sized app icon.

Previously the app icon was a bit larger than it should be.  This
fixes it so that it is more in line with the permission icon.

Change-Id: I2f89b07e0818b8c365b59b87667cf5507f226e55
Fixes: 120632634
Test: View screens.
parent e7149839
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ public class AppPermissionUsageFragment extends SettingsWithHeader {
                        + historyEntry.getBackgroundAccessDuration();
            }

            Preference pref = new PermissionUsagePreference(context, group);
            Preference pref = new PermissionUsagePreference(context, group, null, false);
            pref.setTitle(usage.getPermissionGroupLabel());
            long timeDiff = System.currentTimeMillis() - usage.getTime();
            if (totalDuration == 0) {
+1 −1
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ public final class AppPermissionsFragment extends SettingsWithHeader {

            boolean isPlatform = group.getDeclaringPackage().equals(Utils.OS_PKG);

            Preference preference = new PermissionUsagePreference(context, group);
            Preference preference = new PermissionUsagePreference(context, group, null, false);
            preference.setKey(group.getName());
            Drawable icon = Utils.loadDrawable(context.getPackageManager(),
                    group.getIconPkg(), group.getIconResId());
+1 −1
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
                continue;
            }

            Preference pref = new PermissionUsagePreference(context, group);
            Preference pref = new PermissionUsagePreference(context, group, null, true);
            pref.setKey(key);
            pref.setIcon(app.getIcon());
            pref.setTitle(app.getLabel());
+1 −1
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ public class PermissionUsageFragment extends PermissionsFrameFragment implements
            PermissionApp permApp = usageToApp.get(usage);
            Preference pref = new PermissionUsagePreference(context, group,
                    Utils.applyTint(context, group.getIconResId(),
                            android.R.attr.colorControlNormal));
                            android.R.attr.colorControlNormal), true);
            pref.setTitle(permApp.getLabel());
            long timeDiff = System.currentTimeMillis() - usage.getTime();
            String timeDiffStr = Utils.getTimeDiffStr(context, timeDiff);
+13 −5
Original line number Diff line number Diff line
@@ -37,12 +37,16 @@ import com.android.permissioncontroller.R;
public class PermissionUsagePreference extends Preference {
    private final @NonNull AppPermissionGroup mGroup;
    private final @Nullable Drawable mWidgetIcon;
    private final @NonNull Context mContext;
    private final boolean mUseSmallerIcon;

    public PermissionUsagePreference(@NonNull Context context, @NonNull AppPermissionGroup group,
            @Nullable Drawable widgetIcon) {
            @Nullable Drawable widgetIcon, boolean useSmallerIcon) {
        super(context);
        mGroup = group;
        mWidgetIcon = widgetIcon;
        mContext = context;
        mUseSmallerIcon = useSmallerIcon;
        if (mWidgetIcon != null) {
            setWidgetLayoutResource(R.layout.image_view);
        }
@@ -56,12 +60,16 @@ public class PermissionUsagePreference extends Preference {
        });
    }

    public PermissionUsagePreference(@NonNull Context context, @NonNull AppPermissionGroup group) {
        this(context, group, null);
    }

    @Override
    public void onBindViewHolder(PreferenceViewHolder holder) {
        if (mUseSmallerIcon) {
            ImageView icon = ((ImageView) holder.findViewById(android.R.id.icon));
            icon.setMaxWidth(
                    mContext.getResources().getDimensionPixelSize(R.dimen.secondary_app_icon_size));
            icon.setMaxHeight(
                    mContext.getResources().getDimensionPixelSize(R.dimen.secondary_app_icon_size));
        }

        super.onBindViewHolder(holder);
        if (mWidgetIcon != null) {
            View widgetFrame = holder.findViewById(android.R.id.widget_frame);