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
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
android:name=".activities.AboutActivity"

View file

@ -66,6 +66,30 @@ public class ViewPagerActivity extends AppCompatActivity
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;
mIsFullScreen = true;
mActionbar = getSupportActionBar();
@ -73,7 +97,6 @@ public class ViewPagerActivity extends AppCompatActivity
mBeingDeleted = "";
hideSystemUI();
mPath = getIntent().getStringExtra(Constants.MEDIUM);
MediaScannerConnection.scanFile(this, new String[]{mPath}, null, null);
addUndoMargin();
mDirectory = new File(mPath).getParent();

View file

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