added preference for default resolution

This commit is contained in:
Christian Schabesberger 2015-09-12 22:07:02 +02:00
parent 56e43f411e
commit 07e7167356
5 changed files with 29 additions and 3 deletions

View File

@ -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<String> itemAdapter = new ArrayAdapter<String>(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);

View File

@ -27,4 +27,5 @@
<string name="downloadLocationDialogTitle">Download Verzeichnis eingeben</string>
<string name="autoPlayThroughIntentTitle">Automatisch abspielen durch Intent.</string>
<string name="autoPlayThroughIntentSummary">Startet ein Video automatisch wenn es von einer anderen App aufgerufen wurde.</string>
<string name="defaultResolutionPreferenceTitle">Standard Auflösung</string>
</resources>

View File

@ -3,4 +3,12 @@
<string name="downloadPathPreference">download_path_preference</string>
<string name="useExternalPlayer">use_external_player</string>
<string name="autoPlayThroughIntent">autoplay_through_intent</string>
<string name="defaultResolutionPreference">default_resulution_preference</string>
<string-array name="resolutionList">
<item>720p</item>
<item>360p</item>
<item>240p</item>
<item>144p</item>
</string-array>
<string name="defaultResolutionListItem">360p</string>
</resources>

View File

@ -27,4 +27,5 @@
<string name="downloadLocationDialogTitle">Enter download path</string>
<string name="autoPlayThroughIntentTitle">Autoplay through Intent</string>
<string name="autoPlayThroughIntentSummary">Automatically starts a video when it was called from another app.</string>
<string name="defaultResolutionPreferenceTitle">Default Resolution</string>
</resources>

View File

@ -21,4 +21,11 @@
android:summary="@string/autoPlayThroughIntentSummary"
android:defaultValue="false" />
<ListPreference
android:key="@string/defaultResolutionPreference"
android:title="@string/defaultResolutionPreferenceTitle"
android:entries="@array/resolutionList"
android:entryValues="@array/resolutionList"
android:defaultValue="@string/defaultResolutionListItem"/>
</PreferenceScreen>