diff --git a/res/layout/app_cache_settings.xml b/res/layout/app_cache_settings.xml
new file mode 100644
index 00000000000..bb57433ec34
--- /dev/null
+++ b/res/layout/app_cache_settings.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/app_storage_settings.xml b/res/layout/app_storage_settings.xml
new file mode 100644
index 00000000000..82493f762d3
--- /dev/null
+++ b/res/layout/app_storage_settings.xml
@@ -0,0 +1,151 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/single_button_panel.xml b/res/layout/single_button_panel.xml
new file mode 100755
index 00000000000..5f1fee9c598
--- /dev/null
+++ b/res/layout/single_button_panel.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/storage_settings.xml b/res/layout/storage_settings.xml
deleted file mode 100644
index a73cf4cdfb7..00000000000
--- a/res/layout/storage_settings.xml
+++ /dev/null
@@ -1,306 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 14670a7bd5e..f4edc7a4a58 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6053,15 +6053,18 @@
%1$s used in %2$s
- internal storage
+ Internal storage
- external storage
+ External storage
App data usage
%1$s used since %2$s
+
+ Storage used
+
On
diff --git a/res/xml/app_storage_settings.xml b/res/xml/app_storage_settings.xml
new file mode 100644
index 00000000000..6baaae1dbdc
--- /dev/null
+++ b/res/xml/app_storage_settings.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index cb923c8bd9c..0134c6fdf81 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -19,7 +19,7 @@
android:key="battery_saver">
-
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index db650f3b8cf..70dcb9a6bbc 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -81,7 +81,7 @@
android:entryValues="@array/entryvalues_font_size"
android:dialogTitle="@string/dialog_title_font_size" />
-
diff --git a/res/xml/installed_app_details.xml b/res/xml/installed_app_details.xml
index 2f72f5d27db..09f5bb351fc 100644
--- a/res/xml/installed_app_details.xml
+++ b/res/xml/installed_app_details.xml
@@ -16,7 +16,7 @@
-
diff --git a/res/xml/notification_settings.xml b/res/xml/notification_settings.xml
index 6e62f83f3c4..ac61b001b3e 100644
--- a/res/xml/notification_settings.xml
+++ b/res/xml/notification_settings.xml
@@ -105,7 +105,7 @@
android:persistent="false" />
-
diff --git a/res/xml/other_sound_settings.xml b/res/xml/other_sound_settings.xml
index 08679db9c49..88c41304ce4 100644
--- a/res/xml/other_sound_settings.xml
+++ b/res/xml/other_sound_settings.xml
@@ -60,13 +60,13 @@
android:persistent="false" />
-
-
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 751456574c5..3ac4eef7014 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -20,7 +20,7 @@
android:title="@string/zen_mode_settings_title" >
-
@@ -50,7 +50,7 @@
android:switchTextOff=""
android:switchTextOn="" />
-
@@ -79,7 +79,7 @@
-
-
\ No newline at end of file
+
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 337ec232b87..33581240659 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -17,8 +17,7 @@
package com.android.settings;
import com.android.internal.view.RotationPolicy;
-import com.android.settings.notification.DropDownPreference;
-import com.android.settings.notification.DropDownPreference.Callback;
+import com.android.settings.DropDownPreference.Callback;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
diff --git a/src/com/android/settings/notification/DropDownPreference.java b/src/com/android/settings/DropDownPreference.java
similarity index 98%
rename from src/com/android/settings/notification/DropDownPreference.java
rename to src/com/android/settings/DropDownPreference.java
index 1d1b366785b..8f8ec78c1e4 100644
--- a/src/com/android/settings/notification/DropDownPreference.java
+++ b/src/com/android/settings/DropDownPreference.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.settings.notification;
+package com.android.settings;
import android.content.Context;
import android.preference.Preference;
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
index 72fa8054daf..2f65a76793f 100644
--- a/src/com/android/settings/applications/AppStorageSettings.java
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -32,10 +32,8 @@ import android.os.Message;
import android.os.RemoteException;
import android.text.format.Formatter;
import android.util.Log;
-import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
@@ -43,8 +41,10 @@ import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.applications.ApplicationsState.AppEntry;
import com.android.settings.applications.ApplicationsState.Callbacks;
+import com.android.settings.DropDownPreference;
-public class AppStorageSettings extends AppInfoWithHeader implements OnClickListener, Callbacks {
+public class AppStorageSettings extends AppInfoWithHeader
+ implements OnClickListener, Callbacks, DropDownPreference.Callback {
private static final String TAG = AppStorageSettings.class.getSimpleName();
//internal constants used in Handler
@@ -65,6 +65,10 @@ public class AppStorageSettings extends AppInfoWithHeader implements OnClickList
private static final int DLG_CANNOT_CLEAR_DATA = DLG_BASE + 2;
private static final int DLG_MOVE_FAILED = DLG_BASE + 3;
+ 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 CanBeOnSdCardChecker mCanBeOnSdCardChecker;
private TextView mTotalSize;
private TextView mAppSize;
@@ -76,7 +80,8 @@ public class AppStorageSettings extends AppInfoWithHeader implements OnClickList
private TextView mCacheSize;
private Button mClearDataButton;
private Button mClearCacheButton;
- private Button mMoveAppButton;
+
+ private DropDownPreference mMoveDropDown;
private boolean mMoveInProgress = false;
private boolean mCanClearData = true;
@@ -102,40 +107,38 @@ public class AppStorageSettings extends AppInfoWithHeader implements OnClickList
super.onCreate(savedInstanceState);
mCanBeOnSdCardChecker = new CanBeOnSdCardChecker();
+ addPreferencesFromResource(R.xml.app_storage_settings);
+ setupViews();
}
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- final View view = inflater.inflate(R.layout.storage_settings, container, false);
-
- final ViewGroup allDetails = (ViewGroup)view.findViewById(R.id.all_details);
- Utils.forceCustomPadding(allDetails, true /* additive padding */);
+ 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 = (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);
if (Environment.isExternalStorageEmulated()) {
- ((View)mExternalCodeSize.getParent()).setVisibility(View.GONE);
- ((View)mExternalDataSize.getParent()).setVisibility(View.GONE);
+ ((View) mExternalCodeSize.getParent()).setVisibility(View.GONE);
+ ((View) mExternalDataSize.getParent()).setVisibility(View.GONE);
}
+ mClearDataButton = (Button) view.findViewById(R.id.clear_data_button)
+ .findViewById(R.id.button);
- // Initialize clear data and move install location buttons
- View data_buttons_panel = view.findViewById(R.id.data_buttons_panel);
- mMoveAppButton = (Button) data_buttons_panel.findViewById(R.id.left_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);
- mClearDataButton = (Button) data_buttons_panel.findViewById(R.id.right_button);
-
- return view;
+ mCacheSize = (TextView) view.findViewById(R.id.cache_size_text);
+ mClearCacheButton = (Button) view.findViewById(R.id.clear_cache_button)
+ .findViewById(R.id.button);
+ mClearCacheButton.setText(R.string.clear_cache_btn_text);
}
@Override
@@ -157,16 +160,24 @@ public class AppStorageSettings extends AppInfoWithHeader implements OnClickList
} else {
showDialogInner(DLG_CLEAR_DATA, 0);
}
- } else if (v == mMoveAppButton) {
+ }
+ }
+
+ @Override
+ public boolean onItemSelected(int pos, Object value) {
+ boolean selectedExternal = (Boolean) value;
+ boolean isExternal = (mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
+ if (selectedExternal ^ isExternal) {
if (mPackageMoveObserver == null) {
mPackageMoveObserver = new PackageMoveObserver();
}
- int moveFlags = (mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0 ?
- PackageManager.MOVE_INTERNAL : PackageManager.MOVE_EXTERNAL_MEDIA;
+ int moveFlags = selectedExternal ? PackageManager.MOVE_EXTERNAL_MEDIA
+ : PackageManager.MOVE_INTERNAL;
mMoveInProgress = true;
refreshButtons();
mPm.movePackage(mAppEntry.info.packageName, mPackageMoveObserver, moveFlags);
}
+ return true;
}
private String getSizeStr(long size) {
@@ -248,16 +259,26 @@ public class AppStorageSettings extends AppInfoWithHeader implements OnClickList
retrieveAppEntry();
refreshButtons();
refreshSizeInfo();
+ boolean isExternal = (mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
+ mMoveDropDown.setSelectedItem(isExternal ? 1 : 0);
return true;
}
private void refreshButtons() {
if (!mMoveInProgress) {
- initMoveButton();
+ initMoveDropDown();
initDataButtons();
} else {
- mMoveAppButton.setText(R.string.moving);
- mMoveAppButton.setEnabled(false);
+ mMoveDropDown.setSummary(R.string.moving);
+ mMoveDropDown.setSelectable(false);
+ }
+ }
+
+ private void updateMoveEnabled(boolean enabled) {
+ mMoveDropDown.clearItems();
+ mMoveDropDown.addItem(R.string.storage_type_internal, false);
+ if (enabled) {
+ mMoveDropDown.addItem(R.string.storage_type_external, true);
}
}
@@ -287,30 +308,22 @@ public class AppStorageSettings extends AppInfoWithHeader implements OnClickList
}
}
- private void initMoveButton() {
+ private void initMoveDropDown() {
if (Environment.isExternalStorageEmulated()) {
- mMoveAppButton.setVisibility(View.INVISIBLE);
+ updateMoveEnabled(false);
return;
}
boolean dataOnly = (mPackageInfo == null) && (mAppEntry != null);
boolean moveDisable = true;
- if (dataOnly) {
- mMoveAppButton.setText(R.string.move_app);
- } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
- mMoveAppButton.setText(R.string.move_app_to_internal);
+ if ((mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
// Always let apps move to internal storage from sdcard.
moveDisable = false;
} else {
- mMoveAppButton.setText(R.string.move_app_to_sdcard);
mCanBeOnSdCardChecker.init();
moveDisable = !mCanBeOnSdCardChecker.check(mAppEntry.info);
}
- if (moveDisable || mAppControlRestricted) {
- mMoveAppButton.setEnabled(false);
- } else {
- mMoveAppButton.setOnClickListener(this);
- mMoveAppButton.setEnabled(true);
- }
+ updateMoveEnabled(!moveDisable);
+ mMoveDropDown.setSelectable(!mAppControlRestricted);
}
/*
@@ -360,7 +373,7 @@ public class AppStorageSettings extends AppInfoWithHeader implements OnClickList
int result = msg.arg1;
String packageName = mAppEntry.info.packageName;
mClearDataButton.setText(R.string.clear_user_data_text);
- if(result == OP_SUCCESSFUL) {
+ if (result == OP_SUCCESSFUL) {
Log.i(TAG, "Cleared user data for package : "+packageName);
mState.requestSize(mPackageName, mUserId);
} else {
@@ -485,7 +498,7 @@ public class AppStorageSettings extends AppInfoWithHeader implements OnClickList
class ClearUserDataObserver extends IPackageDataObserver.Stub {
public void onRemoveCompleted(final String packageName, final boolean succeeded) {
final Message msg = mHandler.obtainMessage(MSG_CLEAR_USER_DATA);
- msg.arg1 = succeeded?OP_SUCCESSFUL:OP_FAILED;
+ msg.arg1 = succeeded ? OP_SUCCESSFUL : OP_FAILED;
mHandler.sendMessage(msg);
}
}
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 0ab66ae5a17..85b35235c0f 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -109,7 +109,7 @@ public class InstalledAppDetails extends AppInfoBase
private boolean mInitialized;
private boolean mShowUninstalled;
- private HeaderPreference mHeader;
+ private LayoutPreference mHeader;
private Button mUninstallButton;
private boolean mUpdatedSysApp = false;
private TextView mAppVersion;
@@ -259,7 +259,7 @@ public class InstalledAppDetails extends AppInfoBase
}
private void handleHeader() {
- mHeader = (HeaderPreference) findPreference(KEY_HEADER);
+ mHeader = (LayoutPreference) findPreference(KEY_HEADER);
// Get Control button panel
View btnPanel = mHeader.findViewById(R.id.control_buttons_panel);
diff --git a/src/com/android/settings/applications/HeaderPreference.java b/src/com/android/settings/applications/LayoutPreference.java
similarity index 91%
rename from src/com/android/settings/applications/HeaderPreference.java
rename to src/com/android/settings/applications/LayoutPreference.java
index 3af42a204c1..c74ad16dd4e 100644
--- a/src/com/android/settings/applications/HeaderPreference.java
+++ b/src/com/android/settings/applications/LayoutPreference.java
@@ -27,18 +27,18 @@ import android.view.ViewGroup;
import com.android.settings.R;
import com.android.settings.Utils;
-public class HeaderPreference extends Preference {
+public class LayoutPreference extends Preference {
private View mRootView;
- public HeaderPreference(Context context, AttributeSet attrs) {
+ public LayoutPreference(Context context, AttributeSet attrs) {
super(context, attrs);
final TypedArray a = context.obtainStyledAttributes(
attrs, com.android.internal.R.styleable.Preference, 0, 0);
int layoutResource = a.getResourceId(com.android.internal.R.styleable.Preference_layout,
0);
if (layoutResource == 0) {
- throw new IllegalArgumentException("HeaderPreference requires a layout to be defined");
+ throw new IllegalArgumentException("LayoutPreference requires a layout to be defined");
}
// Need to create view now so that findViewById can be called immediately.
final View view = LayoutInflater.from(getContext())
diff --git a/src/com/android/settings/notification/NotificationSettings.java b/src/com/android/settings/notification/NotificationSettings.java
index 41ae0aba104..123f0ef6443 100644
--- a/src/com/android/settings/notification/NotificationSettings.java
+++ b/src/com/android/settings/notification/NotificationSettings.java
@@ -49,6 +49,7 @@ import android.provider.Settings;
import android.util.Log;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.DropDownPreference;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
diff --git a/src/com/android/settings/notification/SettingPref.java b/src/com/android/settings/notification/SettingPref.java
index a06c35aadad..a20d1b4df6a 100644
--- a/src/com/android/settings/notification/SettingPref.java
+++ b/src/com/android/settings/notification/SettingPref.java
@@ -26,6 +26,7 @@ import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings.Global;
import android.provider.Settings.System;
+import com.android.settings.DropDownPreference;
import com.android.settings.SettingsPreferenceFragment;
/** Helper to manage a two-state or dropdown preference bound to a global or system setting. */
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index 556296c1acf..441990b4ba0 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -50,6 +50,7 @@ import android.util.SparseArray;
import android.widget.ScrollView;
import android.widget.TimePicker;
+import com.android.settings.DropDownPreference;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.search.BaseSearchIndexProvider;