Merge branch 'master' of github.com:theScrabi/NewPipe

This commit is contained in:
chschtsch 2016-01-05 23:12:22 +03:00
commit fd4459e570
3 changed files with 21 additions and 1 deletions

View File

@ -23,6 +23,10 @@ public class App extends Application {
} else {
configureTor(false);
}
// DO NOT REMOVE THIS FUNCTION!!!
// Otherwise downloadPathPreference has invalid value.
SettingsActivity.initSettings(this);
}
/**

View File

@ -81,12 +81,14 @@ public class DownloadDialog extends DialogFragment {
Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + downloadFolder);
final File dir = new File(downloadPath);
if(!dir.exists()) {
boolean mkdir = dir.mkdir(); //attempt to create directory
//attempt to create directory
boolean mkdir = dir.mkdir();
if(!mkdir && !dir.isDirectory()) {
Log.e(TAG, "Cant' create directory named " + dir.toString());
//TODO notify user "download directory should be changed" ?
}
}
String saveFilePath = dir + "/" + title + suffix;
if (App.isUsingTor()) {
// if using Tor, do not use DownloadManager because the proxy cannot be set

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Environment;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
@ -242,4 +243,17 @@ public class SettingsActivity extends PreferenceActivity {
}
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();
}
}
}