mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-25 01:20:34 +00:00
Starting to add a filepicker to the directory preferences
This commit is contained in:
parent
54c32b9fe2
commit
181c83090d
@ -137,5 +137,12 @@
|
|||||||
<service
|
<service
|
||||||
android:name="us.shandian.giga.service.DownloadManagerService"/>
|
android:name="us.shandian.giga.service.DownloadManagerService"/>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="com.nononsenseapps.filepicker.FilePickerActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/FilePickerTheme"
|
||||||
|
android:launchMode="singleTask">
|
||||||
|
</activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
package org.schabi.newpipe;
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.ClipData;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
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;
|
||||||
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
@ -23,7 +27,13 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.nononsenseapps.filepicker.AbstractFilePickerFragment;
|
||||||
|
import com.nononsenseapps.filepicker.FilePickerActivity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
||||||
|
import us.shandian.giga.util.Utility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Christian Schabesberger on 31.08.15.
|
* Created by Christian Schabesberger on 31.08.15.
|
||||||
@ -81,7 +91,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
private ListPreference defaultResolutionPreference;
|
private ListPreference defaultResolutionPreference;
|
||||||
private ListPreference defaultAudioFormatPreference;
|
private ListPreference defaultAudioFormatPreference;
|
||||||
private ListPreference searchLanguagePreference;
|
private ListPreference searchLanguagePreference;
|
||||||
private EditTextPreference downloadPathPreference;
|
private Preference downloadPathPreference;
|
||||||
private EditTextPreference downloadPathAudioPreference;
|
private EditTextPreference downloadPathAudioPreference;
|
||||||
private CheckBoxPreference useTorCheckBox;
|
private CheckBoxPreference useTorCheckBox;
|
||||||
private SharedPreferences defaultPreferences;
|
private SharedPreferences defaultPreferences;
|
||||||
@ -111,8 +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 =
|
downloadPathPreference = (Preference) findPreference(DOWNLOAD_PATH_PREFERENCE);
|
||||||
(EditTextPreference) 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);
|
||||||
@ -141,6 +150,20 @@ public class SettingsActivity extends PreferenceActivity {
|
|||||||
};
|
};
|
||||||
defaultPreferences.registerOnSharedPreferenceChangeListener(prefListener);
|
defaultPreferences.registerOnSharedPreferenceChangeListener(prefListener);
|
||||||
|
|
||||||
|
downloadPathPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener(){
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
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_CREATE_DIR, true);
|
||||||
|
i.putExtra(FilePickerActivity.EXTRA_MODE, AbstractFilePickerFragment.MODE_DIR);
|
||||||
|
startActivityForResult(i, 233);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
updateSummary();
|
updateSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,4 +49,24 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- You can also inherit from NNF_BaseTheme.Light -->
|
||||||
|
<style name="FilePickerTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
|
<!-- Set these to match your theme -->
|
||||||
|
<item name="colorPrimary">@color/light_youtube_primary_color</item>
|
||||||
|
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
|
||||||
|
<item name="colorAccent">@color/light_youtube_accent_color</item>
|
||||||
|
|
||||||
|
<!-- Need to set this also to style create folder dialog -->
|
||||||
|
<item name="alertDialogTheme">@style/FilePickerAlertDialogTheme</item>
|
||||||
|
|
||||||
|
<!-- If you want to set a specific toolbar theme, do it here -->
|
||||||
|
<!-- <item name="nnf_toolbarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item> -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="FilePickerAlertDialogTheme" parent="Theme.AppCompat.Dialog.Alert">
|
||||||
|
<item name="colorPrimary">@color/light_youtube_primary_color</item>
|
||||||
|
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
|
||||||
|
<item name="colorAccent">@color/light_youtube_accent_color</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user