Loading res/values-zh-rCN/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -772,6 +772,7 @@ <string name="sd_format" product="default" msgid="2576054280507119870">"格式化 SD 卡"</string> <string name="sd_format_summary" product="nosdcard" msgid="6331905044907914603">"清除内部 USB 存储设备中的全部数据,例如音乐和照片"</string> <string name="sd_format_summary" product="default" msgid="212703692181793109">"清除 SD 卡中的全部数据,例如音乐和照片"</string> <string name="mtp_ptp_mode_summary">正在使用媒体设备(MTP)或相机(PTP)传输模式</string> <string name="read_only" msgid="6702420168629076340">" (只读)"</string> <string name="dlg_confirm_unmount_title" product="nosdcard" msgid="3077285629197874055">"要卸载 USB 存储设备吗?"</string> <string name="dlg_confirm_unmount_title" product="default" msgid="3634502237262534381">"要卸载 SD 卡吗?"</string> Loading res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1900,6 +1900,10 @@ <!-- SD card & phone storage settings item title that will result in the phone unmounting the SD card. [CHAR LIMIT=80] --> <string name="sd_format_summary" product="default">Erases all data on the SD card, such as music and photos</string> <!-- SD card status when it is mounted as read only. Will be appended to size, starts with an unbreakable space --> <!-- SD card & phone storage settings item summary that will result in the phone connected to PC and MTP/PTP enabled. [CHAR LIMIT=80] --> <string name="mtp_ptp_mode_summary">MTP or PTP function is active</string> <string name="read_only">\u0020(Read-only)</string> <!-- SD card eject confirmation dialog title [CHAR LIMIT=25] --> <string name="dlg_confirm_unmount_title" product="nosdcard">Unmount USB storage?</string> Loading src/com/android/settings/deviceinfo/Memory.java +21 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Resources; import android.hardware.usb.UsbManager; import android.os.Bundle; import android.os.Environment; import android.os.IBinder; Loading Loading @@ -65,6 +66,8 @@ public class Memory extends SettingsPreferenceFragment { private StorageManager mStorageManager = null; private UsbManager mUsbManager = null; private StorageVolumePreferenceCategory mInternalStorageVolumePreferenceCategory; private StorageVolumePreferenceCategory[] mStorageVolumePreferenceCategories; Loading @@ -72,6 +75,8 @@ public class Memory extends SettingsPreferenceFragment { public void onCreate(Bundle icicle) { super.onCreate(icicle); mUsbManager = (UsbManager)getSystemService(Context.USB_SERVICE); if (mStorageManager == null) { mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE); mStorageManager.registerListener(mStorageListener); Loading Loading @@ -119,6 +124,10 @@ public class Memory extends SettingsPreferenceFragment { intentFilter.addDataScheme("file"); getActivity().registerReceiver(mMediaScannerReceiver, intentFilter); intentFilter = new IntentFilter(); intentFilter.addAction(UsbManager.ACTION_USB_STATE); getActivity().registerReceiver(mMediaScannerReceiver, intentFilter); if (mInternalStorageVolumePreferenceCategory != null) { mInternalStorageVolumePreferenceCategory.onResume(); } Loading Loading @@ -237,11 +246,20 @@ public class Memory extends SettingsPreferenceFragment { private final BroadcastReceiver mMediaScannerReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(UsbManager.ACTION_USB_STATE)) { boolean isUsbConnected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false); String usbFunction = mUsbManager.getDefaultFunction(); for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) { mStorageVolumePreferenceCategories[i].onUsbStateChanged(isUsbConnected, usbFunction); } } else if (action.equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) { // mInternalStorageVolumePreferenceCategory is not affected by the media scanner for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) { mStorageVolumePreferenceCategories[i].onMediaScannerFinished(); } } } }; @Override Loading src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java +26 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.pm.IPackageManager; import android.content.res.Resources; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.RectShape; import android.hardware.usb.UsbManager; import android.os.Bundle; import android.os.Environment; import android.os.Handler; Loading Loading @@ -69,6 +70,9 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory implemen private boolean mAllowFormat; private boolean mUsbConnected; private String mUsbFunction; static class CategoryInfo { final int mTitle; final int mColor; Loading Loading @@ -305,6 +309,23 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory implemen removePreference(mFormatPreference); } } if (mUsbConnected && (UsbManager.USB_FUNCTION_MTP.equals(mUsbFunction) || UsbManager.USB_FUNCTION_PTP.equals(mUsbFunction))) { mMountTogglePreference.setEnabled(false); if (Environment.MEDIA_MOUNTED.equals(state)) { mMountTogglePreference.setSummary(mResources.getString(R.string.mtp_ptp_mode_summary)); } if (mFormatPreference != null) { mFormatPreference.setEnabled(false); mFormatPreference.setSummary(mResources.getString(R.string.mtp_ptp_mode_summary)); } } else if (mFormatPreference != null) { mFormatPreference.setEnabled(true); mFormatPreference.setSummary(mResources.getString(R.string.sd_format_summary)); } } public void updateApproximate(long totalSize, long availSize) { Loading Loading @@ -376,6 +397,11 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory implemen measure(); } public void onUsbStateChanged(boolean isUsbConnected, String usbFunction) { mUsbConnected = isUsbConnected; mUsbFunction = usbFunction; measure(); } public void onMediaScannerFinished() { measure(); } Loading Loading
res/values-zh-rCN/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -772,6 +772,7 @@ <string name="sd_format" product="default" msgid="2576054280507119870">"格式化 SD 卡"</string> <string name="sd_format_summary" product="nosdcard" msgid="6331905044907914603">"清除内部 USB 存储设备中的全部数据,例如音乐和照片"</string> <string name="sd_format_summary" product="default" msgid="212703692181793109">"清除 SD 卡中的全部数据,例如音乐和照片"</string> <string name="mtp_ptp_mode_summary">正在使用媒体设备(MTP)或相机(PTP)传输模式</string> <string name="read_only" msgid="6702420168629076340">" (只读)"</string> <string name="dlg_confirm_unmount_title" product="nosdcard" msgid="3077285629197874055">"要卸载 USB 存储设备吗?"</string> <string name="dlg_confirm_unmount_title" product="default" msgid="3634502237262534381">"要卸载 SD 卡吗?"</string> Loading
res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1900,6 +1900,10 @@ <!-- SD card & phone storage settings item title that will result in the phone unmounting the SD card. [CHAR LIMIT=80] --> <string name="sd_format_summary" product="default">Erases all data on the SD card, such as music and photos</string> <!-- SD card status when it is mounted as read only. Will be appended to size, starts with an unbreakable space --> <!-- SD card & phone storage settings item summary that will result in the phone connected to PC and MTP/PTP enabled. [CHAR LIMIT=80] --> <string name="mtp_ptp_mode_summary">MTP or PTP function is active</string> <string name="read_only">\u0020(Read-only)</string> <!-- SD card eject confirmation dialog title [CHAR LIMIT=25] --> <string name="dlg_confirm_unmount_title" product="nosdcard">Unmount USB storage?</string> Loading
src/com/android/settings/deviceinfo/Memory.java +21 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Resources; import android.hardware.usb.UsbManager; import android.os.Bundle; import android.os.Environment; import android.os.IBinder; Loading Loading @@ -65,6 +66,8 @@ public class Memory extends SettingsPreferenceFragment { private StorageManager mStorageManager = null; private UsbManager mUsbManager = null; private StorageVolumePreferenceCategory mInternalStorageVolumePreferenceCategory; private StorageVolumePreferenceCategory[] mStorageVolumePreferenceCategories; Loading @@ -72,6 +75,8 @@ public class Memory extends SettingsPreferenceFragment { public void onCreate(Bundle icicle) { super.onCreate(icicle); mUsbManager = (UsbManager)getSystemService(Context.USB_SERVICE); if (mStorageManager == null) { mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE); mStorageManager.registerListener(mStorageListener); Loading Loading @@ -119,6 +124,10 @@ public class Memory extends SettingsPreferenceFragment { intentFilter.addDataScheme("file"); getActivity().registerReceiver(mMediaScannerReceiver, intentFilter); intentFilter = new IntentFilter(); intentFilter.addAction(UsbManager.ACTION_USB_STATE); getActivity().registerReceiver(mMediaScannerReceiver, intentFilter); if (mInternalStorageVolumePreferenceCategory != null) { mInternalStorageVolumePreferenceCategory.onResume(); } Loading Loading @@ -237,11 +246,20 @@ public class Memory extends SettingsPreferenceFragment { private final BroadcastReceiver mMediaScannerReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(UsbManager.ACTION_USB_STATE)) { boolean isUsbConnected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false); String usbFunction = mUsbManager.getDefaultFunction(); for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) { mStorageVolumePreferenceCategories[i].onUsbStateChanged(isUsbConnected, usbFunction); } } else if (action.equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) { // mInternalStorageVolumePreferenceCategory is not affected by the media scanner for (int i = 0; i < mStorageVolumePreferenceCategories.length; i++) { mStorageVolumePreferenceCategories[i].onMediaScannerFinished(); } } } }; @Override Loading
src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java +26 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.pm.IPackageManager; import android.content.res.Resources; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.RectShape; import android.hardware.usb.UsbManager; import android.os.Bundle; import android.os.Environment; import android.os.Handler; Loading Loading @@ -69,6 +70,9 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory implemen private boolean mAllowFormat; private boolean mUsbConnected; private String mUsbFunction; static class CategoryInfo { final int mTitle; final int mColor; Loading Loading @@ -305,6 +309,23 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory implemen removePreference(mFormatPreference); } } if (mUsbConnected && (UsbManager.USB_FUNCTION_MTP.equals(mUsbFunction) || UsbManager.USB_FUNCTION_PTP.equals(mUsbFunction))) { mMountTogglePreference.setEnabled(false); if (Environment.MEDIA_MOUNTED.equals(state)) { mMountTogglePreference.setSummary(mResources.getString(R.string.mtp_ptp_mode_summary)); } if (mFormatPreference != null) { mFormatPreference.setEnabled(false); mFormatPreference.setSummary(mResources.getString(R.string.mtp_ptp_mode_summary)); } } else if (mFormatPreference != null) { mFormatPreference.setEnabled(true); mFormatPreference.setSummary(mResources.getString(R.string.sd_format_summary)); } } public void updateApproximate(long totalSize, long availSize) { Loading Loading @@ -376,6 +397,11 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory implemen measure(); } public void onUsbStateChanged(boolean isUsbConnected, String usbFunction) { mUsbConnected = isUsbConnected; mUsbFunction = usbFunction; measure(); } public void onMediaScannerFinished() { measure(); } Loading