Add service setting

This commit is contained in:
wb9688 2017-09-11 15:37:41 +02:00
parent 4b0a071a35
commit b500c3f526
4 changed files with 22 additions and 1 deletions

View file

@ -1,6 +1,7 @@
package org.schabi.newpipe.fragments; package org.schabi.newpipe.fragments;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -75,7 +76,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_search: case R.id.action_search:
NavigationHelper.openSearchFragment(getFragmentManager(), 0, ""); NavigationHelper.openSearchFragment(getFragmentManager(), Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("service", "0")), "");
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View file

@ -43,6 +43,17 @@
<item>144p</item> <item>144p</item>
</string-array> </string-array>
<string-array name="service_list_description" translatable="false">
<item>YouTube</item>
<item>SoundCloud</item>
</string-array>
<string-array name="service_list_values" translatable="false">
<item>0</item>
<item>1</item>
</string-array>
<string name="service_key" translatable="false">service</string>
<string name="default_service_value" translatable="false">0</string>
<string name="video_mp4_key" translatable="false">video_mp4</string> <string name="video_mp4_key" translatable="false">video_mp4</string>
<string name="video_webm_key" translatable="false">video_webm</string> <string name="video_webm_key" translatable="false">video_webm</string>
<string name="video_3gp_key" translatable="false">video_3gp</string> <string name="video_3gp_key" translatable="false">video_3gp</string>

View file

@ -81,6 +81,7 @@
<string name="next_video_title">Next video</string> <string name="next_video_title">Next video</string>
<string name="show_next_and_similar_title">Show next and similar videos</string> <string name="show_next_and_similar_title">Show next and similar videos</string>
<string name="url_not_supported_toast">URL not supported</string> <string name="url_not_supported_toast">URL not supported</string>
<string name="service_title">Service</string>
<string name="search_language_title">Default content language</string> <string name="search_language_title">Default content language</string>
<string name="settings_category_player_title">Player</string> <string name="settings_category_player_title">Player</string>
<string name="settings_category_player_behavior_title">Behavior</string> <string name="settings_category_player_behavior_title">Behavior</string>

View file

@ -3,6 +3,14 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/content"> android:title="@string/content">
<ListPreference
android:defaultValue="@string/default_service_value"
android:entries="@array/service_list_description"
android:entryValues="@array/service_list_values"
android:key="@string/service_key"
android:summary="%s"
android:title="@string/service_title"/>
<ListPreference <ListPreference
android:defaultValue="@string/default_language_value" android:defaultValue="@string/default_language_value"
android:entries="@array/language_names" android:entries="@array/language_names"