Java Code Examples for android.preference.PreferenceCategory#addPreference()

The following examples show how to use android.preference.PreferenceCategory#addPreference() . 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: 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 2
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 3
Source File: SavePasswordsPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordExceptionListAvailable(int count) {
    resetList(PREF_CATEGORY_EXCEPTIONS);
    resetList(PREF_CATEGORY_SAVED_PASSWORDS_NO_TEXT);

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

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_EXCEPTIONS);
    profileCategory.setTitle(R.string.section_saved_passwords_exceptions);
    profileCategory.setOrder(ORDER_EXCEPTIONS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        String exception = mPasswordManagerHandler.getSavedPasswordException(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        screen.setTitle(exception);
        screen.setOnPreferenceClickListener(this);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_URL, exception);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example 4
Source File: Pref.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
public static EditTextPreference Edit(Context context, PreferenceCategory category, String caption, String summary, String dialogCaption, String key, Object defaultValue, boolean enabled, Integer type) {
	EditTextPreference retval = new EditTextPreference(context);
	retval.setTitle(caption);
	retval.setSummary(summary);
	retval.setEnabled(enabled);
	retval.setKey(key);
	retval.setDefaultValue(defaultValue);
	retval.setDialogTitle(dialogCaption);
	if (type != null) {
		retval.getEditText().setInputType(type);
	}
	if (category != null) category.addPreference(retval);
	return retval;
}
 
Example 5
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 6
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 7
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 8
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 9
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 10
Source File: ExportActivity.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
private DistanceEditTextPreference editDistance(Context context, PreferenceCategory category, int caption, int summary, int dialogCaption, String key, Object defaultValue, boolean enabled) {
	DistanceEditTextPreference retval = new DistanceEditTextPreference(context);
	retval.setMetric(metric);
	if (caption > 0) retval.setTitle(caption);
	if (summary > 0) retval.setSummary(summary);
	retval.setEnabled(enabled);
	retval.setKey(key);
	retval.setDefaultValue(defaultValue);
	if (dialogCaption > 0) retval.setDialogTitle(dialogCaption);
	retval.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
	if (category != null) category.addPreference(retval);
	return retval;
}
 
Example 11
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 12
Source File: Pref.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
public static EditTextPreference Edit(Context context, PreferenceCategory category, int caption, int summary, int dialogCaption, String key, Object defaultValue, boolean enabled, Integer type) {
	EditTextPreference retval = new EditTextPreference(context);
	if (caption > 0) retval.setTitle(caption);
	if (summary > 0) retval.setSummary(summary);
	retval.setEnabled(enabled);
	retval.setKey(key);
	retval.setDefaultValue(defaultValue);
	if (dialogCaption > 0) retval.setDialogTitle(dialogCaption);
	if (type != null) {
		retval.getEditText().setInputType(type);
	}
	if (category != null) category.addPreference(retval);
	return retval;
}
 
Example 13
Source File: Pref.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
public static ListPreference List(Context context, PreferenceCategory category, String caption, String summary, String dialogCaption, String key, Object defaultValue, CharSequence[] entries, CharSequence[] entryValues, boolean enabled) {
	ListPreference retval = new ListPreference(context);
	retval.setTitle(caption);
	retval.setSummary(summary);
	retval.setEnabled(enabled);
	retval.setKey(key);
	retval.setDefaultValue(defaultValue);
	retval.setDialogTitle(dialogCaption);
	retval.setEntries(entries);
	retval.setEntryValues(entryValues);    	
	if (category != null) category.addPreference(retval);
	return retval;
}
 
Example 14
Source File: SavePasswordsPreferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordExceptionListAvailable(int count) {
    resetList(PREF_CATEGORY_EXCEPTIONS);
    mNoPasswordExceptions = count == 0;
    if (mNoPasswordExceptions) {
        if (mNoPasswords) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_EXCEPTIONS);
    profileCategory.setTitle(R.string.section_saved_passwords_exceptions);
    profileCategory.setOrder(ORDER_EXCEPTIONS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        String exception = mPasswordManagerHandler.getSavedPasswordException(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        screen.setTitle(exception);
        screen.setOnPreferenceClickListener(this);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_URL, exception);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example 15
Source File: SavePasswordsPreferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    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 16
Source File: SavePasswordsPreferences.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordExceptionListAvailable(int count) {
    resetList(PREF_CATEGORY_EXCEPTIONS);
    mNoPasswordExceptions = count == 0;
    if (mNoPasswordExceptions) {
        if (mNoPasswords) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_EXCEPTIONS);
    profileCategory.setTitle(R.string.section_saved_passwords_exceptions);
    profileCategory.setOrder(ORDER_EXCEPTIONS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        String exception = mPasswordManagerHandler.getSavedPasswordException(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        screen.setTitle(exception);
        screen.setOnPreferenceClickListener(this);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_URL, exception);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example 17
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, String caption, String summary, boolean enabled, Preference.OnPreferenceClickListener onClick) {
	Preference retval = new Preference(context);
	retval.setTitle(caption);
	retval.setSummary(summary);
	retval.setEnabled(enabled);
	if (onClick != null) {
		retval.setOnPreferenceClickListener(onClick);
	}
	if (category != null) category.addPreference(retval);
	return retval;
}
 
Example 18
Source File: SettingsFragment.java    From Linphone4Android with GNU General Public License v3.0 5 votes vote down vote up
private void initAccounts() {
	PreferenceCategory accounts = (PreferenceCategory) findPreference(getString(R.string.pref_sipaccounts_key));
	accounts.removeAll();

	// Get already configured extra accounts
	int defaultAccountID = mPrefs.getDefaultAccountIndex();
	int nbAccounts = mPrefs.getAccountCount();
	for (int i = 0; i < nbAccounts; i++) {
		final int accountId = i;
		// For each, add menus to configure it
		String username = mPrefs.getAccountUsername(accountId);
		String domain = mPrefs.getAccountDomain(accountId);
		LedPreference account = new LedPreference(getActivity());

		if (username == null) {
			account.setTitle(getString(R.string.pref_sipaccount));
		} else {
			account.setTitle(username + "@" + domain);
		}

		if (defaultAccountID == i) {
			account.setSummary(R.string.default_account_flag);
		}

		account.setOnPreferenceClickListener(new OnPreferenceClickListener()
		{
			public boolean onPreferenceClick(Preference preference) {
				LinphoneActivity.instance().displayAccountSettings(accountId);
				return false;
			}
		});
		updateAccountLed(account, username, domain, mPrefs.isAccountEnabled(i));
		accounts.addPreference(account);
	}
}
 
Example 19
Source File: SettingsFragment.java    From NewsPushMonitor with Apache License 2.0 5 votes vote down vote up
private void addMonitorApp(String pkg) {
    if (TextUtils.isEmpty(pkg)) {
        return;
    }

    PreferenceManager manager = getPreferenceManager();
    try {
        PreferenceScreen screen = (PreferenceScreen) RefUtil.callDeclaredMethod(manager,
                "inflateFromResource",
                new Class[]{Context.class, int.class, PreferenceScreen.class},
                getActivity(), R.xml.prefs_monitor_apps, null);
        screen.setKey(pkg);
        screen.setTitle(pkg);
        screen.setSummary(getMonitorAppSummary(pkg, null));

        PreferenceGroup appConfigPref = (PreferenceGroup) screen.findPreference("monitor_app_config_pref");
        appConfigPref.setTitle(pkg);

        Preference titleViewIdPref = appConfigPref.findPreference("title_view_id_pref");
        titleViewIdPref.setKey(GlobalConfig.getSharedPrefKeyForTitleId(pkg));
        titleViewIdPref.getExtras().putString(KEY_PREF_EXTRA, pkg);
        titleViewIdPref.setOnPreferenceChangeListener(mOnPreferenceChangeListener);

        Preference contentViewIdPref = appConfigPref.findPreference("content_view_id_pref");
        contentViewIdPref.setKey(GlobalConfig.getSharedPrefKeyForContentId(pkg));
        contentViewIdPref.getExtras().putString(KEY_PREF_EXTRA, pkg);
        contentViewIdPref.setOnPreferenceChangeListener(mOnPreferenceChangeListener);

        PreferenceCategory container = (PreferenceCategory)
                getPreferenceManager().findPreference("monitor_apps_pref");
        container.addPreference(screen);
    } catch (Exception e) {
        LogWriter.e(TAG, "Add monitor ppp to preference error!", e);
    }
}
 
Example 20
Source File: SettingsActivity.java    From javainstaller with GNU General Public License v3.0 4 votes vote down vote up
private PreferenceScreen createPreferenceHierarchy() {

       CharSequence[] cs = new String[] { "Terminal Emulator", "Run Activity", "auto" };
       CharSequence[] cs2 = new String[] { "off", "on" };

       // Root
       PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
       PreferenceCategory dialogBasedPrefCat = new PreferenceCategory(this);
       dialogBasedPrefCat.setTitle("install");
       root.addPreference(dialogBasedPrefCat); // Adding a category

       // List preference under the category
       ListPreference listPref = new ListPreference(this);
       listPref.setKey("runmode");
       listPref.setDefaultValue(cs[2]);
       listPref.setEntries(cs);
       listPref.setEntryValues(cs);
       listPref.setDialogTitle("run install.sh in");
       listPref.setTitle("run install.sh in");
       listPref.setSummary("run install.sh in");
       dialogBasedPrefCat.addPreference(listPref);
       ListPreference rootmode = new ListPreference(this);
       rootmode.setKey("rootmode");
       rootmode.setDefaultValue(cs2[0]);
       rootmode.setEntries(cs2);
       rootmode.setEntryValues(cs2);
       rootmode.setDialogTitle("run install.sh as superuser");
       rootmode.setTitle("run install.sh as superuser");
       rootmode.setSummary("root required");
       dialogBasedPrefCat.addPreference(rootmode);
       
       PreferenceCategory dialogBasedPrefCat2 = new PreferenceCategory(this);
       dialogBasedPrefCat2.setTitle("run");
       root.addPreference(dialogBasedPrefCat2); // Adding a category

       // List preference under the category
       CharSequence[] csjar = new String[] { "Terminal Emulator", "Run Activity" };
       ListPreference listPref2 = new ListPreference(this);
       listPref2.setKey("runmode2");
       listPref2.setDefaultValue(csjar[1]);
       listPref2.setEntries(csjar);
       listPref2.setEntryValues(csjar);
       listPref2.setDialogTitle("run jar file in");
       listPref2.setTitle("run jar file in");
       listPref2.setSummary("run jar file in");
       dialogBasedPrefCat2.addPreference(listPref2);
       ListPreference rootmode2 = new ListPreference(this);
       rootmode2.setKey("rootmode2");
       rootmode2.setDefaultValue(cs2[0]);
       rootmode2.setEntries(cs2);
       rootmode2.setEntryValues(cs2);
       rootmode2.setDialogTitle("run jar file as superuser");
       rootmode2.setTitle("run jar file as superuser");
       rootmode2.setSummary("root required");
       dialogBasedPrefCat2.addPreference(rootmode2);
       
       PreferenceCategory dialogBasedPrefCat3 = new PreferenceCategory(this);
       dialogBasedPrefCat3.setTitle("path broadcast");
       root.addPreference(dialogBasedPrefCat3); // Adding a category

       // List preference under the category
       CharSequence[] cspath = new String[] { "on", "off", "if jamvm is installed" };
       ListPreference listPref3 = new ListPreference(this);
       listPref3.setKey("broadcast");
       listPref3.setDefaultValue(cspath[2]);
       listPref3.setEntries(cspath);
       listPref3.setEntryValues(cspath);
       listPref3.setDialogTitle("broadcast path to terminal emulator");
       listPref3.setTitle("broadcast path to terminal emulator");
       listPref3.setSummary("broadcast path to terminal emulator");
       dialogBasedPrefCat3.addPreference(listPref3);
       EditTextPreference path = new EditTextPreference(this);
       path.setKey("broadcastpath");
       path.setDefaultValue("/data/data/julianwi.javainstaller");
       path.setDialogTitle("path to broadcast");
       path.setTitle("path to broadcast");
       path.setSummary("path to broadcast");
       dialogBasedPrefCat3.addPreference(path);

       return root;
   }