Skip to content

Commit

Permalink
档案压缩包下载位置从Download/EhviewerArchiver/改为Download/Ehviewer/Archiver/;
Browse files Browse the repository at this point in the history
种子下载位置从Download/改为Download/Ehviewer/Torrent/;
  • Loading branch information
xiaojieonly committed Sep 23, 2024
1 parent 7290221 commit 1650485
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (file('google-services.json').exists()) {
android {
namespace 'com.hippo.ehviewer'
testNamespace 'com.hippo.ehviewer.debug'
compileSdkVersion 32
compileSdkVersion 34
// buildToolsVersion "30.0.3"
// ndkVersion '23.1.7779620'

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/hippo/ehviewer/client/EhConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ public class EhConfig implements Cloneable {
*/
public static final String CONTENT_WARNING_NOT_SHOW = "1";

public static final String ARCHIVER_PATH = "Ehviewer/Archiver/";
public static final String TORRENT_PATH = "Ehviewer/Torrent/";

/**
* Load images through the Hentai@Home Network<br/>
* key: {@link #KEY_LOAD_FROM_HAH}<br/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hippo.ehviewer.ui.dialog;

import static com.hippo.ehviewer.client.EhConfig.ARCHIVER_PATH;
import static com.hippo.ehviewer.ui.scene.BaseScene.LENGTH_LONG;
import static com.hippo.ehviewer.ui.scene.BaseScene.LENGTH_SHORT;

Expand Down Expand Up @@ -211,7 +212,7 @@ public void onSuccess(String downloadUrl) {
request.setTitle(galleryDetail.title);
request.setDescription(context.getString(R.string.download_archive_started));
request.setVisibleInDownloadsUi(true);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "EhviewerArchiver/"+galleryDetail.title + ".zip");
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, ARCHIVER_PATH+galleryDetail.title + ".zip");
request.allowScanningByMediaScanner();

DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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

import static com.hippo.ehviewer.client.EhConfig.TORRENT_PATH;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
Expand Down Expand Up @@ -2323,7 +2325,7 @@ private void downLoadPlanB(AdapterView<?> parent, View view, int position, long
try {
String url = mTorrentList[position].first;
String name = mTorrentList[position].second + ".torrent";
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath();
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()+"/"+TORRENT_PATH;
DownloadTorrentManager downloadTorrentManager = DownloadTorrentManager.get(okHttpClient);
if (!EhApplication.addDownloadTorrent(context, url)) {
Toast.makeText(context, R.string.downloading, Toast.LENGTH_LONG).show();
Expand Down
29 changes: 18 additions & 11 deletions app/src/main/java/com/hippo/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.DocumentsContract;
import android.provider.MediaStore;

Expand All @@ -17,6 +18,8 @@

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

import static com.hippo.ehviewer.client.EhConfig.TORRENT_PATH;

import com.hippo.unifile.UniFile;
import com.google.firebase.crashlytics.FirebaseCrashlytics;

Expand Down Expand Up @@ -84,19 +87,23 @@ public static void openAssignFolder(String path, Context context) {
if (!file.exists()) {
return;
}
Intent intent;

Uri uri = Uri.parse("content://com.android.externalstorage.documents/document/primary%3ADownload");
// Uri uri = Uri.parse(path);
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, uri);

//
// Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// intent.setDataAndType(Uri.fromFile(file), "file/*");

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Uri uri = Uri.parse("content://com.android.externalstorage.documents/document/primary%3ADownload/"+TORRENT_PATH);
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, uri);
}else{
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
intent.setDataAndType(Uri.fromFile(file), "file/*");
}


try {
// context.startActivity(intent);
Expand Down

0 comments on commit 1650485

Please sign in to comment.