Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-04-08 21:47:50 +02:00
commit 83f4db59e2
6 changed files with 46 additions and 4 deletions

View File

@ -8,8 +8,8 @@ android {
applicationId "org.schabi.newpipe"
minSdkVersion 15
targetSdkVersion 25
versionCode 27
versionName "0.9.0"
versionCode 28
versionName "0.9.1"
}
buildTypes {
release {

View File

@ -119,15 +119,32 @@ class ActionBarHandler {
.getString(activity.getString(R.string.default_resolution_key),
activity.getString(R.string.default_resolution_value));
String preferedFormat = defaultPreferences
.getString(activity.getString(R.string.preferred_video_format_key),
activity.getString(R.string.preferred_video_format_default));
// first try to find the one with the right resolution
int selectedFormat = 0;
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (defaultResolution.equals(item.resolution)) {
return i;
selectedFormat = i;
}
}
// than try to find the one with the right resolution and format
for (int i = 0; i < videoStreams.size(); i++) {
VideoStream item = videoStreams.get(i);
if (defaultResolution.equals(item.resolution)
&& preferedFormat.equals(MediaFormat.getNameById(item.format))) {
selectedFormat = i;
}
}
// this is actually an error,
// but maybe there is really no stream fitting to the default value.
return 0;
return selectedFormat;
}
public void setupMenu(Menu menu, MenuInflater inflater) {

View File

@ -22,6 +22,7 @@ import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
import java.util.ArrayList;
import java.util.List;
import info.guardianproject.netcipher.proxy.OrbotHelper;
@ -52,6 +53,7 @@ public class SettingsFragment extends PreferenceFragment
SharedPreferences.OnSharedPreferenceChangeListener prefListener;
// get keys
String DEFAULT_RESOLUTION_PREFERENCE;
String PREFERRED_VIDEO_FORMAT_PREFERENCE;
String DEFAULT_AUDIO_FORMAT_PREFERENCE;
String SEARCH_LANGUAGE_PREFERENCE;
String DOWNLOAD_PATH_PREFERENCE;
@ -59,6 +61,7 @@ public class SettingsFragment extends PreferenceFragment
String USE_TOR_KEY;
String THEME;
private ListPreference defaultResolutionPreference;
private ListPreference preferredVideoFormatPreference;
private ListPreference defaultAudioFormatPreference;
private ListPreference searchLanguagePreference;
private Preference downloadPathPreference;
@ -77,6 +80,7 @@ public class SettingsFragment extends PreferenceFragment
// get keys
DEFAULT_RESOLUTION_PREFERENCE = getString(R.string.default_resolution_key);
PREFERRED_VIDEO_FORMAT_PREFERENCE = getString(R.string.preferred_video_format_key);
DEFAULT_AUDIO_FORMAT_PREFERENCE = getString(R.string.default_audio_format_key);
SEARCH_LANGUAGE_PREFERENCE = getString(R.string.search_language_key);
DOWNLOAD_PATH_PREFERENCE = getString(R.string.download_path_key);
@ -87,6 +91,8 @@ public class SettingsFragment extends PreferenceFragment
// get pref objects
defaultResolutionPreference =
(ListPreference) findPreference(DEFAULT_RESOLUTION_PREFERENCE);
preferredVideoFormatPreference =
(ListPreference) findPreference(PREFERRED_VIDEO_FORMAT_PREFERENCE);
defaultAudioFormatPreference =
(ListPreference) findPreference(DEFAULT_AUDIO_FORMAT_PREFERENCE);
searchLanguagePreference =
@ -254,6 +260,9 @@ public class SettingsFragment extends PreferenceFragment
defaultResolutionPreference.setSummary(
defaultPreferences.getString(DEFAULT_RESOLUTION_PREFERENCE,
getString(R.string.default_resolution_value)));
preferredVideoFormatPreference.setSummary(
defaultPreferences.getString(PREFERRED_VIDEO_FORMAT_PREFERENCE,
getString(R.string.preferred_video_format_default)));
defaultAudioFormatPreference.setSummary(
defaultPreferences.getString(DEFAULT_AUDIO_FORMAT_PREFERENCE,
getString(R.string.default_audio_format_value)));

View File

@ -22,6 +22,14 @@
<item>144p</item>
</string-array>
<string name="preferred_video_format_key" translatable="false">preferrfed_video_format</string>
<string name="preferred_video_format_default" translatable="false">WebM</string>
<string-array name="video_format_list">
<item>WebM</item>
<item>MPEG-4</item>
<item>3GPP</item>
</string-array>
<string name="show_play_with_kodi_key" translatable="false">show_play_with_kodi</string>
<string name="theme_key" translatable="false">theme</string>

View File

@ -45,6 +45,7 @@
<string name="show_play_with_kodi_summary">Display an option to play a video via Kodi media center.</string>
<string name="play_audio">Audio</string>
<string name="default_audio_format_title">Default audio format</string>
<string name="preferred_video_format_title">Preferred video format</string>
<string name="webm_description">WebM — free format</string>
<string name="m4a_description">m4a — better quality</string>
<string name="theme_title">Theme</string>

View File

@ -25,6 +25,13 @@
android:entryValues="@array/resolution_list"
android:defaultValue="@string/default_resolution_value"/>
<ListPreference
android:key="@string/preferred_video_format_key"
android:title="@string/preferred_video_format_title"
android:entries="@array/video_format_list"
android:entryValues="@array/video_format_list"
android:defaultValue="@string/preferred_video_format_default"/>
<ListPreference
android:key="@string/default_audio_format_key"
android:title="@string/default_audio_format_title"