From 07e7167356e1a966be2e7d2892ef583c8c3be997 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 12 Sep 2015 22:07:02 +0200 Subject: [PATCH] added preference for default resolution --- .../java/org/schabi/newpipe/ActionBarHandler.java | 15 ++++++++++++--- app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values/settings_keys.xml | 8 ++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/settings_screen.xml | 7 +++++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java b/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java index b3b3eec2e..856e853b1 100644 --- a/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java +++ b/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java @@ -70,19 +70,28 @@ public class ActionBarHandler { } public void setStreams(VideoInfo.Stream[] streams) { - // // TODO: 11.09.15 add auto stream option this.streams = streams; selectedStream = 0; String[] itemArray = new String[streams.length]; + String defaultResolution = PreferenceManager.getDefaultSharedPreferences(context) + .getString(context.getString(R.string.defaultResolutionPreference), + context.getString(R.string.defaultResolutionListItem)); + int defaultResolutionPos = 0; + for(int i = 0; i < streams.length; i++) { itemArray[i] = streams[i].format + " " + streams[i].resolution; + if(defaultResolution.equals(streams[i].resolution)) { + defaultResolutionPos = i; + } } ArrayAdapter itemAdapter = new ArrayAdapter(activity.getBaseContext(), android.R.layout.simple_spinner_dropdown_item, itemArray); if(activity != null) { - activity.getSupportActionBar().setListNavigationCallbacks(itemAdapter + ActionBar ab = activity.getSupportActionBar(); + ab.setListNavigationCallbacks(itemAdapter ,new ForamatItemSelectListener()); + ab.setSelectedNavigationItem(defaultResolutionPos); } } @@ -149,7 +158,7 @@ public class ActionBarHandler { // ----------- THE MAGIC MOMENT --------------- if(!videoTitle.isEmpty()) { if (PreferenceManager.getDefaultSharedPreferences(context) - .getBoolean("use_external_player", false)) { + .getBoolean(context.getString(R.string.useExternalPlayer), false)) { Intent intent = new Intent(); try { intent.setAction(Intent.ACTION_VIEW); diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 7f020928f..4e24b42c1 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -27,4 +27,5 @@ Download Verzeichnis eingeben Automatisch abspielen durch Intent. Startet ein Video automatisch wenn es von einer anderen App aufgerufen wurde. + Standard Auflösung diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 262becd75..464207fb6 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -3,4 +3,12 @@ download_path_preference use_external_player autoplay_through_intent + default_resulution_preference + + 720p + 360p + 240p + 144p + + 360p \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8679ee1d0..9eb05d869 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -27,4 +27,5 @@ Enter download path Autoplay through Intent Automatically starts a video when it was called from another app. + Default Resolution diff --git a/app/src/main/res/xml/settings_screen.xml b/app/src/main/res/xml/settings_screen.xml index d99af4850..e453128bc 100644 --- a/app/src/main/res/xml/settings_screen.xml +++ b/app/src/main/res/xml/settings_screen.xml @@ -21,4 +21,11 @@ android:summary="@string/autoPlayThroughIntentSummary" android:defaultValue="false" /> + + \ No newline at end of file