Merge remote-tracking branch 'newpipe/dev' into rebase
This commit is contained in:
commit
56544802e8
69 changed files with 1189 additions and 1339 deletions
|
|
@ -11,7 +11,5 @@ public class Constants {
|
|||
public static final String KEY_THEME_CHANGE = "key_theme_change";
|
||||
public static final String KEY_MAIN_PAGE_CHANGE = "key_main_page_change";
|
||||
|
||||
public static final String KEY_ENABLE_WATCH_HISTORY = "enable_watch_history";
|
||||
|
||||
public static final int NO_SERVICE_ID = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ import java.util.Locale;
|
|||
|
||||
public class Localization {
|
||||
|
||||
private static PrettyTime prettyTime;
|
||||
private static final String DOT_SEPARATOR = " • ";
|
||||
private static PrettyTime prettyTime;
|
||||
|
||||
private Localization() {
|
||||
}
|
||||
|
|
@ -83,14 +83,20 @@ public class Localization {
|
|||
public static org.schabi.newpipe.extractor.localization.Localization getPreferredLocalization(final Context context) {
|
||||
final String contentLanguage = PreferenceManager
|
||||
.getDefaultSharedPreferences(context)
|
||||
.getString(context.getString(R.string.content_language_key), context.getString(R.string.default_language_value));
|
||||
.getString(context.getString(R.string.content_language_key), context.getString(R.string.default_localization_key));
|
||||
if (contentLanguage.equals(context.getString(R.string.default_localization_key))) {
|
||||
return org.schabi.newpipe.extractor.localization.Localization.fromLocale(Locale.getDefault());
|
||||
}
|
||||
return org.schabi.newpipe.extractor.localization.Localization.fromLocalizationCode(contentLanguage);
|
||||
}
|
||||
|
||||
public static ContentCountry getPreferredContentCountry(final Context context) {
|
||||
final String contentCountry = PreferenceManager
|
||||
.getDefaultSharedPreferences(context)
|
||||
.getString(context.getString(R.string.content_country_key), context.getString(R.string.default_country_value));
|
||||
.getString(context.getString(R.string.content_country_key), context.getString(R.string.default_localization_key));
|
||||
if (contentCountry.equals(context.getString(R.string.default_localization_key))) {
|
||||
return new ContentCountry(Locale.getDefault().getCountry());
|
||||
}
|
||||
return new ContentCountry(contentCountry);
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +104,7 @@ public class Localization {
|
|||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
String languageCode = sp.getString(context.getString(R.string.content_language_key),
|
||||
context.getString(R.string.default_language_value));
|
||||
context.getString(R.string.default_localization_key));
|
||||
|
||||
try {
|
||||
if (languageCode.length() == 2) {
|
||||
|
|
@ -114,8 +120,7 @@ public class Localization {
|
|||
}
|
||||
|
||||
public static String localizeNumber(Context context, long number) {
|
||||
Locale locale = getPreferredLocale(context);
|
||||
NumberFormat nf = NumberFormat.getInstance(locale);
|
||||
NumberFormat nf = NumberFormat.getInstance(getAppLocale(context));
|
||||
return nf.format(number);
|
||||
}
|
||||
|
||||
|
|
@ -132,14 +137,14 @@ public class Localization {
|
|||
return getQuantity(context, R.plurals.views, R.string.no_views, viewCount, localizeNumber(context, viewCount));
|
||||
}
|
||||
|
||||
public static String localizeSubscribersCount(Context context, long subscriberCount) {
|
||||
return getQuantity(context, R.plurals.subscribers, R.string.no_subscribers, subscriberCount, localizeNumber(context, subscriberCount));
|
||||
}
|
||||
|
||||
public static String localizeStreamCount(Context context, long streamCount) {
|
||||
return getQuantity(context, R.plurals.videos, R.string.no_videos, streamCount, localizeNumber(context, streamCount));
|
||||
}
|
||||
|
||||
public static String localizeWatchingCount(Context context, long watchingCount) {
|
||||
return getQuantity(context, R.plurals.watching, R.string.no_one_watching, watchingCount, localizeNumber(context, watchingCount));
|
||||
}
|
||||
|
||||
public static String shortCount(Context context, long count) {
|
||||
if (count >= 1000000000) {
|
||||
return Long.toString(count / 1000000000) + context.getString(R.string.short_billion);
|
||||
|
|
@ -156,7 +161,7 @@ public class Localization {
|
|||
return getQuantity(context, R.plurals.listening, R.string.no_one_listening, listeningCount, shortCount(context, listeningCount));
|
||||
}
|
||||
|
||||
public static String watchingCount(Context context, long watchingCount) {
|
||||
public static String shortWatchingCount(Context context, long watchingCount) {
|
||||
return getQuantity(context, R.plurals.watching, R.string.no_one_watching, watchingCount, shortCount(context, watchingCount));
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +220,9 @@ public class Localization {
|
|||
}
|
||||
|
||||
public static String relativeTime(Calendar calendarTime) {
|
||||
return getPrettyTime().formatUnrounded(calendarTime);
|
||||
String time = getPrettyTime().formatUnrounded(calendarTime);
|
||||
return time.startsWith("-") ? time.substring(1) : time;
|
||||
//workaround fix for russian showing -1 day ago, -19hrs ago…
|
||||
}
|
||||
|
||||
private static void changeAppLanguage(Locale loc, Resources res) {
|
||||
|
|
@ -226,10 +233,10 @@ public class Localization {
|
|||
}
|
||||
|
||||
public static Locale getAppLocale(Context context) {
|
||||
SharedPreferences prefs = androidx.preference.PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String lang = prefs.getString("app_language_key", "en");
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String lang = prefs.getString(context.getString(R.string.app_language_key), "en");
|
||||
Locale loc;
|
||||
if (lang.equals("system")) {
|
||||
if (lang.equals(context.getString(R.string.default_localization_key))) {
|
||||
loc = Locale.getDefault();
|
||||
} else if (lang.matches(".*-.*")) {
|
||||
//to differentiate different versions of the language
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class ServiceHelper {
|
|||
public static String getTranslatedFilterString(String filter, Context c) {
|
||||
switch (filter) {
|
||||
case "all": return c.getString(R.string.all);
|
||||
case "videos": return c.getString(R.string.videos);
|
||||
case "videos": return c.getString(R.string.videos_string);
|
||||
case "channels": return c.getString(R.string.channels);
|
||||
case "playlists": return c.getString(R.string.playlists);
|
||||
case "tracks": return c.getString(R.string.tracks);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue