private PreferenceCategory getCategory(@StringRes int titleRes) { PreferenceCategory c = new PreferenceCategory(getActivity()); c.setTitle(titleRes); return c; }
fakeHeader.setTitle(R.string.hdr_pref_about); fakeHeader.setLayoutResource(R.layout.preference_category); getPreferenceScreen().addPreference(fakeHeader);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.user_cred_prefs); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } String snapp = getIntent().getExtras().getString("netapp"); if (snapp == null) { Log.e(TAG, "Got null snetapp"); finish(); } mNetApp = NetApp.valueOf(snapp); settings = new AppSettings(this); mHeader = (PreferenceCategory) findPreference(KEY_USER_CREDS_HEADER); mHeader.setTitle(mNetApp.getName()); mEditCreds = (EditUserCredentials) findPreference(KEY_EDIT_USER_CREDENTIALS); mEditCreds.setNetApp(mNetApp); mClearCreds = findPreference(KEY_CLEAR_USER_CREDENTIALS); mCreateUser = findPreference(KEY_CREATE_USER); mCreateUser.setSummary(getString(R.string.create_user_summary).replace( "%1", mNetApp.getName())); }
preferenceCategory.setTitle(category.categoryTitle); getPreferenceScreen().addPreference(preferenceCategory);
preferenceCategory.setTitle(category.categoryTitle); getPreferenceScreen().addPreference(preferenceCategory);
/** * 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. addPreferencesFromResource(R.xml.pref_general); // Add 'sending' preferences, and a corresponding header. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_sending); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_sending); // Add 'receiving' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_receiving); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_receiving); // 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("cell_size")); bindPreferenceSummaryToValue(findPreference("code_format")); bindPreferenceSummaryToValue(findPreference("scan_delay")); }
@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); } }
@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); } }
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { PreferenceFragment fragment = (PreferenceFragment) param.thisObject; if (XposedHelpers.getAdditionalInstanceField(fragment, KEY_APP_DETAILS_CATEGORY) == null) { Activity context = fragment.getActivity(); ResourceUtils res = ResourceUtils.getInstance(context); PreferenceScreen root = fragment.getPreferenceScreen(); PreferenceCategory storeCat = new PreferenceCategory(context); storeCat.setTitle(res.getString(R.string.store)); root.addPreference(storeCat); Preference appDetailsPreference = new Preference(context); appDetailsPreference.setTitle(res.getString(R.string.app_details)); appDetailsPreference.setEnabled(false); appDetailsPreference.setKey(KEY_APP_DETAILS); storeCat.addPreference(appDetailsPreference); XposedHelpers.setAdditionalInstanceField(fragment, KEY_APP_DETAILS_CATEGORY, storeCat); } } };
private void populatePreferenceHierarchy(PreferenceScreen root) { inlinePrefCat.setTitle(R.string.inline_preferences); root.addPreference(inlinePrefCat); dialogBasedPrefCat.setTitle(R.string.dialog_based_preferences); root.addPreference(dialogBasedPrefCat); launchPrefCat.setTitle(R.string.launch_preferences); root.addPreference(launchPrefCat); prefAttrsCat.setTitle(R.string.preference_attributes); root.addPreference(prefAttrsCat);
private void populatePreferenceHierarchy(PreferenceScreen root) { inlinePrefCat.setTitle(R.string.inline_preferences); root.addPreference(inlinePrefCat); dialogBasedPrefCat.setTitle(R.string.dialog_based_preferences); root.addPreference(dialogBasedPrefCat); launchPrefCat.setTitle(R.string.launch_preferences); root.addPreference(launchPrefCat); prefAttrsCat.setTitle(R.string.preference_attributes); root.addPreference(prefAttrsCat);
advancedCategory.setTitle("Advanced"); root.addPreference(advancedCategory);