Merge "Fix UI settings display issues" into honeycomb-LTE
diff --git a/res/layout-sw600dp/date_time_settings_setupwizard.xml b/res/layout-sw600dp/date_time_settings_setupwizard.xml
index b31462d..e37a4a6 100644
--- a/res/layout-sw600dp/date_time_settings_setupwizard.xml
+++ b/res/layout-sw600dp/date_time_settings_setupwizard.xml
@@ -1,168 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- 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
+ 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
- android:id="@+id/layout_root"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="@dimen/datetime_margin_top"
- android:paddingLeft="@dimen/screen_margin_sides"
- android:paddingRight="@dimen/screen_margin_sides"
- android:paddingBottom="@dimen/datetime_margin_bottom">
+-->
- <!-- Title: Set date & time-->
- <TextView
- android:id="@+id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minHeight="48dip"
- android:layout_alignParentLeft="true"
- android:layout_marginLeft="16dip"
- android:layout_alignParentTop="true"
- android:textSize="32dip"
- android:textColor="#FF99cc00"
- android:text="@string/date_and_time_settings_title_setup_wizard"
- android:gravity="bottom" />
-
- <!-- Divider -->
- <View
- android:id="@+id/top_divider"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/layout_root"
+ android:layout_height="match_parent"
android:layout_width="match_parent"
- android:layout_height="3dip"
- android:layout_below="@id/title"
- android:layout_marginTop="6dip"
- android:layout_marginBottom="17dip"
- android:background="@color/divider_color" />
+ android:paddingTop="96dip"
+ android:paddingLeft="40dip"
+ android:paddingRight="40dip"
+ android:paddingBottom="96dip"
+ android:orientation="vertical">
- <RelativeLayout
- android:id="@+id/timezone_auto_time"
- android:layout_width="716dip"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_below="@id/top_divider">
- <!-- timezone -->
- <Button
- android:id="@+id/time_zone_button"
- style="?android:attr/dropDownSpinnerStyle"
- android:layout_width="304dip"
- android:layout_height="48dip"
- android:layout_alignParentLeft="true"
- android:layout_alignBottom="@+id/date_time_auto"
- android:gravity="left|center_vertical"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="20dip" />
+ <FrameLayout android:id="@+id/timezone_dropdown_anchor"
+ android:layout_height="0px"
+ android:layout_width="match_parent"
+ android:layout_marginLeft="40dip"
+ android:layout_marginRight="40dip"/>
- <LinearLayout
- android:id="@+id/date_time_auto"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_toRightOf="@id/time_zone_button"
- android:layout_marginLeft="32dip"
- android:layout_alignParentRight="true">
+ <LinearLayout android:layout_height="0px"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:orientation="vertical">
- <Switch
- android:id="@+id/date_time_auto_button"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?android:attr/listPreferredItemHeight"
- android:layout_marginLeft="16dip"
- android:text="@string/date_time_auto"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="20dip" />
+ <fragment android:id="@+id/date_time_settings_fragment"
+ class="com.android.settings.DateTimeSettings"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
- <!-- Divider -->
- <View
- android:layout_width="match_parent"
- android:layout_height="1px"
- android:background="@color/divider_color" />
- </LinearLayout>
- </RelativeLayout>
-
- <LinearLayout
- android:layout_width="624dip"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_below="@+id/timezone_auto_time"
- android:layout_marginTop="48dip"
- android:orientation="horizontal">
-
- <LinearLayout
- android:layout_width="312dip"
- android:layout_height="wrap_content"
- android:orientation="vertical">
- <TextView
- android:id="@+id/date_picker_title"
- android:layout_width="match_parent"
- android:layout_height="48dip"
- android:text="@string/date_picker_title"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="20dip"
- android:clickable="false"
- android:longClickable="false"
- android:gravity="center" />
- <DatePicker
- android:id="@+id/date_picker"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/date_picker_title" />
- </LinearLayout>
-
- <!-- divider -->
- <View
- android:id="@+id/center_divider"
- android:layout_width="1dip"
- android:layout_height="match_parent"
- android:background="@color/divider_color" />
-
- <LinearLayout
- android:layout_width="312dip"
- android:layout_height="wrap_content"
- android:orientation="vertical">
- <TextView
- android:id="@+id/time_picker_title"
- android:layout_width="match_parent"
- android:layout_height="48dip"
- android:text="@string/time_picker_title"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="20dip"
- android:gravity="center" />
-
- <TimePicker
- android:id="@+id/time_picker"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/time_picker_title" />
- </LinearLayout>
</LinearLayout>
- <View
- android:id="@+id/bottom_divider"
- android:layout_width="match_parent"
- android:layout_height="3dip"
- android:layout_alignLeft="@id/timezone_auto_time"
- android:layout_above="@+id/next_button"
- android:layout_marginBottom="16dip"
- android:background="@color/divider_color" />
+ <RelativeLayout android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:layout_width="match_parent">
- <Button
- android:id="@+id/next_button"
- style="@style/setup_wizard_button"
- android:layout_alignParentBottom="true"
- android:layout_alignParentRight="true"
- android:text="@string/next_label" />
-</RelativeLayout>
+ <View
+ android:id="@+id/bottom_divider"
+ android:layout_height="3dip"
+ android:layout_width="match_parent"
+ android:layout_marginTop="0dip"
+ android:layout_marginBottom="16dip"
+ android:background="@color/divider_color"
+ android:layout_above="@+id/next_button"/>
+
+ <Button android:id="@+id/next_button"
+ android:layout_width="wrap_content"
+ android:minWidth="208dip"
+ android:layout_height="48dip"
+ android:layout_marginTop="10dip"
+ android:layout_alignParentRight="true"
+ android:text="@string/next_label"/>
+
+ </RelativeLayout>
+
+</LinearLayout>
diff --git a/res/layout-sw600dp-land/date_time_settings_setupwizard.xml b/res/layout-sw720dp/date_time_settings_setupwizard.xml
similarity index 98%
rename from res/layout-sw600dp-land/date_time_settings_setupwizard.xml
rename to res/layout-sw720dp/date_time_settings_setupwizard.xml
index b31462d..1fc25da 100644
--- a/res/layout-sw600dp-land/date_time_settings_setupwizard.xml
+++ b/res/layout-sw720dp/date_time_settings_setupwizard.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
+<!-- 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
+ 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,
diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java
index 64f42a0..d2c5973 100644
--- a/src/com/android/settings/DateTimeSettings.java
+++ b/src/com/android/settings/DateTimeSettings.java
@@ -60,6 +60,9 @@
private static final int DIALOG_DATEPICKER = 0;
private static final int DIALOG_TIMEPICKER = 1;
+ // have we been launched from the setup wizard?
+ protected static final String EXTRA_IS_FIRST_RUN = "firstRun";
+
private CheckBoxPreference mAutoTimePref;
private Preference mTimePref;
private Preference mTime24Pref;
@@ -81,15 +84,18 @@
boolean autoTimeEnabled = getAutoState(Settings.System.AUTO_TIME);
boolean autoTimeZoneEnabled = getAutoState(Settings.System.AUTO_TIME_ZONE);
+ Intent intent = getActivity().getIntent();
+ boolean isFirstRun = intent.getBooleanExtra(EXTRA_IS_FIRST_RUN, false);
+
mDummyDate = Calendar.getInstance();
mDummyDate.set(mDummyDate.get(Calendar.YEAR), 11, 31, 13, 0, 0);
mAutoTimePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME);
mAutoTimePref.setChecked(autoTimeEnabled);
mAutoTimeZonePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME_ZONE);
- // Override auto-timezone if it's a wifi-only device.
- // TODO: Remove this when auto-timezone is implemented based on wifi-location.
- if (Utils.isWifiOnly()) {
+ // Override auto-timezone if it's a wifi-only device or if we're still in setup wizard.
+ // TODO: Remove the wifiOnly test when auto-timezone is implemented based on wifi-location.
+ if (Utils.isWifiOnly() || isFirstRun) {
getPreferenceScreen().removePreference(mAutoTimeZonePref);
autoTimeZoneEnabled = false;
}
@@ -100,6 +106,10 @@
mTimeZone = findPreference("timezone");
mDatePref = findPreference("date");
mDateFormat = (ListPreference) findPreference(KEY_DATE_FORMAT);
+ if (isFirstRun) {
+ getPreferenceScreen().removePreference(mTime24Pref);
+ getPreferenceScreen().removePreference(mDateFormat);
+ }
String [] dateFormats = getResources().getStringArray(R.array.date_format_values);
String [] formattedDates = new String[dateFormats.length];
@@ -158,7 +168,7 @@
.unregisterOnSharedPreferenceChangeListener(this);
}
- private void updateTimeAndDateDisplay(Context context) {
+ public void updateTimeAndDateDisplay(Context context) {
java.text.DateFormat shortDateFormat = DateFormat.getDateFormat(context);
final Calendar now = Calendar.getInstance();
Date dummyDate = mDummyDate.getTime();
diff --git a/src/com/android/settings/DateTimeSettingsSetupWizard.java b/src/com/android/settings/DateTimeSettingsSetupWizard.java
index 670fcbc..685ee00 100644
--- a/src/com/android/settings/DateTimeSettingsSetupWizard.java
+++ b/src/com/android/settings/DateTimeSettingsSetupWizard.java
@@ -18,6 +18,8 @@
import android.app.Activity;
import android.app.AlarmManager;
+import android.app.Fragment;
+import android.app.FragmentTransaction;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -25,6 +27,8 @@
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.text.format.DateFormat;
@@ -39,6 +43,7 @@
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.DatePicker;
+import android.widget.LinearLayout;
import android.widget.ListPopupWindow;
import android.widget.SimpleAdapter;
import android.widget.TimePicker;
@@ -47,14 +52,18 @@
import java.util.TimeZone;
public class DateTimeSettingsSetupWizard extends Activity
- implements OnClickListener, OnItemClickListener, OnCheckedChangeListener{
+ implements OnClickListener, OnItemClickListener, OnCheckedChangeListener,
+ PreferenceFragment.OnPreferenceStartFragmentCallback {
private static final String TAG = DateTimeSettingsSetupWizard.class.getSimpleName();
// force the first status of auto datetime flag.
private static final String EXTRA_INITIAL_AUTO_DATETIME_VALUE =
"extra_initial_auto_datetime_value";
- private boolean mXLargeScreenSize;
+ // If we have enough screen real estate, we use a radically different layout with
+ // big date and time pickers right on the screen, which requires very different handling.
+ // Otherwise, we use the standard date time settings fragment.
+ private boolean mUsingXLargeLayout;
/* Available only in XL */
private CompoundButton mAutoDateTimeButton;
@@ -74,20 +83,25 @@
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.date_time_settings_setupwizard);
- mXLargeScreenSize = (getResources().getConfiguration().screenLayout
- & Configuration.SCREENLAYOUT_SIZE_MASK)
- >= Configuration.SCREENLAYOUT_SIZE_LARGE;
- if (mXLargeScreenSize) {
+
+ // we know we've loaded the special xlarge layout because it has controls
+ // not present in the standard layout
+ mUsingXLargeLayout = findViewById(R.id.time_zone_button) != null;
+ if (mUsingXLargeLayout) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
initUiForXl();
} else {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
findViewById(R.id.next_button).setOnClickListener(this);
}
+ mTimeZoneAdapter = ZonePicker.constructTimezoneAdapter(this, false,
+ R.layout.date_time_setup_custom_list_item_2);
+
+ final View layoutRoot = findViewById(R.id.layout_root);
+ layoutRoot.setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
}
public void initUiForXl() {
- final View layoutRoot = findViewById(R.id.layout_root);
- layoutRoot.setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
-
// Currently just comment out codes related to auto timezone.
// TODO: Remove them when we are sure they are unnecessary.
/*
@@ -98,16 +112,12 @@
mAutoTimeZoneButton.setText(autoTimeZoneEnabled ? R.string.zone_auto_summaryOn :
R.string.zone_auto_summaryOff);*/
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
-
final TimeZone tz = TimeZone.getDefault();
mSelectedTimeZone = tz;
mTimeZoneButton = (Button)findViewById(R.id.time_zone_button);
mTimeZoneButton.setText(tz.getDisplayName());
// mTimeZoneButton.setText(DateTimeSettings.getTimeZoneText(tz));
mTimeZoneButton.setOnClickListener(this);
- mTimeZoneAdapter = ZonePicker.constructTimezoneAdapter(this, false,
- R.layout.date_time_setup_custom_list_item_2);
final boolean autoDateTimeEnabled;
final Intent intent = getIntent();
@@ -158,22 +168,11 @@
public void onClick(View view) {
switch (view.getId()) {
case R.id.time_zone_button: {
- mTimeZonePopup = new ListPopupWindow(this, null);
- mTimeZonePopup.setWidth(mTimeZoneButton.getWidth());
- mTimeZonePopup.setAnchorView(mTimeZoneButton);
- mTimeZonePopup.setAdapter(mTimeZoneAdapter);
- mTimeZonePopup.setOnItemClickListener(this);
- mTimeZonePopup.setModal(true);
- mTimeZonePopup.show();
+ showTimezonePicker(R.id.time_zone_button);
break;
}
case R.id.next_button: {
- if (mXLargeScreenSize) {
- /* Settings.System.putInt(getContentResolver(), Settings.System.AUTO_TIME_ZONE,
- mAutoTimeZoneButton.isChecked() ? 1 : 0); */
- Settings.System.putInt(getContentResolver(), Settings.System.AUTO_TIME,
- mAutoDateTimeButton.isChecked() ? 1 : 0);
-
+ if (mSelectedTimeZone != null) {
final TimeZone systemTimeZone = TimeZone.getDefault();
if (!systemTimeZone.equals(mSelectedTimeZone)) {
Log.i(TAG, "Another TimeZone is selected by a user. Changing system TimeZone.");
@@ -181,7 +180,10 @@
getSystemService(Context.ALARM_SERVICE);
alarm.setTimeZone(mSelectedTimeZone.getID());
}
-
+ }
+ if (mAutoDateTimeButton != null) {
+ Settings.System.putInt(getContentResolver(), Settings.System.AUTO_TIME,
+ mAutoDateTimeButton.isChecked() ? 1 : 0);
if (!mAutoDateTimeButton.isChecked()) {
DateTimeSettings.setDate(mDatePicker.getYear(), mDatePicker.getMonth(),
mDatePicker.getDayOfMonth());
@@ -203,7 +205,7 @@
final boolean autoEnabled = isChecked; // just for readibility.
/*if (buttonView == mAutoTimeZoneButton) {
// In XL screen, we save all the state only when the next button is pressed.
- if (!mXLargeScreenSize) {
+ if (!mUsingXLargeLayout) {
Settings.System.putInt(getContentResolver(),
Settings.System.AUTO_TIME_ZONE,
isChecked ? 1 : 0);
@@ -233,18 +235,62 @@
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final TimeZone tz = ZonePicker.obtainTimeZoneFromItem(parent.getItemAtPosition(position));
- mSelectedTimeZone = tz;
-
- final Calendar now = Calendar.getInstance(tz);
- mTimeZoneButton.setText(tz.getDisplayName());
- // mTimeZoneButton.setText(DateTimeSettings.getTimeZoneText(tz));
- mDatePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
- now.get(Calendar.DAY_OF_MONTH));
- mTimePicker.setCurrentHour(now.get(Calendar.HOUR_OF_DAY));
- mTimePicker.setCurrentMinute(now.get(Calendar.MINUTE));
+ if (mUsingXLargeLayout) {
+ mSelectedTimeZone = tz;
+ final Calendar now = Calendar.getInstance(tz);
+ if (mTimeZoneButton != null) {
+ mTimeZoneButton.setText(tz.getDisplayName());
+ }
+ // mTimeZoneButton.setText(DateTimeSettings.getTimeZoneText(tz));
+ mDatePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
+ now.get(Calendar.DAY_OF_MONTH));
+ mTimePicker.setCurrentHour(now.get(Calendar.HOUR_OF_DAY));
+ mTimePicker.setCurrentMinute(now.get(Calendar.MINUTE));
+ } else {
+ // in prefs mode, we actually change the setting right now, as opposed to waiting
+ // until Next is pressed in xLarge mode
+ final AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
+ alarm.setTimeZone(tz.getID());
+ DateTimeSettings settingsFragment = (DateTimeSettings) getFragmentManager().
+ findFragmentById(R.id.date_time_settings_fragment);
+ settingsFragment.updateTimeAndDateDisplay(this);
+ }
mTimeZonePopup.dismiss();
}
+ /**
+ * If this is called, that means we're in prefs style portrait mode for a large display
+ * and the user has tapped on the time zone preference. If we were a PreferenceActivity,
+ * we'd then launch the timezone fragment in a new activity, but we aren't, and here
+ * on a tablet display, we really want more of a popup picker look' like the one we use
+ * for the xlarge version of this activity. So we just take this opportunity to launch that.
+ *
+ * TODO: For phones, we might want to change this to do the "normal" opening
+ * of the zonepicker fragment in its own activity. Or we might end up just
+ * creating a separate DateTimeSettingsSetupWizardPhone activity that subclasses
+ * PreferenceActivity in the first place to handle all that automatically.
+ */
+ @Override
+ public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
+ showTimezonePicker(R.id.timezone_dropdown_anchor);
+ return true;
+ }
+
+ private void showTimezonePicker(int anchorViewId) {
+ View anchorView = findViewById(anchorViewId);
+ if (anchorView == null) {
+ Log.e(TAG, "Unable to find zone picker anchor view " + anchorViewId);
+ return;
+ }
+ mTimeZonePopup = new ListPopupWindow(this, null);
+ mTimeZonePopup.setWidth(anchorView.getWidth());
+ mTimeZonePopup.setAnchorView(anchorView);
+ mTimeZonePopup.setAdapter(mTimeZoneAdapter);
+ mTimeZonePopup.setOnItemClickListener(this);
+ mTimeZonePopup.setModal(true);
+ mTimeZonePopup.show();
+ }
+
private boolean isAutoDateTimeEnabled() {
try {
return Settings.System.getInt(getContentResolver(), Settings.System.AUTO_TIME) > 0;
@@ -264,6 +310,9 @@
}*/
private void updateTimeAndDateDisplay() {
+ if (!mUsingXLargeLayout) {
+ return;
+ }
final Calendar now = Calendar.getInstance();
mTimeZoneButton.setText(now.getTimeZone().getDisplayName());
mDatePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java
index 6e7af5c..db60c37 100644
--- a/src/com/android/settings/deviceinfo/Memory.java
+++ b/src/com/android/settings/deviceinfo/Memory.java
@@ -21,7 +21,6 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
@@ -42,7 +41,7 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-public class Memory extends SettingsPreferenceFragment implements OnCancelListener {
+public class Memory extends SettingsPreferenceFragment {
private static final String TAG = "MemorySettings";
private static final int DLG_CONFIRM_UNMOUNT = 1;
@@ -50,9 +49,10 @@
private Resources mResources;
- // The mountToggle Preference that has been clicked.
- // The click event will be discarded if this value is not null. Reset to null after (un)mount.
- private Preference mClickedMountToggle;
+ // The mountToggle Preference that has last been clicked.
+ // Assumes no two successive unmount event on 2 different volumes are performed before the first
+ // one's preference is disabled
+ private Preference mLastClickedMountToggle;
private String mClickedMountPoint;
// Access using getMountService()
@@ -157,9 +157,8 @@
return true;
}
- boolean mountToggleClicked = svpc.mountToggleClicked(preference);
- if (mountToggleClicked && mClickedMountToggle == null) {
- mClickedMountToggle = preference;
+ if (svpc.mountToggleClicked(preference)) {
+ mLastClickedMountToggle = preference;
final StorageVolume storageVolume = svpc.getStorageVolume();
mClickedMountPoint = storageVolume.getPath();
String state = mStorageManager.getVolumeState(storageVolume.getPath());
@@ -208,32 +207,19 @@
return null;
}
- @Override
- protected void showDialog(int id) {
- super.showDialog(id);
-
- switch (id) {
- case DLG_CONFIRM_UNMOUNT:
- case DLG_ERROR_UNMOUNT:
- setOnCancelListener(this);
- break;
- }
- }
-
private void doUnmount() {
// Present a toast here
Toast.makeText(getActivity(), R.string.unmount_inform_text, Toast.LENGTH_SHORT).show();
IMountService mountService = getMountService();
try {
- mClickedMountToggle.setEnabled(false);
- mClickedMountToggle.setTitle(mResources.getString(R.string.sd_ejecting_title));
- mClickedMountToggle.setSummary(mResources.getString(R.string.sd_ejecting_summary));
+ mLastClickedMountToggle.setEnabled(false);
+ mLastClickedMountToggle.setTitle(mResources.getString(R.string.sd_ejecting_title));
+ mLastClickedMountToggle.setSummary(mResources.getString(R.string.sd_ejecting_summary));
mountService.unmountVolume(mClickedMountPoint, true);
} catch (RemoteException e) {
// Informative dialog to user that unmount failed.
showDialogInner(DLG_ERROR_UNMOUNT);
}
- mClickedMountToggle = null;
}
private void showDialogInner(int id) {
@@ -257,7 +243,8 @@
return true;
}
*/
- return false;
+ // Better safe than sorry. Assume the storage is used to ask for confirmation.
+ return true;
}
private void unmount() {
@@ -273,7 +260,6 @@
// Very unlikely. But present an error dialog anyway
Log.e(TAG, "Is MountService running?");
showDialogInner(DLG_ERROR_UNMOUNT);
- mClickedMountToggle = null;
}
}
@@ -288,10 +274,5 @@
} catch (RemoteException ex) {
// Not much can be done
}
- mClickedMountToggle = null;
- }
-
- public void onCancel(DialogInterface dialog) {
- mClickedMountToggle = null;
}
}
diff --git a/src/com/android/settings/deviceinfo/StorageMeasurement.java b/src/com/android/settings/deviceinfo/StorageMeasurement.java
index 14b5108..7fb309c 100644
--- a/src/com/android/settings/deviceinfo/StorageMeasurement.java
+++ b/src/com/android/settings/deviceinfo/StorageMeasurement.java
@@ -478,6 +478,7 @@
File top = new File(mStorageVolume.getPath());
mFileInfoForMisc = new ArrayList<FileInfo>();
File[] files = top.listFiles();
+ if (files == null) return;
final int len = files.length;
// Get sizes of all top level nodes except the ones already computed...
long counter = 0;
@@ -524,4 +525,11 @@
return mFileName + " : " + mSize + ", id:" + mId;
}
}
+
+ /**
+ * TODO remove this method, only used because external SD Card needs a special treatment.
+ */
+ boolean isPrimary() {
+ return mIsPrimary;
+ }
}
diff --git a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
index 83f9ee2..e326b2b 100644
--- a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
+++ b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
@@ -289,6 +289,12 @@
mPreferences[TOTAL_SIZE].setSummary(formatSize(totalSize));
+ if (!mMeasurement.isPrimary()) {
+ // TODO FIXME: external SD card will not report any size. Show used space in bar graph
+ final long usedSize = totalSize - availSize;
+ mUsageBarPreference.addEntry(usedSize / (float) totalSize, android.graphics.Color.GRAY);
+ }
+
updatePreference(appsSize, totalSize, APPLICATIONS);
long totalMediaSize = 0;
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
index b265362..a73f96c 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
@@ -21,6 +21,7 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import android.net.NetworkInfo.DetailedState;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
@@ -54,6 +55,10 @@
private static final String TAG = "SetupWizard";
private static final boolean DEBUG = true;
+ // lock orientation into landscape or portrait
+ private static final String EXTRA_PREFS_LANDSCAPE_LOCK = "extra_prefs_landscape_lock";
+ private static final String EXTRA_PREFS_PORTRAIT_LOCK = "extra_prefs_portrait_lock";
+
private static final EnumMap<DetailedState, DetailedState> sNetworkStateMap =
new EnumMap<DetailedState, DetailedState>(DetailedState.class);
@@ -165,10 +170,18 @@
}
private void initViews() {
- if (getIntent().getBooleanExtra("firstRun", false)) {
+ Intent intent = getIntent();
+
+ if (intent.getBooleanExtra("firstRun", false)) {
final View layoutRoot = findViewById(R.id.layout_root);
layoutRoot.setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
}
+ if (intent.getBooleanExtra(EXTRA_PREFS_LANDSCAPE_LOCK, false)) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
+ }
+ if (intent.getBooleanExtra(EXTRA_PREFS_PORTRAIT_LOCK, false)) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
+ }
mTitleView = (TextView)findViewById(R.id.wifi_setup_title);
mProgressBar = (ProgressBar)findViewById(R.id.scanning_progress_bar);