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

Commit 6ee518f5 authored by Joel Galenson's avatar Joel Galenson
Browse files

Avoid abbreviating package names unnecessarily.

This ensures package names fill up the full width.

Change-Id: I87711d7460b39f10e918fc968517291347fdf843
Fixes: 120661355
Test: See package names ellipsized at the end.
parent 59e99fc2
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.view.Menu;
@@ -263,10 +264,13 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
                continue;
            }

            Preference pref = new PermissionUsagePreference(context, group, null, true);
            PermissionUsagePreference pref = new PermissionUsagePreference(context, group, null,
                    true);
            pref.setKey(key);
            pref.setIcon(app.getIcon());
            pref.setTitle(app.getLabel());
            pref.setTitle(app.getAppInfo().loadSafeLabel(context.getPackageManager(), 0,
                    TextUtils.SAFE_STRING_FLAG_TRIM | TextUtils.SAFE_STRING_FLAG_FIRST_LINE));
            pref.setEllipsizeEnd();
            setSummary(pref, group);

            if (isSystemApp && isTelevision) {
+20 −0
Original line number Diff line number Diff line
@@ -19,8 +19,10 @@ package com.android.packageinstaller.permission.ui.handheld;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -39,6 +41,7 @@ public class PermissionUsagePreference extends Preference {
    private final @Nullable Drawable mWidgetIcon;
    private final @NonNull Context mContext;
    private final boolean mUseSmallerIcon;
    private boolean mEllipsizeEnd;

    public PermissionUsagePreference(@NonNull Context context, @NonNull AppPermissionGroup group,
            @Nullable Drawable widgetIcon, boolean useSmallerIcon) {
@@ -47,6 +50,7 @@ public class PermissionUsagePreference extends Preference {
        mWidgetIcon = widgetIcon;
        mContext = context;
        mUseSmallerIcon = useSmallerIcon;
        mEllipsizeEnd = false;
        if (mWidgetIcon != null) {
            setWidgetLayoutResource(R.layout.image_view);
        }
@@ -60,6 +64,15 @@ public class PermissionUsagePreference extends Preference {
        });
    }

    /**
     * Sets this preference's title to use an ellipsis at the end.
     *
     * Note that this must be called before preference layout to take effect.
     */
    public void setEllipsizeEnd() {
        mEllipsizeEnd = true;
    }

    @Override
    public void onBindViewHolder(PreferenceViewHolder holder) {
        if (mUseSmallerIcon) {
@@ -71,9 +84,16 @@ public class PermissionUsagePreference extends Preference {
        }

        super.onBindViewHolder(holder);

        if (mWidgetIcon != null) {
            View widgetFrame = holder.findViewById(android.R.id.widget_frame);
            ((ImageView) widgetFrame.findViewById(R.id.icon)).setImageDrawable(mWidgetIcon);
        }

        if (mEllipsizeEnd) {
            TextView title = (TextView) holder.findViewById(android.R.id.title);
            title.setMaxLines(1);
            title.setEllipsize(TextUtils.TruncateAt.END);
        }
    }
}