mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 15:27:55 -04:00
Allow users to specify a custom path to search/save toi #40
This commit is contained in:
parent
354b34e7c0
commit
ef2ceed7e1
@ -32,7 +32,7 @@ dependencies {
|
||||
compile project(":kiwixlib")
|
||||
|
||||
// Storage Devices
|
||||
compile 'eu.mhutti1.utils.storage:android-storage-devices:0.5.0'
|
||||
compile 'eu.mhutti1.utils.storage:android-storage-devices:0.6.1'
|
||||
|
||||
// Android Support
|
||||
compile 'com.android.support:appcompat-v7:25.3.1'
|
||||
|
@ -55,10 +55,10 @@ public class FileSearch {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void scan() {
|
||||
public void scan(String defaultPath) {
|
||||
// Start custom file search
|
||||
new Thread(() -> {
|
||||
scanFileSystem();
|
||||
scanFileSystem(defaultPath);
|
||||
fileSystemScanCompleted = true;
|
||||
checkCompleted();
|
||||
}).start();
|
||||
@ -99,16 +99,16 @@ public class FileSearch {
|
||||
}
|
||||
|
||||
// Scan through the file system and find all the files with .zim and .zimaa extensions
|
||||
public void scanFileSystem() {
|
||||
public void scanFileSystem(String defaultPath) {
|
||||
FilenameFilter[] filter = new FilenameFilter[zimFiles.length];
|
||||
|
||||
// Search all external directories that we can find.
|
||||
String[] tempRoots = new String[StorageDeviceUtils.getStorageDevices((Activity) context, false).size() + 1];
|
||||
String[] tempRoots = new String[StorageDeviceUtils.getStorageDevices(context, false).size() + 2];
|
||||
int j = 0;
|
||||
tempRoots[j] = "/mnt";
|
||||
for (StorageDevice storageDevice : StorageDeviceUtils.getStorageDevices((Activity) context, false)) {
|
||||
j++;
|
||||
tempRoots[j] = storageDevice.getName();
|
||||
tempRoots[j++] = "/mnt";
|
||||
tempRoots[j++] = defaultPath;
|
||||
for (StorageDevice storageDevice : StorageDeviceUtils.getStorageDevices(context, false)) {
|
||||
tempRoots[j++] = storageDevice.getName();
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
@ -20,12 +20,15 @@
|
||||
package org.kiwix.kiwixmobile.zim_manager.fileselect_view;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
@ -123,10 +126,10 @@ public class ZimFileSelectFragment extends Fragment
|
||||
File file = new File(path);
|
||||
Uri uri = Uri.fromFile(file);
|
||||
Log.i(TAG_KIWIX, "Opening " + uri);
|
||||
zimManageActivity.setResult(zimManageActivity.RESULT_OK, new Intent().setData(uri));
|
||||
zimManageActivity.setResult(Activity.RESULT_OK, new Intent().setData(uri));
|
||||
zimManageActivity.finish();
|
||||
} else {
|
||||
zimManageActivity.setResult(zimManageActivity.RESULT_CANCELED);
|
||||
zimManageActivity.setResult(Activity.RESULT_CANCELED);
|
||||
zimManageActivity.finish();
|
||||
}
|
||||
}
|
||||
@ -245,7 +248,8 @@ public class ZimFileSelectFragment extends Fragment
|
||||
TestingUtils.unbindResource(ZimFileSelectFragment.class);
|
||||
});
|
||||
}
|
||||
}).scan();
|
||||
}).scan(PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getString(KiwixMobileActivity.PREF_STORAGE, Environment.getExternalStorageDirectory().getPath()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user