Skip to content

Commit 07e7167

Browse files
author
Christian Schabesberger
committed
added preference for default resolution
1 parent 56e43f4 commit 07e7167

5 files changed

Lines changed: 29 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/ActionBarHandler.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,28 @@ public void setupNavMenu(AppCompatActivity activity) {
7070
}
7171

7272
public void setStreams(VideoInfo.Stream[] streams) {
73-
// // TODO: 11.09.15 add auto stream option
7473
this.streams = streams;
7574
selectedStream = 0;
7675
String[] itemArray = new String[streams.length];
76+
String defaultResolution = PreferenceManager.getDefaultSharedPreferences(context)
77+
.getString(context.getString(R.string.defaultResolutionPreference),
78+
context.getString(R.string.defaultResolutionListItem));
79+
int defaultResolutionPos = 0;
80+
7781
for(int i = 0; i < streams.length; i++) {
7882
itemArray[i] = streams[i].format + " " + streams[i].resolution;
83+
if(defaultResolution.equals(streams[i].resolution)) {
84+
defaultResolutionPos = i;
85+
}
7986
}
8087

8188
ArrayAdapter<String> itemAdapter = new ArrayAdapter<String>(activity.getBaseContext(),
8289
android.R.layout.simple_spinner_dropdown_item, itemArray);
8390
if(activity != null) {
84-
activity.getSupportActionBar().setListNavigationCallbacks(itemAdapter
91+
ActionBar ab = activity.getSupportActionBar();
92+
ab.setListNavigationCallbacks(itemAdapter
8593
,new ForamatItemSelectListener());
94+
ab.setSelectedNavigationItem(defaultResolutionPos);
8695
}
8796
}
8897

@@ -149,7 +158,7 @@ public void playVideo() {
149158
// ----------- THE MAGIC MOMENT ---------------
150159
if(!videoTitle.isEmpty()) {
151160
if (PreferenceManager.getDefaultSharedPreferences(context)
152-
.getBoolean("use_external_player", false)) {
161+
.getBoolean(context.getString(R.string.useExternalPlayer), false)) {
153162
Intent intent = new Intent();
154163
try {
155164
intent.setAction(Intent.ACTION_VIEW);

app/src/main/res/values-de/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
<string name="downloadLocationDialogTitle">Download Verzeichnis eingeben</string>
2828
<string name="autoPlayThroughIntentTitle">Automatisch abspielen durch Intent.</string>
2929
<string name="autoPlayThroughIntentSummary">Startet ein Video automatisch wenn es von einer anderen App aufgerufen wurde.</string>
30+
<string name="defaultResolutionPreferenceTitle">Standard Auflösung</string>
3031
</resources>

app/src/main/res/values/settings_keys.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@
33
<string name="downloadPathPreference">download_path_preference</string>
44
<string name="useExternalPlayer">use_external_player</string>
55
<string name="autoPlayThroughIntent">autoplay_through_intent</string>
6+
<string name="defaultResolutionPreference">default_resulution_preference</string>
7+
<string-array name="resolutionList">
8+
<item>720p</item>
9+
<item>360p</item>
10+
<item>240p</item>
11+
<item>144p</item>
12+
</string-array>
13+
<string name="defaultResolutionListItem">360p</string>
614
</resources>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
<string name="downloadLocationDialogTitle">Enter download path</string>
2828
<string name="autoPlayThroughIntentTitle">Autoplay through Intent</string>
2929
<string name="autoPlayThroughIntentSummary">Automatically starts a video when it was called from another app.</string>
30+
<string name="defaultResolutionPreferenceTitle">Default Resolution</string>
3031
</resources>

app/src/main/res/xml/settings_screen.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,11 @@
2121
android:summary="@string/autoPlayThroughIntentSummary"
2222
android:defaultValue="false" />
2323

24+
<ListPreference
25+
android:key="@string/defaultResolutionPreference"
26+
android:title="@string/defaultResolutionPreferenceTitle"
27+
android:entries="@array/resolutionList"
28+
android:entryValues="@array/resolutionList"
29+
android:defaultValue="@string/defaultResolutionListItem"/>
30+
2431
</PreferenceScreen>

0 commit comments

Comments
 (0)