diff options
| author | 2022-03-22 23:00:50 +0000 | |
|---|---|---|
| committer | 2022-03-22 23:00:50 +0000 | |
| commit | b09fe9de577ed052ec97459e8038a4082297587d (patch) | |
| tree | f29729c4cfcda1efa97bef070c109cec3041ce51 | |
| parent | c9476b6dbdcab6f66de3c4bec2e6e67f81b9bc3e (diff) | |
| parent | d927819de229d733adb47bab33d18cdcf4a17405 (diff) | |
Merge "Update Computer dialog UI" into tm-dev
| -rw-r--r-- | packages/CompanionDeviceManager/res/drawable/helper_back_button.xml (renamed from packages/CompanionDeviceManager/res/drawable/helper_ok_button.xml) | 0 | ||||
| -rw-r--r-- | packages/CompanionDeviceManager/res/drawable/ic_info.xml | 26 | ||||
| -rw-r--r-- | packages/CompanionDeviceManager/res/layout/helper_confirmation.xml | 6 | ||||
| -rw-r--r-- | packages/CompanionDeviceManager/res/layout/vendor_header.xml | 2 | ||||
| -rw-r--r-- | packages/CompanionDeviceManager/res/values/strings.xml | 20 | ||||
| -rw-r--r-- | packages/CompanionDeviceManager/res/values/styles.xml | 7 | ||||
| -rw-r--r-- | packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java | 16 | ||||
| -rw-r--r-- | packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java | 31 | ||||
| -rw-r--r-- | packages/CompanionDeviceManager/src/com/android/companiondevicemanager/Utils.java | 12 |
9 files changed, 76 insertions, 44 deletions
diff --git a/packages/CompanionDeviceManager/res/drawable/helper_ok_button.xml b/packages/CompanionDeviceManager/res/drawable/helper_back_button.xml index 8e92051faf6c..8e92051faf6c 100644 --- a/packages/CompanionDeviceManager/res/drawable/helper_ok_button.xml +++ b/packages/CompanionDeviceManager/res/drawable/helper_back_button.xml diff --git a/packages/CompanionDeviceManager/res/drawable/ic_info.xml b/packages/CompanionDeviceManager/res/drawable/ic_info.xml new file mode 100644 index 000000000000..d9f6a2720ab6 --- /dev/null +++ b/packages/CompanionDeviceManager/res/drawable/ic_info.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24" + android:tint="@android:color/system_accent1_600"> + <path android:fillColor="@android:color/white" + android:pathData="M11,17H13V11H11ZM12,9Q12.425,9 12.713,8.712Q13,8.425 13,8Q13,7.575 12.713,7.287Q12.425,7 12,7Q11.575,7 11.288,7.287Q11,7.575 11,8Q11,8.425 11.288,8.712Q11.575,9 12,9ZM12,22Q9.925,22 8.1,21.212Q6.275,20.425 4.925,19.075Q3.575,17.725 2.788,15.9Q2,14.075 2,12Q2,9.925 2.788,8.1Q3.575,6.275 4.925,4.925Q6.275,3.575 8.1,2.787Q9.925,2 12,2Q14.075,2 15.9,2.787Q17.725,3.575 19.075,4.925Q20.425,6.275 21.212,8.1Q22,9.925 22,12Q22,14.075 21.212,15.9Q20.425,17.725 19.075,19.075Q17.725,20.425 15.9,21.212Q14.075,22 12,22ZM12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12Q12,12 12,12ZM12,20Q15.325,20 17.663,17.663Q20,15.325 20,12Q20,8.675 17.663,6.337Q15.325,4 12,4Q8.675,4 6.338,6.337Q4,8.675 4,12Q4,15.325 6.338,17.663Q8.675,20 12,20Z"/> +</vector>
\ No newline at end of file diff --git a/packages/CompanionDeviceManager/res/layout/helper_confirmation.xml b/packages/CompanionDeviceManager/res/layout/helper_confirmation.xml index a22ca941c5eb..a9ace44d49b8 100644 --- a/packages/CompanionDeviceManager/res/layout/helper_confirmation.xml +++ b/packages/CompanionDeviceManager/res/layout/helper_confirmation.xml @@ -59,9 +59,9 @@ android:gravity="end"> <Button - android:id="@+id/btn_ok" - style="@style/VendorHelperOkButton" - android:text="@string/consent_ok" /> + android:id="@+id/btn_back" + style="@style/VendorHelperBackButton" + android:text="@string/consent_back" /> </LinearLayout> diff --git a/packages/CompanionDeviceManager/res/layout/vendor_header.xml b/packages/CompanionDeviceManager/res/layout/vendor_header.xml index 5f6aa9419c6e..c35f59e7e8a0 100644 --- a/packages/CompanionDeviceManager/res/layout/vendor_header.xml +++ b/packages/CompanionDeviceManager/res/layout/vendor_header.xml @@ -43,7 +43,7 @@ <ImageButton android:id="@+id/vendor_header_button" - style="?android:attr/actionOverflowButtonStyle" + android:background="@drawable/ic_info" android:layout_width="31dp" android:layout_height="32dp" android:layout_alignParentRight="true" /> diff --git a/packages/CompanionDeviceManager/res/values/strings.xml b/packages/CompanionDeviceManager/res/values/strings.xml index 67fc6c2dc864..586a0223b460 100644 --- a/packages/CompanionDeviceManager/res/values/strings.xml +++ b/packages/CompanionDeviceManager/res/values/strings.xml @@ -47,20 +47,11 @@ <!-- Confirmation for associating an application with a companion device of APP_STREAMING profile (type) [CHAR LIMIT=NONE] --> <string name="title_app_streaming">Allow <strong><xliff:g id="app_name" example="Exo">%1$s</xliff:g></strong> to access this information from your phone</string> - <!-- Description of the privileges the application will get if associated with the companion device of APP_STREAMING profile (type) [CHAR LIMIT=NONE] --> - <string name="summary_app_streaming" product="default">Let <strong><xliff:g id="app_name" example="Exo">%1$s</xliff:g></strong> to provide <strong><xliff:g id="device_name" example="Pixelbook Go">%2$s</xliff:g></strong> remote access to access to applications installed on this phone when connected.</string> - - <!-- Description of the privileges the application will get if associated with the companion device of APP_STREAMING profile (type) [CHAR LIMIT=NONE] --> - <string name="summary_app_streaming" product="tablet">Let <strong><xliff:g id="app_name" example="Exo">%1$s</xliff:g></strong> to provide <strong><xliff:g id="device_name" example="Pixelbook Go">%2$s</xliff:g></strong> remote access to access to applications installed on this tablet when connected.</string> - - <!-- Description of the privileges the application will get if associated with the companion device of APP_STREAMING profile (type) [CHAR LIMIT=NONE] --> - <string name="summary_app_streaming" product="device">Let <strong><xliff:g id="app_name" example="Exo">%1$s</xliff:g></strong> to provide <strong><xliff:g id="device_name" example="Pixelbook Go">%2$s</xliff:g></strong> remote access to access to applications installed on this device when connected.</string> - <!-- Title of the helper dialog for APP_STREAMING profile [CHAR LIMIT=30]. --> <string name="helper_title_app_streaming">Cross-device services</string> <!-- Description of the helper dialog for APP_STREAMING profile. [CHAR LIMIT=NONE] --> - <string name="helper_summary_app_streaming">This service is used to stream apps between your devices</string> + <string name="helper_summary_app_streaming"><xliff:g id="app_name" example="GMS">%1$s</xliff:g> is requesting permission on behalf of your <xliff:g id="device_type" example="Chromebook">%2$s</xliff:g> to access your phone\u2019s photos, media, and notifications</string> <!-- ================= DEVICE_PROFILE_AUTOMOTIVE_PROJECTION ================= --> @@ -94,10 +85,7 @@ <string name="helper_title_computer">Google Play services</string> <!-- Description of the helper dialog for COMPUTER profile. [CHAR LIMIT=NONE] --> - <string name="helper_summary_computer" product="default">This service shares photos, media, and notifications form your phone to other devices</string> - - <!-- Description of the helper dialog for COMPUTER profile. [CHAR LIMIT=NONE] --> - <string name="helper_summary_computer" product="tablet">This service shares photos, media, and notifications form your phone to other devices</string> + <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_type" example="Chromebook">%2$s</xliff:g> to stream apps between your devices</string> <!-- ================= null profile ================= --> @@ -115,8 +103,8 @@ <!-- Negative button for the device-app association consent dialog [CHAR LIMIT=30] --> <string name="consent_no">Don\u2019t allow</string> - <!-- Ok button for the helper consent dialog [CHAR LIMIT=30] --> - <string name="consent_ok">OK</string> + <!-- Back button for the helper consent dialog [CHAR LIMIT=30] --> + <string name="consent_back">Back</string> <!-- ================== System data transfer ==================== --> <!-- Title of the permission sync confirmation dialog. [CHAR LIMIT=60] --> diff --git a/packages/CompanionDeviceManager/res/values/styles.xml b/packages/CompanionDeviceManager/res/values/styles.xml index a55f30c9be6a..faa303219cf0 100644 --- a/packages/CompanionDeviceManager/res/values/styles.xml +++ b/packages/CompanionDeviceManager/res/values/styles.xml @@ -57,13 +57,14 @@ <item name="android:textColor">?android:attr/textColorSecondary</item> </style> - <style name="VendorHelperOkButton" + <style name="VendorHelperBackButton" parent="@android:style/Widget.Material.Button.Borderless.Colored"> - <item name="android:layout_width">50dp</item> + <item name="android:layout_width">60dp</item> <item name="android:layout_height">36dp</item> <item name="android:layout_marginTop">20dp</item> + <item name="android:textAllCaps">false</item> <item name="android:textColor">@android:color/system_neutral1_900</item> - <item name="android:background">@drawable/helper_ok_button</item> + <item name="android:background">@drawable/helper_back_button</item> </style> <style name="PositiveButton" diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java index 5eeb167ee5e0..b5968162214d 100644 --- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java +++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceActivity.java @@ -38,6 +38,7 @@ import static com.android.companiondevicemanager.Utils.getHtmlFromResources; import static com.android.companiondevicemanager.Utils.getIcon; import static com.android.companiondevicemanager.Utils.getVendorHeaderIcon; import static com.android.companiondevicemanager.Utils.getVendorHeaderName; +import static com.android.companiondevicemanager.Utils.hasVendorIcon; import static com.android.companiondevicemanager.Utils.prepareResultReceiverForIpc; import static java.util.Objects.requireNonNull; @@ -285,7 +286,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements mVendorHeaderButton.setOnClickListener(this::onShowHelperDialog); if (mRequest.isSelfManaged()) { - initUiForSelfManagedAssociation(appLabel); + initUiForSelfManagedAssociation(); } else if (mRequest.isSingleDevice()) { initUiForSingleDevice(appLabel); } else { @@ -396,7 +397,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements finish(); } - private void initUiForSelfManagedAssociation(CharSequence appLabel) { + private void initUiForSelfManagedAssociation() { if (DEBUG) Log.i(TAG, "initUiFor_SelfManaged_Association()"); final CharSequence deviceName = mRequest.getDisplayName(); @@ -412,6 +413,12 @@ public class CompanionDeviceActivity extends FragmentActivity implements try { vendorIcon = getVendorHeaderIcon(this, packageName, userId); vendorName = getVendorHeaderName(this, packageName, userId); + + mVendorHeaderImage.setImageDrawable(vendorIcon); + if (hasVendorIcon(this, packageName, userId)) { + mVendorHeaderImage.setColorFilter(getResources().getColor( + android.R.color.system_accent1_600, /* Theme= */null)); + } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Package u" + userId + "/" + packageName + " not found."); setResultAndFinish(null, RESULT_INTERNAL_ERROR); @@ -446,9 +453,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements mPermissionListRecyclerView.setLayoutManager(new LinearLayoutManager(this)); mTitle.setText(title); - mVendorHeaderImage.setImageDrawable(vendorIcon); mVendorHeaderName.setText(vendorName); - mDeviceListRecyclerView.setVisibility(View.GONE); mProfileIcon.setVisibility(View.GONE); mVendorHeader.setVisibility(View.VISIBLE); @@ -586,8 +591,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements private void onShowHelperDialog(View view) { FragmentManager fragmentManager = getSupportFragmentManager(); CompanionVendorHelperDialogFragment fragmentDialog = - CompanionVendorHelperDialogFragment.newInstance(mRequest.getPackageName(), - mRequest.getUserId(), mRequest.getDeviceProfile()); + CompanionVendorHelperDialogFragment.newInstance(mRequest); mAssociationConfirmationDialog.setVisibility(View.INVISIBLE); diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java index 728e5e5d3b9e..f2f6cb0cda7d 100644 --- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java +++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionVendorHelperDialogFragment.java @@ -23,6 +23,7 @@ import static com.android.companiondevicemanager.Utils.getApplicationIcon; import static com.android.companiondevicemanager.Utils.getHtmlFromResources; import android.annotation.Nullable; +import android.companion.AssociationRequest; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; @@ -44,10 +45,7 @@ import androidx.fragment.app.DialogFragment; */ public class CompanionVendorHelperDialogFragment extends DialogFragment { private static final String TAG = CompanionVendorHelperDialogFragment.class.getSimpleName(); - - private static final String PACKAGE_NAME_EXTRA = "packageName"; - private static final String DEVICE_PROFILE_EXTRA = "deviceProfile"; - private static final String USER_ID_EXTRA = "userId"; + private static final String ASSOCIATION_REQUEST_EXTRA = "association_request"; private CompanionVendorHelperDialogListener mListener; // Only present for selfManaged devices. @@ -63,15 +61,12 @@ public class CompanionVendorHelperDialogFragment extends DialogFragment { private CompanionVendorHelperDialogFragment() {} - static CompanionVendorHelperDialogFragment newInstance(String packageName, - int userId, String deviceProfile) { + static CompanionVendorHelperDialogFragment newInstance(AssociationRequest request) { CompanionVendorHelperDialogFragment fragmentDialog = new CompanionVendorHelperDialogFragment(); Bundle bundle = new Bundle(); - bundle.putString(PACKAGE_NAME_EXTRA, packageName); - bundle.putInt(USER_ID_EXTRA, userId); - bundle.putString(DEVICE_PROFILE_EXTRA, deviceProfile); + bundle.putParcelable(ASSOCIATION_REQUEST_EXTRA, request); fragmentDialog.setArguments(bundle); return fragmentDialog; @@ -102,9 +97,13 @@ public class CompanionVendorHelperDialogFragment extends DialogFragment { super.onViewCreated(view, savedInstanceState); Drawable applicationIcon; - String packageName = getArguments().getString(PACKAGE_NAME_EXTRA); - String deviceProfile = getArguments().getString(DEVICE_PROFILE_EXTRA); - int userId = getArguments().getInt(USER_ID_EXTRA); + AssociationRequest request = getArguments().getParcelable( + ASSOCIATION_REQUEST_EXTRA, AssociationRequest.class); + + final String deviceProfile = request.getDeviceProfile(); + final String packageName = request.getPackageName(); + final CharSequence displayName = request.getDisplayName(); + final int userId = request.getUserId(); try { applicationIcon = getApplicationIcon(getContext(), packageName); @@ -117,7 +116,7 @@ public class CompanionVendorHelperDialogFragment extends DialogFragment { mTitle = view.findViewById(R.id.helper_title); mSummary = view.findViewById(R.id.helper_summary); mAppIcon = view.findViewById(R.id.app_icon); - mButton = view.findViewById(R.id.btn_ok); + mButton = view.findViewById(R.id.btn_back); final Spanned title; final Spanned summary; @@ -125,12 +124,14 @@ public class CompanionVendorHelperDialogFragment extends DialogFragment { switch (deviceProfile) { case DEVICE_PROFILE_APP_STREAMING: title = getHtmlFromResources(getContext(), R.string.helper_title_app_streaming); - summary = getHtmlFromResources(getContext(), R.string.helper_summary_app_streaming); + summary = getHtmlFromResources( + getContext(), R.string.helper_summary_app_streaming, title, displayName); break; case DEVICE_PROFILE_COMPUTER: title = getHtmlFromResources(getContext(), R.string.helper_title_computer); - summary = getHtmlFromResources(getContext(), R.string.helper_summary_computer); + summary = getHtmlFromResources( + getContext(), R.string.helper_summary_computer, title, displayName); break; default: diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/Utils.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/Utils.java index 1852e82cb9f9..fceca91ce617 100644 --- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/Utils.java +++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/Utils.java @@ -108,6 +108,18 @@ class Utils { return appInfo.metaData.getCharSequence(COMPANION_DEVICE_ACTIVITY_VENDOR_NAME, ""); } + static boolean hasVendorIcon(@NonNull Context context, + @NonNull String packageName, int userId) throws PackageManager.NameNotFoundException { + final ApplicationInfo appInfo = getApplicationInfo(context, packageName, userId); + final Bundle bundle = appInfo.metaData; + + if (bundle == null) { + return false; + } else { + return bundle.getInt(COMPANION_DEVICE_ACTIVITY_VENDOR_ICON) != 0; + } + } + /** * Getting ApplicationInfo from meta-data. */ |