aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Garnes <matt@cyngn.com>2015-01-17 16:58:20 +0800
committerMatt Garnes <matt@cyngn.com>2015-01-18 15:15:28 +0000
commit41e0d746284f22fbed08fd6c4c09e46f69458c15 (patch)
tree7c31efe19125df0d2e0ffabc58e7bcd8831ea6c0 /src
parent2ad1c3394e66e23ad934d0ddbbd42118a6b458df (diff)
downloadandroid_packages_apps_CMFileManager-41e0d746284f22fbed08fd6c4c09e46f69458c15.tar.gz
android_packages_apps_CMFileManager-41e0d746284f22fbed08fd6c4c09e46f69458c15.tar.bz2
android_packages_apps_CMFileManager-41e0d746284f22fbed08fd6c4c09e46f69458c15.zip
Add special case for Gallery2 when opening image files.
Gallery2 will change the back button behavior when opening a media URI to a specific image with FLAG_ACTIVITY_NEW_TASK. Do not use this flag for intents resolving to Gallery2 for media URIs. Change-Id: I26d36536bf071403bfd6d8430c2656f1b3ec3449
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java
index 026e31c1..5dcab233 100644
--- a/src/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java
+++ b/src/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java
@@ -27,6 +27,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
+import android.provider.MediaStore;
import android.util.Log;
import android.widget.Toast;
@@ -83,6 +84,11 @@ public final class IntentsActionPolicy extends ActionsPolicy {
"com.cyanogenmod.filemanager.category.EDITOR"; //$NON-NLS-1$
/**
+ * The package name of Gallery2.
+ */
+ public static final String GALLERY2_PACKAGE = "com.android.gallery3d";
+
+ /**
* Method that opens a {@link FileSystemObject} with the default registered application
* by the system, or ask the user for select a registered application.
*
@@ -484,8 +490,15 @@ public final class IntentsActionPolicy extends ActionsPolicy {
}
intent.setAction(a);
} else {
- // Create a new stack for the activity
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ // Opening image files with Gallery2 will behave incorrectly when started
+ // as a new task. We want to be able to return to CMFM with the back button.
+ if (!(Intent.ACTION_VIEW.equals(intent.getAction())
+ && isGallery2(ri)
+ && intent.getData() != null
+ && MediaStore.AUTHORITY.equals(intent.getData().getAuthority()))) {
+ // Create a new stack for the activity
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ }
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
@@ -578,6 +591,10 @@ public final class IntentsActionPolicy extends ActionsPolicy {
IntentsActionPolicy.CATEGORY_INTERNAL_VIEWER, false);
}
+ public static final boolean isGallery2(ResolveInfo ri) {
+ return GALLERY2_PACKAGE.equals(ri.activityInfo.packageName);
+ }
+
/**
* Method that retrieve the finds the preferred activity, if one exists. In case
* of multiple preferred activity exists the try to choose the better