Search in sources :

Example 31 with Locale

use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.

the class Configuration method updateFrom.

/**
     * Copy the fields from delta into this Configuration object, keeping
     * track of which ones have changed.  Any undefined fields in
     * <var>delta</var> are ignored and not copied in to the current
     * Configuration.
     * @return Returns a bit mask of the changed fields, as per
     * {@link #diff}.
     */
public int updateFrom(Configuration delta) {
    int changed = 0;
    if (delta.fontScale > 0 && fontScale != delta.fontScale) {
        changed |= ActivityInfo.CONFIG_FONT_SCALE;
        fontScale = delta.fontScale;
    }
    if (delta.mcc != 0 && mcc != delta.mcc) {
        changed |= ActivityInfo.CONFIG_MCC;
        mcc = delta.mcc;
    }
    if (delta.mnc != 0 && mnc != delta.mnc) {
        changed |= ActivityInfo.CONFIG_MNC;
        mnc = delta.mnc;
    }
    if (delta.locale != null && (locale == null || !locale.equals(delta.locale))) {
        changed |= ActivityInfo.CONFIG_LOCALE;
        locale = delta.locale != null ? (Locale) delta.locale.clone() : null;
        // If locale has changed, then layout direction is also changed ...
        changed |= ActivityInfo.CONFIG_LAYOUT_DIRECTION;
        // ... and we need to update the layout direction (represented by the first
        // 2 most significant bits in screenLayout).
        setLayoutDirection(locale);
    }
    if (delta.userSetLocale && (!userSetLocale || ((changed & ActivityInfo.CONFIG_LOCALE) != 0))) {
        userSetLocale = true;
        changed |= ActivityInfo.CONFIG_LOCALE;
    }
    if (delta.touchscreen != TOUCHSCREEN_UNDEFINED && touchscreen != delta.touchscreen) {
        changed |= ActivityInfo.CONFIG_TOUCHSCREEN;
        touchscreen = delta.touchscreen;
    }
    if (delta.keyboard != KEYBOARD_UNDEFINED && keyboard != delta.keyboard) {
        changed |= ActivityInfo.CONFIG_KEYBOARD;
        keyboard = delta.keyboard;
    }
    if (delta.keyboardHidden != KEYBOARDHIDDEN_UNDEFINED && keyboardHidden != delta.keyboardHidden) {
        changed |= ActivityInfo.CONFIG_KEYBOARD_HIDDEN;
        keyboardHidden = delta.keyboardHidden;
    }
    if (delta.hardKeyboardHidden != HARDKEYBOARDHIDDEN_UNDEFINED && hardKeyboardHidden != delta.hardKeyboardHidden) {
        changed |= ActivityInfo.CONFIG_KEYBOARD_HIDDEN;
        hardKeyboardHidden = delta.hardKeyboardHidden;
    }
    if (delta.navigation != NAVIGATION_UNDEFINED && navigation != delta.navigation) {
        changed |= ActivityInfo.CONFIG_NAVIGATION;
        navigation = delta.navigation;
    }
    if (delta.navigationHidden != NAVIGATIONHIDDEN_UNDEFINED && navigationHidden != delta.navigationHidden) {
        changed |= ActivityInfo.CONFIG_KEYBOARD_HIDDEN;
        navigationHidden = delta.navigationHidden;
    }
    if (delta.orientation != ORIENTATION_UNDEFINED && orientation != delta.orientation) {
        changed |= ActivityInfo.CONFIG_ORIENTATION;
        orientation = delta.orientation;
    }
    if (getScreenLayoutNoDirection(delta.screenLayout) != (SCREENLAYOUT_SIZE_UNDEFINED | SCREENLAYOUT_LONG_UNDEFINED) && (getScreenLayoutNoDirection(screenLayout) != getScreenLayoutNoDirection(delta.screenLayout))) {
        changed |= ActivityInfo.CONFIG_SCREEN_LAYOUT;
        // We need to preserve the previous layout dir bits if they were defined
        if ((delta.screenLayout & SCREENLAYOUT_LAYOUTDIR_MASK) == 0) {
            screenLayout = (screenLayout & SCREENLAYOUT_LAYOUTDIR_MASK) | delta.screenLayout;
        } else {
            screenLayout = delta.screenLayout;
        }
    }
    if (delta.uiMode != (UI_MODE_TYPE_UNDEFINED | UI_MODE_NIGHT_UNDEFINED) && uiMode != delta.uiMode) {
        changed |= ActivityInfo.CONFIG_UI_MODE;
        if ((delta.uiMode & UI_MODE_TYPE_MASK) != UI_MODE_TYPE_UNDEFINED) {
            uiMode = (uiMode & ~UI_MODE_TYPE_MASK) | (delta.uiMode & UI_MODE_TYPE_MASK);
        }
        if ((delta.uiMode & UI_MODE_NIGHT_MASK) != UI_MODE_NIGHT_UNDEFINED) {
            uiMode = (uiMode & ~UI_MODE_NIGHT_MASK) | (delta.uiMode & UI_MODE_NIGHT_MASK);
        }
    }
    if (delta.screenWidthDp != SCREEN_WIDTH_DP_UNDEFINED && screenWidthDp != delta.screenWidthDp) {
        changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
        screenWidthDp = delta.screenWidthDp;
    }
    if (delta.screenHeightDp != SCREEN_HEIGHT_DP_UNDEFINED && screenHeightDp != delta.screenHeightDp) {
        changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
        screenHeightDp = delta.screenHeightDp;
    }
    if (delta.smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED && smallestScreenWidthDp != delta.smallestScreenWidthDp) {
        changed |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
        smallestScreenWidthDp = delta.smallestScreenWidthDp;
    }
    if (delta.densityDpi != DENSITY_DPI_UNDEFINED && densityDpi != delta.densityDpi) {
        changed |= ActivityInfo.CONFIG_DENSITY;
        densityDpi = delta.densityDpi;
    }
    if (delta.compatScreenWidthDp != SCREEN_WIDTH_DP_UNDEFINED) {
        compatScreenWidthDp = delta.compatScreenWidthDp;
    }
    if (delta.compatScreenHeightDp != SCREEN_HEIGHT_DP_UNDEFINED) {
        compatScreenHeightDp = delta.compatScreenHeightDp;
    }
    if (delta.compatSmallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
        compatSmallestScreenWidthDp = delta.compatSmallestScreenWidthDp;
    }
    if (delta.seq != 0) {
        seq = delta.seq;
    }
    if (delta.customTheme != null && (customTheme == null || !customTheme.equals(delta.customTheme))) {
        changed |= ActivityInfo.CONFIG_THEME_RESOURCE;
        customTheme = (CustomTheme) delta.customTheme.clone();
    }
    return changed;
}
Also used : Locale(java.util.Locale) Point(android.graphics.Point)

Example 32 with Locale

use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.

the class TtsEngines method getDefaultLocale.

private String getDefaultLocale() {
    final Locale locale = Locale.getDefault();
    // Note that the default locale might have an empty variant
    // or language, and we take care that the construction is
    // the same as {@link #getV1Locale} i.e no trailing delimiters
    // or spaces.
    String defaultLocale = locale.getISO3Language();
    if (TextUtils.isEmpty(defaultLocale)) {
        Log.w(TAG, "Default locale is empty.");
        return "";
    }
    if (!TextUtils.isEmpty(locale.getISO3Country())) {
        defaultLocale += LOCALE_DELIMITER + locale.getISO3Country();
    } else {
        // an empty country.
        return defaultLocale;
    }
    if (!TextUtils.isEmpty(locale.getVariant())) {
        defaultLocale += LOCALE_DELIMITER + locale.getVariant();
    }
    return defaultLocale;
}
Also used : Locale(java.util.Locale) Secure.getString(android.provider.Settings.Secure.getString)

Example 33 with Locale

use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.

the class SpellCheckerSubtype method getDisplayName.

/**
     * @param context Context will be used for getting Locale and PackageManager.
     * @param packageName The package name of the spell checker
     * @param appInfo The application info of the spell checker
     * @return a display name for this subtype. The string resource of the label (mSubtypeNameResId)
     * can have only one %s in it. If there is, the %s part will be replaced with the locale's
     * display name by the formatter. If there is not, this method simply returns the string
     * specified by mSubtypeNameResId. If mSubtypeNameResId is not specified (== 0), it's up to the
     * framework to generate an appropriate display name.
     */
public CharSequence getDisplayName(Context context, String packageName, ApplicationInfo appInfo) {
    final Locale locale = constructLocaleFromString(mSubtypeLocale);
    final String localeStr = locale != null ? locale.getDisplayName() : mSubtypeLocale;
    if (mSubtypeNameResId == 0) {
        return localeStr;
    }
    final CharSequence subtypeName = context.getPackageManager().getText(packageName, mSubtypeNameResId, appInfo);
    if (!TextUtils.isEmpty(subtypeName)) {
        return String.format(subtypeName.toString(), localeStr);
    } else {
        return localeStr;
    }
}
Also used : Locale(java.util.Locale)

Example 34 with Locale

use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.

the class LocalePicker method onListItemClick.

/**
     * Each listener needs to call {@link #updateLocale(Locale)} to actually change the locale.
     *
     * We don't call {@link #updateLocale(Locale)} automatically, as it halt the system for
     * a moment and some callers won't want it.
     */
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    if (mListener != null) {
        final Locale locale = ((LocaleInfo) getListAdapter().getItem(position)).locale;
        mListener.onLocaleSelected(locale);
    }
}
Also used : Locale(java.util.Locale)

Example 35 with Locale

use of java.util.Locale in project android_frameworks_base by ParanoidAndroid.

the class WebSettingsClassic method getUserAgentString.

/**
     * @see android.webkit.WebSettings#getUserAgentString()
     */
@Override
public synchronized String getUserAgentString() {
    if (DESKTOP_USERAGENT.equals(mUserAgent) || IPHONE_USERAGENT.equals(mUserAgent) || !mUseDefaultUserAgent) {
        return mUserAgent;
    }
    boolean doPostSync = false;
    synchronized (sLockForLocaleSettings) {
        Locale currentLocale = Locale.getDefault();
        if (!sLocale.equals(currentLocale)) {
            sLocale = currentLocale;
            mUserAgent = getCurrentUserAgent();
            mAcceptLanguage = getCurrentAcceptLanguage();
            doPostSync = true;
        }
    }
    if (doPostSync) {
        postSync();
    }
    return mUserAgent;
}
Also used : Locale(java.util.Locale)

Aggregations

Locale (java.util.Locale)2214 Test (org.junit.Test)262 ArrayList (java.util.ArrayList)179 HashMap (java.util.HashMap)108 ResourceBundle (java.util.ResourceBundle)83 SimpleDateFormat (java.text.SimpleDateFormat)78 Date (java.util.Date)77 MissingResourceException (java.util.MissingResourceException)68 IOException (java.io.IOException)67 TimeZone (java.util.TimeZone)63 File (java.io.File)50 Map (java.util.Map)49 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)49 Calendar (java.util.Calendar)46 Configuration (android.content.res.Configuration)41 LocaleList (android.os.LocaleList)39 HashSet (java.util.HashSet)39 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)39 HttpSession (javax.servlet.http.HttpSession)38 Resources (android.content.res.Resources)37