use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.
the class WebSettingsClassic method getCurrentAcceptLanguage.
/**
* Looks at sLocale and returns current AcceptLanguage String.
* @return Current AcceptLanguage String.
*/
private String getCurrentAcceptLanguage() {
Locale locale;
synchronized (sLockForLocaleSettings) {
locale = sLocale;
}
StringBuilder buffer = new StringBuilder();
addLocaleToHttpAcceptLanguage(buffer, locale);
if (!Locale.US.equals(locale)) {
if (buffer.length() > 0) {
buffer.append(", ");
}
buffer.append(ACCEPT_LANG_FOR_US_LOCALE);
}
return buffer.toString();
}
use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.
the class Chronometer method updateText.
private synchronized void updateText(long now) {
long seconds = now - mBase;
seconds /= 1000;
String text = DateUtils.formatElapsedTime(mRecycle, seconds);
if (mFormat != null) {
Locale loc = Locale.getDefault();
if (mFormatter == null || !loc.equals(mFormatterLocale)) {
mFormatterLocale = loc;
mFormatter = new Formatter(mFormatBuilder, loc);
}
mFormatBuilder.setLength(0);
mFormatterArgs[0] = text;
try {
mFormatter.format(mFormat, mFormatterArgs);
text = mFormatBuilder.toString();
} catch (IllegalFormatException ex) {
if (!mLogged) {
Log.w(TAG, "Illegal format string: " + mFormat);
mLogged = true;
}
}
}
setText(text);
}
use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.
the class OverlayBaseTest method setLocale.
private void setLocale(String code) {
Locale locale = new Locale(code);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
mResources.updateConfiguration(config, mResources.getDisplayMetrics());
}
use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.
the class DateView method updateClock.
protected void updateClock() {
final String weekdayFormat = getContext().getString(R.string.system_ui_weekday_pattern);
final String dateFormat = getContext().getString(R.string.system_ui_date_pattern);
final Locale l = Locale.getDefault();
final Date now = new Date();
String weekdayFmt = ICU.getBestDateTimePattern(weekdayFormat, l.toString());
String dateFmt = ICU.getBestDateTimePattern(dateFormat, l.toString());
StringBuilder builder = new StringBuilder();
builder.append(new SimpleDateFormat(weekdayFmt, l).format(now));
builder.append("\n");
builder.append(new SimpleDateFormat(dateFmt, l).format(now));
setText(builder.toString());
}
use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.
the class AppWidgetServiceImpl method onConfigurationChanged.
void onConfigurationChanged() {
if (DBG)
log("Got onConfigurationChanged()");
Locale revised = Locale.getDefault();
if (revised == null || mLocale == null || !(revised.equals(mLocale))) {
mLocale = revised;
synchronized (mAppWidgetIds) {
ensureStateLoadedLocked();
// Note: updateProvidersForPackageLocked() may remove providers, so we must copy the
// list of installed providers and skip providers that we don't need to update.
// Also note that remove the provider does not clear the Provider component data.
ArrayList<Provider> installedProviders = new ArrayList<Provider>(mInstalledProviders);
HashSet<ComponentName> removedProviders = new HashSet<ComponentName>();
int N = installedProviders.size();
for (int i = N - 1; i >= 0; i--) {
Provider p = installedProviders.get(i);
ComponentName cn = p.info.provider;
if (!removedProviders.contains(cn)) {
updateProvidersForPackageLocked(cn.getPackageName(), removedProviders);
}
}
saveStateAsync();
}
}
}
Aggregations