diff --git a/android/jdonkey/src/main/java/org/dkf/jmule/AndroidPaths.java b/android/jdonkey/src/main/java/org/dkf/jmule/AndroidPaths.java index 653f556e..dadc2b4a 100644 --- a/android/jdonkey/src/main/java/org/dkf/jmule/AndroidPaths.java +++ b/android/jdonkey/src/main/java/org/dkf/jmule/AndroidPaths.java @@ -33,112 +33,27 @@ /** * @author gubatron * @author aldenml + * JED2K stores all files to one place without sub dirs */ public final class AndroidPaths { - - /** - * base storage path - */ - private static final String STORAGE_PATH = "Mule_on_Android"; - - /** - * downloaded files path - */ - private static final String DOWNLOADS_PATH = ""; - - /** - * metadata path for fast resume data saving - */ - private static final String METADATA_PATH = ".metadata"; - - private static final String TEMP_PATH = "temp"; - private static final boolean USE_EXTERNAL_STORAGE_DIR_ON_OR_AFTER_ANDROID_10 = true; - private final Context context; - //private final Application app; public AndroidPaths(Context app) { this.context = app; } - // public File data(Context ctx) { - //return new File(storage(), DOWNLOADS_PATH); - // return storage(ctx); - //} - public File data() { - //return new File(storage(), DOWNLOADS_PATH); - return storage(); - } - - //public File metadata(Context ctx) { - // return new File(storage(ctx), METADATA_PATH); - //} - - //public File temp() { - // return new File(context.getExternalFilesDir(null), TEMP_PATH); - //} - - private static final Logger LOG = LoggerFactory.getLogger(AndroidPaths.class); -/* - private static File storage(Context ctx) { - if (SystemUtils.hasAndroid10OrNewer()) { - File externalDir = ctx.getExternalFilesDir(null); - return new File(USE_EXTERNAL_STORAGE_DIR_ON_OR_AFTER_ANDROID_10 ? - externalDir : ctx.getFilesDir(), - STORAGE_PATH); - } -*/ - /* For Older versions of Android where we used to have access to write to external storage - * /FrostWire/ - */ -/* String path = ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath()); - if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) { - return new File(path); - } else { - return new File(path, STORAGE_PATH); - } -*/ - //String path = ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH); - /*if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) { - return new File(path); - } else { - return new File(path, STORAGE_PATH); - } - */ - //return new File(path); - //} - - private File storage() { if (SystemUtils.hasAndroid10OrNewer()) { File externalDir = context.getExternalFilesDir(null); - LOG.info("storage: external path {}", externalDir); return USE_EXTERNAL_STORAGE_DIR_ON_OR_AFTER_ANDROID_10 ? externalDir : context.getFilesDir(); } /* For Older versions of Android where we used to have access to write to external storage - * /FrostWire/ + * */ String path = ConfigurationManager.instance().getStoragePath(); - //ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath()); - LOG.info("storage: internal path {}", path); return new File(ConfigurationManager.instance().getStoragePath()); - /* - if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) { - return new File(path); - } else { - return new File(path); - }*/ - - //String path = ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH); - /*if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) { - return new File(path); - } else { - return new File(path, STORAGE_PATH); - } - */ - //return new File(path); } } diff --git a/android/jdonkey/src/main/java/org/dkf/jmule/Platforms.java b/android/jdonkey/src/main/java/org/dkf/jmule/Platforms.java index 2bdb632e..9efaf21b 100644 --- a/android/jdonkey/src/main/java/org/dkf/jmule/Platforms.java +++ b/android/jdonkey/src/main/java/org/dkf/jmule/Platforms.java @@ -18,8 +18,6 @@ package org.dkf.jmule; -import android.content.Context; - import java.io.File; /** @@ -65,34 +63,7 @@ public static AndroidSettings appSettings() { return get().appSettings(); } - /** - * Shortcut to current platform file system data method. - * - * @return - */ - //public static File data(Context ctx) { - // return get().systemPaths().data(ctx); - //} - public static File data() { return get().systemPaths().data(); } - - /** - * Shortcut to current platform file system torrents method. - * - * @return - */ - //public static File metadata(Context ctx) { - // return get().systemPaths().metadata(ctx); - //} - - /** - * Shortcut to current platform file system temp method. - * - * @return - */ - //public static File temp() { - // return get().systemPaths().temp(); - //} } diff --git a/android/jdonkey/src/main/java/org/dkf/jmule/activities/MainActivity.java b/android/jdonkey/src/main/java/org/dkf/jmule/activities/MainActivity.java index 101d52c1..b2961b6a 100644 --- a/android/jdonkey/src/main/java/org/dkf/jmule/activities/MainActivity.java +++ b/android/jdonkey/src/main/java/org/dkf/jmule/activities/MainActivity.java @@ -824,35 +824,6 @@ public void onClick(DialogInterface dialogInterface, int i) { } } - // TODO: refactor and move this method for a common place when needed - /*private static String saveViewContent(Context context, Uri uri, String name) { - InputStream inStream = null; - OutputStream outStream = null; - if (!Platforms.temp().exists()) { - Platforms.temp().mkdirs(); - } - File target = new File(Platforms.temp(), name); - try { - inStream = context.getContentResolver().openInputStream(uri); - outStream = new FileOutputStream(target); - - byte[] buffer = new byte[16384]; // MAGIC_NUMBER - int bytesRead; - while ((bytesRead = inStream.read(buffer)) != -1) { - outStream.write(buffer, 0, bytesRead); - } - - } catch (Exception e) { - log.error("Error when copying file from " + uri + " to temp/" + name, e); - return null; - } finally { - IOUtils.closeQuietly(inStream); - IOUtils.closeQuietly(outStream); - } - - return "file://" + target.getAbsolutePath(); - }*/ - public Fragment getFragmentByNavMenuId(int id) { if (id == R.id.menu_main_search) { return search; diff --git a/android/jdonkey/src/main/java/org/dkf/jmule/activities/SettingsActivity.java b/android/jdonkey/src/main/java/org/dkf/jmule/activities/SettingsActivity.java index 2b68a1db..ca4d1b18 100644 --- a/android/jdonkey/src/main/java/org/dkf/jmule/activities/SettingsActivity.java +++ b/android/jdonkey/src/main/java/org/dkf/jmule/activities/SettingsActivity.java @@ -388,13 +388,7 @@ public void startActivity(Intent intent) { protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == StoragePicker.SELECT_FOLDER_REQUEST_CODE) { StoragePreference.onDocumentTreeActivityResult(this, requestCode, resultCode, data); - }/* else if (requestCode == BuyActivity.PURCHASE_SUCCESSFUL_RESULT_CODE && - data != null && - data.hasExtra(BuyActivity.EXTRA_KEY_PURCHASE_TIMESTAMP)) { - // We (onActivityResult) are invoked before onResume() - removeAdsPurchaseTime = data.getLongExtra(BuyActivity.EXTRA_KEY_PURCHASE_TIMESTAMP, 0); - LOG.info("onActivityResult: User just purchased something. removeAdsPurchaseTime="+removeAdsPurchaseTime); - }*/ + } else { super.onActivityResult(requestCode, resultCode, data); }