зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset dc9229077eaa (bug 1420335) for security/manager* and toolkit/mozapps/* xpc failures CLOSED TREE
This commit is contained in:
Родитель
04f94d6d52
Коммит
60482b14fc
|
@ -541,51 +541,3 @@ OSPreferences::GetDateTimePattern(int32_t aDateFormatStyle,
|
|||
aRetVal = pattern;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void OSPreferences::OverrideSkeletonHourCycle(bool aIs24Hour,
|
||||
nsAutoCString& aSkeleton) {
|
||||
if (aIs24Hour) {
|
||||
// If aSkeleton contains 'h' or 'K', replace with 'H' or 'k' respectively,
|
||||
// and delete 'a' if present.
|
||||
if (aSkeleton.FindChar('h') == -1 && aSkeleton.FindChar('K') == -1) {
|
||||
return;
|
||||
}
|
||||
for (int32_t i = 0; i < int32_t(aSkeleton.Length()); ++i) {
|
||||
switch (aSkeleton[i]) {
|
||||
case 'a':
|
||||
aSkeleton.Cut(i, 1);
|
||||
--i;
|
||||
break;
|
||||
case 'h':
|
||||
aSkeleton.SetCharAt('H', i);
|
||||
break;
|
||||
case 'K':
|
||||
aSkeleton.SetCharAt('k', i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If skeleton contains 'H' or 'k', replace with 'h' or 'K' respectively,
|
||||
// and add 'a' unless already present.
|
||||
if (aSkeleton.FindChar('H') == -1 && aSkeleton.FindChar('k') == -1) {
|
||||
return;
|
||||
}
|
||||
bool foundA = false;
|
||||
for (size_t i = 0; i < aSkeleton.Length(); ++i) {
|
||||
switch (aSkeleton[i]) {
|
||||
case 'a':
|
||||
foundA = true;
|
||||
break;
|
||||
case 'H':
|
||||
aSkeleton.SetCharAt('h', i);
|
||||
break;
|
||||
case 'k':
|
||||
aSkeleton.SetCharAt('K', i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundA) {
|
||||
aSkeleton.Append(char16_t('a'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,12 +160,6 @@ class OSPreferences : public mozIOSPreferences {
|
|||
DateTimeFormatStyle aTimeFormatStyle,
|
||||
const nsACString& aLocale, nsACString& aRetVal);
|
||||
|
||||
/**
|
||||
* This is called to override the hour cycle in the skeleton based upon
|
||||
* the OS preference for AM/PM or 24 hour display.
|
||||
*/
|
||||
void OverrideSkeletonHourCycle(bool aIs24Hour, nsAutoCString& aSkeleton);
|
||||
|
||||
/**
|
||||
* This is called by the destructor to clean up any OS specific observers
|
||||
* that are registered.
|
||||
|
|
|
@ -38,28 +38,11 @@ bool OSPreferences::ReadRegionalPrefsLocales(nsTArray<nsCString>& aLocaleList) {
|
|||
return ReadSystemLocales(aLocaleList);
|
||||
}
|
||||
|
||||
/*
|
||||
* Similar to Gtk, Android does not provide a way to customize or format
|
||||
* date/time patterns, so we're reusing ICU data here, but we do modify it
|
||||
* according to the Android DateFormat is24HourFormat setting.
|
||||
*/
|
||||
bool OSPreferences::ReadDateTimePattern(DateTimeFormatStyle aDateStyle,
|
||||
DateTimeFormatStyle aTimeStyle,
|
||||
const nsACString& aLocale,
|
||||
nsACString& aRetVal) {
|
||||
nsAutoCString skeleton;
|
||||
if (!GetDateTimeSkeletonForStyle(aDateStyle, aTimeStyle, aLocale, skeleton)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Customize the skeleton if necessary to reflect user's 12/24hr pref
|
||||
OverrideSkeletonHourCycle(java::GeckoAppShell::GetIs24HourFormat(), skeleton);
|
||||
|
||||
if (!GetPatternForSkeleton(skeleton, aLocale, aRetVal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void OSPreferences::RemoveObservers() {}
|
||||
|
|
|
@ -117,9 +117,53 @@ bool OSPreferences::ReadDateTimePattern(DateTimeFormatStyle aDateStyle,
|
|||
}
|
||||
|
||||
// Customize the skeleton if necessary to reflect user's 12/24hr pref
|
||||
int hourCycle = HourCycle();
|
||||
if (hourCycle == 12 || hourCycle == 24) {
|
||||
OverrideSkeletonHourCycle(hourCycle == 24, skeleton);
|
||||
switch (HourCycle()) {
|
||||
case 12: {
|
||||
// If skeleton contains 'H' or 'k', replace with 'h' or 'K' respectively,
|
||||
// and add 'a' unless already present.
|
||||
if (skeleton.FindChar('H') == -1 && skeleton.FindChar('k') == -1) {
|
||||
break; // nothing to do
|
||||
}
|
||||
bool foundA = false;
|
||||
for (size_t i = 0; i < skeleton.Length(); ++i) {
|
||||
switch (skeleton[i]) {
|
||||
case 'a':
|
||||
foundA = true;
|
||||
break;
|
||||
case 'H':
|
||||
skeleton.SetCharAt('h', i);
|
||||
break;
|
||||
case 'k':
|
||||
skeleton.SetCharAt('K', i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundA) {
|
||||
skeleton.Append(char16_t('a'));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 24:
|
||||
// If skeleton contains 'h' or 'K', replace with 'H' or 'k' respectively,
|
||||
// and delete 'a' if present.
|
||||
if (skeleton.FindChar('h') == -1 && skeleton.FindChar('K') == -1) {
|
||||
break; // nothing to do
|
||||
}
|
||||
for (int32_t i = 0; i < int32_t(skeleton.Length()); ++i) {
|
||||
switch (skeleton[i]) {
|
||||
case 'a':
|
||||
skeleton.Cut(i, 1);
|
||||
--i;
|
||||
break;
|
||||
case 'h':
|
||||
skeleton.SetCharAt('H', i);
|
||||
break;
|
||||
case 'K':
|
||||
skeleton.SetCharAt('k', i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!GetPatternForSkeleton(skeleton, aLocale, aRetVal)) {
|
||||
|
|
|
@ -134,8 +134,7 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
ASSERT_TRUE(formattedTime.Find("1.") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("Januar") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("1970") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("12:00:00 AM") != kNotFound ||
|
||||
formattedTime.Find("00:00:00") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("00:00:00") != kNotFound);
|
||||
|
||||
prExplodedTime = {0, 0, 19, 0, 1, 0, 1970, 4, 0, {(19 * 60), 0}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
|
@ -144,8 +143,7 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
ASSERT_TRUE(formattedTime.Find("1.") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("Januar") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("1970") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("12:19:00 AM") != kNotFound ||
|
||||
formattedTime.Find("00:19:00") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("00:19:00") != kNotFound);
|
||||
|
||||
prExplodedTime = {0, 0, 0, 7, 1,
|
||||
0, 1970, 4, 0, {(6 * 60 * 60), (1 * 60 * 60)}};
|
||||
|
@ -155,8 +153,7 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
ASSERT_TRUE(formattedTime.Find("1.") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("Januar") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("1970") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("7:00:00 AM") != kNotFound ||
|
||||
formattedTime.Find("07:00:00") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("07:00:00") != kNotFound);
|
||||
|
||||
prExplodedTime = {
|
||||
0, 0, 29, 11, 1,
|
||||
|
@ -167,8 +164,7 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
ASSERT_TRUE(formattedTime.Find("1.") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("Januar") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("1970") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("11:29:00 AM") != kNotFound ||
|
||||
formattedTime.Find("11:29:00") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("11:29:00") != kNotFound);
|
||||
|
||||
prExplodedTime = {0, 0, 37, 23, 31, 11, 1969, 3, 364, {-(23 * 60), 0}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
|
@ -177,8 +173,7 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
ASSERT_TRUE(formattedTime.Find("31.") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("Dezember") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("1969") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("11:37:00 PM") != kNotFound ||
|
||||
formattedTime.Find("23:37:00") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("23:37:00") != kNotFound);
|
||||
|
||||
prExplodedTime = {0, 0, 0, 17, 31, 11, 1969, 3, 364, {-(7 * 60 * 60), 0}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
|
@ -187,8 +182,7 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
ASSERT_TRUE(formattedTime.Find("31.") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("Dezember") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("1969") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("5:00:00 PM") != kNotFound ||
|
||||
formattedTime.Find("17:00:00") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("17:00:00") != kNotFound);
|
||||
|
||||
prExplodedTime = {
|
||||
0, 0, 47, 14, 31,
|
||||
|
@ -199,8 +193,7 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
ASSERT_TRUE(formattedTime.Find("31.") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("Dezember") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("1969") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("2:47:00 PM") != kNotFound ||
|
||||
formattedTime.Find("14:47:00") != kNotFound);
|
||||
ASSERT_TRUE(formattedTime.Find("14:47:00") != kNotFound);
|
||||
}
|
||||
|
||||
TEST(DateTimeFormat, DateFormatSelectorsForeign)
|
||||
|
|
|
@ -79,7 +79,6 @@ import androidx.annotation.Nullable;
|
|||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.collection.SimpleArrayMap;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.format.DateFormat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
@ -2019,12 +2018,6 @@ public class GeckoAppShell {
|
|||
return locales;
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
public static boolean getIs24HourFormat() {
|
||||
final Context context = getApplicationContext();
|
||||
return DateFormat.is24HourFormat(context);
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
public static String getAppName() {
|
||||
final Context context = getApplicationContext();
|
||||
|
|
Загрузка…
Ссылка в новой задаче