mirror of
https://github.com/androidx/media.git
synced 2025-05-05 22:50:57 +08:00
Localize IMA based on device locale by default
PiperOrigin-RevId: 343871061
This commit is contained in:
parent
a04400cfb9
commit
10bc77c15d
@ -42,6 +42,7 @@
|
|||||||
* Fix a bug that caused multiple ads in an ad pod to be skipped when one
|
* Fix a bug that caused multiple ads in an ad pod to be skipped when one
|
||||||
ad in the ad pod was skipped.
|
ad in the ad pod was skipped.
|
||||||
* Fix passing an ads response to the `ImaAdsLoader` builder.
|
* Fix passing an ads response to the `ImaAdsLoader` builder.
|
||||||
|
* Set the overlay language based on the device locale by default.
|
||||||
* Cronet extension:
|
* Cronet extension:
|
||||||
* Fix handling of HTTP status code 200 when making unbounded length range
|
* Fix handling of HTTP status code 200 when making unbounded length range
|
||||||
requests ([#8090](https://github.com/google/ExoPlayer/issues/8090)).
|
requests ([#8090](https://github.com/google/ExoPlayer/issues/8090)).
|
||||||
|
@ -82,6 +82,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
@ -1912,7 +1913,9 @@ public final class ImaAdsLoader
|
|||||||
private static final class DefaultImaFactory implements ImaUtil.ImaFactory {
|
private static final class DefaultImaFactory implements ImaUtil.ImaFactory {
|
||||||
@Override
|
@Override
|
||||||
public ImaSdkSettings createImaSdkSettings() {
|
public ImaSdkSettings createImaSdkSettings() {
|
||||||
return ImaSdkFactory.getInstance().createImaSdkSettings();
|
ImaSdkSettings settings = ImaSdkFactory.getInstance().createImaSdkSettings();
|
||||||
|
settings.setLanguage(getImaLanguageCodeForDefaultLocale());
|
||||||
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1953,5 +1956,16 @@ public final class ImaAdsLoader
|
|||||||
return ImaSdkFactory.getInstance()
|
return ImaSdkFactory.getInstance()
|
||||||
.createAdsLoader(context, imaSdkSettings, adDisplayContainer);
|
.createAdsLoader(context, imaSdkSettings, adDisplayContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a language code that's suitable for passing to {@link ImaSdkSettings#setLanguage} and
|
||||||
|
* corresponds to the device's {@link Locale#getDefault() default Locale}.
|
||||||
|
*/
|
||||||
|
// TODO: It may be possible to define a better mapping onto IMA's supported language codes. See:
|
||||||
|
// https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/localization.
|
||||||
|
// IMA will fall back to its default language code ("en") if the value returned is unsupported.
|
||||||
|
private static String getImaLanguageCodeForDefaultLocale() {
|
||||||
|
return Util.splitAtFirst(Util.getSystemLanguageCodes()[0], "-")[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user