Java Code Examples for android.preference.ListPreference#setEntries()
The following examples show how to use
android.preference.ListPreference#setEntries() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorSettingsActivity.java From LaunchTime with GNU General Public License v3.0 | 6 votes |
private static void setListPreferenceIconsPacksData(ListPreference lp, Context context) { IconsHandler iph = GlobState.getIconsHandler(context); iph.loadAvailableIconsPacks(); Map<String, String> iconsPacks = iph.getAllIconsThemes(); CharSequence[] entries = new CharSequence[iconsPacks.size()]; CharSequence[] entryValues = new CharSequence[iconsPacks.size()]; int i = 0; for (String packageIconsPack : iconsPacks.keySet()) { entries[i] = iconsPacks.get(packageIconsPack); entryValues[i] = packageIconsPack; i++; } lp.setEntries(entries); lp.setDefaultValue(IconsHandler.DEFAULT_PACK); lp.setEntryValues(entryValues); }
Example 2
Source File: CreateModulePreference.java From GNSS_Compare with Apache License 2.0 | 6 votes |
/** * defines a list preference * @param preferenceKey Key of the preference * @param registeredObjectNames set containing possible values in the list preference * @param intentExtras intent passed to the fragment */ private void defineListPrefernece(String preferenceKey, Set<String> registeredObjectNames, Bundle intentExtras) { ListPreference preference = (ListPreference) findPreference(preferenceKey); CharSequence[] entries = registeredObjectNames.toArray(new CharSequence[registeredObjectNames.size()]); preference.setEntries(entries); preference.setEntryValues(entries); if(intentExtras != null){ preference.setValue(intentExtras.getString(preferenceKey)); } else { preference.setValue(null); } }
Example 3
Source File: AccountPreferencesFragment.java From Linphone4Android with GNU General Public License v3.0 | 5 votes |
private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) { CharSequence[] contents = new CharSequence[entries.size()]; entries.toArray(contents); pref.setEntries(contents); contents = new CharSequence[values.size()]; values.toArray(contents); pref.setEntryValues(contents); }
Example 4
Source File: SettingsFragment.java From Linphone4Android with GNU General Public License v3.0 | 5 votes |
private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) { CharSequence[] contents = new CharSequence[entries.size()]; entries.toArray(contents); pref.setEntries(contents); contents = new CharSequence[values.size()]; values.toArray(contents); pref.setEntryValues(contents); }
Example 5
Source File: SingleWebsitePreferences.java From 365browser with Apache License 2.0 | 5 votes |
/** * Updates the location preference to indicate that the site has access to location (via X-Geo) * for searches that happen from the omnibox. * @param preference The Location preference to modify. */ private void updateLocationPreferenceForDSESetting(Preference preference) { ListPreference listPreference = (ListPreference) preference; Resources res = getResources(); listPreference.setEntries(new String[] { res.getString(R.string.website_settings_permissions_allow_dse), res.getString(R.string.website_settings_permissions_block_dse), }); listPreference.setValueIndex( WebsitePreferenceBridge.getDSEGeolocationSetting() ? 0 : 1); }
Example 6
Source File: SettingsActivity.java From android_app_cputempinstatusbar with GNU General Public License v2.0 | 5 votes |
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown. */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); bindPreferenceSummaryToValue(findPreference("update_interval")); bindPreferenceSummaryToValue(findPreference("position")); ListPreference temperature_file = (ListPreference)findPreference("temperature_file"); bindPreferenceSummaryToValue(findPreference("temperature_divider")); String[] files = Utils.getTemperatureFiles(); temperature_file.setEntries(files); temperature_file.setEntryValues(files); bindPreferenceSummaryToValue(findPreference("temperature_file")); bindPreferenceSummaryToValue(findPreference("measurement")); bindPreferenceSummaryToValue(findPreference("color_mode")); bindPreferenceSummaryToValue(findPreference("configured_color")); bindPreferenceSummaryToValue(findPreference("color_low")); bindPreferenceSummaryToValue(findPreference("color_middle")); bindPreferenceSummaryToValue(findPreference("color_high")); bindPreferenceSummaryToValue(findPreference("temp_middle")); bindPreferenceSummaryToValue(findPreference("temp_high")); bindPreferenceSummaryToValue(findPreference("show_unit")); }
Example 7
Source File: IiNet.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
@Override public void fillLayout(final SipProfile account) { super.fillLayout(account); CharSequence[] states = new CharSequence[] {"act", "nsw", "nt", "qld", "sa", "tas", "vic", "wa"}; accountState = new ListPreference(parent); accountState.setEntries(states); accountState.setEntryValues(states); accountState.setKey("state"); accountState.setDialogTitle(R.string.w_iinet_state); accountState.setTitle(R.string.w_iinet_state); accountState.setSummary(R.string.w_iinet_state_desc); accountState.setDefaultValue("act"); addPreference(accountState); String domain = account.reg_uri; if( domain != null ) { for(CharSequence state : states) { String currentComp = "sip:sip."+state+".iinet.net.au"; if( currentComp.equalsIgnoreCase(domain) ) { accountState.setValue(state.toString()); break; } } } accountUsername.setTitle(R.string.w_iinet_username); accountUsername.setDialogTitle(R.string.w_iinet_username); accountPassword.setTitle(R.string.w_iinet_password); accountPassword.setDialogTitle(R.string.w_iinet_password); }
Example 8
Source File: MyPreferencesActivity.java From EasyVPN-Free with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); DBHelper dbHelper = new DBHelper(getActivity().getApplicationContext()); List<Server> countryList = dbHelper.getUniqueCountries(); CharSequence entriesValues[] = new CharSequence[countryList.size()]; CharSequence entries[] = new CharSequence[countryList.size()]; for (int i = 0; i < countryList.size(); i++) { entriesValues[i] = countryList.get(i).getCountryLong(); String localeCountryName = CountriesNames.getCountries().get(countryList.get(i).getCountryShort()) != null ? CountriesNames.getCountries().get(countryList.get(i).getCountryShort()) : countryList.get(i).getCountryLong(); entries[i] = localeCountryName; } ListPreference listPreference = (ListPreference) findPreference("selectedCountry"); if (entries.length == 0) { PreferenceCategory countryPriorityCategory = (PreferenceCategory) findPreference("countryPriorityCategory"); getPreferenceScreen().removePreference(countryPriorityCategory); } else { listPreference.setEntries(entries); listPreference.setEntryValues(entriesValues); if (PropertiesService.getSelectedCountry() == null) listPreference.setValueIndex(0); } }
Example 9
Source File: SettingsShortcutActivity.java From JotaTextEditor with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPm = getPreferenceManager(); mPs = mPm.createPreferenceScreen(this); setTitle(R.string.label_customize_shortcut); int len = TBL_SUMMARY.length; String[] tbl_summary = new String[ len ]; String[] tbl_function = new String[ len ]; for( int i=0;i<len;i++ ){ tbl_summary[i] = getString(TBL_SUMMARY[i]); tbl_function[i] = Integer.toString(TBL_FUNCTION[i]); } for( DefineShortcut sd : TBL_SHORTCUT ) { final ListPreference pr = new ListPreference(this); pr.setKey(KEY_SHORTCUT + sd.key ); pr.setTitle( sd.name ); pr.setEntries(tbl_summary); pr.setEntryValues(tbl_function); mPs.addPreference(pr); } setPreferenceScreen(mPs); setSummary(); }
Example 10
Source File: SettingsShortcutActivity.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPm = getPreferenceManager(); mPs = mPm.createPreferenceScreen(this); setTitle(R.string.label_customize_shortcut); int len = TBL_SUMMARY.length; String[] tbl_summary = new String[ len ]; String[] tbl_function = new String[ len ]; for( int i=0;i<len;i++ ){ tbl_summary[i] = getString(TBL_SUMMARY[i]); tbl_function[i] = Integer.toString(TBL_FUNCTION[i]); } for( DefineShortcut sd : TBL_SHORTCUT ) { final ListPreference pr = new ListPreference(this); pr.setKey(KEY_SHORTCUT + sd.key ); pr.setTitle( sd.name ); pr.setEntries(tbl_summary); pr.setEntryValues(tbl_function); mPs.addPreference(pr); } setPreferenceScreen(mPs); setSummary(); }
Example 11
Source File: AdvancedSettingsFragment.java From Android-Keyboard with Apache License 2.0 | 4 votes |
@Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_advanced); final Resources res = getResources(); final Context context = getActivity(); // When we are called from the Settings application but we are not already running, some // singleton and utility classes may not have been initialized. We have to call // initialization method of these classes here. See {@link LatinIME#onCreate()}. AudioAndHapticFeedbackManager.init(context); final SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); if (!Settings.isInternal(prefs)) { removePreference(Settings.SCREEN_DEBUG); } if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) { removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS); } // TODO: consolidate key preview dismiss delay with the key preview animation parameters. if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) { removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); } else { // TODO: Cleanup this setup. final ListPreference keyPreviewPopupDismissDelay = (ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger( R.integer.config_key_preview_linger_timeout)); keyPreviewPopupDismissDelay.setEntries(new String[] { res.getString(R.string.key_preview_popup_dismiss_no_delay), res.getString(R.string.key_preview_popup_dismiss_default_delay), }); keyPreviewPopupDismissDelay.setEntryValues(new String[] { "0", popupDismissDelayDefaultValue }); if (null == keyPreviewPopupDismissDelay.getValue()) { keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue); } keyPreviewPopupDismissDelay.setEnabled( Settings.readKeyPreviewPopupEnabled(prefs, res)); } setupKeypressVibrationDurationSettings(); setupKeypressSoundVolumeSettings(); setupKeyLongpressTimeoutSettings(); refreshEnablingsOfKeypressSoundAndVibrationSettings(); }
Example 12
Source File: GeneralPreferenceFragment.java From V2EX with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); getPreferenceManager().setSharedPreferencesName( Config.getConfig(ConfigRefEnum.CONFIG_PREFERENCE_SETTING_FILE)); addPreferencesFromResource(R.xml.pref_general); ListPreference themePreference = (ListPreference) findPreference( getString(R.string.key_theme)); themePreference.setSummary(Config.getConfig(ConfigRefEnum.CONFIG_THEME)); ListPreference dateFormatPreference = (ListPreference)findPreference( getString(R.string.key_date_format)); String[] dateEntries = new String[dateFormatPreference.getEntryValues().length]; int i = 0; for (CharSequence s:dateFormatPreference.getEntryValues()){ String date = TimeUtil.getDateNow(String.valueOf(s)); dateEntries[i++] = date; } dateFormatPreference.setEntries(dateEntries); dateFormatPreference.setSummary(TimeUtil.getDateNow(Config.getConfig( ConfigRefEnum.CONFIG_DATE_FORMAT))); ListPreference localePreference = (ListPreference) findPreference(getString(R.string.key_local)); String[] localesEntryValue = new String[Config.LOCAL_LIST.size()]; String[] localesEntries= new String[Config.LOCAL_LIST.size()]; int index = 0; for (Locale locale:Config.LOCAL_LIST){ localesEntryValue[index] = locale.toString(); localesEntries[index++] = locale.getDisplayCountry(); } localePreference.setDefaultValue(localesEntryValue[0]); localePreference.setEntryValues(localesEntryValue); localePreference.setEntries(localesEntries); Preference clearCachePreference = findPreference(getString(R.string.clear_cache)); clearCachePreference.setOnPreferenceClickListener(this::clearCache); clearCachePreference.setSummary("缓存大小 12 MB"); findPreference(getString(R.string.key_home_tabs)).setOnPreferenceClickListener(preference -> { CustomTabActivity.start(getActivity()); return false; }); }
Example 13
Source File: SingleWebsitePreferences.java From 365browser with Apache License 2.0 | 4 votes |
/** * Initialize a ListPreference with a certain value. * @param preference The ListPreference to initialize. * @param value The value to initialize it to. */ private void setUpListPreference(Preference preference, ContentSetting value) { if (value == null) { getPreferenceScreen().removePreference(preference); return; } ListPreference listPreference = (ListPreference) preference; int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); CharSequence[] keys = new String[2]; CharSequence[] descriptions = new String[2]; keys[0] = ContentSetting.ALLOW.toString(); keys[1] = ContentSetting.BLOCK.toString(); descriptions[0] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW)); descriptions[1] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK)); listPreference.setEntryValues(keys); listPreference.setEntries(descriptions); int index = (value == ContentSetting.ALLOW ? 0 : 1); listPreference.setValueIndex(index); int explanationResourceId = ContentSettingsResources.getExplanation(contentType); if (explanationResourceId != 0) { listPreference.setTitle(explanationResourceId); } if (listPreference.isEnabled()) { SiteSettingsCategory category = SiteSettingsCategory.fromContentSettingsType(contentType); if (category != null && !category.enabledInAndroid(getActivity())) { listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity())); listPreference.setEnabled(false); } else { listPreference.setIcon(ContentSettingsResources.getIcon(contentType)); } } else { listPreference.setIcon( ContentSettingsResources.getDisabledIcon(contentType, getResources())); } preference.setSummary("%s"); listPreference.setOnPreferenceChangeListener(this); }
Example 14
Source File: SingleWebsitePreferences.java From delion with Apache License 2.0 | 4 votes |
/** * Initialize a ListPreference with a certain value. * @param preference The ListPreference to initialize. * @param value The value to initialize it to. */ private void setUpListPreference(Preference preference, ContentSetting value) { if (value == null) { getPreferenceScreen().removePreference(preference); return; } ListPreference listPreference = (ListPreference) preference; int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); CharSequence[] keys = new String[2]; CharSequence[] descriptions = new String[2]; keys[0] = ContentSetting.ALLOW.toString(); keys[1] = ContentSetting.BLOCK.toString(); descriptions[0] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW)); descriptions[1] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK)); listPreference.setEntryValues(keys); listPreference.setEntries(descriptions); int index = (value == ContentSetting.ALLOW ? 0 : 1); listPreference.setValueIndex(index); int explanationResourceId = ContentSettingsResources.getExplanation(contentType); if (explanationResourceId != 0) { listPreference.setTitle(explanationResourceId); } if (listPreference.isEnabled()) { SiteSettingsCategory category = SiteSettingsCategory.fromContentSettingsType(contentType); if (category != null && !category.enabledInAndroid(getActivity())) { listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity())); listPreference.setEnabled(false); } else { listPreference.setIcon(ContentSettingsResources.getIcon(contentType)); } } else { listPreference.setIcon(getDisabledInChromeIcon(contentType)); } preference.setSummary("%s"); listPreference.setOnPreferenceChangeListener(this); }
Example 15
Source File: SettingsActivity.java From Paddle-Lite-Demo with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setDisplayHomeAsUpEnabled(true); } // Initialize pre-installed models preInstalledModelDirs = new ArrayList<String>(); preInstalledLabelPaths = new ArrayList<String>(); preInstalledCPUThreadNums = new ArrayList<String>(); preInstalledCPUPowerModes = new ArrayList<String>(); preInstalledInputWidths = new ArrayList<String>(); preInstalledInputHeights = new ArrayList<String>(); preInstalledInputMeans = new ArrayList<String>(); preInstalledInputStds = new ArrayList<String>(); preInstalledScoreThresholds = new ArrayList<String>(); preInstalledModelDirs.add(getString(R.string.MODEL_DIR_DEFAULT)); preInstalledLabelPaths.add(getString(R.string.LABEL_PATH_DEFAULT)); preInstalledCPUThreadNums.add(getString(R.string.CPU_THREAD_NUM_DEFAULT)); preInstalledCPUPowerModes.add(getString(R.string.CPU_POWER_MODE_DEFAULT)); preInstalledInputWidths.add(getString(R.string.INPUT_WIDTH_DEFAULT)); preInstalledInputHeights.add(getString(R.string.INPUT_HEIGHT_DEFAULT)); preInstalledInputMeans.add(getString(R.string.INPUT_MEAN_DEFAULT)); preInstalledInputStds.add(getString(R.string.INPUT_STD_DEFAULT)); preInstalledScoreThresholds.add(getString(R.string.SCORE_THRESHOLD_DEFAULT)); // Add ssd_mobilenet_v1_pascalvoc_for_hybrid_cpu_npu for CPU and huawei NPU if (Utils.isSupportedNPU()) { preInstalledModelDirs.add("models/ssd_mobilenet_v1_pascalvoc_for_hybrid_cpu_npu"); preInstalledLabelPaths.add("labels/pascalvoc_label_list"); preInstalledCPUThreadNums.add("1"); // Useless for NPU preInstalledCPUPowerModes.add("LITE_POWER_HIGH"); // Useless for NPU preInstalledInputWidths.add("300"); preInstalledInputHeights.add("300"); preInstalledInputMeans.add("0.5,0.5,0.5"); preInstalledInputStds.add("0.5,0.5,0.5"); preInstalledScoreThresholds.add("0.5"); } else { Toast.makeText(this, "NPU model is not supported by your device.", Toast.LENGTH_LONG).show(); } // Setup UI components lpChoosePreInstalledModel = (ListPreference) findPreference(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY)); String[] preInstalledModelNames = new String[preInstalledModelDirs.size()]; for (int i = 0; i < preInstalledModelDirs.size(); i++) { preInstalledModelNames[i] = preInstalledModelDirs.get(i).substring(preInstalledModelDirs.get(i).lastIndexOf("/") + 1); } lpChoosePreInstalledModel.setEntries(preInstalledModelNames); lpChoosePreInstalledModel.setEntryValues(preInstalledModelDirs.toArray(new String[preInstalledModelDirs.size()])); lpCPUThreadNum = (ListPreference) findPreference(getString(R.string.CPU_THREAD_NUM_KEY)); lpCPUPowerMode = (ListPreference) findPreference(getString(R.string.CPU_POWER_MODE_KEY)); etModelDir = (EditTextPreference) findPreference(getString(R.string.MODEL_DIR_KEY)); etModelDir.setTitle("Model dir (SDCard: " + Utils.getSDCardDirectory() + ")"); etLabelPath = (EditTextPreference) findPreference(getString(R.string.LABEL_PATH_KEY)); etLabelPath.setTitle("Label path (SDCard: " + Utils.getSDCardDirectory() + ")"); etInputWidth = (EditTextPreference) findPreference(getString(R.string.INPUT_WIDTH_KEY)); etInputHeight = (EditTextPreference) findPreference(getString(R.string.INPUT_HEIGHT_KEY)); etInputMean = (EditTextPreference) findPreference(getString(R.string.INPUT_MEAN_KEY)); etInputStd = (EditTextPreference) findPreference(getString(R.string.INPUT_STD_KEY)); etScoreThreshold = (EditTextPreference) findPreference(getString(R.string.SCORE_THRESHOLD_KEY)); }
Example 16
Source File: SettingsActivity.java From padland with Apache License 2.0 | 4 votes |
private void setDefaultServerPreferenceValues() { String[] entries = (String[]) getArguments().get("server_name_list"); final ListPreference defaultServer = (ListPreference) findPreference("padland_default_server"); defaultServer.setEntries(entries); defaultServer.setEntryValues(entries); }
Example 17
Source File: SettingsActivity.java From Paddle-Lite-Demo with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setDisplayHomeAsUpEnabled(true); } // Initialize pre-installed models preInstalledModelDirs = new ArrayList<String>(); preInstalledLabelPaths = new ArrayList<String>(); preInstalledCPUThreadNums = new ArrayList<String>(); preInstalledCPUPowerModes = new ArrayList<String>(); preInstalledInputWidths = new ArrayList<String>(); preInstalledInputHeights = new ArrayList<String>(); preInstalledInputMeans = new ArrayList<String>(); preInstalledInputStds = new ArrayList<String>(); preInstalledScoreThresholds = new ArrayList<String>(); preInstalledModelDirs.add(getString(R.string.MODEL_DIR_DEFAULT)); preInstalledLabelPaths.add(getString(R.string.LABEL_PATH_DEFAULT)); preInstalledCPUThreadNums.add(getString(R.string.CPU_THREAD_NUM_DEFAULT)); preInstalledCPUPowerModes.add(getString(R.string.CPU_POWER_MODE_DEFAULT)); preInstalledInputWidths.add(getString(R.string.INPUT_WIDTH_DEFAULT)); preInstalledInputHeights.add(getString(R.string.INPUT_HEIGHT_DEFAULT)); preInstalledInputMeans.add(getString(R.string.INPUT_MEAN_DEFAULT)); preInstalledInputStds.add(getString(R.string.INPUT_STD_DEFAULT)); preInstalledScoreThresholds.add(getString(R.string.SCORE_THRESHOLD_DEFAULT)); // Add yolov3_mobilenet_v3_for_hybrid_cpu_npu for CPU and huawei NPU if (Utils.isSupportedNPU()) { preInstalledModelDirs.add("models/yolov3_mobilenet_v3_for_hybrid_cpu_npu"); preInstalledLabelPaths.add("labels/coco-labels-2014_2017.txt"); preInstalledCPUThreadNums.add("1"); // Useless for NPU preInstalledCPUPowerModes.add("LITE_POWER_HIGH"); // Useless for NPU preInstalledInputWidths.add("320"); preInstalledInputHeights.add("320"); preInstalledInputMeans.add("0.485,0.456,0.406"); preInstalledInputStds.add("0.229,0.224,0.225"); preInstalledScoreThresholds.add("0.2"); } else { Toast.makeText(this, "NPU model is not supported by your device.", Toast.LENGTH_LONG).show(); } // Setup UI components lpChoosePreInstalledModel = (ListPreference) findPreference(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY)); String[] preInstalledModelNames = new String[preInstalledModelDirs.size()]; for (int i = 0; i < preInstalledModelDirs.size(); i++) { preInstalledModelNames[i] = preInstalledModelDirs.get(i).substring(preInstalledModelDirs.get(i).lastIndexOf("/") + 1); } lpChoosePreInstalledModel.setEntries(preInstalledModelNames); lpChoosePreInstalledModel.setEntryValues(preInstalledModelDirs.toArray(new String[preInstalledModelDirs.size()])); lpCPUThreadNum = (ListPreference) findPreference(getString(R.string.CPU_THREAD_NUM_KEY)); lpCPUPowerMode = (ListPreference) findPreference(getString(R.string.CPU_POWER_MODE_KEY)); etModelDir = (EditTextPreference) findPreference(getString(R.string.MODEL_DIR_KEY)); etModelDir.setTitle("Model dir (SDCard: " + Utils.getSDCardDirectory() + ")"); etLabelPath = (EditTextPreference) findPreference(getString(R.string.LABEL_PATH_KEY)); etLabelPath.setTitle("Label path (SDCard: " + Utils.getSDCardDirectory() + ")"); etInputWidth = (EditTextPreference) findPreference(getString(R.string.INPUT_WIDTH_KEY)); etInputHeight = (EditTextPreference) findPreference(getString(R.string.INPUT_HEIGHT_KEY)); etInputMean = (EditTextPreference) findPreference(getString(R.string.INPUT_MEAN_KEY)); etInputStd = (EditTextPreference) findPreference(getString(R.string.INPUT_STD_KEY)); etScoreThreshold = (EditTextPreference) findPreference(getString(R.string.SCORE_THRESHOLD_KEY)); }
Example 18
Source File: SettingsActivity.java From Paddle-Lite-Demo with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setDisplayHomeAsUpEnabled(true); } // Initialize pre-installed models preInstalledModelDirs = new ArrayList<String>(); preInstalledLabelPaths = new ArrayList<String>(); preInstalledCPUThreadNums = new ArrayList<String>(); preInstalledCPUPowerModes = new ArrayList<String>(); preInstalledInputWidths = new ArrayList<String>(); preInstalledInputHeights = new ArrayList<String>(); preInstalledInputMeans = new ArrayList<String>(); preInstalledInputStds = new ArrayList<String>(); preInstalledModelDirs.add(getString(R.string.MODEL_DIR_DEFAULT)); preInstalledLabelPaths.add(getString(R.string.LABEL_PATH_DEFAULT)); preInstalledCPUThreadNums.add(getString(R.string.CPU_THREAD_NUM_DEFAULT)); preInstalledCPUPowerModes.add(getString(R.string.CPU_POWER_MODE_DEFAULT)); preInstalledInputWidths.add(getString(R.string.INPUT_WIDTH_DEFAULT)); preInstalledInputHeights.add(getString(R.string.INPUT_HEIGHT_DEFAULT)); preInstalledInputMeans.add(getString(R.string.INPUT_MEAN_DEFAULT)); preInstalledInputStds.add(getString(R.string.INPUT_STD_DEFAULT)); // Add mobilenet_v1_for_npu if Soc is kirin 810 or 990 if (Utils.isSupportedNPU()) { preInstalledModelDirs.add("models/mobilenet_v1_for_npu"); preInstalledLabelPaths.add("labels/synset_words.txt"); preInstalledCPUThreadNums.add("1"); // Useless for NPU preInstalledCPUPowerModes.add("LITE_POWER_HIGH"); // Useless for NPU preInstalledInputWidths.add("224"); preInstalledInputHeights.add("224"); preInstalledInputMeans.add("0.485,0.456,0.406"); preInstalledInputStds.add("0.229,0.224,0.225"); } else { Toast.makeText(this, "NPU model is not supported by your device.", Toast.LENGTH_LONG).show(); } // Setup UI components lpChoosePreInstalledModel = (ListPreference) findPreference(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY)); String[] preInstalledModelNames = new String[preInstalledModelDirs.size()]; for (int i = 0; i < preInstalledModelDirs.size(); i++) { preInstalledModelNames[i] = preInstalledModelDirs.get(i).substring(preInstalledModelDirs.get(i).lastIndexOf("/") + 1); } lpChoosePreInstalledModel.setEntries(preInstalledModelNames); lpChoosePreInstalledModel.setEntryValues(preInstalledModelDirs.toArray(new String[preInstalledModelDirs.size()])); lpCPUThreadNum = (ListPreference) findPreference(getString(R.string.CPU_THREAD_NUM_KEY)); lpCPUPowerMode = (ListPreference) findPreference(getString(R.string.CPU_POWER_MODE_KEY)); etModelDir = (EditTextPreference) findPreference(getString(R.string.MODEL_DIR_KEY)); etModelDir.setTitle("Model dir (SDCard: " + Utils.getSDCardDirectory() + ")"); etLabelPath = (EditTextPreference) findPreference(getString(R.string.LABEL_PATH_KEY)); etLabelPath.setTitle("Label path (SDCard: " + Utils.getSDCardDirectory() + ")"); etInputWidth = (EditTextPreference) findPreference(getString(R.string.INPUT_WIDTH_KEY)); etInputHeight = (EditTextPreference) findPreference(getString(R.string.INPUT_HEIGHT_KEY)); etInputMean = (EditTextPreference) findPreference(getString(R.string.INPUT_MEAN_KEY)); etInputStd = (EditTextPreference) findPreference(getString(R.string.INPUT_STD_KEY)); }
Example 19
Source File: DesktopModeFragment.java From Taskbar with Apache License 2.0 | 4 votes |
private void updateAdditionalSettings(boolean desktopModeEnabled) { finishedLoadingPrefs = false; boolean enabled = desktopModeEnabled && U.hasWriteSecureSettingsPermission(getActivity()) && U.isDesktopModeActive(getActivity()); findPreference(PREF_DISPLAY_DENSITY).setEnabled(enabled); if(U.isShowHideNavbarSupported()) { findPreference(PREF_AUTO_HIDE_NAVBAR_DESKTOP_MODE).setEnabled(enabled); findPreference(PREF_AUTO_HIDE_NAVBAR_DESKTOP_MODE).setOnPreferenceClickListener(this); } SharedPreferences pref = U.getSharedPreferences(getActivity()); DisplayInfo info = U.getExternalDisplayInfo(getActivity()); String densityPrefValue = info.currentDensity == info.defaultDensity ? "reset" : Integer.toString(info.currentDensity); pref.edit().putString(PREF_DISPLAY_DENSITY, densityPrefValue).apply(); String[] noDefaultList = getResources().getStringArray(R.array.tb_pref_display_density_list_alt); String[] noDefaultValues = getResources().getStringArray(R.array.tb_pref_display_density_list_values_alt); boolean useNoDefault = false; for(int i = 0; i < noDefaultValues.length; i++) { if(info.defaultDensity == Integer.parseInt(noDefaultValues[i])) { noDefaultList[i] = getString(R.string.tb_density_default, info.defaultDensity); noDefaultValues[i] = "reset"; useNoDefault = true; break; } } ListPreference densityPref = ((ListPreference) findPreference(PREF_DISPLAY_DENSITY)); if(useNoDefault) { densityPref.setEntries(noDefaultList); densityPref.setEntryValues(noDefaultValues); } else { densityPref.setEntries(R.array.tb_pref_display_density_list); densityPref.setEntryValues(R.array.tb_pref_display_density_list_values); } densityPref.setValue(densityPrefValue); bindPreferenceSummaryToValue(densityPref); if(densityPref.getSummary() == null || densityPref.getSummary().equals("")) densityPref.setSummary(getString(R.string.tb_density_custom, info.currentDensity)); finishedLoadingPrefs = true; }
Example 20
Source File: SettingsActivity.java From Paddle-Lite-Demo with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setDisplayHomeAsUpEnabled(true); } // initialized pre-installed models preInstalledModelPaths = new ArrayList<String>(); preInstalledLabelPaths = new ArrayList<String>(); preInstalledImagePaths = new ArrayList<String>(); preInstalledInputShapes = new ArrayList<String>(); preInstalledCPUThreadNums = new ArrayList<String>(); preInstalledCPUPowerModes = new ArrayList<String>(); preInstalledInputColorFormats = new ArrayList<String>(); preInstalledInputMeans = new ArrayList<String>(); preInstalledInputStds = new ArrayList<String>(); // add fused_deeplab_for_cpu preInstalledModelPaths.add(getString(R.string.MODEL_PATH_DEFAULT)); preInstalledLabelPaths.add(getString(R.string.LABEL_PATH_DEFAULT)); preInstalledImagePaths.add(getString(R.string.IMAGE_PATH_DEFAULT)); preInstalledCPUThreadNums.add(getString(R.string.CPU_THREAD_NUM_DEFAULT)); preInstalledCPUPowerModes.add(getString(R.string.CPU_POWER_MODE_DEFAULT)); preInstalledInputColorFormats.add(getString(R.string.INPUT_COLOR_FORMAT_DEFAULT)); preInstalledInputShapes.add(getString(R.string.INPUT_SHAPE_DEFAULT)); preInstalledInputMeans.add(getString(R.string.INPUT_MEAN_DEFAULT)); preInstalledInputStds.add(getString(R.string.INPUT_STD_DEFAULT)); // initialize UI components lpChoosePreInstalledModel = (ListPreference) findPreference(getString(R.string.CHOOSE_PRE_INSTALLED_MODEL_KEY)); String[] preInstalledModelNames = new String[preInstalledModelPaths.size()]; for (int i = 0; i < preInstalledModelPaths.size(); i++) { preInstalledModelNames[i] = preInstalledModelPaths.get(i).substring(preInstalledModelPaths.get(i).lastIndexOf("/") + 1); } lpChoosePreInstalledModel.setEntries(preInstalledModelNames); lpChoosePreInstalledModel.setEntryValues(preInstalledModelPaths.toArray(new String[preInstalledModelPaths.size()])); cbEnableCustomSettings = (CheckBoxPreference) findPreference(getString(R.string.ENABLE_CUSTOM_SETTINGS_KEY)); etModelPath = (EditTextPreference) findPreference(getString(R.string.MODEL_PATH_KEY)); etModelPath.setTitle("Model Path (SDCard: " + Utils.getSDCardDirectory() + ")"); etLabelPath = (EditTextPreference) findPreference(getString(R.string.LABEL_PATH_KEY)); etImagePath = (EditTextPreference) findPreference(getString(R.string.IMAGE_PATH_KEY)); lpCPUThreadNum = (ListPreference) findPreference(getString(R.string.CPU_THREAD_NUM_KEY)); lpCPUPowerMode = (ListPreference) findPreference(getString(R.string.CPU_POWER_MODE_KEY)); lpInputColorFormat = (ListPreference) findPreference(getString(R.string.INPUT_COLOR_FORMAT_KEY)); etInputShape = (EditTextPreference) findPreference(getString(R.string.INPUT_SHAPE_KEY)); etInputMean = (EditTextPreference) findPreference(getString(R.string.INPUT_MEAN_KEY)); etInputStd = (EditTextPreference) findPreference(getString(R.string.INPUT_STD_KEY)); }