Added the ability to limit video quality if using mobile data.

* Added a dropdown to video & audio settings
* Changes to ListHelper:
** Limits resolution when code requests the default video resolution
** Limits audio bitrate when code requests the default audio bitrate
** Removed some dead code and did some cleanup
** Make methods private/protected to help understand what was in use
** The code now chooses one format over an other using a simple raking system defined in array constants. I realized I needed to do this in order to choose the most efficient video stream. I did my best to evaluate the video and audio formats based on quality and efficiency. It's not an exact science.
** Made changes to the tests to support my changes
This commit is contained in:
James Straub 2018-04-21 12:35:04 -04:00
parent 7d427b4cc4
commit d1b0cd74be
7 changed files with 432 additions and 119 deletions

View file

@ -851,4 +851,32 @@
<item>ZM</item>
<item>ZW</item>
</string-array>
<!-- Limit mobile data usage -->
<string name="limit_mobile_data_usage_key" translatable="false">limit_mobile_data_usage</string>
<string name="limit_mobile_data_usage_value" translatable="false">@string/limit_data_usage_none_key</string>
<string-array name="limit_data_usage_description_list">
<item>@string/limit_data_usage_none_description</item>
<item>1080p60</item>
<item>1080p</item>
<item>720p60</item>
<item>720p</item>
<item>480p</item>
<item>360p</item>
<item>240p</item>
<item>144p</item>
</string-array>
<string-array name="limit_data_usage_values_list">
<item>@string/limit_data_usage_none_key</item>
<item>1080p60</item>
<item>1080p</item>
<item>720p60</item>
<item>720p</item>
<item>480p</item>
<item>360p</item>
<item>240p</item>
<item>144p</item>
</string-array>
<string name="limit_data_usage_none_key" translatable="false">limit_data_usage_none</string>
</resources>

View file

@ -66,6 +66,8 @@
<string name="default_video_format_title">Default video format</string>
<string name="webm_description">WebM — free format</string>
<string name="m4a_description">M4A — better quality</string>
<string name="limit_data_usage_none_description">No limit</string>
<string name="limit_mobile_data_usage_title">Limit resolution when using mobile data</string>
<string name="theme_title">Theme</string>
<string name="light_theme_title">Light</string>
<string name="dark_theme_title">Dark</string>

View file

@ -19,6 +19,14 @@
android:summary="%s"
android:title="@string/default_popup_resolution_title"/>
<ListPreference
android:defaultValue="@string/limit_mobile_data_usage_value"
android:entries="@array/limit_data_usage_description_list"
android:entryValues="@array/limit_data_usage_values_list"
android:key="@string/limit_mobile_data_usage_key"
android:summary="%s"
android:title="@string/limit_mobile_data_usage_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/show_higher_resolutions_key"
@ -39,7 +47,7 @@
android:entryValues="@array/audio_format_values_list"
android:key="@string/default_audio_format_key"
android:summary="%s"
android:title="@string/default_audio_format_title"/>
android:title="@string/default_audio_format_title" />
<PreferenceCategory
android:layout="@layout/settings_category_header_layout"