readPreference();
if (mRecordLocation) startReceivingLocationUpdates();
+ checkStorage();
+
// Initialize last picture button.
mContentResolver = getContentResolver();
if (!mIsImageCaptureIntent) {
ImageManager.ensureOSXCompatibleFolder();
- calculatePicturesRemaining();
-
installIntentFilter();
initializeFocusTone();
}
private void updateThumbnailButton() {
- if (!mThumbController.isUriValid()) {
+ // Update last image if URI is invalid and the storage is ready.
+ if (!mThumbController.isUriValid() && mPicturesRemaining >= 0) {
updateLastImage();
}
mThumbController.updateDisplayIfNeeded();
initializeFocusTone();
+ checkStorage();
+
if (!mIsImageCaptureIntent) {
updateThumbnailButton();
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
- // SD card available
- updateStorageHint(calculatePicturesRemaining());
- } else if (action.equals(Intent.ACTION_MEDIA_UNMOUNTED) ||
+ if (action.equals(Intent.ACTION_MEDIA_UNMOUNTED) ||
action.equals(Intent.ACTION_MEDIA_CHECKING)) {
// SD card unavailable
mPicturesRemaining = MenuHelper.NO_STORAGE_ERROR;
updateStorageHint(mPicturesRemaining);
} else if (action.equals(Intent.ACTION_MEDIA_SCANNER_STARTED)) {
- Toast.makeText(Camera.this,
- getResources().getString(R.string.wait), 5000);
+ mPicturesRemaining = MenuHelper.NO_STORAGE_ERROR;
+ updateStorageHint(mPicturesRemaining);
} else if (action.equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
- updateStorageHint();
+ updateStorageHint(calculatePicturesRemaining());
+ if (!mIsImageCaptureIntent) {
+ updateThumbnailButton();
+ }
}
}
};
if (!mIsImageCaptureIntent) {
mSwitcher.setSwitch(SWITCH_CAMERA);
}
- Thread t = new Thread(new Runnable() {
- public void run() {
- final boolean storageOK = calculatePicturesRemaining() > 0;
- if (!storageOK) {
- mHandler.post(new Runnable() {
- public void run() {
- updateStorageHint(mPicturesRemaining);
- }
- });
- }
- }
- });
- t.start();
}
+ private void checkStorage() {
+ calculatePicturesRemaining();
+ if (ImageManager.isMediaScannerScanning(getContentResolver())) {
+ mPicturesRemaining = MenuHelper.NO_STORAGE_ERROR;
+ }
+ if (mPicturesRemaining < 0) {
+ updateStorageHint(mPicturesRemaining);
+ }
+ }
+
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_retake:
if (remaining == MenuHelper.NO_STORAGE_ERROR) {
String state = Environment.getExternalStorageState();
- if (state == Environment.MEDIA_CHECKING) {
+ if (state == Environment.MEDIA_CHECKING ||
+ ImageManager.isMediaScannerScanning(getContentResolver())) {
noStorageText = getString(R.string.preparing_sd);
} else {
noStorageText = getString(R.string.no_storage);