Merge "App info > storage updates" into mnc-dev

This commit is contained in:
Jason Monk
2015-05-12 19:20:38 +00:00
committed by Android (Google) Code Review
6 changed files with 134 additions and 195 deletions

View File

@@ -1,151 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/all_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:orientation="vertical">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/category_title"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_category_title_height"
android:singleLine="true"
android:gravity="center_vertical"
android:textAppearance="@style/TextAppearance.CategoryTitle"
android:textAlignment="viewStart"
android:text="@string/storage_label"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="0dip">
<TextView
android:id="@+id/total_size_prefix"
android:text="@string/total_size_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="?android:textColorPrimary"
android:maxLines="1" />
<TextView
android:id="@+id/total_size_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:maxLines="1" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="3dip">
<TextView
android:id="@+id/application_size_prefix"
android:text="@string/application_size_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="?android:textColorPrimary"
android:maxLines="1" />
<TextView
android:id="@+id/application_size_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:maxLines="1" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="3dip">
<TextView
android:id="@+id/external_code_size_prefix"
android:text="@string/external_code_size_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="?android:textColorPrimary"
android:maxLines="1" />
<TextView
android:id="@+id/external_code_size_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:maxLines="1" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="3dip">
<TextView
android:id="@+id/data_size_prefix"
android:text="@string/data_size_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="?android:textColorPrimary"
android:maxLines="1" />
<TextView
android:id="@+id/data_size_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:maxLines="1" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="3dip">
<TextView
android:id="@+id/external_data_size_prefix"
android:text="@string/external_data_size_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="?android:textColorPrimary"
android:maxLines="1" />
<TextView
android:id="@+id/external_data_size_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:maxLines="1" />
</FrameLayout>
<include
android:id="@+id/clear_data_button"
layout="@layout/single_button_panel" />
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
</LinearLayout>

View File

@@ -20,7 +20,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="3dp"
android:paddingTop="1dp"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">

View File

@@ -22,15 +22,20 @@
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"
android:gravity="bottom"
android:paddingTop="4dip"
android:paddingTop="6dip"
android:paddingBottom="6dip"
android:orientation="horizontal">
<Button
android:id="@+id/button"
android:layout_width="120dip"
android:layout_weight="0.4"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
android:layout_gravity="center_vertical"
android:backgroundTint="?android:attr/colorAccent"
android:textColor="@android:color/white" />
<Space
android:layout_width="0dip"
android:layout_height="wrap_content"

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 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.
-->
<!-- Based on frameworks/base/core/res/res/layout/preference_category_material.xml.
except has paddingBottom set.-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:textAppearance="@android:style/TextAppearance.Material.Body2"
android:textColor="?android:attr/colorAccent"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingBottom="8dp"
android:paddingTop="16dip" />

View File

@@ -23,12 +23,54 @@
android:summary="@string/storage_type_internal"
android:selectable="true" />
<com.android.settings.applications.LayoutPreference
android:key="storage_settings"
android:layout="@layout/app_storage_settings" />
<PreferenceCategory
android:key="storage_category"
android:layout="@layout/tall_preference_category"
android:title="@string/storage_label">
<Preference
android:key="total_size"
android:title="@string/total_size_label"
android:selectable="false"
android:layout="@layout/horizontal_preference" />
<Preference
android:key="app_size"
android:title="@string/application_size_label"
android:selectable="false"
android:layout="@layout/horizontal_preference" />
<Preference
android:key="external_code_size"
android:title="@string/external_code_size_label"
android:selectable="false"
android:layout="@layout/horizontal_preference" />
<Preference
android:key="data_size"
android:title="@string/data_size_label"
android:selectable="false"
android:layout="@layout/horizontal_preference" />
<Preference
android:key="external_data_size"
android:title="@string/external_data_size_label"
android:selectable="false"
android:layout="@layout/horizontal_preference" />
<com.android.settings.applications.LayoutPreference
android:key="cache_settings"
android:layout="@layout/app_cache_settings" />
android:key="clear_data_button"
android:layout="@layout/single_button_panel" />
</PreferenceCategory>
<Preference
android:key="cache_size"
android:title="@string/cache_size_label"
android:layout="@layout/horizontal_preference" />
<com.android.settings.applications.LayoutPreference
android:key="clear_cache_button"
android:selectable="false"
android:layout="@layout/single_button_panel" />
</PreferenceScreen>

View File

@@ -29,6 +29,8 @@ import android.os.Handler;
import android.os.Message;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.text.format.Formatter;
import android.util.Log;
import android.view.View;
@@ -69,17 +71,26 @@ public class AppStorageSettings extends AppInfoWithHeader
private static final int DLG_CANNOT_CLEAR_DATA = DLG_BASE + 2;
private static final String KEY_MOVE_PREFERENCE = "app_location_setting";
private static final String KEY_STORAGE_SETTINGS = "storage_settings";
private static final String KEY_CACHE_SETTINGS = "cache_settings";
private static final String KEY_STORAGE_CATEGORY = "storage_category";
private TextView mTotalSize;
private TextView mAppSize;
private TextView mDataSize;
private TextView mExternalCodeSize;
private TextView mExternalDataSize;
private static final String KEY_TOTAL_SIZE = "total_size";
private static final String KEY_APP_SIZE = "app_size";
private static final String KEY_EXTERNAL_CODE_SIZE = "external_code_size";
private static final String KEY_DATA_SIZE = "data_size";
private static final String KEY_EXTERNAL_DATA_SIZE = "external_data_size";
private static final String KEY_CACHE_SIZE = "cache_size";
private static final String KEY_CLEAR_DATA = "clear_data_button";
private static final String KEY_CLEAR_CACHE = "clear_cache_button";
private Preference mTotalSize;
private Preference mAppSize;
private Preference mDataSize;
private Preference mExternalCodeSize;
private Preference mExternalDataSize;
// Views related to cache info
private TextView mCacheSize;
private Preference mCacheSize;
private Button mClearDataButton;
private Button mClearCacheButton;
@@ -113,29 +124,28 @@ public class AppStorageSettings extends AppInfoWithHeader
private void setupViews() {
mComputingStr = getActivity().getText(R.string.computing_size);
mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value);
LayoutPreference view = (LayoutPreference) findPreference(KEY_STORAGE_SETTINGS);
// Set default values on sizes
mTotalSize = (TextView) view.findViewById(R.id.total_size_text);
mAppSize = (TextView) view.findViewById(R.id.application_size_text);
mDataSize = (TextView) view.findViewById(R.id.data_size_text);
mExternalCodeSize = (TextView) view.findViewById(R.id.external_code_size_text);
mExternalDataSize = (TextView) view.findViewById(R.id.external_data_size_text);
mTotalSize = findPreference(KEY_TOTAL_SIZE);
mAppSize = findPreference(KEY_APP_SIZE);
mDataSize = findPreference(KEY_DATA_SIZE);
mExternalCodeSize = findPreference(KEY_EXTERNAL_CODE_SIZE);
mExternalDataSize = findPreference(KEY_EXTERNAL_DATA_SIZE);
if (Environment.isExternalStorageEmulated()) {
((View) mExternalCodeSize.getParent()).setVisibility(View.GONE);
((View) mExternalDataSize.getParent()).setVisibility(View.GONE);
PreferenceCategory category = (PreferenceCategory) findPreference(KEY_STORAGE_CATEGORY);
category.removePreference(mExternalCodeSize);
category.removePreference(mExternalDataSize);
}
mClearDataButton = (Button) view.findViewById(R.id.clear_data_button)
mClearDataButton = (Button) ((LayoutPreference) findPreference(KEY_CLEAR_DATA))
.findViewById(R.id.button);
mMoveDropDown = (DropDownPreference) findPreference(KEY_MOVE_PREFERENCE);
mMoveDropDown.setCallback(this);
view = (LayoutPreference) findPreference(KEY_CACHE_SETTINGS);
// Cache section
mCacheSize = (TextView) view.findViewById(R.id.cache_size_text);
mClearCacheButton = (Button) view.findViewById(R.id.clear_cache_button)
mCacheSize = findPreference(KEY_CACHE_SIZE);
mClearCacheButton = (Button) ((LayoutPreference) findPreference(KEY_CLEAR_CACHE))
.findViewById(R.id.button);
mClearCacheButton.setText(R.string.clear_cache_btn_text);
}
@@ -192,10 +202,10 @@ public class AppStorageSettings extends AppInfoWithHeader
|| mAppEntry.size == ApplicationsState.SIZE_UNKNOWN) {
mLastCodeSize = mLastDataSize = mLastCacheSize = mLastTotalSize = -1;
if (!mHaveSizes) {
mAppSize.setText(mComputingStr);
mDataSize.setText(mComputingStr);
mCacheSize.setText(mComputingStr);
mTotalSize.setText(mComputingStr);
mAppSize.setSummary(mComputingStr);
mDataSize.setSummary(mComputingStr);
mCacheSize.setSummary(mComputingStr);
mTotalSize.setSummary(mComputingStr);
}
mClearDataButton.setEnabled(false);
mClearCacheButton.setEnabled(false);
@@ -210,29 +220,29 @@ public class AppStorageSettings extends AppInfoWithHeader
} else {
if (mLastExternalCodeSize != mAppEntry.externalCodeSize) {
mLastExternalCodeSize = mAppEntry.externalCodeSize;
mExternalCodeSize.setText(getSizeStr(mAppEntry.externalCodeSize));
mExternalCodeSize.setSummary(getSizeStr(mAppEntry.externalCodeSize));
}
if (mLastExternalDataSize != mAppEntry.externalDataSize) {
mLastExternalDataSize = mAppEntry.externalDataSize;
mExternalDataSize.setText(getSizeStr( mAppEntry.externalDataSize));
mExternalDataSize.setSummary(getSizeStr( mAppEntry.externalDataSize));
}
}
if (mLastCodeSize != codeSize) {
mLastCodeSize = codeSize;
mAppSize.setText(getSizeStr(codeSize));
mAppSize.setSummary(getSizeStr(codeSize));
}
if (mLastDataSize != dataSize) {
mLastDataSize = dataSize;
mDataSize.setText(getSizeStr(dataSize));
mDataSize.setSummary(getSizeStr(dataSize));
}
long cacheSize = mAppEntry.cacheSize + mAppEntry.externalCacheSize;
if (mLastCacheSize != cacheSize) {
mLastCacheSize = cacheSize;
mCacheSize.setText(getSizeStr(cacheSize));
mCacheSize.setSummary(getSizeStr(cacheSize));
}
if (mLastTotalSize != mAppEntry.size) {
mLastTotalSize = mAppEntry.size;
mTotalSize.setText(getSizeStr(mAppEntry.size));
mTotalSize.setSummary(getSizeStr(mAppEntry.size));
}
if ((mAppEntry.dataSize+ mAppEntry.externalDataSize) <= 0 || !mCanClearData) {
@@ -304,6 +314,7 @@ public class AppStorageSettings extends AppInfoWithHeader
final List<VolumeInfo> candidates = context.getPackageManager()
.getPackageCandidateVolumes(mAppEntry.info);
if (candidates.size() > 1) {
Collections.sort(candidates, VolumeInfo.getDescriptionComparator());
mMoveDropDown.clearItems();
@@ -312,6 +323,9 @@ public class AppStorageSettings extends AppInfoWithHeader
mMoveDropDown.addItem(volDescrip, vol);
}
mMoveDropDown.setSelectable(!mAppControlRestricted);
} else {
removePreference(KEY_MOVE_PREFERENCE);
}
}
/*