android.preference.PreferenceCategory Java Examples

The following examples show how to use android.preference.PreferenceCategory. 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: SettingsFragment.java    From sms-ticket with Apache License 2.0 7 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
private void fillDualSimList(PreferenceScreen preferenceScreen) {
    PreferenceCategory category = (PreferenceCategory) preferenceScreen.findPreference("sms_category");
    ListPreference preference = (ListPreference) category.findPreference(Preferences.DUALSIM_SIM);
    List<String> simIds = new ArrayList<>();
    List<String> simNames = new ArrayList<>();
    simIds.add(String.valueOf(Preferences.VALUE_DEFAULT_SIM));
    simNames.add(getString(R.string.sim_default));
    SubscriptionManager subscriptionManager = SubscriptionManager.from(getActivity());
    for (SubscriptionInfo subscriptionInfo : subscriptionManager.getActiveSubscriptionInfoList()) {
        simIds.add(String.valueOf(subscriptionInfo.getSubscriptionId()));
        simNames.add(getString(R.string.sim_name, subscriptionInfo.getSimSlotIndex() + 1, subscriptionInfo
            .getDisplayName()));
    }
    preference.setEntries(simNames.toArray(new String[simNames.size()]));
    preference.setEntryValues(simIds.toArray(new String[simIds.size()]));
    preference.setDefaultValue(String.valueOf(Preferences.VALUE_DEFAULT_SIM));
    preference.setSummary(preference.getEntry());
}
 
Example #2
Source File: SettingsActivity.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);

    // Add 'data and sync' preferences, and a corresponding header.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.pref_header_server);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.pref_server);

    // Bind the summaries of EditText/List/Dialog/Ringtone preferences to
    // their values. When their values change, their summaries are updated
    // to reflect the new value, per the Android Design guidelines.
    bindPreferenceSummaryToValue(findPreference("server_custom_url"));
    bindPreferenceSummaryToValue(findPreference("server_custom_sender_id"));

    findPreference("general_reset").setOnPreferenceClickListener(sBindOnPreferenceClickListener);
    findPreference("server_register").setOnPreferenceClickListener(sBindOnPreferenceClickListener);
}
 
Example #3
Source File: StealthSettingActivity.java    From droid-stealth with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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.

    /*Empty for now. Can be used for general settings. Needs to be set, otherwise
     *getPreferenceScreen() returns null.
     */
    addPreferencesFromResource(R.xml.pref_general);

    // Add 'sharing' preferences, and a corresponding header.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.pref_header_sharing);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.pref_sharing);

    // Bind the summaries of EditText/List/Dialog preferences to
    // their values. When their values change, their summaries are updated
    // to reflect the new value, per the Android Design guidelines.
    bindPreferenceSummaryToValue(findPreference(getString(R.string.key_pref_ssid)));
    bindPreferenceSummaryToValue(findPreference(getString(R.string.key_pref_pass)));
}
 
Example #4
Source File: SettingsFragment.java    From NightWidget with GNU General Public License v2.0 6 votes vote down vote up
private void initSummary(Preference p) {

		if (p instanceof PreferenceCategory) {
			PreferenceCategory pCat = (PreferenceCategory) p;
			for (int i = 0; i < pCat.getPreferenceCount(); i++) {
				initSummary(pCat.getPreference(i));
			}

		} else if (p instanceof PreferenceScreen) {
			PreferenceScreen pSc = (PreferenceScreen) p;
			for (int i = 0; i < pSc.getPreferenceCount(); i++) {
				initSummary(pSc.getPreference(i));
			}

		} else {

			updatePrefSummary(p);
		}
	}
 
Example #5
Source File: AdvancedSettingsFragment.java    From FwdPortForwardingApp with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.advanced_preferences);
    advertisementsEnabled = (Preference) findPreference(getString(R.string.pref_disable_ads_key));

    // Remove advertisements option
    PreferenceGroup mCategory = (PreferenceCategory) findPreference("pref_advanced_category");
    mCategory.removePreference(advertisementsEnabled);

    ipChecker = (Preference) findPreference(getString(R.string.pref_ip_checker));
    ipChecker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent ipCheckerActivity = new Intent(getActivity(), IpAddressCheckerActivity.class);
            startActivity(ipCheckerActivity);
            return true;
        }
    });

}
 
Example #6
Source File: SettingsActivity.java    From logmein-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);

    // Add 'notifications' preferences, and a corresponding header.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(org.developfreedom.logmein.R.string.pref_header_notifications);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(org.developfreedom.logmein.R.xml.pref_notification);

}
 
Example #7
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Accountant.getInstance(getActivity());
    getActivity().setTitle(getString(R.string.media_settings));
    addPreferencesFromResource(R.xml.media_preferences);

    // Check whether to show the notification-ringer volume link setting.
    AudioManager manager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
    RingerNotificationLink linkChecker = new RingerNotificationLink();
    boolean isNotifRingLinked = linkChecker.apply(manager);
    Preference link = findPreference("VolumePanel_linkNotifRinger");
    link.setEnabled(!isNotifRingLinked);
    if (isNotifRingLinked) {
        PreferenceCategory category = (PreferenceCategory) findPreference("AudioMedia");
        category.removePreference(link);
    }
}
 
Example #8
Source File: SettingsActivity.java    From HayaiLauncher with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	addPreferencesFromResource(R.xml.preferences);

	if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
		//remove priority preference (not supported)
		PreferenceCategory notificationCategory =
				(PreferenceCategory) findPreference("pref_category_notification");
		ListPreference priorityPreference =
				(ListPreference) findPreference("pref_notification_priority");
		notificationCategory.removePreference(priorityPreference);
	}
}
 
Example #9
Source File: MobileMainActivity.java    From android-wear-gopro-remote with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);
    bindPreferencesSummaryToValue(getPreferenceScreen());
    mPrefCategoryWatch = (PreferenceCategory)findPreference(getString(R.string.preference_category_watch_key));
    fCurrentWearSettings = new WearSettings();
    fCurrentWearSettings.loadFromPreferences(this, PreferenceManager.getDefaultSharedPreferences(this));

    mWifiNamePref = ((EditTextPreference)findPreference(getString(R.string.preference_wifi_name_key)));
    mWifiPassPref = ((EditTextPreference)findPreference(getString(R.string.preference_wifi_password_key)));

    Preference version = findPreference("preference_version_number");
    version.setTitle(BuildConfig.VERSION_NAME);
    version.setSummary(BuildConfig.FLAVOR + " " + BuildConfig.BUILD_TYPE);
}
 
Example #10
Source File: SettingsActivity.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);

    // Add 'data and sync' preferences, and a corresponding header.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.pref_header_server);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.pref_server);

    // Bind the summaries of EditText/List/Dialog/Ringtone preferences to
    // their values. When their values change, their summaries are updated
    // to reflect the new value, per the Android Design guidelines.
    bindPreferenceSummaryToValue(findPreference("server_custom_url"));
    bindPreferenceSummaryToValue(findPreference("server_custom_sender_id"));

    findPreference("general_reset").setOnPreferenceClickListener(sBindOnPreferenceClickListener);
    findPreference("server_register").setOnPreferenceClickListener(sBindOnPreferenceClickListener);
}
 
Example #11
Source File: BlackListFragment.java    From Botifier with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	mSharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
	setHasOptionsMenu(true);
	addPreferencesFromResource(R.xml.list_preference);
	mBlackList = (PreferenceCategory) findPreference(getString(R.string.cat_filterlist));
	Set<String> entries = mSharedPref.getStringSet(getString(R.string.pref_blacklist), null);
	if (entries == null) {
		mBlackListEntries = new HashSet<String>();
	} else {
		mBlackListEntries = new HashSet<String>(entries);
	}
	for (String blackitem : mBlackListEntries) {
		Preference test = new Preference(getActivity());
		test.setTitle(blackitem);
		mBlackList.addPreference(test);
	}
}
 
Example #12
Source File: OpenFitActivity.java    From OpenFit with MIT License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    final String packageName = intent.getStringExtra(OpenFitIntent.EXTRA_PACKAGE_NAME);
    final String appName = intent.getStringExtra(OpenFitIntent.EXTRA_APP_NAME);
    Log.d(LOG_TAG, "Recieved del application: "+appName+" : "+packageName);
    appManager.delNotificationApp(packageName);
    oPrefs.removeSet(packageName);
    oPrefs.removeString(packageName);
    PreferenceCategory category = (PreferenceCategory) findPreference("preference_category_apps");
    Preference app = (Preference) findPreference(packageName);
    category.removePreference(app);
    // If no more preference in the category, restore the placeholder
    if(category.getPreferenceCount() <= 0) {
        category.addPreference(preference_apps_placeholder);
    }
    sendNotificationApplications();
}
 
Example #13
Source File: NWPreferences.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    screen = (PreferenceScreen) findPreference("preferenceScreen");
    category = (PreferenceCategory) findPreference("collection_category");
    collectionMethod = findPreference("dex_collection_method");
    showBridgeBattery = findPreference("showBridgeBattery");
    watchcategory = (PreferenceCategory) findPreference("category");
    bindPreferenceSummaryToValue(collectionMethod);
    listenForChangeInSettings();
    setCollectionPrefs();
}
 
Example #14
Source File: SettingsFragment.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle bundle) {
	super.onCreate(bundle);
	if(Build.VERSION.SDK_INT >= 21) {
		CheckBoxPreference mediaButtons = (CheckBoxPreference) findPreference("mediaButtons");
		if (mediaButtons != null) {
			PreferenceCategory otherCategory = (PreferenceCategory) findPreference("otherSettings");
			otherCategory.removePreference(mediaButtons);
		}
	}

	int instance = this.getArguments().getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, -1);
	if (instance != -1) {
		PreferenceScreen preferenceScreen = expandServer(instance);
		setPreferenceScreen(preferenceScreen);

		serverSettings.put(Integer.toString(instance), new ServerSettings(instance));
		onInitPreferences(preferenceScreen);
	}

}
 
Example #15
Source File: General.java    From redalert-android with Apache License 2.0 6 votes vote down vote up
void initializeUI() {
    // Allow click on home button
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Load settings from XML There is no non-deprecated way to do it on API Level 7
    addPreferencesFromResource(R.xml.settings);

    // Cache resource IDs
    mRate = findPreference(getString(R.string.ratePref));
    mWebsite = findPreference(getString(R.string.websitePref));
    mContact = findPreference(getString(R.string.contactPref));
    mAdvanced = findPreference(getString(R.string.advancedPref));
    mTestAlert = findPreference(getString(R.string.selfTestPref));
    mLifeshield = findPreference(getString(R.string.lifeshieldPref));
    mMainCategory = (PreferenceCategory) findPreference(getString(R.string.mainCategoryPref));
    mCitySelection = ((SearchableMultiSelectPreference) findPreference(getString(R.string.selectedCitiesPref)));
    mZoneSelection = ((SearchableMultiSelectPreference) findPreference(getString(R.string.selectedZonesPref)));
    mLanguageSelection = (ListPreference) findPreference(getString(R.string.langPref));

    // Populate setting values
    initializeSettings();

    // Set up listeners
    initializeListeners();
}
 
Example #16
Source File: SettingsActivity.java    From NetworkMapper with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);

    // Add 'advanced' preferences, and a corresponding header.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.pref_header_advanced);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.pref_advanced);

    // Bind the summaries of EditText/List/Dialog/Ringtone preferences to
    // their values. When their values change, their summaries are updated
    // to reflect the new value, per the Android Design guidelines.
    bindPreferenceSummaryToValue(findPreference("pref_defaultopts"));
    // Advanced
    bindPreferenceSummaryToValue(findPreference("pref_updateurl"));
    bindPreferenceSummaryToValue(findPreference("pref_binaryloc"));
}
 
Example #17
Source File: ConfigurationActivity.java    From Noyze with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Accountant.getInstance(getActivity());
    getActivity().setTitle(getString(R.string.media_settings));
    addPreferencesFromResource(R.xml.media_preferences);

    // Check whether to show the notification-ringer volume link setting.
    AudioManager manager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
    RingerNotificationLink linkChecker = new RingerNotificationLink();
    boolean isNotifRingLinked = linkChecker.apply(manager);
    Preference link = findPreference("VolumePanel_linkNotifRinger");
    link.setEnabled(!isNotifRingLinked);
    if (isNotifRingLinked) {
        PreferenceCategory category = (PreferenceCategory) findPreference("AudioMedia");
        category.removePreference(link);
    }
}
 
Example #18
Source File: SwitchAccessPreferenceActivity.java    From talkback with Apache License 2.0 6 votes vote down vote up
private void adjustHighlightingPrefs() {
  PreferenceCategory customizeScanningCategory =
      (PreferenceCategory) findPreference(R.string.pref_category_display_and_sound_key);
  int[] highlightPrefKeys = {
    R.string.pref_highlight_0_key,
    R.string.pref_highlight_1_key,
    R.string.pref_highlight_2_key,
    R.string.pref_highlight_3_key,
    R.string.pref_highlight_4_key
  };
  if (SwitchAccessPreferenceUtils.isGroupSelectionEnabled(getActivity())) {
    // Configure the switch names. User-facing numbers start at 1
    addPreferenceIfPreviouslyRemoved(customizeScanningCategory, R.string.pref_highlights_key);
    for (int i = 0; i < highlightPrefKeys.length; i++) {
      findPreference(highlightPrefKeys[i])
          .setTitle(getString(R.string.option_scan_switch_format, i + 1));
    }
    removeAndSavePreference(customizeScanningCategory, R.string.pref_standard_highlight_key);
  } else {
    addPreferenceIfPreviouslyRemoved(
        customizeScanningCategory, R.string.pref_standard_highlight_key);
    removeAndSavePreference(customizeScanningCategory, R.string.pref_highlights_key);
  }
}
 
Example #19
Source File: GatewayEditTextPreferenceTest.java    From openwebnet-android with MIT License 6 votes vote down vote up
private void initGatewayEditTextPreference(Preference preference) {
    if (preference instanceof PreferenceGroup) {
        PreferenceGroup preferenceGroup = (PreferenceGroup) preference;
        for (int i=0; i<preferenceGroup.getPreferenceCount(); i++) {
            if (preferenceGroup.getPreference(i).getTitle().equals("Gateway")) {
                PreferenceCategory preferenceCategory = (PreferenceCategory) preferenceGroup.getPreference(i);
                initGatewayEditTextPreference(preferenceCategory.getPreference(0));
            } else {
                initGatewayEditTextPreference(preferenceGroup.getPreference(i));
            }
        }
    } else if (preference instanceof EditTextPreference) {
        // TODO wrong ClassCastException ?!?!
        gatewayEditTextPreference = (GatewayEditTextPreference) preference;
    }
}
 
Example #20
Source File: SettingsFragment.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	addPreferencesFromResource(R.xml.preferences);

	// Remove from standard preferences if the flag ONLY_INTERNAL_STORAGE is false
	if (!Config.ONLY_INTERNAL_STORAGE) {
		PreferenceCategory mCategory = (PreferenceCategory) findPreference("security_options");
		if (mCategory != null) {
			Preference cleanCache = findPreference("clean_cache");
			Preference cleanPrivateStorage = findPreference("clean_private_storage");
			mCategory.removePreference(cleanCache);
			mCategory.removePreference(cleanPrivateStorage);
		}
	}
	Compatibility.removeUnusedPreferences(this);

	if (!TextUtils.isEmpty(page)) {
		openPreferenceScreen(page);
	}

}
 
Example #21
Source File: PADherderAccountsPreferenceFragment.java    From PADListener with GNU General Public License v2.0 5 votes vote down vote up
private void addPreferencesForOneAccount(int accountId) {
	MyLog.entry("accountId = " + accountId);

	final PreferenceCategory accountCategory = new PreferenceCategory(getActivity());
	accountCategory.setTitle(getString(R.string.settings_padherder_account_category, accountId));
	accountsByPosition.put(accountId, accountCategory);
	getPreferenceScreen().addPreference(accountCategory);

	final EditTextPreference accountName = new EditTextPreference(getActivity());
	accountName.setKey("padherder_name_" + accountId);
	accountName.setTitle(R.string.settings_padherder_name_title);
	accountName.setDialogTitle(R.string.settings_padherder_name_title);
	accountName.setSummary(R.string.settings_padherder_name_summary);
	accountCategory.addPreference(accountName);

	final EditTextPreference accountLogin = new EditTextPreference(getActivity());
	accountLogin.setKey("padherder_login_" + accountId);
	accountLogin.setTitle(R.string.settings_padherder_login_title);
	accountLogin.setDialogTitle(R.string.settings_padherder_login_title);
	accountLogin.setSummary(R.string.settings_padherder_login_summary);
	accountCategory.addPreference(accountLogin);

	final EditTextPreference accountPassword = new EditTextPreference(getActivity());
	accountPassword.setKey("padherder_password_" + accountId);
	accountPassword.setTitle(R.string.settings_padherder_password_title);
	accountPassword.setDialogTitle(R.string.settings_padherder_password_title);
	accountPassword.setSummary(R.string.settings_padherder_password_summary);
	accountPassword.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
	accountCategory.addPreference(accountPassword);

	MyLog.exit();
}
 
Example #22
Source File: OpenFitActivity.java    From OpenFit with MIT License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    final String packageName = intent.getStringExtra(OpenFitIntent.EXTRA_PACKAGE_NAME);
    final String appName = intent.getStringExtra(OpenFitIntent.EXTRA_APP_NAME);
    Log.d(LOG_TAG, "Recieved add application: "+appName+" : "+packageName);
    appManager.addNotificationApp(packageName);
    oPrefs.saveSet(packageName);
    oPrefs.saveString(packageName, appName);
    Preference app = createAppPreference(packageName, appName);
    PreferenceCategory category = (PreferenceCategory) findPreference("preference_category_apps");
    category.removePreference(preference_apps_placeholder);
    category.addPreference(app);
    sendNotificationApplications();
}
 
Example #23
Source File: PreferenceFragment.java    From material-preferences with MIT License 5 votes vote down vote up
private ArrayList<Preference> getAllPreferenceScreen(Preference p, ArrayList<Preference> list) {
    if( p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
        PreferenceGroup pGroup = (PreferenceGroup) p;
        int pCount = pGroup.getPreferenceCount();
        if(p instanceof PreferenceScreen){
            list.add(p);
        }
        for(int i = 0; i < pCount; i++) {
            getAllPreferenceScreen(pGroup.getPreference(i), list);
        }
    }
    return list;
}
 
Example #24
Source File: ReviewBootPreferenceFragment.java    From android-kernel-tweaker with GNU General Public License v3.0 5 votes vote down vote up
private void createListPreference(PreferenceCategory mCategory,  
		String fPath, String fName, String value,String[] entries, String[] names, String color, 
		final String category, boolean excludeEdit) {

	final CustomListPreference pref = new CustomListPreference(mContext, category);
	pref.setTitle(fName);
	pref.setTitleColor(color);
	pref.setSummary(value);
	pref.setEntries(names);
	pref.setEntryValues(entries);
	pref.hideBoot(true);
	pref.setKey(fPath);
	Log.d("CONTENT", value);
	mCategory.addPreference(pref);
	if(!excludeEdit) {
		pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener(){

			@Override
			public boolean onPreferenceChange(final Preference p, Object newValue) {
				// TODO Auto-generated method stub
				p.setSummary((String)newValue);
				pref.setValue(p.getSummary().toString());
				CMDProcessor.runSuCommand("echo \""+(String)newValue+"\" > "+p.getKey());
				updateDb(p, (String)newValue, true, category);
				return true;
			}

		});
	}
}
 
Example #25
Source File: MakabaModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
/** Добавить категорию настроек домена (в т.ч. https) */
private void addDomainPreferences(PreferenceGroup group) {
    Context context = group.getContext();
    Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) {
                updateDomain((String) newValue, preferences.getBoolean(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA), true));
                return true;
            } else if (preference.getKey().equals(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA))) {
                updateDomain(preferences.getString(getSharedKey(PREF_KEY_DOMAIN), DEFAULT_DOMAIN), (boolean)newValue);
                return true;
            }
            return false;
        }
    };
    PreferenceCategory domainCat = new PreferenceCategory(context);
    domainCat.setTitle(R.string.makaba_prefs_domain_category);
    group.addPreference(domainCat);
    EditTextPreference domainPref = new EditTextPreference(context); //поле ввода домена
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    domainPref.setOnPreferenceChangeListener(updateDomainListener);
    domainCat.addPreference(domainPref);
    CheckBoxPreference httpsPref = new LazyPreferences.CheckBoxPreference(context); //чекбокс "использовать https"
    httpsPref.setTitle(R.string.pref_use_https);
    httpsPref.setSummary(R.string.pref_use_https_summary);
    httpsPref.setKey(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA));
    httpsPref.setDefaultValue(true);
    httpsPref.setOnPreferenceChangeListener(updateDomainListener);
    domainCat.addPreference(httpsPref);
}
 
Example #26
Source File: AbstractChanModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Добавить в группу параметров (на экран/в категорию) новую категорию настроек прокси-сервера
 * @param group группа, на которую добавляются параметры
 */
protected void addProxyPreferences(PreferenceGroup group) {
    final Context context = group.getContext();
    PreferenceCategory proxyCat = new PreferenceCategory(context); //категория настроек прокси
    proxyCat.setTitle(R.string.pref_cat_proxy);
    group.addPreference(proxyCat);
    CheckBoxPreference useProxyPref = new LazyPreferences.CheckBoxPreference(context); //чекбокс "использовать ли прокси вообще"
    useProxyPref.setTitle(R.string.pref_use_proxy);
    useProxyPref.setSummary(R.string.pref_use_proxy_summary);
    useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY));
    useProxyPref.setDefaultValue(false);
    useProxyPref.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(useProxyPref);
    EditTextPreference proxyHostPref = new LazyPreferences.EditTextPreference(context); //поле ввода адреса прокси-сервера
    proxyHostPref.setTitle(R.string.pref_proxy_host);
    proxyHostPref.setDialogTitle(R.string.pref_proxy_host);
    proxyHostPref.setSummary(R.string.pref_proxy_host_summary);
    proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST));
    proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST);
    proxyHostPref.getEditText().setSingleLine();
    proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    proxyHostPref.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(proxyHostPref);
    proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
    EditTextPreference proxyHostPort = new LazyPreferences.EditTextPreference(context); //поле ввода порта прокси-сервера
    proxyHostPort.setTitle(R.string.pref_proxy_port);
    proxyHostPort.setDialogTitle(R.string.pref_proxy_port);
    proxyHostPort.setSummary(R.string.pref_proxy_port_summary);
    proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT));
    proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT);
    proxyHostPort.getEditText().setSingleLine();
    proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    proxyHostPort.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(proxyHostPort);
    proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
}
 
Example #27
Source File: DeviceAdminSample.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.device_admin_quality);

    mQualityCategory = (PreferenceCategory) findPreference(KEY_CATEGORY_QUALITY);
    mPasswordQuality = (ListPreference) findPreference(KEY_QUALITY);
    mMinLength = (EditTextPreference) findPreference(KEY_MIN_LENGTH);
    mMinLetters = (EditTextPreference) findPreference(KEY_MIN_LETTERS);
    mMinNumeric = (EditTextPreference) findPreference(KEY_MIN_NUMERIC);
    mMinLowerCase = (EditTextPreference) findPreference(KEY_MIN_LOWER_CASE);
    mMinUpperCase = (EditTextPreference) findPreference(KEY_MIN_UPPER_CASE);
    mMinSymbols = (EditTextPreference) findPreference(KEY_MIN_SYMBOLS);
    mMinNonLetter = (EditTextPreference) findPreference(KEY_MIN_NON_LETTER);

    mPasswordQuality.setOnPreferenceChangeListener(this);
    mMinLength.setOnPreferenceChangeListener(this);
    mMinLetters.setOnPreferenceChangeListener(this);
    mMinNumeric.setOnPreferenceChangeListener(this);
    mMinLowerCase.setOnPreferenceChangeListener(this);
    mMinUpperCase.setOnPreferenceChangeListener(this);
    mMinSymbols.setOnPreferenceChangeListener(this);
    mMinNonLetter.setOnPreferenceChangeListener(this);

    // Finish setup of the quality dropdown
    mPasswordQuality.setEntryValues(mPasswordQualityValueStrings);
}
 
Example #28
Source File: SettingsFragment.java    From MedtronicUploader with GNU General Public License v2.0 5 votes vote down vote up
private void initSummary(Preference p) {
    if (p instanceof PreferenceCategory) {
        PreferenceCategory pCat = (PreferenceCategory) p;
        for (int i = 0; i < pCat.getPreferenceCount(); i++) {
            initSummary(pCat.getPreference(i));
        }
    } else {
        updatePrefSummary(p);
    }
}
 
Example #29
Source File: SavePasswordsPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    resetList(PREF_CATEGORY_SAVED_PASSWORDS_NO_TEXT);

    mNoPasswords = count == 0;
    if (mNoPasswords) {
        if (mNoPasswordExceptions) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS);
    profileCategory.setTitle(R.string.section_saved_passwords);
    profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        PasswordUIView.SavedPasswordEntry saved =
                mPasswordManagerHandler.getSavedPasswordEntry(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        String url = saved.getUrl();
        String name = saved.getUserName();
        screen.setTitle(url);
        screen.setOnPreferenceClickListener(this);
        screen.setSummary(name);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_NAME, name);
        args.putString(PASSWORD_LIST_URL, url);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example #30
Source File: Pref.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
public static Preference Preference(Context context, PreferenceCategory category, int caption, int summary, boolean enabled, Preference.OnPreferenceClickListener onClick) {
	Preference retval = new Preference(context);
	if (caption > 0) retval.setTitle(caption);
	if (summary > 0) retval.setSummary(summary);
	retval.setEnabled(enabled);
	if (onClick != null) {
		retval.setOnPreferenceClickListener(onClick);
	}
	if (category != null) category.addPreference(retval);
	return retval;
}