aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaxwen <max.weninger@gmail.com>2020-06-07 13:54:47 +0200
committerGeorge Zacharia <george.zcharia@gmail.com>2021-08-25 18:41:46 +0530
commitaf9bf79d12bee4884cb95e5d7e1c970431b610fd (patch)
treeb0100fd3ff0ac00d7d2843bb0bc10466c73f1f01
parentb17ff91a0d945db524c150e4cf5f496ba1d9bb6d (diff)
OmniStyle: after download remote image call ACTION_VIEW
Change-Id: I57a931a448fb9a63711d06ce64d49fde339e75c3
-rw-r--r--AndroidManifest.xml10
-rw-r--r--res/xml/provider_paths.xml24
-rw-r--r--src/org/omnirom/omnistyle/BrowseWallsActivity.java27
3 files changed, 60 insertions, 1 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7a87022..f28edf7 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -140,5 +140,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
+
+ <provider
+ android:name="androidx.core.content.FileProvider"
+ android:authorities="org.omnirom.omnistyle.provider"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/provider_paths" />
+ </provider>
</application>
</manifest>
diff --git a/res/xml/provider_paths.xml b/res/xml/provider_paths.xml
new file mode 100644
index 0000000..cb690f4
--- /dev/null
+++ b/res/xml/provider_paths.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (c) 2016-2017 Projekt Substratum
+ ~ This file is part of Substratum.
+ ~
+ ~ Substratum is free software: you can redistribute it and/or modify
+ ~ it under the terms of the GNU General Public License as published by
+ ~ the Free Software Foundation, either version 3 of the License, or
+ ~ (at your option) any later version.
+ ~
+ ~ Substratum is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ~ GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License
+ ~ along with Substratum. If not, see <http://www.gnu.org/licenses/>.
+ -->
+
+<paths>
+ <external-path
+ name="external_files"
+ path="."/>
+</paths> \ No newline at end of file
diff --git a/src/org/omnirom/omnistyle/BrowseWallsActivity.java b/src/org/omnirom/omnistyle/BrowseWallsActivity.java
index ad30a00..b342030 100644
--- a/src/org/omnirom/omnistyle/BrowseWallsActivity.java
+++ b/src/org/omnirom/omnistyle/BrowseWallsActivity.java
@@ -57,6 +57,7 @@ import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
+import androidx.core.content.FileProvider;
import com.squareup.picasso.Picasso;
@@ -443,6 +444,24 @@ public class BrowseWallsActivity extends Activity {
return cropAndSetWallpaperIntent;
}
+ private Intent getViewActivity(File localFile) {
+ final Intent viewIntent = new Intent();
+ viewIntent.setAction(Intent.ACTION_VIEW);
+ viewIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ Uri imageUri = FileProvider.getUriForFile(this, "org.omnirom.omnistyle.provider", localFile);
+ viewIntent.setDataAndType(imageUri, "image/*");
+ return viewIntent;
+ }
+
+ private void openFileInGalleryApp(String wallpaperFile) {
+ Intent viewIntent = getViewActivity(new File(wallpaperFile));
+ if (viewIntent.resolveActivity(getPackageManager()) != null) {
+ startActivity(viewIntent);
+ } else {
+ Toast.makeText(BrowseWallsActivity.this, R.string.download_wallpaper_view_notice, Toast.LENGTH_LONG).show();
+ }
+ }
+
private boolean checkCropActivity() {
final Intent cropAndSetWallpaperIntent = getCropActivity();
return cropAndSetWallpaperIntent.resolveActivityInfo(getPackageManager(), 0) != null;
@@ -588,8 +607,14 @@ public class BrowseWallsActivity extends Activity {
if (!mDownloadOnly) {
doSetRemoteWallpaperPost(mWallpaperFile);
} else {
- MediaScannerConnection.scanFile(BrowseWallsActivity.this,
+ if (!new File(mWallpaperFile).exists()) {
+ Toast.makeText(BrowseWallsActivity.this, R.string.download_wallpaper_failed_notice, Toast.LENGTH_LONG).show();
+ } else {
+ MediaScannerConnection.scanFile(BrowseWallsActivity.this,
new String[] { mWallpaperFile }, null, null);
+
+ openFileInGalleryApp(mWallpaperFile);
+ }
mScrollDisabled = false;
}
}