summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/deviceinfo
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-06-07 17:17:56 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-06-07 17:17:56 -0700
commit94129ad9a2002643e8bdd85adcc7adcf964db8b3 (patch)
tree8cf5b6daaba9ded797b491dfea188af44e25ff48 /src/com/android/settings/deviceinfo
parentadcbf72c80232b0c019c11b9cdf2303a7bd97d27 (diff)
parent62634b309ab6c352a37c4d79d50fc78ab806304f (diff)
downloadpackages_apps_Settings-94129ad9a2002643e8bdd85adcc7adcf964db8b3.tar.gz
packages_apps_Settings-94129ad9a2002643e8bdd85adcc7adcf964db8b3.tar.bz2
packages_apps_Settings-94129ad9a2002643e8bdd85adcc7adcf964db8b3.zip
am 62634b30: am 440ca974: am 8f1bd8a7: Bug 4539424: confirmation dialog always shown
* commit '62634b309ab6c352a37c4d79d50fc78ab806304f': Bug 4539424: confirmation dialog always shown
Diffstat (limited to 'src/com/android/settings/deviceinfo')
-rw-r--r--src/com/android/settings/deviceinfo/Memory.java40
1 files changed, 10 insertions, 30 deletions
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java
index 069e1bfe1..db60c37f6 100644
--- a/src/com/android/settings/deviceinfo/Memory.java
+++ b/src/com/android/settings/deviceinfo/Memory.java
@@ -21,7 +21,6 @@ import android.app.Dialog;
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 android.widget.Toast;
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 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
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 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
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 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
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) {
@@ -274,7 +260,6 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
// Very unlikely. But present an error dialog anyway
Log.e(TAG, "Is MountService running?");
showDialogInner(DLG_ERROR_UNMOUNT);
- mClickedMountToggle = null;
}
}
@@ -289,10 +274,5 @@ public class Memory extends SettingsPreferenceFragment implements OnCancelListen
} catch (RemoteException ex) {
// Not much can be done
}
- mClickedMountToggle = null;
- }
-
- public void onCancel(DialogInterface dialog) {
- mClickedMountToggle = null;
}
}