summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaxwen <max.weninger@gmail.com>2016-05-25 21:52:46 +0200
committerSteve Kondik <shade@chemlab.org>2016-08-10 14:20:23 -0700
commit2b5331e3ffa729625863fbcc955f1c7b5262d333 (patch)
tree375d57c6015449fb4a44da9dcf4130ccbc14675e
parentc5ce73372e206614c28c0c46064ded0230cfd5ab (diff)
downloadandroid_packages_apps_Snap-2b5331e3ffa729625863fbcc955f1c7b5262d333.zip
android_packages_apps_Snap-2b5331e3ffa729625863fbcc955f1c7b5262d333.tar.gz
android_packages_apps_Snap-2b5331e3ffa729625863fbcc955f1c7b5262d333.tar.bz2
Snap: Remove storage menu if no external storage available
Change-Id: I9807c7f9303f17eb971ff1a82fbd35dfbdbfa529 Signed-off-by: Zdrowy Gosciu <ZdrowyGosciu+GITHUB@gmail.com>
-rw-r--r--src/com/android/camera/CameraActivity.java1
-rw-r--r--src/com/android/camera/CameraSettings.java11
-rw-r--r--src/com/android/camera/SDCard.java15
3 files changed, 22 insertions, 5 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index a9a78e7..6a3bddb 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -337,6 +337,7 @@ public class CameraActivity extends Activity
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "SDcard status changed, update storage space");
+ SDCard.instance().scanVolumes();
updateStorageSpaceAndHint();
}
};
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index bc717c7..bf6dfc0 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -900,6 +900,7 @@ public class CameraSettings {
ListPreference videoHfrMode =
group.findPreference(KEY_VIDEO_HIGH_FRAME_RATE);
ListPreference seeMoreMode = group.findPreference(KEY_SEE_MORE);
+ ListPreference savePath = group.findPreference(KEY_CAMERA_SAVEPATH);
// Since the screen could be loaded from different resources, we need
// to check if the preference is available here
@@ -1013,7 +1014,7 @@ public class CameraSettings {
final String CAMERA_SAVEPATH_SDCARD = "1";
final int CAMERA_SAVEPATH_SDCARD_IDX = 1;
final int CAMERA_SAVEPATH_PHONE_IDX = 0;
- ListPreference savePath = group.findPreference(KEY_CAMERA_SAVEPATH);
+
SharedPreferences pref = group.getSharedPreferences();
String savePathValue = null;
if (pref != null) {
@@ -1029,7 +1030,13 @@ public class CameraSettings {
Log.d(TAG, "set Phone as save path when sdCard is unavailable.");
savePath.setValueIndex(CAMERA_SAVEPATH_PHONE_IDX);
}
- }
+ }
+ }
+ if (savePath != null) {
+ Log.d(TAG, "check storage menu " + SDCard.instance().isWriteable());
+ if (!SDCard.instance().isWriteable()) {
+ removePreference(group, savePath.getKey());
+ }
}
qcomInitPreferences(group);
diff --git a/src/com/android/camera/SDCard.java b/src/com/android/camera/SDCard.java
index 8fda17c..fa532f8 100644
--- a/src/com/android/camera/SDCard.java
+++ b/src/com/android/camera/SDCard.java
@@ -89,13 +89,22 @@ public class SDCard {
return mVolume.getState();
}
- private SDCard(Context context) {
- try {
- mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
+ public void scanVolumes() {
+ if (mStorageManager != null) {
final StorageVolume[] volumes = mStorageManager.getVolumeList();
if (volumes.length > VOLUME_SDCARD_INDEX) {
mVolume = volumes[VOLUME_SDCARD_INDEX];
+ Log.i(TAG, "found SDCard volume");
}
+ } else {
+ Log.e(TAG, "couldn't talk to MountService");
+ }
+ }
+
+ private SDCard(Context context) {
+ try {
+ mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
+ scanVolumes();
} catch (Exception e) {
Log.e(TAG, "couldn't talk to MountService", e);
}