mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-25 12:32:31 +01:00
set download path on startup
This commit is contained in:
parent
0aade598ff
commit
eb0df2b101
@ -23,6 +23,10 @@ public class App extends Application {
|
|||||||
} else {
|
} else {
|
||||||
configureTor(false);
|
configureTor(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DO NOT REMOVE THIS FUNCTION!!!
|
||||||
|
// Otherwise downloadPathPreference has invalid value.
|
||||||
|
SettingsActivity.initSettings(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,12 +81,14 @@ public class DownloadDialog extends DialogFragment {
|
|||||||
Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + downloadFolder);
|
Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + downloadFolder);
|
||||||
final File dir = new File(downloadPath);
|
final File dir = new File(downloadPath);
|
||||||
if(!dir.exists()) {
|
if(!dir.exists()) {
|
||||||
boolean mkdir = dir.mkdir(); //attempt to create directory
|
//attempt to create directory
|
||||||
|
boolean mkdir = dir.mkdir();
|
||||||
if(!mkdir && !dir.isDirectory()) {
|
if(!mkdir && !dir.isDirectory()) {
|
||||||
Log.e(TAG, "Cant' create directory named " + dir.toString());
|
Log.e(TAG, "Cant' create directory named " + dir.toString());
|
||||||
//TODO notify user "download directory should be changed" ?
|
//TODO notify user "download directory should be changed" ?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String saveFilePath = dir + "/" + title + suffix;
|
String saveFilePath = dir + "/" + title + suffix;
|
||||||
if (App.isUsingTor()) {
|
if (App.isUsingTor()) {
|
||||||
// if using Tor, do not use DownloadManager because the proxy cannot be set
|
// if using Tor, do not use DownloadManager because the proxy cannot be set
|
||||||
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
@ -245,4 +246,17 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void initSettings(Context context) {
|
||||||
|
PreferenceManager.setDefaultValues(context, R.xml.settings_screen, false);
|
||||||
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
if(sp.getString(context.getString(R.string.downloadPathPreference), "").isEmpty()){
|
||||||
|
SharedPreferences.Editor spEditor = sp.edit();
|
||||||
|
String newPipeDownloadStorage =
|
||||||
|
Environment.getExternalStorageDirectory().getAbsolutePath() + "/NewPipe";
|
||||||
|
spEditor.putString(context.getString(R.string.downloadPathPreference)
|
||||||
|
, newPipeDownloadStorage);
|
||||||
|
spEditor.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user