diff options
author | Mike Lockwood <lockwood@android.com> | 2011-07-20 11:55:34 -0700 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2011-07-20 11:55:34 -0700 |
commit | 23a006236b2c8fc2b4ee5da35912150c7d6756d0 (patch) | |
tree | dd05e78b3e10a875362abde0081e1bcb350f1573 /src/com | |
parent | 79da62dce8f7b27f727e2dac35fda7ec003d1ec8 (diff) | |
download | packages_apps_settings-23a006236b2c8fc2b4ee5da35912150c7d6756d0.zip packages_apps_settings-23a006236b2c8fc2b4ee5da35912150c7d6756d0.tar.gz packages_apps_settings-23a006236b2c8fc2b4ee5da35912150c7d6756d0.tar.bz2 |
USB: Add dialog with instructions for installing AFT
Bug: 5032807
Change-Id: Ic7737629c6081a3d6192e060da525fcc4c494919
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/settings/deviceinfo/UsbSettings.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/com/android/settings/deviceinfo/UsbSettings.java b/src/com/android/settings/deviceinfo/UsbSettings.java index ca6a0cc..4820234 100644 --- a/src/com/android/settings/deviceinfo/UsbSettings.java +++ b/src/com/android/settings/deviceinfo/UsbSettings.java @@ -16,10 +16,13 @@ package com.android.settings.deviceinfo; +import android.app.AlertDialog; +import android.app.Dialog; import android.content.BroadcastReceiver; import android.content.ContentQueryMap; import android.content.ContentResolver; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.hardware.usb.UsbManager; @@ -52,6 +55,8 @@ public class UsbSettings extends SettingsPreferenceFragment { private static final String KEY_INSTALLER_CD = "usb_installer_cd"; private static final int MENU_ID_INSTALLER_CD = Menu.FIRST; + private static final int DLG_INSTALLER_CD = 1; + private UsbManager mUsbManager; private String mInstallerImagePath; private CheckBoxPreference mMtp; @@ -60,6 +65,9 @@ public class UsbSettings extends SettingsPreferenceFragment { private final BroadcastReceiver mStateReceiver = new BroadcastReceiver() { public void onReceive(Context content, Intent intent) { + if (!intent.getBooleanExtra(UsbManager.USB_CONNECTED, false)) { + removeDialog(DLG_INSTALLER_CD); + } updateToggles(); } }; @@ -108,6 +116,24 @@ public class UsbSettings extends SettingsPreferenceFragment { new IntentFilter(UsbManager.ACTION_USB_STATE)); } + @Override + public Dialog onCreateDialog(int id) { + switch (id) { + case DLG_INSTALLER_CD: + return new AlertDialog.Builder(getActivity()) + .setTitle(R.string.dlg_installer_cd_title) + .setMessage(R.string.dlg_installer_cd_text) + .setPositiveButton(R.string.dlg_installer_cd_ok, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + // Disable installer CD, return to default function. + mUsbManager.setCurrentFunction(null, false); + }}) + .create(); + } + return null; + } + private void updateToggles() { if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_MTP)) { mMtp.setChecked(true); @@ -164,10 +190,12 @@ public class UsbSettings extends SettingsPreferenceFragment { if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_MASS_STORAGE)) { // Disable installer CD, return to default function. mUsbManager.setCurrentFunction(null, false); + removeDialog(DLG_INSTALLER_CD); } else { // Enable installer CD. Don't set as default function. mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MASS_STORAGE, false); mUsbManager.setMassStorageBackingFile(mInstallerImagePath); + showDialog(DLG_INSTALLER_CD); } updateToggles(); return true; |