summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2012-09-30 13:53:29 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-30 13:53:29 -0700
commit5168509fe260a9d549278a9a287c3d7e0c1b739e (patch)
tree00fac4a114fe31602a421256848f4a67b963c590 /src
parent3e2e9e9c7ee62b79632243a3e52f0abd70ce2a59 (diff)
parentd44b0d8348a9f91259ecbd59ec48c9df9f058141 (diff)
downloadandroid_packages_apps_Gallery2-5168509fe260a9d549278a9a287c3d7e0c1b739e.tar.gz
android_packages_apps_Gallery2-5168509fe260a9d549278a9a287c3d7e0c1b739e.tar.bz2
android_packages_apps_Gallery2-5168509fe260a9d549278a9a287c3d7e0c1b739e.zip
Merge "Trimming: clean up strings and prevent too short or no trimming." into gb-ub-photos-arches
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/app/TrimVideo.java35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/com/android/gallery3d/app/TrimVideo.java b/src/com/android/gallery3d/app/TrimVideo.java
index ed66b4e88..cb5b1711f 100644
--- a/src/com/android/gallery3d/app/TrimVideo.java
+++ b/src/com/android/gallery3d/app/TrimVideo.java
@@ -31,7 +31,6 @@ import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore.Video;
import android.provider.MediaStore.Video.VideoColumns;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
@@ -258,6 +257,21 @@ public class TrimVideo extends Activity implements
}
private void trimVideo() {
+ int delta = mTrimEndTime - mTrimStartTime;
+ // Considering that we only trim at sync frame, we don't want to trim
+ // when the time interval is too short or too close to the origin.
+ if (delta < 100 ) {
+ Toast.makeText(getApplicationContext(),
+ getString(R.string.trim_too_short),
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+ if (Math.abs(mVideoView.getDuration() - delta) < 100) {
+ Toast.makeText(getApplicationContext(),
+ getString(R.string.trim_too_long),
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
// Use the default save directory if the source directory cannot be
// saved.
mSaveDirectory = getSaveDirectory();
@@ -281,6 +295,8 @@ public class TrimVideo extends Activity implements
public void run() {
try {
TrimVideoUtils.startTrim(mSrcFile, mDstFile, mTrimStartTime, mTrimEndTime);
+ // Update the database for adding a new video file.
+ insertContent(mDstFile);
} catch (IOException e) {
e.printStackTrace();
}
@@ -288,16 +304,19 @@ public class TrimVideo extends Activity implements
mHandler.post(new Runnable() {
@Override
public void run() {
+ Toast.makeText(getApplicationContext(),
+ getString(R.string.save_into) + " " + saveFolderName,
+ Toast.LENGTH_SHORT)
+ .show();
// TODO: change trimming into a service to avoid
// this progressDialog and add notification properly.
if (mProgress != null) {
mProgress.dismiss();
- // Update the database for adding a new video file.
- insertContent(mDstFile);
- Toast.makeText(getApplicationContext(),
- "Saved into " + saveFolderName, Toast.LENGTH_SHORT)
- .show();
mProgress = null;
+ // Show the result only when the activity not stopped.
+ Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
+ intent.setDataAndTypeAndNormalize(Uri.fromFile(mDstFile), "video/*");
+ startActivity(intent);
}
}
});
@@ -309,8 +328,8 @@ public class TrimVideo extends Activity implements
// create a background thread to trim the video.
// and show the progress.
mProgress = new ProgressDialog(this);
- mProgress.setTitle("Trimming");
- mProgress.setMessage("please wait");
+ mProgress.setTitle(getString(R.string.trimming));
+ mProgress.setMessage(getString(R.string.please_wait));
// TODO: make this cancelable.
mProgress.setCancelable(false);
mProgress.setCanceledOnTouchOutside(false);