USB Settings: Remove AFT installer CD; add help text to MTP and PTP widget summary
Bug: 4335199 Change-Id: I5f2a5d650a184b528028596e03e01ea98bf3815f Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
@@ -22,27 +22,19 @@ 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;
|
||||
import android.os.Bundle;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.os.storage.StorageVolume;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* USB storage settings.
|
||||
*/
|
||||
@@ -52,22 +44,13 @@ public class UsbSettings extends SettingsPreferenceFragment {
|
||||
|
||||
private static final String KEY_MTP = "usb_mtp";
|
||||
private static final String KEY_PTP = "usb_ptp";
|
||||
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;
|
||||
private CheckBoxPreference mPtp;
|
||||
private MenuItem mInstallerCd;
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
@@ -90,11 +73,6 @@ public class UsbSettings extends SettingsPreferenceFragment {
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
mUsbManager = (UsbManager)getSystemService(Context.USB_SERVICE);
|
||||
mInstallerImagePath = getString(com.android.internal.R.string.config_isoImagePath);
|
||||
if (!(new File(mInstallerImagePath)).exists()) {
|
||||
mInstallerImagePath = null;
|
||||
}
|
||||
setHasOptionsMenu(mInstallerImagePath != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,24 +94,6 @@ 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);
|
||||
@@ -145,13 +105,6 @@ public class UsbSettings extends SettingsPreferenceFragment {
|
||||
mMtp.setChecked(false);
|
||||
mPtp.setChecked(false);
|
||||
}
|
||||
if (mInstallerCd != null) {
|
||||
if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_MASS_STORAGE)) {
|
||||
mInstallerCd.setTitle( R.string.usb_label_installer_cd_done);
|
||||
} else {
|
||||
mInstallerCd.setTitle( R.string.usb_label_installer_cd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,31 +128,4 @@ public class UsbSettings extends SettingsPreferenceFragment {
|
||||
updateToggles();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
mInstallerCd = menu.add(Menu.NONE, MENU_ID_INSTALLER_CD, 0,
|
||||
R.string.usb_label_installer_cd);
|
||||
mInstallerCd.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_ID_INSTALLER_CD:
|
||||
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;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user