1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-04 17:16:24 +00:00

Trying to make last filepicker version work, maybe I'm having some memory problems

This commit is contained in:
David 2016-06-14 06:13:06 -03:00
parent 45be3fb0e8
commit 36babcaf36
2 changed files with 42 additions and 5 deletions

View File

@ -121,7 +121,7 @@ public class SettingsActivity extends PreferenceActivity {
(ListPreference) findPreference(DEFAULT_AUDIO_FORMAT_PREFERENCE); (ListPreference) findPreference(DEFAULT_AUDIO_FORMAT_PREFERENCE);
searchLanguagePreference = searchLanguagePreference =
(ListPreference) findPreference(SEARCH_LANGUAGE_PREFERENCE); (ListPreference) findPreference(SEARCH_LANGUAGE_PREFERENCE);
downloadPathPreference = (Preference) findPreference(DOWNLOAD_PATH_PREFERENCE); downloadPathPreference = findPreference(DOWNLOAD_PATH_PREFERENCE);
downloadPathAudioPreference = downloadPathAudioPreference =
(EditTextPreference) findPreference(DOWNLOAD_PATH_AUDIO_PREFERENCE); (EditTextPreference) findPreference(DOWNLOAD_PATH_AUDIO_PREFERENCE);
useTorCheckBox = (CheckBoxPreference) findPreference(USE_TOR_KEY); useTorCheckBox = (CheckBoxPreference) findPreference(USE_TOR_KEY);
@ -154,16 +154,17 @@ public class SettingsActivity extends PreferenceActivity {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
Intent i = new Intent(getActivity(), FilePickerActivity.class); Intent i = new Intent(getActivity(), FilePickerActivity.class);
i.setAction(Intent.ACTION_GET_CONTENT);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false); i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true); i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true);
i.putExtra(FilePickerActivity.EXTRA_MODE, AbstractFilePickerFragment.MODE_DIR); i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_DIR);
startActivityForResult(i, 233); startActivityForResult(i, 233);
return true; return true;
} }
}); });
updateSummary(); updateSummary();
} }
@ -189,11 +190,47 @@ public class SettingsActivity extends PreferenceActivity {
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 233 && resultCode == Activity.RESULT_OK) {
if (data.getBooleanExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false)) {
// For JellyBean and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ClipData clip = data.getClipData();
if (clip != null) {
for (int i = 0; i < clip.getItemCount(); i++) {
Uri uri = clip.getItemAt(i).getUri();
// Do something with the URI
}
}
// For Ice Cream Sandwich
} else {
ArrayList<String> paths = data.getStringArrayListExtra
(FilePickerActivity.EXTRA_PATHS);
if (paths != null) {
for (String path: paths) {
Uri uri = Uri.parse(path);
// Do something with the URI
}
}
}
} else {
Uri uri = data.getData();
// Do something with the URI
}
}
// try to start tor regardless of resultCode since clicking back after // try to start tor regardless of resultCode since clicking back after
// installing the app does not necessarily return RESULT_OK // installing the app does not necessarily return RESULT_OK
App.configureTor(requestCode == REQUEST_INSTALL_ORBOT App.configureTor(requestCode == REQUEST_INSTALL_ORBOT
&& OrbotHelper.requestStartTor(this)); && OrbotHelper.requestStartTor(this));
super.onActivityResult(requestCode, resultCode, data);
} }
@Override @Override

View File

@ -92,7 +92,7 @@
android:title="@string/settings_category_other_title" android:title="@string/settings_category_other_title"
android:textAllCaps="true"> android:textAllCaps="true">
<EditTextPreference <Preference
android:key="@string/download_path_key" android:key="@string/download_path_key"
android:title="@string/download_path_title" android:title="@string/download_path_title"
android:summary="@string/download_path_summary" android:summary="@string/download_path_summary"