Skip to content

Commit 3c748e8

Browse files
committed
Restore Localization.java to match upstream
1 parent 25e96d5 commit 3c748e8

1 file changed

Lines changed: 0 additions & 41 deletions

File tree

app/src/main/java/org/schabi/newpipe/util/Localization.java

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import androidx.annotation.PluralsRes;
1919
import androidx.annotation.StringRes;
2020
import androidx.appcompat.app.AppCompatDelegate;
21-
import androidx.core.content.ContextCompat;
2221
import androidx.core.math.MathUtils;
2322
import androidx.core.os.LocaleListCompat;
2423
import androidx.preference.PreferenceManager;
@@ -72,46 +71,6 @@ public final class Localization {
7271

7372
private Localization() { }
7473

75-
/**
76-
* Gets a string like you would normally do with {@link Context#getString}, except that when
77-
* Context is not an AppCompatActivity the correct locale is still used. The latter step uses
78-
* {@link ContextCompat#getString}, which might fail if the Locale system service is not
79-
* available (e.g. inside of Compose previews). In that case this method falls back to plain old
80-
* {@link Context#getString}.
81-
* <p>This method also supports format args (see {@link #compatGetString(Context, int,
82-
* Object...)}, unlike {@link ContextCompat#getString}.</p>
83-
*
84-
* @param context any Android context, even the App context
85-
* @param resId the string resource to resolve
86-
* @return the resolved string
87-
*/
88-
public static String compatGetString(final Context context, @StringRes final int resId) {
89-
try {
90-
return ContextCompat.getString(context, resId);
91-
} catch (final Throwable e) {
92-
return context.getString(resId);
93-
}
94-
}
95-
96-
/**
97-
* @see #compatGetString(Context, int)
98-
* @param context any Android context, even the App context
99-
* @param resId the string resource to resolve
100-
* @param formatArgs the formatting arguments
101-
* @return the resolved string
102-
*/
103-
public static String compatGetString(final Context context,
104-
@StringRes final int resId,
105-
final Object... formatArgs) {
106-
try {
107-
// ContextCompat.getString() with formatArgs does not exist, so we just
108-
// replicate its source code but with formatArgs
109-
return ContextCompat.getContextForLanguage(context).getString(resId, formatArgs);
110-
} catch (final Throwable e) {
111-
return context.getString(resId, formatArgs);
112-
}
113-
}
114-
11574
@NonNull
11675
public static String concatenateStrings(final String... strings) {
11776
return concatenateStrings(DOT_SEPARATOR, Arrays.asList(strings));

0 commit comments

Comments
 (0)