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:
@@ -1,58 +0,0 @@
|
|||||||
<!--
|
|
||||||
Copyright (C) 2014 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?android:attr/actionBarSize"
|
|
||||||
android:background="@drawable/switchbar_background"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:theme="?attr/switchBarTheme" >
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/app_icon"
|
|
||||||
android:layout_width="@dimen/switchbar_subsettings_margin_start"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:gravity="end"
|
|
||||||
android:layout_centerVertical="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/app_name"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_toStartOf="@+id/app_settings"
|
|
||||||
android:layout_marginStart="@dimen/switchbar_subsettings_margin_start"
|
|
||||||
android:layout_alignWithParentIfMissing="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:textAppearance="@style/TextAppearance.Switch"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textAlignment="viewStart" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@id/app_settings"
|
|
||||||
android:layout_width="56dp"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_marginEnd="@dimen/switchbar_subsettings_margin_end"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:minHeight="0dp"
|
|
||||||
android:minWidth="0dp"
|
|
||||||
android:contentDescription="@string/notification_app_settings_button"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:src="@drawable/ic_settings_24dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
style="?android:attr/borderlessButtonStyle" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
@@ -1,81 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2011 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:minHeight="72dp"
|
|
||||||
android:paddingTop="12dp"
|
|
||||||
android:paddingBottom="12dp"
|
|
||||||
android:gravity="top"
|
|
||||||
android:columnCount="3"
|
|
||||||
android:duplicateParentState="true">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@android:id/icon"
|
|
||||||
android:layout_width="48dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:layout_marginEnd="16dip"
|
|
||||||
android:contentDescription="@null"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toEndOf="@android:id/icon"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
android:textAlignment="viewStart"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/summary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toEndOf="@android:id/title"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_marginStart="6dip"
|
|
||||||
android:gravity="end"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee"
|
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
<Switch
|
|
||||||
android:id="@android:id/switch_widget"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:background="@null"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@android:id/widget_frame"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_toEndOf="@android:id/icon"
|
|
||||||
android:layout_below="@android:id/title"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_gravity="fill_horizontal|top"
|
|
||||||
android:duplicateParentState="true" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2011 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
|
||||||
|
|
||||||
<include layout="@layout/app_item" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
@@ -13,13 +13,74 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
<LinearLayout
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||||
|
|
||||||
<include layout="@layout/app_item" />
|
<LinearLayout
|
||||||
|
android:id="@+id/icon_frame"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:minWidth="60dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingEnd="12dp"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="4dp">
|
||||||
|
<android.support.v7.internal.widget.PreferenceImageView
|
||||||
|
android:id="@android:id/icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
settings:maxWidth="24dp"
|
||||||
|
settings:maxHeight="24dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
<TextView android:id="@android:id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="@style/TextAppearance.TileTitle"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:fadingEdge="horizontal" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/summary_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView android:id="@android:id/summary"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textAppearance="@style/TextAppearance.Small"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end" />
|
||||||
|
|
||||||
|
<TextView android:id="@+id/appendix"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/TextAppearance.Small"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end" />
|
||||||
|
</LinearLayout>
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@android:id/widget_frame"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -231,6 +231,7 @@ public class RecentAppsPreferenceController extends AbstractPreferenceController
|
|||||||
Preference pref = appPreferences.remove(pkgName);
|
Preference pref = appPreferences.remove(pkgName);
|
||||||
if (pref == null) {
|
if (pref == null) {
|
||||||
pref = new Preference(prefContext);
|
pref = new Preference(prefContext);
|
||||||
|
pref.setLayoutResource(R.layout.preference_app);
|
||||||
rebindPref = false;
|
rebindPref = false;
|
||||||
}
|
}
|
||||||
pref.setKey(pkgName);
|
pref.setKey(pkgName);
|
||||||
|
@@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import android.support.annotation.VisibleForTesting;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -38,33 +39,39 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
|||||||
private final TextView mAppName;
|
private final TextView mAppName;
|
||||||
private final ImageView mAppIcon;
|
private final ImageView mAppIcon;
|
||||||
|
|
||||||
|
private final boolean mKeepStableHeight;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
View mSummaryContainer;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final TextView mSummary;
|
final TextView mSummary;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final TextView mDisabled;
|
final TextView mDisabled;
|
||||||
|
|
||||||
ApplicationViewHolder(View itemView) {
|
|
||||||
|
ApplicationViewHolder(View itemView, boolean keepStableHeight) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
mAppName = itemView.findViewById(android.R.id.title);
|
mAppName = itemView.findViewById(android.R.id.title);
|
||||||
mAppIcon = itemView.findViewById(android.R.id.icon);
|
mAppIcon = itemView.findViewById(android.R.id.icon);
|
||||||
mSummary = itemView.findViewById(R.id.widget_text1);
|
mSummaryContainer = itemView.findViewById(R.id.summary_container);
|
||||||
mDisabled = itemView.findViewById(R.id.widget_text2);
|
mSummary = itemView.findViewById(android.R.id.summary);
|
||||||
|
mDisabled = itemView.findViewById(R.id.appendix);
|
||||||
|
mKeepStableHeight = keepStableHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
static View newView(LayoutInflater inflater, ViewGroup parent) {
|
static View newView(ViewGroup parent) {
|
||||||
final View root = LayoutInflater.from(parent.getContext())
|
return LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.preference_app, parent, false);
|
.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) {
|
void setSummary(CharSequence summary) {
|
||||||
mSummary.setText(summary);
|
mSummary.setText(summary);
|
||||||
|
updateSummaryContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSummary(@StringRes int summary) {
|
void setSummary(@StringRes int summary) {
|
||||||
mSummary.setText(summary);
|
mSummary.setText(summary);
|
||||||
|
updateSummaryContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEnabled(boolean isEnabled) {
|
void setEnabled(boolean isEnabled) {
|
||||||
@@ -78,6 +85,10 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
|||||||
mAppName.setText(title);
|
mAppName.setText(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setIcon(int drawableRes) {
|
||||||
|
mAppIcon.setImageResource(drawableRes);
|
||||||
|
}
|
||||||
|
|
||||||
void setIcon(Drawable icon) {
|
void setIcon(Drawable icon) {
|
||||||
if (icon == null) {
|
if (icon == null) {
|
||||||
return;
|
return;
|
||||||
@@ -96,6 +107,17 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
|||||||
} else {
|
} else {
|
||||||
mDisabled.setVisibility(View.GONE);
|
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) {
|
void updateSizeText(AppEntry entry, CharSequence invalidSizeStr, int whichSize) {
|
||||||
|
@@ -412,20 +412,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
return null;
|
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
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
switch (mListType) {
|
switch (mListType) {
|
||||||
@@ -924,9 +910,9 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ApplicationViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
final View view = ApplicationViewHolder.newView(
|
final View view = ApplicationViewHolder.newView(parent);
|
||||||
LayoutInflater.from(parent.getContext()), parent);
|
return new ApplicationViewHolder(view,
|
||||||
return new ApplicationViewHolder(view);
|
shouldUseStableItemHeight(mManageApplications.mListType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (info1 == null || info2 == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,6 @@ package com.android.settings.applications.manageapplications;
|
|||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.InsetDrawable;
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.DocumentsContract;
|
import android.provider.DocumentsContract;
|
||||||
import android.support.annotation.WorkerThread;
|
import android.support.annotation.WorkerThread;
|
||||||
@@ -39,7 +38,6 @@ public class MusicViewHolderController implements FileViewHolderController {
|
|||||||
private static final String TAG = "MusicViewHolderCtrl";
|
private static final String TAG = "MusicViewHolderCtrl";
|
||||||
|
|
||||||
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
|
private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
|
||||||
private static final int INSET_SIZE = 24; // dp
|
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private StorageStatsSource mSource;
|
private StorageStatsSource mSource;
|
||||||
@@ -73,8 +71,7 @@ public class MusicViewHolderController implements FileViewHolderController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupView(ApplicationViewHolder holder) {
|
public void setupView(ApplicationViewHolder holder) {
|
||||||
holder.setIcon(
|
holder.setIcon(R.drawable.ic_headset_24dp);
|
||||||
new InsetDrawable(mContext.getDrawable(R.drawable.ic_headset_24dp), INSET_SIZE));
|
|
||||||
holder.setTitle(mContext.getText(R.string.audio_files_title));
|
holder.setTitle(mContext.getText(R.string.audio_files_title));
|
||||||
holder.setSummary(Formatter.formatFileSize(mContext, mMusicSize));
|
holder.setSummary(Formatter.formatFileSize(mContext, mMusicSize));
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,6 @@ package com.android.settings.applications.manageapplications;
|
|||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.InsetDrawable;
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.support.annotation.WorkerThread;
|
import android.support.annotation.WorkerThread;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
@@ -36,7 +35,6 @@ public class PhotosViewHolderController implements FileViewHolderController {
|
|||||||
private static final String TAG = "PhotosViewHolderCtrl";
|
private static final String TAG = "PhotosViewHolderCtrl";
|
||||||
|
|
||||||
private static final String IMAGE_MIME_TYPE = "image/*";
|
private static final String IMAGE_MIME_TYPE = "image/*";
|
||||||
private static final int INSET_SIZE = 24; // dp
|
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private StorageStatsSource mSource;
|
private StorageStatsSource mSource;
|
||||||
@@ -72,8 +70,7 @@ public class PhotosViewHolderController implements FileViewHolderController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupView(ApplicationViewHolder holder) {
|
public void setupView(ApplicationViewHolder holder) {
|
||||||
holder.setIcon(
|
holder.setIcon(R.drawable.ic_photo_library);
|
||||||
new InsetDrawable(mContext.getDrawable(R.drawable.ic_photo_library), INSET_SIZE));
|
|
||||||
holder.setTitle(mContext.getText(R.string.storage_detail_images));
|
holder.setTitle(mContext.getText(R.string.storage_detail_images));
|
||||||
holder.setSummary(Formatter.formatFileSize(mContext, mFilesSize));
|
holder.setSummary(Formatter.formatFileSize(mContext, mFilesSize));
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ public class AppDataUsagePreference extends Preference {
|
|||||||
super(context);
|
super(context);
|
||||||
mItem = item;
|
mItem = item;
|
||||||
mPercent = percent;
|
mPercent = percent;
|
||||||
setLayoutResource(R.layout.data_usage_item);
|
setLayoutResource(R.layout.preference_app);
|
||||||
setWidgetLayoutResource(R.layout.widget_progress_bar);
|
setWidgetLayoutResource(R.layout.widget_progress_bar);
|
||||||
|
|
||||||
if (item.restricted && item.total <= 0) {
|
if (item.restricted && item.total <= 0) {
|
||||||
|
@@ -18,7 +18,6 @@ package com.android.settings.development;
|
|||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -37,23 +36,21 @@ public class AppViewHolder {
|
|||||||
static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
|
static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = inflater.inflate(R.layout.preference_app, 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
|
// Creates a ViewHolder and store references to the two children views
|
||||||
// we want to bind data to.
|
// we want to bind data to.
|
||||||
AppViewHolder holder = new AppViewHolder();
|
AppViewHolder holder = new AppViewHolder();
|
||||||
holder.rootView = convertView;
|
holder.rootView = convertView;
|
||||||
holder.appName = (TextView) convertView.findViewById(android.R.id.title);
|
holder.appName = convertView.findViewById(android.R.id.title);
|
||||||
holder.appIcon = (ImageView) convertView.findViewById(android.R.id.icon);
|
holder.appIcon = convertView.findViewById(android.R.id.icon);
|
||||||
holder.summary = (TextView) convertView.findViewById(R.id.widget_text1);
|
holder.summary = convertView.findViewById(android.R.id.summary);
|
||||||
holder.disabled = (TextView) convertView.findViewById(R.id.widget_text2);
|
holder.disabled = convertView.findViewById(R.id.appendix);
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
return holder;
|
return holder;
|
||||||
} else {
|
} else {
|
||||||
// Get the ViewHolder back to get fast access to the TextView
|
// Get the ViewHolder back to get fast access to the TextView
|
||||||
// and the ImageView.
|
// 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.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import android.support.annotation.VisibleForTesting;
|
||||||
|
import android.support.annotation.XmlRes;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -133,8 +134,13 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
|||||||
final String systemDefaultKey = getSystemDefaultKey();
|
final String systemDefaultKey = getSystemDefaultKey();
|
||||||
final PreferenceScreen screen = getPreferenceScreen();
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
screen.removeAll();
|
screen.removeAll();
|
||||||
|
|
||||||
|
final int customLayoutResId = getRadioButtomPreferenceCustomLayoutResId();
|
||||||
if (shouldShowItemNone()) {
|
if (shouldShowItemNone()) {
|
||||||
final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
|
final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
|
||||||
|
if (customLayoutResId > 0) {
|
||||||
|
nonePref.setLayoutResource(customLayoutResId);
|
||||||
|
}
|
||||||
nonePref.setIcon(R.drawable.ic_remove_circle);
|
nonePref.setIcon(R.drawable.ic_remove_circle);
|
||||||
nonePref.setTitle(R.string.app_list_preference_none);
|
nonePref.setTitle(R.string.app_list_preference_none);
|
||||||
nonePref.setChecked(TextUtils.isEmpty(defaultKey));
|
nonePref.setChecked(TextUtils.isEmpty(defaultKey));
|
||||||
@@ -144,6 +150,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
|||||||
if (candidateList != null) {
|
if (candidateList != null) {
|
||||||
for (CandidateInfo info : candidateList) {
|
for (CandidateInfo info : candidateList) {
|
||||||
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
|
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
|
||||||
|
if (customLayoutResId > 0) {
|
||||||
|
pref.setLayoutResource(customLayoutResId);
|
||||||
|
}
|
||||||
bindPreference(pref, info.getKey(), info, defaultKey);
|
bindPreference(pref, info.getKey(), info, defaultKey);
|
||||||
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
|
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
|
||||||
screen.addPreference(pref);
|
screen.addPreference(pref);
|
||||||
@@ -206,6 +215,14 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a custom layout for each candidate row.
|
||||||
|
*/
|
||||||
|
@XmlRes
|
||||||
|
protected int getRadioButtomPreferenceCustomLayoutResId() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static abstract class CandidateInfo {
|
public static abstract class CandidateInfo {
|
||||||
|
|
||||||
public final boolean enabled;
|
public final boolean enabled;
|
||||||
|
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
@@ -48,9 +47,8 @@ public class ApplicationViewHolderTest {
|
|||||||
@Before
|
@Before
|
||||||
public void seUp() {
|
public void seUp() {
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mView = ApplicationViewHolder.newView(LayoutInflater.from(mContext),
|
mView = ApplicationViewHolder.newView(new FrameLayout(mContext));
|
||||||
new FrameLayout(mContext));
|
mHolder = new ApplicationViewHolder(mView, false /* useStableHeight */);
|
||||||
mHolder = new ApplicationViewHolder(mView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -71,6 +69,10 @@ public class ApplicationViewHolderTest {
|
|||||||
|
|
||||||
mHolder.setSummary(R.string.disabled);
|
mHolder.setSummary(R.string.disabled);
|
||||||
assertThat(mHolder.mSummary.getText()).isEqualTo(mContext.getText(R.string.disabled));
|
assertThat(mHolder.mSummary.getText()).isEqualTo(mContext.getText(R.string.disabled));
|
||||||
|
assertThat(mHolder.mSummaryContainer.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
|
||||||
|
mHolder.setSummary(null);
|
||||||
|
assertThat(mHolder.mSummaryContainer.getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -18,6 +18,10 @@ package com.android.settings.applications.manageapplications;
|
|||||||
|
|
||||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
||||||
.FILTER_APPS_ALL;
|
.FILTER_APPS_ALL;
|
||||||
|
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||||
|
.LIST_TYPE_MAIN;
|
||||||
|
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||||
|
.LIST_TYPE_NOTIFICATION;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
@@ -102,7 +106,7 @@ public class ManageApplicationsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void updateMenu_mainListType_showAppReset() {
|
public void updateMenu_mainListType_showAppReset() {
|
||||||
setUpOptionMenus();
|
setUpOptionMenus();
|
||||||
ReflectionHelpers.setField(mFragment, "mListType", ManageApplications.LIST_TYPE_MAIN);
|
ReflectionHelpers.setField(mFragment, "mListType", LIST_TYPE_MAIN);
|
||||||
ReflectionHelpers.setField(mFragment, "mOptionsMenu", mMenu);
|
ReflectionHelpers.setField(mFragment, "mOptionsMenu", mMenu);
|
||||||
|
|
||||||
mFragment.updateOptionsMenu();
|
mFragment.updateOptionsMenu();
|
||||||
@@ -182,6 +186,21 @@ public class ManageApplicationsTest {
|
|||||||
verify(loadingViewController).showLoadingViewDelayed();
|
verify(loadingViewController).showLoadingViewDelayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldUseStableItemHeight_mainType_yes() {
|
||||||
|
assertThat(ManageApplications.ApplicationsAdapter.shouldUseStableItemHeight(
|
||||||
|
LIST_TYPE_MAIN))
|
||||||
|
.isTrue();
|
||||||
|
assertThat(ManageApplications.ApplicationsAdapter.shouldUseStableItemHeight(
|
||||||
|
LIST_TYPE_NOTIFICATION))
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldUseStableItemHeight_notificationType_no() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onRebuildComplete_shouldHideLoadingView() {
|
public void onRebuildComplete_shouldHideLoadingView() {
|
||||||
final Context context = RuntimeEnvironment.application;
|
final Context context = RuntimeEnvironment.application;
|
||||||
|
@@ -27,7 +27,6 @@ import android.content.Intent;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.storage.VolumeInfo;
|
import android.os.storage.VolumeInfo;
|
||||||
import android.provider.DocumentsContract;
|
import android.provider.DocumentsContract;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
@@ -68,9 +67,8 @@ public class MusicViewHolderControllerTest {
|
|||||||
mController = new MusicViewHolderController(mContext, mSource, mVolume.fsUuid,
|
mController = new MusicViewHolderController(mContext, mSource, mVolume.fsUuid,
|
||||||
new UserHandle(0));
|
new UserHandle(0));
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
mView = ApplicationViewHolder.newView(new FrameLayout(mContext));
|
||||||
mView = ApplicationViewHolder.newView(inflater, new FrameLayout(mContext));
|
mHolder = new ApplicationViewHolder(mView, false /* useStableHeight */);
|
||||||
mHolder = new ApplicationViewHolder(mView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -26,7 +26,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.storage.VolumeInfo;
|
import android.os.storage.VolumeInfo;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
@@ -67,9 +66,8 @@ public class PhotosViewHolderControllerTest {
|
|||||||
new PhotosViewHolderController(
|
new PhotosViewHolderController(
|
||||||
mContext, mSource, mVolume.fsUuid, new UserHandle(0));
|
mContext, mSource, mVolume.fsUuid, new UserHandle(0));
|
||||||
|
|
||||||
final LayoutInflater inflater = LayoutInflater.from(mContext);
|
mView = ApplicationViewHolder.newView(new FrameLayout(mContext));
|
||||||
mView = ApplicationViewHolder.newView(inflater, new FrameLayout(mContext));
|
mHolder = new ApplicationViewHolder(mView, false /* useStableHeight */);
|
||||||
mHolder = new ApplicationViewHolder(mView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -32,6 +32,7 @@ import android.content.Context;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.TestConfig;
|
import com.android.settings.TestConfig;
|
||||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||||
@@ -41,6 +42,8 @@ import com.android.settings.testutils.FakeFeatureFactory;
|
|||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
|
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
|
||||||
import com.android.settings.widget.MasterSwitchPreference;
|
import com.android.settings.widget.MasterSwitchPreference;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -83,6 +86,10 @@ public class AutomaticStorageManagementSwitchPreferenceControllerTest {
|
|||||||
mContext, mMetricsFeature, mFragmentManager);
|
mContext, mMetricsFeature, mFragmentManager);
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
}
|
}
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
SettingsShadowSystemProperties.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_shouldReturnTrue_forHighRamDevice() {
|
public void isAvailable_shouldReturnTrue_forHighRamDevice() {
|
||||||
@@ -146,6 +153,9 @@ public class AutomaticStorageManagementSwitchPreferenceControllerTest {
|
|||||||
public void togglingOnShouldTriggerWarningFragment() {
|
public void togglingOnShouldTriggerWarningFragment() {
|
||||||
FragmentTransaction transaction = mock(FragmentTransaction.class);
|
FragmentTransaction transaction = mock(FragmentTransaction.class);
|
||||||
when (mFragmentManager.beginTransaction()).thenReturn(transaction);
|
when (mFragmentManager.beginTransaction()).thenReturn(transaction);
|
||||||
|
SettingsShadowSystemProperties.set(
|
||||||
|
AutomaticStorageManagementSwitchPreferenceController
|
||||||
|
.STORAGE_MANAGER_ENABLED_BY_DEFAULT_PROPERTY, "false");
|
||||||
|
|
||||||
mController.onSwitchToggled(true);
|
mController.onSwitchToggled(true);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user