Add app icons to leasee view in shared data dev options.
Also disable clicking the header view and list items in the same view. Bug: 156671006 Test: make RunSettingsRoboTests ROBOTEST_FILTER=SharedDataPreferenceControllerTest Test: manual (visual) Change-Id: I2821bc6cdc523097283ab44b864088278850be53
This commit is contained in:
@@ -18,35 +18,46 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:orientation="horizontal"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:padding="@dimen/list_preferred_item_padding">
|
||||
|
||||
<!-- TODO (varunshah@): add an image view for the app icon -->
|
||||
<ImageView
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_width="@dimen/secondary_app_icon_size"
|
||||
android:layout_height="@dimen/secondary_app_icon_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lease_package"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textDirection="locale"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lease_desc"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:padding="@dimen/list_preferred_item_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lease_expiry"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
<TextView
|
||||
android:id="@+id/lease_package"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textDirection="locale"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lease_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lease_expiry"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
@@ -23,8 +23,10 @@ import android.app.blob.BlobStoreManager;
|
||||
import android.app.blob.LeaseInfo;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -90,6 +92,7 @@ public class LeaseInfoListView extends ListActivity {
|
||||
private LinearLayout getHeaderView() {
|
||||
final LinearLayout headerView = (LinearLayout) mInflater.inflate(
|
||||
R.layout.blob_list_item_view , null);
|
||||
headerView.setEnabled(false); // disable clicking
|
||||
final TextView blobLabel = headerView.findViewById(R.id.blob_label);
|
||||
final TextView blobId = headerView.findViewById(R.id.blob_id);
|
||||
final TextView blobExpiry = headerView.findViewById(R.id.blob_expiry);
|
||||
@@ -137,9 +140,12 @@ public class LeaseInfoListView extends ListActivity {
|
||||
}
|
||||
|
||||
private class LeaseListAdapter extends ArrayAdapter<LeaseInfo> {
|
||||
private Context mContext;
|
||||
|
||||
LeaseListAdapter(Context context) {
|
||||
super(context, 0);
|
||||
|
||||
mContext = context;
|
||||
final List<LeaseInfo> leases = mBlobInfo.getLeases();
|
||||
if (CollectionUtils.isEmpty(leases)) {
|
||||
return;
|
||||
@@ -152,8 +158,17 @@ public class LeaseInfoListView extends ListActivity {
|
||||
final LeaseInfoViewHolder holder = LeaseInfoViewHolder.createOrRecycle(
|
||||
mInflater, convertView);
|
||||
convertView = holder.rootView;
|
||||
convertView.setEnabled(false); // disable clicking
|
||||
|
||||
final LeaseInfo lease = getItem(position);
|
||||
Drawable appIcon;
|
||||
try {
|
||||
appIcon = mContext.getPackageManager().getApplicationIcon(lease.getPackageName());
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// set to system default app icon
|
||||
appIcon = mContext.getDrawable(android.R.drawable.sym_def_app_icon);
|
||||
}
|
||||
holder.appIcon.setImageDrawable(appIcon);
|
||||
holder.leasePackageName.setText(lease.getPackageName());
|
||||
holder.leaseDescription.setText(getDescriptionString(lease));
|
||||
holder.leaseExpiry.setText(getString(R.string.accessor_expires_text,
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.development.storage;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -27,6 +28,7 @@ import com.android.settings.R;
|
||||
*/
|
||||
class LeaseInfoViewHolder {
|
||||
View rootView;
|
||||
ImageView appIcon;
|
||||
TextView leasePackageName;
|
||||
TextView leaseDescription;
|
||||
TextView leaseExpiry;
|
||||
@@ -39,6 +41,7 @@ class LeaseInfoViewHolder {
|
||||
|
||||
final LeaseInfoViewHolder holder = new LeaseInfoViewHolder();
|
||||
holder.rootView = convertView;
|
||||
holder.appIcon = convertView.findViewById(R.id.app_icon);
|
||||
holder.leasePackageName = convertView.findViewById(R.id.lease_package);
|
||||
holder.leaseDescription = convertView.findViewById(R.id.lease_desc);
|
||||
holder.leaseExpiry = convertView.findViewById(R.id.lease_expiry);
|
||||
|
@@ -103,9 +103,9 @@ public class SharedDataPreferenceControllerTest {
|
||||
}
|
||||
|
||||
private List<BlobInfo> generateBlobList() {
|
||||
LeaseInfo one = new LeaseInfo("com.google.android.photos",
|
||||
LeaseInfo one = new LeaseInfo("com.google.android.apps.photos",
|
||||
System.currentTimeMillis(), -1, "test description");
|
||||
LeaseInfo two = new LeaseInfo("com.google.android.drive",
|
||||
LeaseInfo two = new LeaseInfo("om.google.android.googlequicksearchbox",
|
||||
System.currentTimeMillis(), -1, "test description 2");
|
||||
|
||||
List<LeaseInfo> accessors = new ArrayList<>();
|
||||
|
Reference in New Issue
Block a user