Skip to content

Commit 1650485

Browse files
committed
档案压缩包下载位置从Download/EhviewerArchiver/改为Download/Ehviewer/Archiver/;
种子下载位置从Download/改为Download/Ehviewer/Torrent/;
1 parent 7290221 commit 1650485

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (file('google-services.json').exists()) {
1010
android {
1111
namespace 'com.hippo.ehviewer'
1212
testNamespace 'com.hippo.ehviewer.debug'
13-
compileSdkVersion 32
13+
compileSdkVersion 34
1414
// buildToolsVersion "30.0.3"
1515
// ndkVersion '23.1.7779620'
1616

app/src/main/java/com/hippo/ehviewer/client/EhConfig.java

+3
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,9 @@ public class EhConfig implements Cloneable {
530530
*/
531531
public static final String CONTENT_WARNING_NOT_SHOW = "1";
532532

533+
public static final String ARCHIVER_PATH = "Ehviewer/Archiver/";
534+
public static final String TORRENT_PATH = "Ehviewer/Torrent/";
535+
533536
/**
534537
* Load images through the Hentai@Home Network<br/>
535538
* key: {@link #KEY_LOAD_FROM_HAH}<br/>

app/src/main/java/com/hippo/ehviewer/ui/dialog/ArchiverDownloadDialog.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.hippo.ehviewer.ui.dialog;
22

3+
import static com.hippo.ehviewer.client.EhConfig.ARCHIVER_PATH;
34
import static com.hippo.ehviewer.ui.scene.BaseScene.LENGTH_LONG;
45
import static com.hippo.ehviewer.ui.scene.BaseScene.LENGTH_SHORT;
56

@@ -211,7 +212,7 @@ public void onSuccess(String downloadUrl) {
211212
request.setTitle(galleryDetail.title);
212213
request.setDescription(context.getString(R.string.download_archive_started));
213214
request.setVisibleInDownloadsUi(true);
214-
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "EhviewerArchiver/"+galleryDetail.title + ".zip");
215+
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, ARCHIVER_PATH+galleryDetail.title + ".zip");
215216
request.allowScanningByMediaScanner();
216217

217218
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);

app/src/main/java/com/hippo/ehviewer/ui/scene/gallery/detail/GalleryDetailScene.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.hippo.ehviewer.ui.scene.gallery.detail;
1818

19+
import static com.hippo.ehviewer.client.EhConfig.TORRENT_PATH;
20+
1921
import android.annotation.SuppressLint;
2022
import android.app.Activity;
2123
import android.app.Dialog;
@@ -2323,7 +2325,7 @@ private void downLoadPlanB(AdapterView<?> parent, View view, int position, long
23232325
try {
23242326
String url = mTorrentList[position].first;
23252327
String name = mTorrentList[position].second + ".torrent";
2326-
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath();
2328+
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()+"/"+TORRENT_PATH;
23272329
DownloadTorrentManager downloadTorrentManager = DownloadTorrentManager.get(okHttpClient);
23282330
if (!EhApplication.addDownloadTorrent(context, url)) {
23292331
Toast.makeText(context, R.string.downloading, Toast.LENGTH_LONG).show();

app/src/main/java/com/hippo/util/FileUtils.java

+18-11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.Intent;
66
import android.database.Cursor;
77
import android.net.Uri;
8+
import android.os.Build;
89
import android.provider.DocumentsContract;
910
import android.provider.MediaStore;
1011

@@ -17,6 +18,8 @@
1718

1819
import static androidx.core.app.ActivityCompat.startActivityForResult;
1920

21+
import static com.hippo.ehviewer.client.EhConfig.TORRENT_PATH;
22+
2023
import com.hippo.unifile.UniFile;
2124
import com.google.firebase.crashlytics.FirebaseCrashlytics;
2225

@@ -84,19 +87,23 @@ public static void openAssignFolder(String path, Context context) {
8487
if (!file.exists()) {
8588
return;
8689
}
90+
Intent intent;
8791

88-
Uri uri = Uri.parse("content://com.android.externalstorage.documents/document/primary%3ADownload");
8992
// Uri uri = Uri.parse(path);
90-
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
91-
intent.addCategory(Intent.CATEGORY_OPENABLE);
92-
intent.setType("*/*");
93-
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, uri);
94-
95-
//
96-
// Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
97-
// intent.addCategory(Intent.CATEGORY_DEFAULT);
98-
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
99-
// intent.setDataAndType(Uri.fromFile(file), "file/*");
93+
94+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
95+
Uri uri = Uri.parse("content://com.android.externalstorage.documents/document/primary%3ADownload/"+TORRENT_PATH);
96+
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
97+
intent.addCategory(Intent.CATEGORY_OPENABLE);
98+
intent.setType("*/*");
99+
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, uri);
100+
}else{
101+
intent = new Intent(Intent.ACTION_GET_CONTENT);
102+
intent.addCategory(Intent.CATEGORY_OPENABLE);
103+
intent.setType("*/*");
104+
intent.setDataAndType(Uri.fromFile(file), "file/*");
105+
}
106+
100107

101108
try {
102109
// context.startActivity(intent);

0 commit comments

Comments
 (0)