Skip to content

Commit c313a0c

Browse files
committedFeb 12, 2022
Code cleanup
1 parent 318c18c commit c313a0c

File tree

4 files changed

+3
-152
lines changed

4 files changed

+3
-152
lines changed
 

‎android/jdonkey/src/main/java/org/dkf/jmule/AndroidPaths.java

+2-87
Original file line numberDiff line numberDiff line change
@@ -33,112 +33,27 @@
3333
/**
3434
* @author gubatron
3535
* @author aldenml
36+
* JED2K stores all files to one place without sub dirs
3637
*/
3738
public final class AndroidPaths {
38-
39-
/**
40-
* base storage path
41-
*/
42-
private static final String STORAGE_PATH = "Mule_on_Android";
43-
44-
/**
45-
* downloaded files path
46-
*/
47-
private static final String DOWNLOADS_PATH = "";
48-
49-
/**
50-
* metadata path for fast resume data saving
51-
*/
52-
private static final String METADATA_PATH = ".metadata";
53-
54-
private static final String TEMP_PATH = "temp";
55-
5639
private static final boolean USE_EXTERNAL_STORAGE_DIR_ON_OR_AFTER_ANDROID_10 = true;
57-
5840
private final Context context;
59-
//private final Application app;
6041

6142
public AndroidPaths(Context app) {
6243
this.context = app;
6344
}
6445

65-
// public File data(Context ctx) {
66-
//return new File(storage(), DOWNLOADS_PATH);
67-
// return storage(ctx);
68-
//}
69-
7046
public File data() {
71-
//return new File(storage(), DOWNLOADS_PATH);
72-
return storage();
73-
}
74-
75-
//public File metadata(Context ctx) {
76-
// return new File(storage(ctx), METADATA_PATH);
77-
//}
78-
79-
//public File temp() {
80-
// return new File(context.getExternalFilesDir(null), TEMP_PATH);
81-
//}
82-
83-
private static final Logger LOG = LoggerFactory.getLogger(AndroidPaths.class);
84-
/*
85-
private static File storage(Context ctx) {
86-
if (SystemUtils.hasAndroid10OrNewer()) {
87-
File externalDir = ctx.getExternalFilesDir(null);
88-
return new File(USE_EXTERNAL_STORAGE_DIR_ON_OR_AFTER_ANDROID_10 ?
89-
externalDir : ctx.getFilesDir(),
90-
STORAGE_PATH);
91-
}
92-
*/
93-
/* For Older versions of Android where we used to have access to write to external storage
94-
* <externalStoragePath>/FrostWire/
95-
*/
96-
/* String path = ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath());
97-
if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) {
98-
return new File(path);
99-
} else {
100-
return new File(path, STORAGE_PATH);
101-
}
102-
*/
103-
//String path = ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH);
104-
/*if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) {
105-
return new File(path);
106-
} else {
107-
return new File(path, STORAGE_PATH);
108-
}
109-
*/
110-
//return new File(path);
111-
//}
112-
113-
private File storage() {
11447
if (SystemUtils.hasAndroid10OrNewer()) {
11548
File externalDir = context.getExternalFilesDir(null);
116-
LOG.info("storage: external path {}", externalDir);
11749
return USE_EXTERNAL_STORAGE_DIR_ON_OR_AFTER_ANDROID_10 ? externalDir : context.getFilesDir();
11850

11951
}
12052

12153
/* For Older versions of Android where we used to have access to write to external storage
122-
* <externalStoragePath>/FrostWire/
54+
* <externalStoragePath>
12355
*/
12456
String path = ConfigurationManager.instance().getStoragePath();
125-
//ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath());
126-
LOG.info("storage: internal path {}", path);
12757
return new File(ConfigurationManager.instance().getStoragePath());
128-
/*
129-
if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) {
130-
return new File(path);
131-
} else {
132-
return new File(path);
133-
}*/
134-
135-
//String path = ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH);
136-
/*if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) {
137-
return new File(path);
138-
} else {
139-
return new File(path, STORAGE_PATH);
140-
}
141-
*/
142-
//return new File(path);
14358
}
14459
}

‎android/jdonkey/src/main/java/org/dkf/jmule/Platforms.java

-29
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
package org.dkf.jmule;
2020

21-
import android.content.Context;
22-
2321
import java.io.File;
2422

2523
/**
@@ -65,34 +63,7 @@ public static AndroidSettings appSettings() {
6563
return get().appSettings();
6664
}
6765

68-
/**
69-
* Shortcut to current platform file system data method.
70-
*
71-
* @return
72-
*/
73-
//public static File data(Context ctx) {
74-
// return get().systemPaths().data(ctx);
75-
//}
76-
7766
public static File data() {
7867
return get().systemPaths().data();
7968
}
80-
81-
/**
82-
* Shortcut to current platform file system torrents method.
83-
*
84-
* @return
85-
*/
86-
//public static File metadata(Context ctx) {
87-
// return get().systemPaths().metadata(ctx);
88-
//}
89-
90-
/**
91-
* Shortcut to current platform file system temp method.
92-
*
93-
* @return
94-
*/
95-
//public static File temp() {
96-
// return get().systemPaths().temp();
97-
//}
9869
}

‎android/jdonkey/src/main/java/org/dkf/jmule/activities/MainActivity.java

-29
Original file line numberDiff line numberDiff line change
@@ -824,35 +824,6 @@ public void onClick(DialogInterface dialogInterface, int i) {
824824
}
825825
}
826826

827-
// TODO: refactor and move this method for a common place when needed
828-
/*private static String saveViewContent(Context context, Uri uri, String name) {
829-
InputStream inStream = null;
830-
OutputStream outStream = null;
831-
if (!Platforms.temp().exists()) {
832-
Platforms.temp().mkdirs();
833-
}
834-
File target = new File(Platforms.temp(), name);
835-
try {
836-
inStream = context.getContentResolver().openInputStream(uri);
837-
outStream = new FileOutputStream(target);
838-
839-
byte[] buffer = new byte[16384]; // MAGIC_NUMBER
840-
int bytesRead;
841-
while ((bytesRead = inStream.read(buffer)) != -1) {
842-
outStream.write(buffer, 0, bytesRead);
843-
}
844-
845-
} catch (Exception e) {
846-
log.error("Error when copying file from " + uri + " to temp/" + name, e);
847-
return null;
848-
} finally {
849-
IOUtils.closeQuietly(inStream);
850-
IOUtils.closeQuietly(outStream);
851-
}
852-
853-
return "file://" + target.getAbsolutePath();
854-
}*/
855-
856827
public Fragment getFragmentByNavMenuId(int id) {
857828
if (id == R.id.menu_main_search) {
858829
return search;

‎android/jdonkey/src/main/java/org/dkf/jmule/activities/SettingsActivity.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,7 @@ public void startActivity(Intent intent) {
388388
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
389389
if (requestCode == StoragePicker.SELECT_FOLDER_REQUEST_CODE) {
390390
StoragePreference.onDocumentTreeActivityResult(this, requestCode, resultCode, data);
391-
}/* else if (requestCode == BuyActivity.PURCHASE_SUCCESSFUL_RESULT_CODE &&
392-
data != null &&
393-
data.hasExtra(BuyActivity.EXTRA_KEY_PURCHASE_TIMESTAMP)) {
394-
// We (onActivityResult) are invoked before onResume()
395-
removeAdsPurchaseTime = data.getLongExtra(BuyActivity.EXTRA_KEY_PURCHASE_TIMESTAMP, 0);
396-
LOG.info("onActivityResult: User just purchased something. removeAdsPurchaseTime="+removeAdsPurchaseTime);
397-
}*/
391+
}
398392
else {
399393
super.onActivityResult(requestCode, resultCode, data);
400394
}

0 commit comments

Comments
 (0)
Please sign in to comment.