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

Commit bc029f72 authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Improve CDM dialog permission string support.

Allow permission title and summary strings access to app name,
local device type and remote device name.

No-op for now because no strings reference these new args.

Bug: 402786380
Test: presubmit
Flag: EXEMPT no-op
Change-Id: Iaf814af27d6fec9f3991923dad16661825d9aac1
parent 8ae47f5d
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ public class CompanionAssociationActivity extends FragmentActivity implements
    private ImageView mProfileIcon;
    // Present for self managed association only;
    private ImageView mDeviceIcon;
    private CharSequence mDeviceName;

    // Only present for selfManaged devices.
    private ImageView mVendorHeaderImage;
@@ -296,6 +297,7 @@ public class CompanionAssociationActivity extends FragmentActivity implements
        mVendorHeaderButton = findViewById(R.id.vendor_header_button);

        mDeviceIcon = findViewById(R.id.device_icon);
        mDeviceName = mRequest.getDisplayName();

        mTimeoutMessage = findViewById(R.id.timeout_message);
        mDeviceListRecyclerView = findViewById(R.id.device_list);
@@ -469,7 +471,6 @@ public class CompanionAssociationActivity extends FragmentActivity implements
    private void initUiForSelfManagedAssociation() {
        Slog.d(TAG, "initUiForSelfManagedAssociation()");

        final CharSequence deviceName = mRequest.getDisplayName();
        final String deviceProfile = mRequest.getDeviceProfile();
        final String packageName = mRequest.getPackageName();
        final int userId = mRequest.getUserId();
@@ -497,7 +498,7 @@ public class CompanionAssociationActivity extends FragmentActivity implements
        }

        title = getHtmlFromResources(this, PROFILE_TITLES.get(deviceProfile), mAppLabel,
                getString(R.string.device_type), deviceName);
                getString(R.string.device_type), mDeviceName);

        if (deviceIcon != null) {
            mDeviceIcon.setImageIcon(deviceIcon);
@@ -507,7 +508,7 @@ public class CompanionAssociationActivity extends FragmentActivity implements
        if (PROFILE_SUMMARIES.containsKey(deviceProfile)) {
            final int summaryResourceId = PROFILE_SUMMARIES.get(deviceProfile);
            final Spanned summary = getHtmlFromResources(this, summaryResourceId,
                    mAppLabel, getString(R.string.device_type), deviceName);
                    mAppLabel, getString(R.string.device_type), mDeviceName);
            mSummary.setText(summary);
        } else {
            mSummary.setVisibility(View.GONE);
@@ -741,6 +742,8 @@ public class CompanionAssociationActivity extends FragmentActivity implements
            return;
        }
        mPermissionListAdapter.setPermissionType(perms);
        mPermissionListAdapter.setAppLabel(mAppLabel);
        mPermissionListAdapter.setDeviceName(mDeviceName);
        mPermissionListRecyclerView.setAdapter(mPermissionListAdapter);
        // Only attach the LinearLayoutManager if it's not already attached.
        if (mPermissionListRecyclerView.getLayoutManager() == null) {
+14 −2
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ class PermissionListAdapter extends RecyclerView.Adapter<PermissionListAdapter.V
    public static final int PERMISSION_SIZE = 2;
    private final Context mContext;
    private List<Integer> mPermissions;
    private CharSequence mAppLabel;
    private CharSequence mDeviceName;

    PermissionListAdapter(Context context) {
        mContext = context;
@@ -96,10 +98,12 @@ class PermissionListAdapter extends RecyclerView.Adapter<PermissionListAdapter.V
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        int type = getItemViewType(position);
        final Spanned title = getHtmlFromResources(mContext, PERMISSION_TITLES.get(type));
        final Spanned title = getHtmlFromResources(mContext, PERMISSION_TITLES.get(type),
                mContext.getString(R.string.device_type));
        holder.mPermissionName.setText(title);
        if (PERMISSION_SUMMARIES.containsKey(type)) {
            final Spanned summary = getHtmlFromResources(mContext, PERMISSION_SUMMARIES.get(type));
            final Spanned summary = getHtmlFromResources(mContext, PERMISSION_SUMMARIES.get(type),
                    mAppLabel, mContext.getString(R.string.device_type), mDeviceName);
            holder.mPermissionSummary.setText(summary);
        } else {
            holder.mPermissionSummary.setVisibility(View.GONE);
@@ -157,4 +161,12 @@ class PermissionListAdapter extends RecyclerView.Adapter<PermissionListAdapter.V
    void setPermissionType(List<Integer> permissions) {
        mPermissions = permissions;
    }

    void setAppLabel(CharSequence appLabel) {
        mAppLabel = appLabel;
    }

    void setDeviceName(CharSequence deviceName) {
        mDeviceName = deviceName;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ class Utils {
            @NonNull Context context, @StringRes int resId, CharSequence... formatArgs) {
        final String[] escapedArgs = new String[formatArgs.length];
        for (int i = 0; i < escapedArgs.length; i++) {
            escapedArgs[i] = Html.escapeHtml(formatArgs[i]);
            escapedArgs[i] = formatArgs[i] == null ? null : Html.escapeHtml(formatArgs[i]);
        }
        final String plain = context.getString(resId, (Object[]) escapedArgs);
        return Html.fromHtml(plain, 0);