summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values/qcomstrings.xml3
-rw-r--r--src/com/android/camera/CameraActivity.java4
-rw-r--r--src/com/android/camera/CameraModule.java2
-rw-r--r--src/com/android/camera/PhotoModule.java6
-rw-r--r--src/com/android/camera/Storage.java69
-rw-r--r--src/com/android/camera/VideoMenu.java8
-rw-r--r--src/com/android/camera/VideoModule.java7
-rw-r--r--src/com/android/camera/VideoUI.java4
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java8
9 files changed, 86 insertions, 25 deletions
diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml
index 134a6d053..620b70e42 100644
--- a/res/values/qcomstrings.xml
+++ b/res/values/qcomstrings.xml
@@ -684,5 +684,8 @@
<string name="pref_camera_auto_hdr_entry_disable">Disable</string>
<string name="pref_camera_auto_hdr_value_enable">enable</string>
<string name="pref_camera_auto_hdr_value_disable">disable</string>
+
+ <!-- toast message for storage location switch -->
+ <string name="on_switch_save_path_to_sdcard">Internal storage space is not enough - switched save path to SD card</string>
</resources>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 4ad1bd0d0..36b5111ca 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -1359,6 +1359,10 @@ public class CameraActivity extends Activity
protected void updateStorageSpace() {
mStorageSpaceBytes = Storage.getAvailableSpace();
+ if (Storage.switchSavePath()) {
+ mStorageSpaceBytes = Storage.getAvailableSpace();
+ mCurrentModule.onSwitchSavePath();
+ }
}
protected long getStorageSpaceBytes() {
diff --git a/src/com/android/camera/CameraModule.java b/src/com/android/camera/CameraModule.java
index 48d7eec4a..2c8f5a91b 100644
--- a/src/com/android/camera/CameraModule.java
+++ b/src/com/android/camera/CameraModule.java
@@ -68,4 +68,6 @@ public interface CameraModule {
public boolean arePreviewControlsVisible();
public void resizeForPreviewAspectRatio();
+
+ public void onSwitchSavePath();
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 4948772c1..2e5466c62 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -697,6 +697,12 @@ public class PhotoModule
mUI.setAspectRatio((float) size.width / size.height);
}
+ @Override
+ public void onSwitchSavePath() {
+ mUI.setPreference(CameraSettings.KEY_CAMERA_SAVEPATH, "1");
+ Toast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
+ Toast.LENGTH_SHORT).show();
+ }
private void keepMediaProviderInstance() {
// We want to keep a reference to MediaProvider in camera's lifecycle.
diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java
index d27cf259f..53950f2f2 100644
--- a/src/com/android/camera/Storage.java
+++ b/src/com/android/camera/Storage.java
@@ -216,8 +216,8 @@ public class Storage {
}
}
- public static long getAvailableSpace() {
- if (isSaveSDCard() && SDCard.instance().isWriteable()) {
+ private static long getSDCardAvailableSpace() {
+ if (SDCard.instance().isWriteable()) {
File dir = new File(SDCard.instance().getDirectory());
dir.mkdirs();
try {
@@ -227,32 +227,51 @@ public class Storage {
} catch (Exception e) {
}
return UNKNOWN_SIZE;
- } else if (isSaveSDCard() && !SDCard.instance().isWriteable()) {
- return UNKNOWN_SIZE;
- } else {
- String state = Environment.getExternalStorageState();
- Log.d(TAG, "External storage state=" + state);
- if (Environment.MEDIA_CHECKING.equals(state)) {
- return PREPARING;
- }
- if (!Environment.MEDIA_MOUNTED.equals(state)) {
- return UNAVAILABLE;
- }
+ }
+ return UNKNOWN_SIZE;
+ }
- File dir = new File(DIRECTORY);
- dir.mkdirs();
- if (!dir.isDirectory() || !dir.canWrite()) {
- return UNAVAILABLE;
- }
+ private static long getInternalStorageAvailableSpace() {
+ String state = Environment.getExternalStorageState();
+ Log.d(TAG, "External storage state=" + state);
+ if (Environment.MEDIA_CHECKING.equals(state)) {
+ return PREPARING;
+ }
+ if (!Environment.MEDIA_MOUNTED.equals(state)) {
+ return UNAVAILABLE;
+ }
- try {
- StatFs stat = new StatFs(DIRECTORY);
- return stat.getAvailableBlocks() * (long) stat.getBlockSize();
- } catch (Exception e) {
- Log.i(TAG, "Fail to access external storage", e);
- }
- return UNKNOWN_SIZE;
+ File dir = new File(DIRECTORY);
+ dir.mkdirs();
+ if (!dir.isDirectory() || !dir.canWrite()) {
+ return UNAVAILABLE;
+ }
+
+ try {
+ StatFs stat = new StatFs(DIRECTORY);
+ return stat.getAvailableBlocks() * (long) stat.getBlockSize();
+ } catch (Exception e) {
+ Log.i(TAG, "Failed to access external storage", e);
+ }
+ return UNKNOWN_SIZE;
+ }
+
+ public static long getAvailableSpace() {
+ if (isSaveSDCard()) {
+ return getSDCardAvailableSpace();
+ } else {
+ return getInternalStorageAvailableSpace();
+ }
+ }
+
+ public static boolean switchSavePath() {
+ if (!isSaveSDCard()
+ && getInternalStorageAvailableSpace() <= LOW_STORAGE_THRESHOLD_BYTES
+ && getSDCardAvailableSpace() > LOW_STORAGE_THRESHOLD_BYTES) {
+ setSaveSDCard(true);
+ return true;
}
+ return false;
}
/**
diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java
index c15033529..ae6d67072 100644
--- a/src/com/android/camera/VideoMenu.java
+++ b/src/com/android/camera/VideoMenu.java
@@ -160,6 +160,14 @@ public class VideoMenu extends PieController
}
}
+ public void setPreference(String key, String value) {
+ ListPreference pref = mPreferenceGroup.findPreference(key);
+ if (pref != null && !value.equals(pref.getValue())) {
+ pref.setValue(value);
+ reloadPreferences();
+ }
+ }
+
@Override
public void overrideSettings(final String ... keyvalues) {
super.overrideSettings(keyvalues);
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 97cb8e490..224f9f7eb 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -878,6 +878,13 @@ public class VideoModule implements CameraModule,
}
@Override
+ public void onSwitchSavePath() {
+ mUI.setPreference(CameraSettings.KEY_CAMERA_SAVEPATH, "1");
+ Toast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
+ Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
public void installIntentFilter() {
// install an intent filter to receive SD card related events.
IntentFilter intentFilter =
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 75105822b..328645a30 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -846,4 +846,8 @@ public class VideoUI implements PieRenderer.PieListener,
R.drawable.ic_recording_indicator, 0, 0, 0);
mPauseButton.setPaused(false);
}
+
+ public void setPreference(String key, String value) {
+ mVideoMenu.setPreference(key, value);
+ }
}
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 4594b2ac6..61a416f37 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -44,6 +44,7 @@ import android.view.OrientationEventListener;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.widget.Toast;
import com.android.camera.PhotoModule;
import com.android.camera.CameraManager.CameraProxy;
import com.android.camera.app.OrientationManager;
@@ -884,6 +885,13 @@ public class WideAnglePanoramaModule
}
@Override
+ public void onSwitchSavePath() {
+ mPreferences.edit().putString(CameraSettings.KEY_CAMERA_SAVEPATH, "1").apply();
+ Toast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
+ Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
public void onResumeBeforeSuper() {
mPaused = false;
}