Merge "Introduce watch and multiple device icon" into tm-dev

This commit is contained in:
Evan Chen
2022-03-11 21:31:14 +00:00
committed by Android (Google) Code Review
9 changed files with 113 additions and 10 deletions

View File

@@ -20,6 +20,6 @@
<corners android:topLeftRadius="16dp" android:topRightRadius="16dp"
android:bottomLeftRadius="16dp" android:bottomRightRadius="16dp"/>
<stroke
android:width="2dp"
android:width="1dp"
android:color="@android:color/system_accent1_600" />
</shape>

View File

@@ -0,0 +1,23 @@
<!--
~ 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="?attr/colorControlNormal">
<path android:fillColor="@android:color/white"
android:pathData="M7,20H4Q3.175,20 2.588,19.413Q2,18.825 2,18V6Q2,5.175 2.588,4.588Q3.175,4 4,4H20V6H4Q4,6 4,6Q4,6 4,6V18Q4,18 4,18Q4,18 4,18H7ZM9,20V18.2Q8.55,17.775 8.275,17.225Q8,16.675 8,16Q8,15.325 8.275,14.775Q8.55,14.225 9,13.8V12H13V13.8Q13.45,14.225 13.725,14.775Q14,15.325 14,16Q14,16.675 13.725,17.225Q13.45,17.775 13,18.2V20ZM11,17.5Q11.65,17.5 12.075,17.075Q12.5,16.65 12.5,16Q12.5,15.35 12.075,14.925Q11.65,14.5 11,14.5Q10.35,14.5 9.925,14.925Q9.5,15.35 9.5,16Q9.5,16.65 9.925,17.075Q10.35,17.5 11,17.5ZM21,20H16Q15.575,20 15.288,19.712Q15,19.425 15,19V10Q15,9.575 15.288,9.287Q15.575,9 16,9H21Q21.425,9 21.712,9.287Q22,9.575 22,10V19Q22,19.425 21.712,19.712Q21.425,20 21,20ZM17,18H20V11H17Z"/>
</vector>

View File

@@ -0,0 +1,25 @@
<!--
~ 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="?attr/colorControlNormal">
<path android:fillColor="@android:color/white"
android:pathData="M9,22 L7.65,17.45Q6.45,16.5 5.725,15.075Q5,13.65 5,12Q5,10.35 5.725,8.925Q6.45,7.5 7.65,6.55L9,2H15L16.35,6.55Q17.55,7.5 18.275,8.925Q19,10.35 19,12Q19,13.65 18.275,15.075Q17.55,16.5 16.35,17.45L15,22ZM12,17Q14.075,17 15.538,15.537Q17,14.075 17,12Q17,9.925 15.538,8.462Q14.075,7 12,7Q9.925,7 8.463,8.462Q7,9.925 7,12Q7,14.075 8.463,15.537Q9.925,17 12,17ZM10.1,5.25Q11.075,4.975 12,4.975Q12.925,4.975 13.9,5.25L13.5,4H10.5ZM10.5,20H13.5L13.9,18.75Q12.925,19.025 12,19.025Q11.075,19.025 10.1,18.75ZM10.1,4H10.5H13.5H13.9Q12.925,4 12,4Q11.075,4 10.1,4ZM10.5,20H10.1Q11.075,20 12,20Q12.925,20 13.9,20H13.5Z"/>
</vector>

View File

@@ -20,6 +20,15 @@
<!-- A header for selfManaged devices only. -->
<include layout="@layout/vendor_header" />
<ImageView
android:id="@+id/profile_icon"
android:layout_width="match_parent"
android:layout_height="32dp"
android:gravity="center"
android:layout_marginBottom="12dp"
android:layout_marginTop="1dp"
android:tint="@android:color/system_accent1_600"/>
<!-- Do NOT change the ID of the root LinearLayout above: it's referenced in CTS tests. -->
<TextView
@@ -28,7 +37,8 @@
android:layout_height="wrap_content"
android:gravity="center"
android:paddingHorizontal="12dp"
style="@*android:style/TextAppearance.Widget.Toolbar.Title"/>
android:layout_marginBottom="12dp"
style="@*android:style/TextAppearance.Widget.Toolbar.Title" />
<TextView
android:id="@+id/summary"
@@ -45,11 +55,29 @@
android:layout_height="0dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/device_list"
<LinearLayout
android:id="@+id/multiple_device_list"
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_height="200dp" />
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<View
android:id="@+id/border_top"
android:layout_marginTop="12dp"
style="@style/DeviceListBorder" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/device_list"
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_height="200dp" />
<View
android:id="@+id/border_bottom"
style="@style/DeviceListBorder" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/permission_list"

View File

@@ -28,7 +28,8 @@
android:id="@android:id/icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginRight="12dp"/>
android:layout_marginRight="12dp"
android:tint="@android:color/system_accent1_600"/>
<TextView
android:id="@android:id/text1"

View File

@@ -27,6 +27,7 @@
android:layout_height="24dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="12dp"
android:tint="@android:color/system_accent1_600"
android:contentDescription="Permission Icon"/>
<LinearLayout

View File

@@ -65,4 +65,10 @@
<item name="android:background">@drawable/btn_negative_multiple_devices</item>
</style>
<style name="DeviceListBorder">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:background">@android:color/system_accent1_300</item>
</style>
</resources>

View File

@@ -29,6 +29,7 @@ import static com.android.companiondevicemanager.PermissionListAdapter.TYPE_NOTI
import static com.android.companiondevicemanager.PermissionListAdapter.TYPE_STORAGE;
import static com.android.companiondevicemanager.Utils.getApplicationLabel;
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.prepareResultReceiverForIpc;
@@ -106,6 +107,9 @@ public class CompanionDeviceActivity extends FragmentActivity implements
private TextView mTitle;
private TextView mSummary;
// Present for single device and multiple device only.
private ImageView mProfileIcon;
// Only present for selfManaged devices.
private ImageView mVendorHeaderImage;
private TextView mVendorHeaderName;
@@ -119,10 +123,11 @@ public class CompanionDeviceActivity extends FragmentActivity implements
// regular.
private Button mButtonAllow;
private Button mButtonNotAllow;
// Present for multiple devices association requests only.
// Present for multiple device association requests only.
private Button mButtonNotAllowMultipleDevices;
private LinearLayout mAssociationConfirmationDialog;
private LinearLayout mMultipleDeviceList;
private RelativeLayout mVendorHeader;
// The recycler view is only shown for multiple-device regular association request, after
@@ -130,6 +135,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
private @Nullable RecyclerView mDeviceListRecyclerView;
private @Nullable DeviceListAdapter mDeviceAdapter;
// The recycler view is only shown for selfManaged association request.
private @Nullable RecyclerView mPermissionListRecyclerView;
private @Nullable PermissionListAdapter mPermissionListAdapter;
@@ -243,12 +249,15 @@ public class CompanionDeviceActivity extends FragmentActivity implements
setContentView(R.layout.activity_confirmation);
mMultipleDeviceList = findViewById(R.id.multiple_device_list);
mAssociationConfirmationDialog = findViewById(R.id.activity_confirmation);
mVendorHeader = findViewById(R.id.vendor_header);
mTitle = findViewById(R.id.title);
mSummary = findViewById(R.id.summary);
mProfileIcon = findViewById(R.id.profile_icon);
mVendorHeaderImage = findViewById(R.id.vendor_header_image);
mVendorHeaderName = findViewById(R.id.vendor_header_name);
mVendorHeaderButton = findViewById(R.id.vendor_header_button);
@@ -420,6 +429,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
mVendorHeaderName.setText(vendorName);
mDeviceListRecyclerView.setVisibility(View.GONE);
mProfileIcon.setVisibility(View.GONE);
mVendorHeader.setVisibility(View.VISIBLE);
}
@@ -447,17 +457,22 @@ public class CompanionDeviceActivity extends FragmentActivity implements
final Spanned title = getHtmlFromResources(
this, R.string.confirmation_title, appLabel, deviceName);
final Spanned summary;
final Drawable profileIcon;
if (deviceProfile == null) {
summary = getHtmlFromResources(this, R.string.summary_generic);
profileIcon = getIcon(this, R.drawable.ic_device_other);
mSummary.setVisibility(View.GONE);
} else if (deviceProfile.equals(DEVICE_PROFILE_WATCH)) {
summary = getHtmlFromResources(this, R.string.summary_watch, appLabel, deviceName);
profileIcon = getIcon(this, R.drawable.ic_watch);
} else {
throw new RuntimeException("Unsupported profile " + deviceProfile);
}
mTitle.setText(title);
mSummary.setText(summary);
mProfileIcon.setImageDrawable(profileIcon);
}
private void initUiForMultipleDevices(CharSequence appLabel) {
@@ -467,12 +482,16 @@ public class CompanionDeviceActivity extends FragmentActivity implements
final String profileName;
final Spanned summary;
final Drawable profileIcon;
if (deviceProfile == null) {
profileName = getString(R.string.profile_name_generic);
summary = getHtmlFromResources(this, R.string.summary_generic);
profileIcon = getIcon(this, R.drawable.ic_device_other);
mSummary.setVisibility(View.GONE);
} else if (deviceProfile.equals(DEVICE_PROFILE_WATCH)) {
profileName = getString(R.string.profile_name_watch);
summary = getHtmlFromResources(this, R.string.summary_watch, appLabel);
profileIcon = getIcon(this, R.drawable.ic_watch);
} else {
throw new RuntimeException("Unsupported profile " + deviceProfile);
}
@@ -481,6 +500,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
mTitle.setText(title);
mSummary.setText(summary);
mProfileIcon.setImageDrawable(profileIcon);
mDeviceAdapter = new DeviceListAdapter(this, this::onListItemClick);
@@ -496,6 +516,7 @@ public class CompanionDeviceActivity extends FragmentActivity implements
mButtonAllow.setVisibility(View.GONE);
mButtonNotAllow.setVisibility(View.GONE);
mButtonNotAllowMultipleDevices.setVisibility(View.VISIBLE);
mMultipleDeviceList.setVisibility(View.VISIBLE);
}
private void onListItemClick(int position) {

View File

@@ -22,7 +22,6 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.ApplicationInfoFlags;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
@@ -124,7 +123,6 @@ class Utils {
static @NonNull Drawable getIcon(@NonNull Context context, int resId) {
Drawable icon = context.getResources().getDrawable(resId, null);
icon.setTint(Color.DKGRAY);
return icon;
}