properly open a couple more VIEW intents

This commit is contained in:
tibbi 2016-07-09 22:18:05 +02:00
parent c3420aa748
commit 11af15fb80
3 changed files with 38 additions and 2 deletions

View file

@ -53,7 +53,19 @@
<activity <activity
android:name=".activities.ViewPagerActivity" android:name=".activities.ViewPagerActivity"
android:theme="@style/FullScreenTheme"/> android:theme="@style/FullScreenTheme">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="com.android.camera.action.REVIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/*"/>
<data android:mimeType="video/*"/>
</intent-filter>
</activity>
<activity <activity
android:name=".activities.AboutActivity" android:name=".activities.AboutActivity"

View file

@ -66,6 +66,30 @@ public class ViewPagerActivity extends AppCompatActivity
return; return;
} }
final Uri uri = getIntent().getData();
if (uri != null) {
Cursor cursor = null;
try {
final String[] proj = {MediaStore.Images.Media.DATA};
cursor = getContentResolver().query(uri, proj, null, null, null);
final int dataIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
mPath = cursor.getString(dataIndex);
} finally {
if (cursor != null) {
cursor.close();
}
}
} else {
mPath = getIntent().getStringExtra(Constants.MEDIUM);
}
if (mPath == null || mPath.isEmpty()) {
Utils.showToast(getApplicationContext(), R.string.unknown_error);
finish();
return;
}
mPos = 0; mPos = 0;
mIsFullScreen = true; mIsFullScreen = true;
mActionbar = getSupportActionBar(); mActionbar = getSupportActionBar();
@ -73,7 +97,6 @@ public class ViewPagerActivity extends AppCompatActivity
mBeingDeleted = ""; mBeingDeleted = "";
hideSystemUI(); hideSystemUI();
mPath = getIntent().getStringExtra(Constants.MEDIUM);
MediaScannerConnection.scanFile(this, new String[]{mPath}, null, null); MediaScannerConnection.scanFile(this, new String[]{mPath}, null, null);
addUndoMargin(); addUndoMargin();
mDirectory = new File(mPath).getParent(); mDirectory = new File(mPath).getParent();

View file

@ -19,6 +19,7 @@
<string name="file_deleted">File deleted</string> <string name="file_deleted">File deleted</string>
<string name="setting_wallpaper">Setting wallpaper</string> <string name="setting_wallpaper">Setting wallpaper</string>
<string name="open_camera">Open camera</string> <string name="open_camera">Open camera</string>
<string name="unknown_error">An unknown error occurred</string>
<plurals name="folders_deleted"> <plurals name="folders_deleted">
<item quantity="one">1 folder deleted</item> <item quantity="one">1 folder deleted</item>