1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-05 01:26:23 +00:00

Starting to add a filepicker to the directory preferences

This commit is contained in:
David 2016-05-26 11:59:12 -03:00
parent 54c32b9fe2
commit 181c83090d
3 changed files with 53 additions and 3 deletions

View File

@ -137,5 +137,12 @@
<service
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>
</manifest>

View File

@ -1,16 +1,20 @@
package org.schabi.newpipe;
import android.app.Activity;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
@ -23,7 +27,13 @@ import android.view.MenuItem;
import android.view.View;
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 us.shandian.giga.util.Utility;
/**
* Created by Christian Schabesberger on 31.08.15.
@ -81,7 +91,7 @@ public class SettingsActivity extends PreferenceActivity {
private ListPreference defaultResolutionPreference;
private ListPreference defaultAudioFormatPreference;
private ListPreference searchLanguagePreference;
private EditTextPreference downloadPathPreference;
private Preference downloadPathPreference;
private EditTextPreference downloadPathAudioPreference;
private CheckBoxPreference useTorCheckBox;
private SharedPreferences defaultPreferences;
@ -111,8 +121,7 @@ public class SettingsActivity extends PreferenceActivity {
(ListPreference) findPreference(DEFAULT_AUDIO_FORMAT_PREFERENCE);
searchLanguagePreference =
(ListPreference) findPreference(SEARCH_LANGUAGE_PREFERENCE);
downloadPathPreference =
(EditTextPreference) findPreference(DOWNLOAD_PATH_PREFERENCE);
downloadPathPreference = (Preference) findPreference(DOWNLOAD_PATH_PREFERENCE);
downloadPathAudioPreference =
(EditTextPreference) findPreference(DOWNLOAD_PATH_AUDIO_PREFERENCE);
useTorCheckBox = (CheckBoxPreference) findPreference(USE_TOR_KEY);
@ -141,6 +150,20 @@ public class SettingsActivity extends PreferenceActivity {
};
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();
}

View File

@ -49,4 +49,24 @@
</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>