Bug 1890689 remove DynamicResampler::mSetBufferDuration r=pehrsons
[gecko.git] / intl / locale / android / OSPreferences_android.cpp
blob8ef27c526b7da78019a7d382a8c75b9e104d0159
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "OSPreferences.h"
8 #include "mozilla/Preferences.h"
10 #include "mozilla/java/GeckoAppShellWrappers.h"
12 using namespace mozilla::intl;
14 OSPreferences::OSPreferences() {}
16 bool OSPreferences::ReadSystemLocales(nsTArray<nsCString>& aLocaleList) {
17 if (!mozilla::jni::IsAvailable()) {
18 return false;
21 // XXX: Notice, this value may be empty on an early read. In that case
22 // we won't add anything to the return list so that it doesn't get
23 // cached in mSystemLocales.
24 auto locales = java::GeckoAppShell::GetDefaultLocales();
25 if (locales) {
26 for (size_t i = 0; i < locales->Length(); i++) {
27 jni::String::LocalRef locale = locales->GetElement(i);
28 aLocaleList.AppendElement(locale->ToCString());
30 return true;
32 return false;
35 bool OSPreferences::ReadRegionalPrefsLocales(nsTArray<nsCString>& aLocaleList) {
36 // For now we're just taking System Locales since we don't know of any better
37 // API for regional prefs.
38 return ReadSystemLocales(aLocaleList);
42 * Similar to Gtk, Android does not provide a way to customize or format
43 * date/time patterns, so we're reusing ICU data here, but we do modify it
44 * according to the Android DateFormat is24HourFormat setting.
46 bool OSPreferences::ReadDateTimePattern(DateTimeFormatStyle aDateStyle,
47 DateTimeFormatStyle aTimeStyle,
48 const nsACString& aLocale,
49 nsACString& aRetVal) {
50 if (!mozilla::jni::IsAvailable()) {
51 return false;
54 nsAutoCString skeleton;
55 if (!GetDateTimeSkeletonForStyle(aDateStyle, aTimeStyle, aLocale, skeleton)) {
56 return false;
59 // Customize the skeleton if necessary to reflect user's 12/24hr pref
60 OverrideSkeletonHourCycle(java::GeckoAppShell::GetIs24HourFormat(), skeleton);
62 if (!GetPatternForSkeleton(skeleton, aLocale, aRetVal)) {
63 return false;
66 return true;
69 void OSPreferences::RemoveObservers() {}