import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
+import android.app.ProgressDialog;
import android.content.ContentValues;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.util.TypedValue;
-import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.widget.SeekBar;
import android.widget.ShareActionProvider;
import android.widget.ShareActionProvider.OnShareTargetSelectedListener;
-import android.widget.Toast;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.ui.ImageCurves;
import java.io.File;
+import java.lang.ref.WeakReference;
import java.util.Vector;
@TargetApi(16)
private boolean mSharingImage = false;
+ private WeakReference<ProgressDialog> mSavingProgressDialog;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
+ private void showSavingProgress() {
+ ProgressDialog progress;
+ if (mSavingProgressDialog != null) {
+ progress = mSavingProgressDialog.get();
+ if (progress != null) {
+ progress.show();
+ return;
+ }
+ }
+ // TODO: Allow cancellation of the saving process
+ progress = ProgressDialog.show(this, "", getString(R.string.saving_image), true, false);
+ mSavingProgressDialog = new WeakReference<ProgressDialog>(progress);
+ }
+
+ private void hideSavingProgress() {
+ if (mSavingProgressDialog != null) {
+ ProgressDialog progress = mSavingProgressDialog.get();
+ if (progress != null) progress.dismiss();
+ }
+ }
+
public void completeSaveImage(Uri saveUri) {
if (mSharingImage && mSharedOutputFile != null) {
// Image saved, we unblock the content provider
getContentResolver().insert(uri, values);
}
setResult(RESULT_OK, new Intent().setData(saveUri));
+ hideSavingProgress();
finish();
}
mSharingImage = true;
// Process and save the image in the background.
+ showSavingProgress();
mImageShow.saveImage(this, mSharedOutputFile);
return true;
}
}
public void saveImage() {
- Toast toast = Toast.makeText(getBaseContext(), getString(R.string.saving_image),
- Toast.LENGTH_SHORT);
- toast.setGravity(Gravity.CENTER, 0, 0);
- toast.show();
-
+ showSavingProgress();
mImageShow.saveImage(this, null);
}