Update UI to use a smaller icon for ManageApplication page.
- Rewrite preference_app.xml to have a small icon - Update ApplicationViewHolder to hide/show summary row dynamically - but only do this for notification settings - this UI has empty summary for most row. For other UI, just keep the empty summary row until summary comes in. If we also hide/show summary row there will be a height change animation which is janky. Bug : 65182905 Fixes: 63582851 Test: robotests Change-Id: Ice67324f08c67e014a018dfc51e00fe4449036dd
This commit is contained in:
@@ -231,6 +231,7 @@ public class RecentAppsPreferenceController extends AbstractPreferenceController
|
||||
Preference pref = appPreferences.remove(pkgName);
|
||||
if (pref == null) {
|
||||
pref = new Preference(prefContext);
|
||||
pref.setLayoutResource(R.layout.preference_app);
|
||||
rebindPref = false;
|
||||
}
|
||||
pref.setKey(pkgName);
|
||||
|
@@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -38,33 +39,39 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
||||
private final TextView mAppName;
|
||||
private final ImageView mAppIcon;
|
||||
|
||||
private final boolean mKeepStableHeight;
|
||||
|
||||
@VisibleForTesting
|
||||
View mSummaryContainer;
|
||||
@VisibleForTesting
|
||||
final TextView mSummary;
|
||||
@VisibleForTesting
|
||||
final TextView mDisabled;
|
||||
|
||||
ApplicationViewHolder(View itemView) {
|
||||
|
||||
ApplicationViewHolder(View itemView, boolean keepStableHeight) {
|
||||
super(itemView);
|
||||
mAppName = itemView.findViewById(android.R.id.title);
|
||||
mAppIcon = itemView.findViewById(android.R.id.icon);
|
||||
mSummary = itemView.findViewById(R.id.widget_text1);
|
||||
mDisabled = itemView.findViewById(R.id.widget_text2);
|
||||
mSummaryContainer = itemView.findViewById(R.id.summary_container);
|
||||
mSummary = itemView.findViewById(android.R.id.summary);
|
||||
mDisabled = itemView.findViewById(R.id.appendix);
|
||||
mKeepStableHeight = keepStableHeight;
|
||||
}
|
||||
|
||||
static View newView(LayoutInflater inflater, ViewGroup parent) {
|
||||
final View root = LayoutInflater.from(parent.getContext())
|
||||
static View newView(ViewGroup parent) {
|
||||
return LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.preference_app, parent, false);
|
||||
inflater.inflate(R.layout.widget_text_views,
|
||||
root.findViewById(android.R.id.widget_frame));
|
||||
return root;
|
||||
}
|
||||
|
||||
void setSummary(CharSequence summary) {
|
||||
mSummary.setText(summary);
|
||||
updateSummaryContainer();
|
||||
}
|
||||
|
||||
void setSummary(@StringRes int summary) {
|
||||
mSummary.setText(summary);
|
||||
updateSummaryContainer();
|
||||
}
|
||||
|
||||
void setEnabled(boolean isEnabled) {
|
||||
@@ -78,6 +85,10 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
||||
mAppName.setText(title);
|
||||
}
|
||||
|
||||
void setIcon(int drawableRes) {
|
||||
mAppIcon.setImageResource(drawableRes);
|
||||
}
|
||||
|
||||
void setIcon(Drawable icon) {
|
||||
if (icon == null) {
|
||||
return;
|
||||
@@ -96,6 +107,17 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
||||
} else {
|
||||
mDisabled.setVisibility(View.GONE);
|
||||
}
|
||||
updateSummaryContainer();
|
||||
}
|
||||
|
||||
void updateSummaryContainer() {
|
||||
if (mKeepStableHeight) {
|
||||
mSummaryContainer.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
final boolean hasContent =
|
||||
!TextUtils.isEmpty(mDisabled.getText()) || !TextUtils.isEmpty(mSummary.getText());
|
||||
mSummaryContainer.setVisibility(hasContent ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
void updateSizeText(AppEntry entry, CharSequence invalidSizeStr, int whichSize) {
|
||||
|
@@ -412,20 +412,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isFastScrollEnabled() {
|
||||
switch (mListType) {
|
||||
case LIST_TYPE_MAIN:
|
||||
case LIST_TYPE_NOTIFICATION:
|
||||
case LIST_TYPE_STORAGE:
|
||||
case LIST_TYPE_GAMES:
|
||||
case LIST_TYPE_MOVIES:
|
||||
case LIST_TYPE_PHOTOGRAPHY:
|
||||
return mSortOrder == R.id.sort_order_alpha;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
switch (mListType) {
|
||||
@@ -924,9 +910,9 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
|
||||
@Override
|
||||
public ApplicationViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
final View view = ApplicationViewHolder.newView(
|
||||
LayoutInflater.from(parent.getContext()), parent);
|
||||
return new ApplicationViewHolder(view);
|
||||
final View view = ApplicationViewHolder.newView(parent);
|
||||
return new ApplicationViewHolder(view,
|
||||
shouldUseStableItemHeight(mManageApplications.mListType));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -994,7 +980,21 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
});
|
||||
}
|
||||
|
||||
static private boolean packageNameEquals(PackageItemInfo info1, PackageItemInfo info2) {
|
||||
@VisibleForTesting
|
||||
static boolean shouldUseStableItemHeight(int listType) {
|
||||
switch (listType) {
|
||||
case LIST_TYPE_NOTIFICATION:
|
||||
// Most entries in notification type has no summary. Don't use stable height
|
||||
// so height is short for most entries.
|
||||
return false;
|
||||
default:
|
||||
// Other types have non-empty summary, so keep the height as we expect summary
|
||||
// to fill in.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean packageNameEquals(PackageItemInfo info1, PackageItemInfo info2) {
|
||||
if (info1 == null || info2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.applications.manageapplications;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.support.annotation.WorkerThread;
|
||||
@@ -39,7 +38,6 @@ public class MusicViewHolderController implements FileViewHolderController {
|
||||
private static final String TAG = "MusicViewHolderCtrl";
|
||||
|
||||
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
|
||||
private static final int INSET_SIZE = 24; // dp
|
||||
|
||||
private Context mContext;
|
||||
private StorageStatsSource mSource;
|
||||
@@ -73,8 +71,7 @@ public class MusicViewHolderController implements FileViewHolderController {
|
||||
|
||||
@Override
|
||||
public void setupView(ApplicationViewHolder holder) {
|
||||
holder.setIcon(
|
||||
new InsetDrawable(mContext.getDrawable(R.drawable.ic_headset_24dp), INSET_SIZE));
|
||||
holder.setIcon(R.drawable.ic_headset_24dp);
|
||||
holder.setTitle(mContext.getText(R.string.audio_files_title));
|
||||
holder.setSummary(Formatter.formatFileSize(mContext, mMusicSize));
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.applications.manageapplications;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.os.UserHandle;
|
||||
import android.support.annotation.WorkerThread;
|
||||
import android.text.format.Formatter;
|
||||
@@ -36,7 +35,6 @@ public class PhotosViewHolderController implements FileViewHolderController {
|
||||
private static final String TAG = "PhotosViewHolderCtrl";
|
||||
|
||||
private static final String IMAGE_MIME_TYPE = "image/*";
|
||||
private static final int INSET_SIZE = 24; // dp
|
||||
|
||||
private Context mContext;
|
||||
private StorageStatsSource mSource;
|
||||
@@ -72,8 +70,7 @@ public class PhotosViewHolderController implements FileViewHolderController {
|
||||
|
||||
@Override
|
||||
public void setupView(ApplicationViewHolder holder) {
|
||||
holder.setIcon(
|
||||
new InsetDrawable(mContext.getDrawable(R.drawable.ic_photo_library), INSET_SIZE));
|
||||
holder.setIcon(R.drawable.ic_photo_library);
|
||||
holder.setTitle(mContext.getText(R.string.storage_detail_images));
|
||||
holder.setSummary(Formatter.formatFileSize(mContext, mFilesSize));
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ public class AppDataUsagePreference extends Preference {
|
||||
super(context);
|
||||
mItem = item;
|
||||
mPercent = percent;
|
||||
setLayoutResource(R.layout.data_usage_item);
|
||||
setLayoutResource(R.layout.preference_app);
|
||||
setWidgetLayoutResource(R.layout.widget_progress_bar);
|
||||
|
||||
if (item.restricted && item.total <= 0) {
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.development;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -37,23 +36,21 @@ public class AppViewHolder {
|
||||
static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
|
||||
if (convertView == null) {
|
||||
convertView = inflater.inflate(R.layout.preference_app, null);
|
||||
inflater.inflate(R.layout.widget_text_views,
|
||||
(ViewGroup) convertView.findViewById(android.R.id.widget_frame));
|
||||
|
||||
// Creates a ViewHolder and store references to the two children views
|
||||
// we want to bind data to.
|
||||
AppViewHolder holder = new AppViewHolder();
|
||||
holder.rootView = convertView;
|
||||
holder.appName = (TextView) convertView.findViewById(android.R.id.title);
|
||||
holder.appIcon = (ImageView) convertView.findViewById(android.R.id.icon);
|
||||
holder.summary = (TextView) convertView.findViewById(R.id.widget_text1);
|
||||
holder.disabled = (TextView) convertView.findViewById(R.id.widget_text2);
|
||||
holder.appName = convertView.findViewById(android.R.id.title);
|
||||
holder.appIcon = convertView.findViewById(android.R.id.icon);
|
||||
holder.summary = convertView.findViewById(android.R.id.summary);
|
||||
holder.disabled = convertView.findViewById(R.id.appendix);
|
||||
convertView.setTag(holder);
|
||||
return holder;
|
||||
} else {
|
||||
// Get the ViewHolder back to get fast access to the TextView
|
||||
// and the ImageView.
|
||||
return (AppViewHolder)convertView.getTag();
|
||||
return (AppViewHolder) convertView.getTag();
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,6 +22,7 @@ import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.annotation.XmlRes;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.text.TextUtils;
|
||||
@@ -133,8 +134,13 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
final String systemDefaultKey = getSystemDefaultKey();
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
screen.removeAll();
|
||||
|
||||
final int customLayoutResId = getRadioButtomPreferenceCustomLayoutResId();
|
||||
if (shouldShowItemNone()) {
|
||||
final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
|
||||
if (customLayoutResId > 0) {
|
||||
nonePref.setLayoutResource(customLayoutResId);
|
||||
}
|
||||
nonePref.setIcon(R.drawable.ic_remove_circle);
|
||||
nonePref.setTitle(R.string.app_list_preference_none);
|
||||
nonePref.setChecked(TextUtils.isEmpty(defaultKey));
|
||||
@@ -144,6 +150,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
if (candidateList != null) {
|
||||
for (CandidateInfo info : candidateList) {
|
||||
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
|
||||
if (customLayoutResId > 0) {
|
||||
pref.setLayoutResource(customLayoutResId);
|
||||
}
|
||||
bindPreference(pref, info.getKey(), info, defaultKey);
|
||||
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
|
||||
screen.addPreference(pref);
|
||||
@@ -206,6 +215,14 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a custom layout for each candidate row.
|
||||
*/
|
||||
@XmlRes
|
||||
protected int getRadioButtomPreferenceCustomLayoutResId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static abstract class CandidateInfo {
|
||||
|
||||
public final boolean enabled;
|
||||
|
Reference in New Issue
Block a user