diff options
| author | Teng-Hui Zhu <ztenghui@google.com> | 2012-09-30 13:54:34 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2012-09-30 13:54:34 -0700 |
| commit | d133b9613f721ef91ae0858ef2160e1104ac0d50 (patch) | |
| tree | 00fac4a114fe31602a421256848f4a67b963c590 | |
| parent | 5d76d0f31b4a5bd22f2bf352fccd3492e980e6ae (diff) | |
| parent | 5168509fe260a9d549278a9a287c3d7e0c1b739e (diff) | |
| download | android_packages_apps_Gallery2-d133b9613f721ef91ae0858ef2160e1104ac0d50.tar.gz android_packages_apps_Gallery2-d133b9613f721ef91ae0858ef2160e1104ac0d50.tar.bz2 android_packages_apps_Gallery2-d133b9613f721ef91ae0858ef2160e1104ac0d50.zip | |
am 5168509f: Merge "Trimming: clean up strings and prevent too short or no trimming." into gb-ub-photos-arches
* commit '5168509fe260a9d549278a9a287c3d7e0c1b739e':
Trimming: clean up strings and prevent too short or no trimming.
| -rw-r--r-- | res/values/strings.xml | 15 | ||||
| -rw-r--r-- | src/com/android/gallery3d/app/TrimVideo.java | 35 |
2 files changed, 42 insertions, 8 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 7323a7d4b..61b45a28b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -463,4 +463,19 @@ <!-- Label for album grid button --> <string name="switch_photo_grid">Grid</string> + + <!-- The tilte of a dialog showing trimming in progress. [CHAR LIMIT=20] --> + <string name="trimming">Trimming</string> + + <!-- The content of a dialog showing trimming in progress. [CHAR LIMIT=30] --> + <string name="please_wait">Please wait</string> + + <!-- Toast after the trimming is done. [CHAR LIMIT=50] --> + <string name="save_into">Save trimmed video into</string> + + <!-- Toast if the trimmed video is too short to trim. [CHAR LIMIT=80] --> + <string name="trim_too_short">Can not trim : target video is too short</string> + + <!-- Toast if the trimmed video is the same as the original one. [CHAR LIMIT=80] --> + <string name="trim_too_long">Did not trim : the same length as origin</string> </resources> 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); |
