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

Commit bf08ec3d authored by Joel Galenson's avatar Joel Galenson
Browse files

Do not use truncated app label when there is room.

Change-Id: I3e2de3e446fe0ae7c2c7bd7b5df8d8a56354b105
Fixes: 120872584
Test: See app label without truncation.
parent 4ae320e4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ public class AppPermissionFragment extends SettingsWithButtonHeader {
            return root;
        }

        String appLabel = Utils.getAppLabel(mGroup.getApp().applicationInfo, context);
        String appLabel = Utils.getFullAppLabel(mGroup.getApp().applicationInfo, context);
        setHeader(getAppIcon(), appLabel);
        updateHeader(root.requireViewById(R.id.button_header));

+1 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ 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;
@@ -269,8 +268,7 @@ public final class PermissionAppsFragment extends PermissionsFrameFragment imple
            PermissionControlPreference pref = new PermissionControlPreference(context, group);
            pref.setKey(key);
            pref.setIcon(app.getIcon());
            pref.setTitle(app.getAppInfo().loadSafeLabel(context.getPackageManager(), 0,
                    TextUtils.SAFE_STRING_FLAG_TRIM | TextUtils.SAFE_STRING_FLAG_FIRST_LINE));
            pref.setTitle(Utils.getFullAppLabel(app.getAppInfo(), context));
            pref.setEllipsizeEnd();
            pref.useSmallerIcon();
            pref.setGroupSummary(group);
+31 −2
Original line number Diff line number Diff line
@@ -330,7 +330,7 @@ public final class Utils {
    }

    /**
     * Get the label for an application.
     * Get the label for an application, truncating if it is too long.
     *
     * @param applicationInfo the {@link ApplicationInfo} of the application
     * @param context the {@code Context} to retrieve {@code PackageManager}
@@ -340,8 +340,37 @@ public final class Utils {
    @NonNull
    public static String getAppLabel(@NonNull ApplicationInfo applicationInfo,
            @NonNull Context context) {
        return getAppLabel(applicationInfo, DEFAULT_MAX_LABEL_SIZE_PX, context);
    }

    /**
     * Get the full label for an application without truncation.
     *
     * @param applicationInfo the {@link ApplicationInfo} of the application
     * @param context the {@code Context} to retrieve {@code PackageManager}
     *
     * @return the label for the application
     */
    @NonNull
    public static String getFullAppLabel(@NonNull ApplicationInfo applicationInfo,
            @NonNull Context context) {
        return getAppLabel(applicationInfo, 0, context);
    }

    /**
     * Get the label for an application with the ability to control truncating.
     *
     * @param applicationInfo the {@link ApplicationInfo} of the application
     * @param ellipsizeDip see {@link TextUtils#makeSafeForPresentation}.
     * @param context the {@code Context} to retrieve {@code PackageManager}
     *
     * @return the label for the application
     */
    @NonNull
    private static String getAppLabel(@NonNull ApplicationInfo applicationInfo, float ellipsizeDip,
            @NonNull Context context) {
        return BidiFormatter.getInstance().unicodeWrap(applicationInfo.loadSafeLabel(
                context.getPackageManager(), DEFAULT_MAX_LABEL_SIZE_PX,
                context.getPackageManager(), ellipsizeDip,
                TextUtils.SAFE_STRING_FLAG_TRIM | TextUtils.SAFE_STRING_FLAG_FIRST_LINE)
                .toString());
    }