List of usage examples for java.util Locale getAvailableLocales
public static Locale[] getAvailableLocales()
From source file:org.tightblog.ui.restapi.WeblogController.java
@GetMapping(value = "/tb-ui/authoring/rest/weblogconfig/metadata") public WeblogConfigMetadata getWeblogConfigMetadata(Locale locale, Principal p) { User user = userRepository.findEnabledByUserName(p.getName()); WeblogConfigMetadata metadata = new WeblogConfigMetadata(); metadata.absoluteSiteURL = dp.getAbsoluteUrl(); metadata.usersOverrideAnalyticsCode = webloggerPropertiesRepository.findOrNull() .isUsersOverrideAnalyticsCode(); metadata.usersCommentNotifications = webloggerPropertiesRepository.findOrNull() .isUsersCommentNotifications(); metadata.sharedThemeMap = themeManager.getEnabledSharedThemesList().stream() // Remove sitewide theme options for non-admins, if desired admin can create a sitewide blog // and assign a non-admin user ownership of it on the members page. .filter(theme -> !theme.isSiteWide() || user.hasEffectiveGlobalRole(GlobalRole.ADMIN)) .collect(Utilities.toLinkedHashMap(SharedTheme::getId, st -> st)); metadata.editFormats = Arrays.stream(Weblog.EditFormat.values()).collect(Utilities.toLinkedHashMap( Weblog.EditFormat::name, eF -> messages.getMessage(eF.getDescriptionKey(), null, locale))); metadata.locales = Arrays.stream(Locale.getAvailableLocales()) .sorted(Comparator.comparing(Locale::getDisplayName)) .collect(Utilities.toLinkedHashMap(Locale::toString, Locale::getDisplayName)); metadata.timezones = Arrays.stream(TimeZone.getAvailableIDs()).sorted(Comparator.comparing(tz -> tz)) .collect(Utilities.toLinkedHashMap(tz -> tz, tz -> tz)); WebloggerProperties.CommentPolicy globalCommentPolicy = webloggerPropertiesRepository.findOrNull() .getCommentPolicy();// www. ja va 2s.c o m metadata.commentOptions = Arrays.stream(WebloggerProperties.CommentPolicy.values()) .filter(co -> co.getLevel() <= globalCommentPolicy.getLevel()) .collect(Utilities.toLinkedHashMap(WebloggerProperties.CommentPolicy::name, co -> messages.getMessage(co.getWeblogDescription(), null, locale))); metadata.commentDayOptions = Arrays.stream(WeblogEntry.CommentDayOption.values()) .collect(Utilities.toLinkedHashMap(cdo -> Integer.toString(cdo.getDays()), cdo -> messages.getMessage(cdo.getDescriptionKey(), null, locale))); return metadata; }
From source file:com.doculibre.constellio.wicket.panels.search.SearchFormPanel.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public SearchFormPanel(String id, final IModel simpleSearchModel) { super(id);//from w w w . j a v a 2 s .com searchForm = new WebMarkupContainer("searchForm", new CompoundPropertyModel(simpleSearchModel)); simpleSearchFormDiv = new WebMarkupContainer("simpleSearchFormDiv") { @Override public boolean isVisible() { SimpleSearch search = (SimpleSearch) simpleSearchModel.getObject(); return search.getAdvancedSearchRule() == null; } }; advancedSearchFormDiv = new WebMarkupContainer("advancedSearchFormDiv") { @Override public boolean isVisible() { SimpleSearch search = (SimpleSearch) simpleSearchModel.getObject(); return search.getAdvancedSearchRule() != null; } }; advancedSearchPanel = new AdvancedSearchPanel("advanceForm", simpleSearchModel); searchForm.add(new AttributeModifier("action", new LoadableDetachableModel() { @Override protected Object load() { PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class); return urlFor(pageFactoryPlugin.getSearchResultsPage(), new PageParameters()); } })); hiddenFields = new ListView("hiddenFields", new LoadableDetachableModel() { @Override protected Object load() { List<SimpleParam> hiddenParams = new ArrayList<SimpleParam>(); HiddenSearchFormParamsPlugin hiddenSearchFormParamsPlugin = PluginFactory .getPlugin(HiddenSearchFormParamsPlugin.class); if (hiddenSearchFormParamsPlugin != null) { WebRequestCycle webRequestCycle = (WebRequestCycle) RequestCycle.get(); HttpServletRequest request = webRequestCycle.getWebRequest().getHttpServletRequest(); SimpleParams hiddenSimpleParams = hiddenSearchFormParamsPlugin.getHiddenParams(request); for (String paramName : hiddenSimpleParams.keySet()) { for (String paramValue : hiddenSimpleParams.getList(paramName)) { hiddenParams.add(new SimpleParam(paramName, paramValue)); } } } SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject(); SimpleSearch clone = simpleSearch.clone(); SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils .getSearchInterfaceConfigServices(); SearchInterfaceConfig config = searchInterfaceConfigServices.get(); if (!config.isKeepFacetsNewSearch()) { // Will be true if we just clicked on a delete link // on the CurrentSearchPanel if (!clone.isRefinedSearch()) { clone.getSearchedFacets().clear(); clone.setCloudKeyword(null); } // We must click on a delete link on // CurrentSearchPanel so that it is considered // again as refined clone.setRefinedSearch(false); } clone.initFacetPages(); List<String> ignoredParamNames = Arrays.asList("query", "searchType", "page", "singleSearchLocale"); SimpleParams searchParams = clone.toSimpleParams(); for (String paramName : searchParams.keySet()) { if (!ignoredParamNames.contains(paramName) && !paramName.contains(SearchRule.ROOT_PREFIX)) { List<String> paramValues = searchParams.getList(paramName); for (String paramValue : paramValues) { SimpleParam hiddenParam = new SimpleParam(paramName, paramValue); hiddenParams.add(hiddenParam); } } } return hiddenParams; } }) { @Override protected void populateItem(ListItem item) { SimpleParam hiddenParam = (SimpleParam) item.getModelObject(); if (hiddenParam.value != null) { item.add(new SimpleAttributeModifier("name", hiddenParam.name)); item.add(new SimpleAttributeModifier("value", hiddenParam.value)); } else { item.setVisible(false); } } }; SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils .getSearchInterfaceConfigServices(); SearchInterfaceConfig config = searchInterfaceConfigServices.get(); if (config.isSimpleSearchAutocompletion() && ((SimpleSearch) simpleSearchModel.getObject()).getAdvancedSearchRule() == null) { AutoCompleteSettings settings = new AutoCompleteSettings(); settings.setCssClassName("simpleSearchAutoCompleteChoices"); IModel model = new Model(((SimpleSearch) simpleSearchModel.getObject()).getQuery()); WordsAndValueAutoCompleteRenderer render = new WordsAndValueAutoCompleteRenderer() { @Override protected String getTextValue(String word, Object value) { return word; } }; queryField = new TextAndValueAutoCompleteTextField("query", model, String.class, settings, render) { @Override public String getInputName() { return super.getId(); } @Override protected Iterator getChoicesForWord(String word) { SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject(); String collectionName = simpleSearch.getCollectionName(); AutocompleteServices autocompleteServices = ConstellioSpringUtils.getAutocompleteServices(); RecordCollectionServices collectionServices = ConstellioSpringUtils .getRecordCollectionServices(); RecordCollection collection = collectionServices.get(collectionName); List<String> suggestions = autocompleteServices.suggestSimpleSearch(word, collection, getLocale()); return suggestions.iterator(); } @Override protected boolean supportMultipleWords() { return false; } }; } else { queryField = new TextField("query") { @Override public String getInputName() { return super.getId(); } }; } searchTypeField = new RadioGroup("searchType") { @Override public String getInputName() { return super.getId(); } }; IModel languages = new LoadableDetachableModel() { protected Object load() { Set<String> localeCodes = new HashSet<String>(); SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject(); RecordCollectionServices recordCollectionServices = ConstellioSpringUtils .getRecordCollectionServices(); RecordCollection collection = recordCollectionServices.get(simpleSearch.getCollectionName()); List<Locale> searchableLocales = ConstellioSpringUtils.getSearchableLocales(); if (!collection.isOpenSearch()) { localeCodes.add(""); if (!searchableLocales.isEmpty()) { for (Locale searchableLocale : searchableLocales) { localeCodes.add(searchableLocale.getLanguage()); } } else { IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices(); IndexField languageField = indexFieldServices.get(IndexField.LANGUAGE_FIELD, collection); for (String localeCode : indexFieldServices.suggestValues(languageField)) { localeCodes.add(localeCode); } } } else { localeCodes.add(""); if (!searchableLocales.isEmpty()) { for (Locale searchableLocale : searchableLocales) { localeCodes.add(searchableLocale.getLanguage()); } } else { for (Locale availableLocale : Locale.getAvailableLocales()) { localeCodes.add(availableLocale.getLanguage()); } } } List<Locale> locales = new ArrayList<Locale>(); for (String localeCode : localeCodes) { locales.add(new Locale(localeCode)); } Collections.sort(locales, new Comparator<Locale>() { @Override public int compare(Locale locale1, Locale locale2) { Locale locale1Display; Locale locale2Display; SearchInterfaceConfig config = ConstellioSpringUtils.getSearchInterfaceConfigServices() .get(); if (config.isTranslateLanguageNames()) { locale1Display = locale2Display = getLocale(); } else { locale1Display = locale1; locale2Display = locale2; } List<Locale> searchableLocales = ConstellioSpringUtils.getSearchableLocales(); if (searchableLocales.isEmpty()) { searchableLocales = ConstellioSpringUtils.getSupportedLocales(); } Integer indexOfLocale1; Integer indexOfLocale2; if (locale1.getLanguage().equals(getLocale().getLanguage())) { indexOfLocale1 = Integer.MIN_VALUE; } else { indexOfLocale1 = searchableLocales.indexOf(locale1); } if (locale2.getLanguage().equals(getLocale().getLanguage())) { indexOfLocale2 = Integer.MIN_VALUE; } else { indexOfLocale2 = searchableLocales.indexOf(locale2); } if (indexOfLocale1 == -1) { indexOfLocale1 = Integer.MAX_VALUE; } if (indexOfLocale2 == -1) { indexOfLocale2 = Integer.MAX_VALUE; } if (!indexOfLocale1.equals(Integer.MAX_VALUE) || !indexOfLocale2.equals(Integer.MAX_VALUE)) { return indexOfLocale1.compareTo(indexOfLocale2); } else if (StringUtils.isBlank(locale1.getLanguage())) { return Integer.MIN_VALUE; } else { return locale1.getDisplayLanguage(locale1Display) .compareTo(locale2.getDisplayLanguage(locale2Display)); } } }); return locales; } }; IChoiceRenderer languageRenderer = new ChoiceRenderer() { @Override public Object getDisplayValue(Object object) { Locale locale = (Locale) object; String text; if (locale.getLanguage().isEmpty()) { text = (String) new StringResourceModel("all", SearchFormPanel.this, null).getObject(); } else { Locale localeDisplay; SearchInterfaceConfig config = ConstellioSpringUtils.getSearchInterfaceConfigServices().get(); if (config.isTranslateLanguageNames()) { localeDisplay = getLocale(); } else { localeDisplay = locale; } text = StringUtils.capitalize(locale.getDisplayLanguage(localeDisplay)); } return text; } @Override public String getIdValue(Object object, int index) { return ((Locale) object).getLanguage(); } }; IModel languageModel = new Model() { @Override public Object getObject() { SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject(); Locale singleSearchLocale = simpleSearch.getSingleSearchLocale(); if (singleSearchLocale == null) { SearchedFacet facet = simpleSearch.getSearchedFacet(IndexField.LANGUAGE_FIELD); List<String> values = facet == null ? new ArrayList<String>() : facet.getIncludedValues(); singleSearchLocale = values.isEmpty() ? null : new Locale(values.get(0)); } if (singleSearchLocale == null) { singleSearchLocale = getLocale(); } return singleSearchLocale; } @Override public void setObject(Object object) { Locale singleSearchLocale = (Locale) object; SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject(); simpleSearch.setSingleSearchLocale(singleSearchLocale); } }; languageDropDown = new DropDownChoice("singleSearchLocale", languageModel, languages, languageRenderer) { @Override public String getInputName() { return "singleSearchLocale"; } @Override public boolean isVisible() { SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils .getSearchInterfaceConfigServices(); SearchInterfaceConfig config = searchInterfaceConfigServices.get(); return config.isLanguageInSearchForm(); } @Override protected CharSequence getDefaultChoice(Object selected) { return ""; }; }; searchButton = new Button("searchButton") { @Override public String getMarkupId() { return super.getId(); } @Override public String getInputName() { return super.getId(); } }; String submitImgUrl = "" + urlFor(new ResourceReference(BaseConstellioPage.class, "images/ico_loupe.png")); add(searchForm); searchForm.add(simpleSearchFormDiv); searchForm.add(advancedSearchFormDiv); searchForm.add(hiddenFields); queryField.add(new SetFocusBehavior(queryField)); addChoice(SimpleSearch.ALL_WORDS); addChoice(SimpleSearch.AT_LEAST_ONE_WORD); addChoice(SimpleSearch.EXACT_EXPRESSION); simpleSearchFormDiv.add(queryField); simpleSearchFormDiv.add(searchTypeField); simpleSearchFormDiv.add(languageDropDown); simpleSearchFormDiv.add(searchButton); advancedSearchFormDiv.add(advancedSearchPanel); searchButton.add(new SimpleAttributeModifier("src", submitImgUrl)); }
From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java
private void testLocales(final String format, final boolean eraBC) throws Exception { final Calendar cal = Calendar.getInstance(GMT); cal.clear();//from w w w. j av a2 s . co m cal.set(2003, Calendar.FEBRUARY, 10); if (eraBC) { cal.set(Calendar.ERA, GregorianCalendar.BC); } for (final Locale locale : Locale.getAvailableLocales()) { // ja_JP_JP cannot handle dates before 1868 properly if (eraBC && locale.equals(FastDateParser.JAPANESE_IMPERIAL)) { continue; } final SimpleDateFormat sdf = new SimpleDateFormat(format, locale); final DateParser fdf = getInstance(format, locale); try { checkParse(locale, cal, sdf, fdf); } catch (final ParseException ex) { Assert.fail("Locale " + locale + " failed with " + format + " era " + (eraBC ? "BC" : "AD") + "\n" + trimMessage(ex.toString())); } } }
From source file:net.sf.nmedit.nomad.core.NomadLoader.java
private void initLocale() { SystemProperties properties = SystemPropertyFactory.getProperties(NomadLoader.class); properties.defineStringProperty(NOMAD_CURRENT_LOCALE, null); String locale = properties.stringValue(NOMAD_CURRENT_LOCALE); if (locale != null) { for (Locale l : Locale.getAvailableLocales()) { if (locale.equals(l.toString())) { LocaleConfiguration conf = LocaleConfiguration.getLocaleConfiguration(); if (!conf.getCurrentLocale().equals(l)) conf.setCurrentLocale(l); break; }//from w w w . ja v a2 s. co m } } }
From source file:net.sf.jsptest.compiler.jsp20.mock.MockHttpServletRequest.java
public Enumeration getLocales() { List locales = Arrays.asList(Locale.getAvailableLocales()); return new Vector(locales).elements(); }
From source file:org.yccheok.jstock.gui.OptionsSellAdvisorJPanel.java
private static ComboBoxModel getComboBoxModel() { synchronized (defaultComboBoxModel) { if (defaultComboBoxModel.getSize() > 0) { return defaultComboBoxModel; }/*ww w .j av a 2s. c o m*/ String[] countries = { "AU", // Austrialia "AT", // Austria "BE", // Belgium "BR", // Brazil "CA", // Canada "CN", // China "CZ", // Czech "DK", // Denmark "FR", // France "DE", // Germany "HK", // HongKong "HU", // Hungary "IN", // India "ID", // Indonesia "IT", // Italy "KR", // Korea "MY", // Malaysia "NL", // Netherlands "NZ", // NewZealand "NO", // Norway "PT", // Portugal "SG", // Singapore "ES", // Spain "SE", // Sweden "CH", // Switzerland "TW", // Taiwan "GB", // Unitedkingdom "US", // UnitedState }; final List<String> countryList = Arrays.asList(countries); final Locale[] locales = Locale.getAvailableLocales(); // Order is important. final Set<String> set = new LinkedHashSet<String>(); set.add(Utils.getDefaultCurrencySymbol()); for (Locale locale : locales) { if (countryList.contains(locale.getCountry()) == false) { continue; } set.add(Currency.getInstance(locale).getSymbol(locale)); } for (String s : set) { defaultComboBoxModel.addElement(s); } } return defaultComboBoxModel; }
From source file:root.gast.playground.speech.SpeechRecognitionPlay.java
public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.m_speechparam) { //launch preferences activity Intent i = new Intent(this, SummarizingEditPreferences.class); i.putExtra(SummarizingEditPreferences.WHICH_PREFERENCES_INTENT, R.xml.speech_preferences); String preferenceName = getResources().getString(R.string.pref_speech_key); i.putExtra(SummarizingEditPreferences.WHICH_PREFERENCES_NAME_INTENT, preferenceName); startActivity(i);//from w ww . ja v a 2s .c o m } else if (item.getItemId() == R.id.m_speech_language_details) { OnLanguageDetailsListener andThen = new OnLanguageDetailsListener() { @Override public void onLanguageDetailsReceived(LanguageDetailsChecker data) { String languagesSupportedDescription = data.toString(); DialogGenerator.createInfoDialog(SpeechRecognitionPlay.this, getResources().getString(R.string.speech_data_check_result_title), languagesSupportedDescription).show(); } }; Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS); sendOrderedBroadcast(detailsIntent, null, new LanguageDetailsChecker(andThen), null, Activity.RESULT_OK, null, null); } else if (item.getItemId() == R.id.m_setlanguage) { OnLanguageDetailsListener andThenSetLanguage = new OnLanguageDetailsListener() { @Override public void onLanguageDetailsReceived(LanguageDetailsChecker data) { final List<String> langs = data.getSupportedLanguages(); DialogGenerator.makeSelectListDialog(getResources().getString(R.string.d_select_language), SpeechRecognitionPlay.this, langs, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String setLanguagePreferenceTo = langs.get(which); preferences.setString(getResources().getString(R.string.pref_language), setLanguagePreferenceTo); } }).show(); } }; Intent details = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS); sendOrderedBroadcast(details, null, new LanguageDetailsChecker(andThenSetLanguage), null, Activity.RESULT_OK, null, null); } else if (item.getItemId() == R.id.m_checkmenu_languageavailable) { //show all the locales, and pic one to check final List<Locale> localesUsed = Arrays.asList(Locale.getAvailableLocales()); DialogGenerator.makeSelectListDialog(getResources().getString(R.string.d_select_language), this, localesUsed, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Locale loc = localesUsed.get(which); Toast.makeText(SpeechRecognitionPlay.this, "Checking language support for: " + loc, Toast.LENGTH_SHORT).show(); checkForLanguage(loc); } }).show(); } else if (item.getItemId() == R.id.m_speech_compute_index) { final View frameLayout = getLayoutInflater().inflate(R.layout.enterworddialog, null); final EditText dialogtext = (EditText) frameLayout.findViewById(R.id.et_dialog_text_input); String hint = whatYouAreTryingToSay.getText().toString(); if ((hint != null) && (hint.length() > 0)) { hint = hint.split("\\s")[0]; } dialogtext.setText(hint); //reply with the word's index //show an edit box DialogGenerator.createFrameDialog(this, "Enter word to index", frameLayout, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String input = dialogtext.getText().toString(); String soundex = new Soundex().encode(input); String stem = Stemmer.stem(input); StringBuilder message = new StringBuilder(); message.append("input: ").append(input).append("\n"); message.append("soundex: ").append(soundex).append("\n"); message.append("stem: ").append(stem); DialogGenerator.createInfoDialog(SpeechRecognitionPlay.this, getResources().getString(R.string.d_info), message.toString()).show(); } }).show(); } else if (item.getItemId() == R.id.m_write_speech_activation_tag) { Log.d(TAG, "start write activation"); Intent doTag = new Intent(this, SpeechActivatorTagWriter.class); startActivity(doTag); } else { throw new RuntimeException("unknown menu selection"); } return true; }
From source file:com.lewa.crazychapter11.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //set to full screen // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); ///set to no title // requestWindowFeature(Window.FEATURE_NO_TITLE); // acionBar = getSupportActionBar(); // acionBar = getActionBar(); // acionBar.hide(); // Window win = getWindow(); // win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); // win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); // win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // win.setStatusBarColor(Color.TRANSPARENT); // win.setNavigationBarColor(Color.TRANSPARENT); /*//*w ww . jav a2 s . c o m*/ win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); win.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); win.setStatusBarColor(Color.TRANSPARENT); win.setNavigationBarColor(Color.TRANSPARENT); //*/ super.onCreate(savedInstanceState); setContentView(R.layout.main); /* setTheme(R.style.CrazyTheme); */ AddGameBtn(); AddNoification(); LookupContact(); AddServiceBtn(); broadcastMain(); mediaPlayerMain(); mediaRecordSoundMain(); cameraMain(); recordvideoMain(); queMySql(); TestFragment(); justForTest(); LoadJson(); AddTestBtn(); AddUsageStatsBtn(); AddPeopleProvideBtn(); getInput(); ////just for test shutdown broadcast receiver IntentFilter mIntentFilter = new IntentFilter("android.intent.action.ACTION_SHUTDOWN"); mIntentFilter.addAction("com.lewa.alarm.test"); mIntentFilter.addAction("android.provider.Telephony.SECRET_CODE"); mIntentFilter.addAction("android.intent.action.SCREEN_ON"); mIntentFilter.addAction("android.intent.action.SCREEN_OFF"); mShoutdown = new shutdownReceiver(); registerReceiver(mShoutdown, mIntentFilter); ////test preferences = getSharedPreferences("crazyit", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); editor = preferences.edit(); preferencestime = getSharedPreferences("RMS_Shutdown_time", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); editortime = preferencestime.edit(); SharedShutdownTimeRead(); AddSharedPreBtn(); etNum = (EditText) findViewById(R.id.etNum); // // int maxLength = 4; InputFilter[] fArray = new InputFilter[1]; fArray[0] = new InputFilter.LengthFilter(maxLength); etNum.setFilters(fArray); // // calThread = new CalThread(); calThread.start(); Log.i("algerheMain", "MainActivity onCreate in!!"); String page = getString(R.string.str_page, "345", "24"); Log.i("algerheMain", "page=" + page); // /just for test here ComponentName comp = getIntent().getComponent(); show_txt = (EditText) findViewById(R.id.show_txt); show_txt.setText( "??" + comp.getPackageName() + " \n ??" + comp.getClassName()); ////MD5 check item ///1.IMEI TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); String szImei = TelephonyMgr.getDeviceId(); String m_szSIMSerialNm = TelephonyMgr.getSimSerialNumber(); CellLocation m_location = TelephonyMgr.getCellLocation(); String m_Line1Number = TelephonyMgr.getLine1Number(); String m_OperatorName = TelephonyMgr.getSimOperatorName(); Log.i("algerheTelephonyMgr", "szImei=" + szImei); Log.i("algerheTelephonyMgr", "m_szSIMSerialNm=" + m_szSIMSerialNm); Log.i("algerheTelephonyMgr", "m_location=" + m_location); Log.i("algerheTelephonyMgr", "m_Line1Number=" + m_Line1Number); Log.i("algerheTelephonyMgr", "m_OperatorName=" + m_OperatorName); Log.i("algerheMain01", "szImei=" + szImei); Log.i("algerheMain01", "m_szSIMSerialNm=" + m_szSIMSerialNm); ///2.Pseudo-Unique ID String m_szDevIDShort = "35" + //we make this look like a valid IMEI Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10; //13 digits Log.i("algerheMain01", "m_szDevIDShort=" + m_szDevIDShort); ///3. Android ID String m_szAndroidID = Secure.getString(getContentResolver(), Secure.ANDROID_ID); Log.i("algerheMain01", "m_szAndroidID=" + m_szAndroidID); ///4.WLAN MAC Address string WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); String m_szWLANMAC = "unknow_wifi_mac"; if (wm != null && wm.getConnectionInfo() != null) { m_szWLANMAC = wm.getConnectionInfo().getMacAddress(); } Log.i("algerheMain01", "m_szWLANMAC=" + m_szWLANMAC); ///5.BT MAC Address string BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); String m_szBTMAC = m_BluetoothAdapter.getAddress(); Log.i("algerheMain01", "m_szBTMAC=" + m_szBTMAC); ///6.sim serial number .getSimSerialNumber() // / ///reflect test checkMethod(); // */ final Intent alarmIntent = new Intent(); Log.i("algerheMain00", "isLewaRom=" + isLewaRom(this, alarmIntent)); handler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0x4567) { String languageStr = null; String countryStr = null; Locale[] locList = Locale.getAvailableLocales(); for (int i = 0; i < locList.length; i++) { languageStr += locList[i].getLanguage(); countryStr += locList[i].getCountry(); } // show_txt = (EditText) findViewById(R.id.show_txt); show_txt.setText("" + languageStr + " \n " + countryStr); } else if (msg.what == 0x2789) { Log.i("algerheAlarm", "send alarm message in time=" + System.currentTimeMillis() + "\n action=" + alarmIntent.getAction()); // sendBroadcast(alarmIntent); } } }; // String strApkPath = intent.getStringExtra("apkPath"); // String strCmd = "pm install -r " + strApkPath; // try { // Process install = Runtime.getRuntime().exec(strCmd); // Log.d(TAG, "install = " + install + ", strCmd =" + strCmd); // }catch (Exception ex){ // Log.d(TAG, ex.getMessage()); // } // */ }
From source file:org.openmrs.web.filter.StartupFilter.java
/** * Gets tool context for specified locale parameter. If context does not exists, it creates new * context, configured for that locale. Otherwise, it changes locale property of * {@link LocalizationTool} object, that is being contained in tools context * * @param locale the string with locale parameter for configuring tools context * @return the tool context object/*from ww w. j a v a2 s . c o m*/ */ public ToolContext getToolContext(String locale) { Locale systemLocale = LocaleUtility.fromSpecification(locale); //Defaults to en if systemLocale is null or invalid e.g en_GBs if (systemLocale == null || !ArrayUtils.contains(Locale.getAvailableLocales(), systemLocale)) { systemLocale = Locale.ENGLISH; } // If tool context has not been configured yet if (toolContext == null) { // first we are creating manager for tools, factory for configuring tools // and empty configuration object for velocity tool box ToolManager velocityToolManager = new ToolManager(); FactoryConfiguration factoryConfig = new FactoryConfiguration(); // since we are using one tool box for all request within wizard // we should propagate toolbox's scope on all application ToolboxConfiguration toolbox = new ToolboxConfiguration(); toolbox.setScope(Scope.APPLICATION); // next we are directly configuring custom localization tool by // setting its class name, locale property etc. ToolConfiguration localizationTool = new ToolConfiguration(); localizationTool.setClassname(LocalizationTool.class.getName()); localizationTool.setProperty(ToolContext.LOCALE_KEY, systemLocale); localizationTool.setProperty(LocalizationTool.BUNDLES_KEY, "messages"); // and finally we are adding just configured tool into toolbox // and creating tool context for this toolbox toolbox.addTool(localizationTool); factoryConfig.addToolbox(toolbox); velocityToolManager.configure(factoryConfig); toolContext = velocityToolManager.createContext(); toolContext.setUserCanOverwriteTools(true); } else { // if it already has been configured, we just pull out our custom localization tool // from tool context, then changing its locale property and putting this tool back to the context // First, we need to obtain the value of default key annotation of our localization tool // class using reflection Annotation annotation = LocalizationTool.class.getAnnotation(DefaultKey.class); DefaultKey defaultKeyAnnotation = (DefaultKey) annotation; String key = defaultKeyAnnotation.value(); // LocalizationTool localizationTool = (LocalizationTool) toolContext.get(key); localizationTool.setLocale(systemLocale); toolContext.put(key, localizationTool); } return toolContext; }
From source file:org.libreplan.web.common.ConfigurationModel.java
private static Map<String, String> getAllCurrencies() { Map<String, String> currencies = new TreeMap<>(); for (Locale locale : Locale.getAvailableLocales()) { if (StringUtils.isNotBlank(locale.getCountry())) { Currency currency = Currency.getInstance(locale); currencies.put(currency.getCurrencyCode(), currency.getSymbol(locale)); }//from w ww. ja v a 2s . c om } return currencies; }