diff options
author | Vasantha Balla <vballa@codeaurora.org> | 2013-10-07 15:29:52 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2014-11-04 08:23:13 -0700 |
commit | 07a1c98abfa8f4816cfa66efa06bf331d99e65ee (patch) | |
tree | 8236647e994035033e7ce52dfb17082e4c906f44 /src/com/android/gallery3d/app/MuteVideo.java | |
parent | d73fd7eb45f643c98c40279d6a096de56f39260c (diff) | |
download | android_packages_apps_Gallery2-07a1c98abfa8f4816cfa66efa06bf331d99e65ee.tar.gz android_packages_apps_Gallery2-07a1c98abfa8f4816cfa66efa06bf331d99e65ee.tar.bz2 android_packages_apps_Gallery2-07a1c98abfa8f4816cfa66efa06bf331d99e65ee.zip |
Gallery2: Fix crash for unsupported format on mute operation
MPEG4Writer does not support formats other than mp4/h264/h263. The
app needs to check for unsupported formats before starting any mute
operation. Add a condition in the app to check for unsupported
formats and display a toast message.
CRs-Fixed: 514347 696137
Change-Id: Ib2ce48d2b8ebaef80936bc7a446e1c97e3a10c31
Diffstat (limited to 'src/com/android/gallery3d/app/MuteVideo.java')
-rw-r--r-- | src/com/android/gallery3d/app/MuteVideo.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/app/MuteVideo.java b/src/com/android/gallery3d/app/MuteVideo.java index d3f3aa594..a385fbb9f 100644 --- a/src/com/android/gallery3d/app/MuteVideo.java +++ b/src/com/android/gallery3d/app/MuteVideo.java @@ -16,6 +16,8 @@ package com.android.gallery3d.app; +import java.util.ArrayList; + import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; @@ -40,6 +42,13 @@ public class MuteVideo { private SaveVideoFileInfo mDstFileInfo = null; private Activity mActivity = null; private final Handler mHandler = new Handler(); + private String mMimeType; + ArrayList<String> mUnsupportedMuteFileTypes = new ArrayList<String>(); + private final String FILE_TYPE_DIVX = "video/divx"; + private final String FILE_TYPE_AVI = "video/avi"; + private final String FILE_TYPE_WMV = "video/x-ms-wmv"; + private final String FILE_TYPE_ASF = "video/x-ms-asf"; + private final String FILE_TYPE_WEBM = "video/webm"; final String TIME_STAMP_NAME = "'MUTE'_yyyyMMdd_HHmmss"; @@ -47,6 +56,13 @@ public class MuteVideo { mUri = uri; mFilePath = filePath; mActivity = activity; + if (mUnsupportedMuteFileTypes != null) { + mUnsupportedMuteFileTypes.add(FILE_TYPE_DIVX); + mUnsupportedMuteFileTypes.add(FILE_TYPE_AVI); + mUnsupportedMuteFileTypes.add(FILE_TYPE_WMV); + mUnsupportedMuteFileTypes.add(FILE_TYPE_ASF); + mUnsupportedMuteFileTypes.add(FILE_TYPE_WEBM); + } } public void muteInBackground() { @@ -54,6 +70,15 @@ public class MuteVideo { mActivity.getContentResolver(), mUri, mActivity.getString(R.string.folder_download)); + mMimeType = mActivity.getContentResolver().getType(mUri); + if(!isValidFileForMute(mMimeType)) { + Toast.makeText(mActivity.getApplicationContext(), + mActivity.getString(R.string.mute_nosupport), + Toast.LENGTH_SHORT) + .show(); + return; + } + showProgressDialog(); new Thread(new Runnable() { @Override @@ -101,4 +126,16 @@ public class MuteVideo { mMuteProgress.setCanceledOnTouchOutside(false); mMuteProgress.show(); } + private boolean isValidFileForMute(String mimeType) { + if (mimeType != null) { + for (String fileType : mUnsupportedMuteFileTypes) { + if (mimeType.equals(fileType)) { + return false; + } + } + return true; + } else { + return false; + } + } } |