1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-25 01:20:34 +00:00

Update to mobile data limiting

- Moved non-key strings from string_keys.xml to strings.xml
- Code style changes
- Replaced a hard coded key string with resource constant
This commit is contained in:
James Straub 2018-04-22 10:20:19 -04:00
parent d1b0cd74be
commit 646fa877ba
3 changed files with 34 additions and 34 deletions

View File

@ -71,15 +71,11 @@ public final class ListHelper {
// If the user has chosen to limit resolution to conserve mobile data // If the user has chosen to limit resolution to conserve mobile data
// usage then we should also limit our audio usage. // usage then we should also limit our audio usage.
int result;
if (isLimitingDataUsage(context)) { if (isLimitingDataUsage(context)) {
result = getMostCompactAudioIndex(defaultFormat, audioStreams); return getMostCompactAudioIndex(defaultFormat, audioStreams);
} else {
return getHighestQualityAudioIndex(defaultFormat, audioStreams);
} }
else {
result = getHighestQualityAudioIndex(defaultFormat, audioStreams);
}
return result;
} }
/** /**
@ -109,8 +105,9 @@ public final class ListHelper {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
// Load the prefered resolution otherwise the best available // Load the prefered resolution otherwise the best available
String resolution = preferences != null ? preferences.getString(context.getString(key), String resolution = preferences != null
context.getString(value)) : context.getString(R.string.best_resolution_key); ? preferences.getString(context.getString(key), context.getString(value))
: context.getString(R.string.best_resolution_key);
String maxResolution = getResolutionLimit(context); String maxResolution = getResolutionLimit(context);
if (maxResolution != null && compareVideoStreamResolution(maxResolution, resolution) < 1){ if (maxResolution != null && compareVideoStreamResolution(maxResolution, resolution) < 1){

View File

@ -854,29 +854,6 @@
<!-- Limit mobile data usage --> <!-- Limit mobile data usage -->
<string name="limit_mobile_data_usage_key" translatable="false">limit_mobile_data_usage</string> <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> <string name="limit_data_usage_none_key" translatable="false">limit_data_usage_none</string>
</resources> </resources>

View File

@ -66,8 +66,6 @@
<string name="default_video_format_title">Default video format</string> <string name="default_video_format_title">Default video format</string>
<string name="webm_description">WebM — free format</string> <string name="webm_description">WebM — free format</string>
<string name="m4a_description">M4A — better quality</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="theme_title">Theme</string>
<string name="light_theme_title">Light</string> <string name="light_theme_title">Light</string>
<string name="dark_theme_title">Dark</string> <string name="dark_theme_title">Dark</string>
@ -468,4 +466,32 @@
<string name="unhook_checkbox">Unhook (may cause distortion)</string> <string name="unhook_checkbox">Unhook (may cause distortion)</string>
<string name="playback_nightcore">Nightcore</string> <string name="playback_nightcore">Nightcore</string>
<string name="playback_default">Default</string> <string name="playback_default">Default</string>
<!-- Limit mobile data usage -->
<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="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>
</resources> </resources>