mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Added fallback and toast if android app can't write to desired directory
This commit is contained in:
parent
91823e2a7f
commit
70cd3a7960
@ -141,4 +141,5 @@
|
||||
<string name="help_21">We are glad to have you on board and would appreciate any feedback or suggestions.</string>
|
||||
<string name="pref_storage">Storage</string>
|
||||
<string name="pref_current_folder">Current Folder</string>
|
||||
<string name="path_not_writable">Can't access desired directory, using default. To fix this reselect the desired directory in app settings.</string>
|
||||
</resources>
|
||||
|
@ -20,6 +20,7 @@ import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -90,6 +91,7 @@ public class DownloadService extends Service {
|
||||
.getString(KiwixMobileActivity.PREF_STORAGE,Environment.getExternalStorageDirectory().getPath());
|
||||
KIWIX_ROOT = SD_CARD + "/Kiwix/";
|
||||
|
||||
KIWIX_ROOT = checkWritable(KIWIX_ROOT);
|
||||
|
||||
notificationTitle = intent.getExtras().getString(DownloadIntent.DOWNLOAD_ZIM_TITLE);
|
||||
LibraryNetworkEntity.Book book = (LibraryNetworkEntity.Book) intent.getSerializableExtra("Book");
|
||||
@ -129,6 +131,12 @@ public class DownloadService extends Service {
|
||||
notificationManager.cancel(notificationID);
|
||||
}
|
||||
|
||||
public String checkWritable(String path){
|
||||
if (new File(path).canWrite())
|
||||
return path;
|
||||
Toast.makeText(this, getResources().getString(R.string.path_not_writable), Toast.LENGTH_LONG).show();
|
||||
return Environment.getExternalStorageDirectory().getPath();
|
||||
}
|
||||
|
||||
public void pauseDownload(int notificationID) {
|
||||
downloadStatus.put(notificationID, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user