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

Commit e5d564bd authored by Evan Chen's avatar Evan Chen Committed by Android (Google) Code Review
Browse files

Merge "Fix UI regression for COMPUTER profile" into main

parents 191c4185 43de6c04
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -39,7 +39,9 @@
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="center_vertical"
        android:padding="6dp"
        android:paddingTop="6dp"
        android:paddingLeft="6dp"
        android:paddingRight="6dp"
        android:layout_weight="1">

        <TextView
+1 −5
Original line number Diff line number Diff line
@@ -87,11 +87,7 @@
    <!-- ================= DEVICE_PROFILE_COMPUTER ================= -->

    <!-- Confirmation for associating an application with a companion device of COMPUTER profile (type) [CHAR LIMIT=NONE] -->
    <string name="title_computer">Allow &lt;strong&gt;<xliff:g id="app_name" example="GMS">%1$s</xliff:g>&lt;/strong&gt; to access this information from your <xliff:g id="device_type" example="phone">%2$s</xliff:g></string>

    <!-- Description of the privileges the application will get if associated with the companion device of COMPUTER profile (type) [CHAR LIMIT=NONE] -->
    <string name="summary_computer"></string>

    <string name="title_computer">Allow &lt;strong&gt;<xliff:g id="display_name" example="Chromebook">%1$s</xliff:g>&lt;/strong&gt; to access this information from your phone</string>
    <!-- Description of the helper dialog for COMPUTER profile. [CHAR LIMIT=NONE] -->
    <string name="helper_summary_computer"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="device_name" example="Chromebook">%2$s</xliff:g> to access your <xliff:g id="device_type" example="phone">%3$s</xliff:g>\u2019s photos, media, and notifications</string>

+8 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.companiondevicemanager;

import static android.companion.AssociationRequest.DEVICE_PROFILE_COMPUTER;
import static android.companion.CompanionDeviceManager.RESULT_INTERNAL_ERROR;
import static android.companion.CompanionDeviceManager.RESULT_SECURITY_ERROR;
import static android.companion.CompanionDeviceManager.RESULT_USER_REJECTED;
@@ -496,8 +497,12 @@ public class CompanionAssociationActivity extends FragmentActivity implements
            return;
        }

        if (DEVICE_PROFILE_COMPUTER.equals(deviceProfile)) {
            title = getHtmlFromResources(this, PROFILE_TITLES.get(deviceProfile), deviceName);
        } else {
            title = getHtmlFromResources(this, PROFILE_TITLES.get(deviceProfile), mAppLabel,
                    getString(R.string.device_type), deviceName);
        }

        if (deviceIcon != null) {
            mDeviceIcon.setImageIcon(deviceIcon);
@@ -788,7 +793,7 @@ public class CompanionAssociationActivity extends FragmentActivity implements
    // Enable the Allow button if the last element in the PermissionListRecyclerView is reached.
    private void enableAllowButtonIfNeeded(LinearLayoutManager layoutManager) {
        int lastVisibleItemPosition =
                layoutManager.findLastCompletelyVisibleItemPosition();
                layoutManager.findLastVisibleItemPosition();
        int numItems = mPermissionListRecyclerView.getAdapter().getItemCount();

        if (lastVisibleItemPosition >= numItems - 1) {
+0 −1
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ final class CompanionDeviceResources {
        final Map<Integer, Integer> map = new ArrayMap<>();
        map.put(PERMISSION_NOTIFICATION_LISTENER_ACCESS,
                R.string.permission_notification_listener_access_summary);
        map.put(PERMISSION_STORAGE, R.string.permission_storage_summary);
        map.put(PERMISSION_PHONE, R.string.permission_phone_summary);
        map.put(PERMISSION_SMS, R.string.permission_sms_summary);
        map.put(PERMISSION_CONTACTS, R.string.permission_contacts_summary);
+8 −5
Original line number Diff line number Diff line
@@ -37,10 +37,10 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.List;

class PermissionListAdapter extends RecyclerView.Adapter<PermissionListAdapter.ViewHolder> {
    // Add the expand buttons if permissions are more than PERMISSION_SIZE in the permission list.
    public static final int PERMISSION_SIZE = 2;
    private final Context mContext;
    private List<Integer> mPermissions;
    // Add the expand buttons if permissions are more than PERMISSION_SIZE in the permission list.
    private static final int PERMISSION_SIZE = 2;

    PermissionListAdapter(Context context) {
        mContext = context;
@@ -97,10 +97,13 @@ class PermissionListAdapter extends RecyclerView.Adapter<PermissionListAdapter.V
    public void onBindViewHolder(ViewHolder holder, int position) {
        int type = getItemViewType(position);
        final Spanned title = getHtmlFromResources(mContext, PERMISSION_TITLES.get(type));
        holder.mPermissionName.setText(title);
        if (PERMISSION_SUMMARIES.containsKey(type)) {
            final Spanned summary = getHtmlFromResources(mContext, PERMISSION_SUMMARIES.get(type));

            holder.mPermissionSummary.setText(summary);
        holder.mPermissionName.setText(title);
        } else {
            holder.mPermissionSummary.setVisibility(View.GONE);
        }
    }

    @Override