List of usage examples for android.preference PreferenceScreen setOnPreferenceClickListener
public void setOnPreferenceClickListener(OnPreferenceClickListener onPreferenceClickListener)
From source file:cc.redpen.ui.fragment.SettingsFragment.java
private void setUpLayout() { ListPreference languagePref = getPreference(this, getString(R.string.label_setting_language)); languagePref.setSummary(languagePref.getEntry()); PreferenceScreen aboutScreen = getPreference(this, getString(R.string.label_setting_about)); aboutScreen.setOnPreferenceClickListener(this); PreferenceScreen feedbackScreen = getPreference(this, getString(R.string.label_setting_feedback)); feedbackScreen.setOnPreferenceClickListener(this); PreferenceScreen licenceScreen = getPreference(this, getString(R.string.label_setting_licence)); licenceScreen.setOnPreferenceClickListener(this); PreferenceScreen versionScreen = getPreference(this, getString(R.string.label_setting_version)); versionScreen.setSummary(MetaDataUtil.getVersionName(getContext())); }
From source file:com.tinfoil.sms.settings.QuickPrefsActivity.java
/** * Things done when the preference menu is created * Left as default/* w ww . ja v a2 s . co m*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); /* * Add preferences from the options.xml file. */ addPreferencesFromResource(R.xml.options); setKitKatPref(); PreferenceScreen sourceCode = (PreferenceScreen) findPreference(SOURCE_CODE_SETTING_KEY); sourceCode.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(QuickPrefsActivity.this.getString(R.string.tinfoil_sms_github))); QuickPrefsActivity.this.startActivity(i); return true; } }); EditTextPreference vibrateLength = (EditTextPreference) findPreference(VIBRATE_LENGTH_SETTING_KEY); vibrateLength.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean ret = false; try { if (SMSUtility.isASmallNumber(newValue.toString()) && Integer.valueOf(newValue.toString()) > 0) { ret = true; } } catch (NumberFormatException e) { e.printStackTrace(); } return ret; } }); //TODO implement the OnPreferenceChangeListener for the other preferences that use numbers only EditTextPreference messageLimit = (EditTextPreference) findPreference(MESSAGE_LIMIT_SETTING_KEY); messageLimit.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { boolean ret = false; try { if (SMSUtility.isASmallNumber(newValue.toString()) && Integer.valueOf(newValue.toString()) > 0) { ret = true; } } catch (NumberFormatException e) { e.printStackTrace(); } return ret; } }); findPreference("enable_walkthrough").setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { // If walkthrough enabled, reset all the steps so they are displayed again if (Boolean.valueOf(newValue.toString())) { Walkthrough.enableWalkthrough(QuickPrefsActivity.this); } else { Walkthrough.disableWalkthrough(QuickPrefsActivity.this); } return true; } }); /* Set an onclick listener for contact developers */ findPreference("contact").setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { /** * Create the Intent */ final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); /** * Fill it with Data */ emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, QuickPrefsActivity.this.getResources().getStringArray(R.array.dev_emails)); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject)); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, ""); /** * Send it off to the Activity-Chooser */ QuickPrefsActivity.this.startActivity(Intent.createChooser(emailIntent, QuickPrefsActivity.this.getResources().getString(R.string.email_chooser))); return true; } }); }
From source file:de.tum.in.tumcampus.fragments.SettingsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); mContext = getActivity();/* www .ja v a2s .c om*/ // Disables silence service if the app is used without TUMOnline access CheckBoxPreference silent = (CheckBoxPreference) findPreference("silent_mode"); if (!new AccessTokenManager(mContext).hasValidAccessToken()) { silent.setEnabled(false); } // Click listener for preference list entries. Used to simulate a button // (since it is not possible to add a button to the preferences screen) findPreference("button_wizard").setOnPreferenceClickListener(this); findPreference("button_clear_cache").setOnPreferenceClickListener(this); findPreference("facebook").setOnPreferenceClickListener(this); findPreference("github").setOnPreferenceClickListener(this); findPreference("first_run").setOnPreferenceClickListener(this); findPreference("licenses").setOnPreferenceClickListener(this); findPreference("feedback").setOnPreferenceClickListener(this); findPreference("privacy").setOnPreferenceClickListener(this); // Set summary for these preferences setSummary("card_cafeteria_default_G"); setSummary("card_cafeteria_default_K"); setSummary("card_cafeteria_default_W"); setSummary("card_role"); setSummary("card_stations_default_G"); setSummary("card_stations_default_C"); setSummary("card_stations_default_K"); setSummary("card_default_campus"); setSummary("silent_mode_set_to"); setSummary("background_mode_set_to"); // Register the change listener to react immediately on changes PreferenceManager.getDefaultSharedPreferences(mContext).registerOnSharedPreferenceChangeListener(this); // Populate news sources populateNewsSources(); // Open a card's preference screen if selected from it's context menu Bundle bundle = getArguments(); if (bundle != null && bundle.containsKey(Const.PREFERENCE_SCREEN)) { final String key = bundle.getString(Const.PREFERENCE_SCREEN); PreferenceScreen screen = (PreferenceScreen) findPreference("cards_pref_container"); final PreferenceScreen cardPreferenceScreen = (PreferenceScreen) findPreference(key); cardPreferenceScreen.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { initializeActionBar(cardPreferenceScreen); return true; } }); final ListAdapter listAdapter = screen.getRootAdapter(); final int itemsCount = listAdapter.getCount(); for (int i = 0; i < itemsCount; ++i) { if (listAdapter.getItem(i).equals(cardPreferenceScreen)) { screen.onItemClick(null, null, i, 0); break; } } } }
From source file:com.aokp.romcontrol.github.tasks.GetJSONChangelogTask.java
protected Void doInBackground(Void... unused) { HttpClient httpClient = null;/* w w w . j a va 2 s . c om*/ try { httpClient = new DefaultHttpClient(); String url = String.valueOf(STATIC_DEBUG ? "https://raw.github.com/JBirdVegas/tests/master/example.json" : mConfig.CHANGELOG_JSON); HttpGet requestWebsite = new HttpGet(url); Log.d(TAG, "attempting to connect to: " + url); ResponseHandler<String> responseHandler = new BasicResponseHandler(); JSONArray projectCommitsArray = new JSONArray(httpClient.execute(requestWebsite, responseHandler)); // debugging if (DEBUG) Log.d(TAG, "projectCommitsArray.length() is: " + projectCommitsArray.length()); if (Config.StaticVars.JSON_SPEW) Log.d(TAG, "projectCommitsArray.toString() is: " + projectCommitsArray.toString()); final ChangelogObject commitObject = new ChangelogObject(new JSONObject()); for (int i = 0; i < projectCommitsArray.length(); i++) { JSONObject projectsObject = (JSONObject) projectCommitsArray.get(i); PreferenceScreen newCommitPreference = mCategory.getPreferenceManager() .createPreferenceScreen(mContext); commitObject.reParse(projectsObject); newCommitPreference.setTitle(commitObject.getSubject()); newCommitPreference.setSummary(commitObject.getBody()); newCommitPreference.setKey(commitObject.getCommitHash()); newCommitPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { mAlertDialog.setCommitAndShow(commitObject); return false; } }); mCategory.addPreference(newCommitPreference); } } catch (HttpResponseException httpError) { Log.e(TAG, "bad HTTP response:", httpError); } catch (ClientProtocolException e) { Log.d(TAG, "client protocal exception:", e); } catch (JSONException e) { Log.d(TAG, "bad json interaction:", e); } catch (IOException e) { Log.d(TAG, "io exception:", e); } finally { if (httpClient != null) { httpClient.getConnectionManager().shutdown(); } } return null; }
From source file:fr.s13d.photobackup.preferences.PBPreferenceFragment.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); migratePreferences();//from w w w . j ava2 s.c om // create preferences addPreferencesFromResource(R.xml.preferences); // add click listeners to launch activities on click // Intents were historically defined into preferences.xml but as build variants cannot // inject applicationId as intent packageName properly, it was done this way now... setOnClickListener(PBConstants.PREF_ABOUT, PBAboutActivity.class); setOnClickListener(PBConstants.PREF_UPLOAD_JOURNAL, PBJournalActivity.class); final PreferenceScreen mediasPreferenceScreen = (PreferenceScreen) findPreference( PBConstants.PREF_MEDIAS_TO_BACKUP); mediasPreferenceScreen.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { checkPermissions(PBConstants.PERM_ORIGIN_MEDIAS); return true; } }); setHasOptionsMenu(true); }
From source file:de.ub0r.android.callmeter.ui.prefs.PreferencesPlain.java
private void loadRules() { new AsyncTask<Void, Void, JSONObject>() { @Override// w w w. j av a 2 s . com protected JSONObject doInBackground(final Void... params) { try { String l; StringBuilder sb = new StringBuilder(); File f = new File(PreferencesPlain.this.getCacheDir(), "ub0rrules.json"); if (f.exists() && f.lastModified() + CACHE_TIMEOUT > System.currentTimeMillis()) { Log.i(TAG, "found cached data: " + f.getAbsolutePath()); BufferedReader r = new BufferedReader(new FileReader(f)); while ((l = r.readLine()) != null) { sb.append(l); } r.close(); } if (sb.length() == 0) { if (f.exists()) { f.delete(); } HttpURLConnection c = (HttpURLConnection) new URL( "http://ub0r.de/android/callmeter/rulesets/rulesets.json").openConnection(); Log.i(TAG, "load new data: " + c.getURL()); BufferedReader r = new BufferedReader(new InputStreamReader(c.getInputStream())); FileWriter w = new FileWriter(f); while ((l = r.readLine()) != null) { sb.append(l); w.write(l); } r.close(); w.close(); } try { return new JSONObject(sb.toString()); } catch (JSONException e) { Log.e(TAG, "JSON Error", e); Log.e(TAG, "JSON: " + sb.toString()); return null; } } catch (IOException e) { Log.e(TAG, "IOError", e); } return null; } @SuppressWarnings({ "deprecation", "rawtypes" }) @Override protected void onPostExecute(final JSONObject result) { if (result == null) { Toast.makeText(PreferencesPlain.this, R.string.err_export_read, Toast.LENGTH_LONG).show(); return; } PreferenceGroup base = (PreferenceGroup) PreferencesPlain.this.findPreference("import_rules_users"); PreferenceManager pm = base.getPreferenceManager(); // delete old base.removeAll(); base = (PreferenceGroup) PreferencesPlain.this.findPreference("import_rules_base"); // build list ArrayList<String> keys = new ArrayList<String>(result.length()); Iterator it = result.keys(); while (it.hasNext()) { keys.add(it.next().toString()); } Collections.sort(keys); keys.remove("common"); keys.add(0, "common"); OnPreferenceClickListener opcl = new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(final Preference preference) { Intent intent = new Intent(PreferencesPlain.this, PreferencesRules.class); intent.putExtra(PreferencesRules.EXTRA_JSON, result.toString()); intent.putExtra(PreferencesRules.EXTRA_COUNTRY, preference.getKey()); PreferencesPlain.this.startActivity(intent); return true; } }; for (String k : keys) { PreferenceScreen p = pm.createPreferenceScreen(PreferencesPlain.this); p.setPersistent(false); p.setKey(k); p.setTitle(k); p.setOnPreferenceClickListener(opcl); base.addPreference(p); } } ; }.execute((Void) null); }
From source file:net.openfiretechnologies.veloxcontrol.github.tasks.GetCommitsInProjectTask.java
protected Void doInBackground(String... params) { PROJECT_ = params[0];/*w w w . j a v a 2 s . c o m*/ LAST_SHA_ = params[1]; String requestCommits; if (LAST_SHA_ == null) { mCategory.removeAll(); requestCommits = String.format(mConfig.INITIAL_COMMITS_REQUEST_FORMAT, PROJECT_); } else { requestCommits = String.format(mConfig.COMMITS_REQUEST_FORMAT, PROJECT_, LAST_SHA_); } if (BRANCH_ == null) BRANCH_ = DEFAULT_BRANCH; try { HttpClient httpClient = new DefaultHttpClient(); Log.i(TAG, "attempting to connect to: " + requestCommits); HttpGet requestWebsite = new HttpGet(requestCommits); ResponseHandler<String> responseHandler = new BasicResponseHandler(); JSONArray projectCommitsArray = new JSONArray(httpClient.execute(requestWebsite, responseHandler)); // debugging if (DEBUG) Log.d(TAG, "projectCommitsArray.length() is: " + projectCommitsArray.length()); String lastSha = null; // make a PreferenceScreen for all commits in package for (int i = 0; i < projectCommitsArray.length(); i++) { // make an object of each commit try { final CommitObject commitObject = new GithubObject(projectCommitsArray.getJSONObject(i)); // if we are looking for the next set the we skip the first commit // as it is represented as the last commit from the first commit // loading loop //if (LAST_SHA_ != null && i == 1) { //continue; //} // debugging if (Config.StaticVars.JSON_SPEW) Log.d(TAG, "commitObject.toString() is: " + commitObject.toString()); PreferenceScreen mCommit = mCategory.getPreferenceManager().createPreferenceScreen(mContext); // apply info to our preference screen mCommit.setKey(commitObject.getCommitHash()); mCommit.setTitle(commitObject.getSubject()); mCommit.setSummary(commitObject.getAuthorName()); mCommit.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference p) { mAlertDialog.setCommitAndShow(commitObject); return true; } }); mCategory.addPreference(mCommit); // most recent non null sha hash will be to iterate throught commits list if (commitObject.getCommitHash() != null) { lastSha = commitObject.getCommitHash(); } } catch (JSONException je) { // no author found for commit if (DEBUG) Log.d(TAG, "encountered a null value", je); } } if (projectCommitsArray.length() == 100) { // append next 100 commits onClick() final PreferenceScreen mNext = mCategory.getPreferenceManager().createPreferenceScreen(mContext); mNext.setTitle(mContext.getString(R.string.next_commits_page_title)); mNext.setSummary(mContext.getString(R.string.next_commits_page_summary)); final String finalString = lastSha; mNext.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference p) { GetCommitsInProjectTask nextList = new GetCommitsInProjectTask(mContext, mCategory, mAlertDialog); Log.d(TAG, "Sending project: " + PROJECT_ + " with last sha of " + finalString); nextList.execute(PROJECT_, finalString); // remove last entry it will be first entry in next list mCategory.removePreference(mCategory.findPreference(finalString)); // don't keep in list after we click mCategory.removePreference(mNext); return true; } }); mCategory.addPreference(mNext); } } catch (JSONException je) { if (DEBUG) Log.e(TAG, "Bad json interaction...", je); } catch (IOException ioe) { if (DEBUG) Log.e(TAG, "IOException...", ioe); } catch (NullPointerException ne) { if (DEBUG) Log.e(TAG, "NullPointer...", ne); } return null; }
From source file:com.aokp.romcontrol.github.tasks.GetCommitsInProjectTask.java
protected Void doInBackground(String... params) { PROJECT_ = params[0];//ww w . jav a2 s .c o m LAST_SHA_ = params[1]; String requestCommits; if (LAST_SHA_ == null) { mCategory.removeAll(); requestCommits = String.format(mConfig.INITIAL_COMMITS_REQUEST_FORMAT, PROJECT_); } else { requestCommits = String.format(mConfig.COMMITS_REQUEST_FORMAT, PROJECT_, LAST_SHA_); } if (BRANCH_ == null) BRANCH_ = DEFAULT_BRANCH; try { HttpClient httpClient = new DefaultHttpClient(); Log.i(TAG, "attempting to connect to: " + requestCommits); HttpGet requestWebsite = new HttpGet(requestCommits); ResponseHandler<String> responseHandler = new BasicResponseHandler(); JSONArray projectCommitsArray = new JSONArray(httpClient.execute(requestWebsite, responseHandler)); // debugging if (DEBUG) Log.d(TAG, "projectCommitsArray.length() is: " + projectCommitsArray.length()); String lastSha = null; // make a PreferenceScreen for all commits in package for (int i = 0; i < projectCommitsArray.length(); i++) { // make an object of each commit try { final CommitObject commitObject = new GithubObject(projectCommitsArray.getJSONObject(i)); // if we are looking for the next set the we skip the first commit // as it is represented as the last commit from the first commit // loading loop //if (LAST_SHA_ != null && i == 1) { //continue; //} // debugging if (Config.StaticVars.JSON_SPEW) Log.d(TAG, "commitObject.toString() is: " + commitObject.toString()); if ("merge".contains(commitObject.getSubject().substring(0, 5).toLowerCase())) continue; PreferenceScreen mCommit = mCategory.getPreferenceManager().createPreferenceScreen(mContext); // apply info to our preference screen mCommit.setKey(commitObject.getCommitHash()); mCommit.setTitle(commitObject.getSubject()); mCommit.setSummary(commitObject.getAuthorName()); mCommit.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference p) { mAlertDialog.setCommitAndShow(commitObject); return true; } }); mCategory.addPreference(mCommit); // most recent non null sha hash will be to iterate throught commits list if (commitObject.getCommitHash() != null) { lastSha = commitObject.getCommitHash(); } } catch (JSONException je) { // no author found for commit if (DEBUG) Log.d(TAG, "encountered a null value", je); } } if (projectCommitsArray.length() == 100) { // append next 100 commits onClick() final PreferenceScreen mNext = mCategory.getPreferenceManager().createPreferenceScreen(mContext); mNext.setTitle(mContext.getString(R.string.next_commits_page_title)); mNext.setSummary(mContext.getString(R.string.next_commits_page_summary)); final String finalString = lastSha; mNext.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference p) { GetCommitsInProjectTask nextList = new GetCommitsInProjectTask(mContext, mCategory, mAlertDialog); Log.d(TAG, "Sending project: " + PROJECT_ + " with last sha of " + finalString); nextList.execute(PROJECT_, finalString); // remove last entry it will be first entry in next list mCategory.removePreference(mCategory.findPreference(finalString)); // don't keep in list after we click mCategory.removePreference(mNext); return true; } }); mCategory.addPreference(mNext); } } catch (JSONException je) { if (DEBUG) Log.e(TAG, "Bad json interaction...", je); } catch (IOException ioe) { if (DEBUG) Log.e(TAG, "IOException...", ioe); } catch (NullPointerException ne) { if (DEBUG) Log.e(TAG, "NullPointer...", ne); } return null; }
From source file:com.ubuntuone.android.files.activity.PreferencesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mContext = this; mTracker = GoogleAnalyticsTracker.getInstance(); mTracker.start(Analytics.U1F_ACCOUNT, this); mTracker.trackPageView(TAG);/*from w w w.j av a2 s.c o m*/ super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); // Account category. final Preference username = findPreference(Preferences.USERNAME_KEY); final String usernameSummary = Preferences.getString(Preferences.USERNAME_KEY, "(?)"); username.setSummary(usernameSummary); setupOnClickPreference(Pref.INVITE_FRIEND, this); final Preference purchaseStorage = findPreference(Pref.PURCHASE_STORAGE); purchaseStorage.setOnPreferenceClickListener(mPurchaseStorageListener); final Preference upgradePlan = findPreference(Pref.UPGRADE_PLAN); upgradePlan.setOnPreferenceClickListener(mLinkListener); // Options category. final PreferenceScreen mediaUploadScreen = (PreferenceScreen) findPreference(Pref.MEDIA_UPLOAD); mediaUploadScreen.setOnPreferenceClickListener(whiteHackClick); // Photo Auto Upload final CheckBoxPreference photosAutoUploadToggle = (CheckBoxPreference) findPreference( Preferences.PHOTO_UPLOAD_ENABLED_KEY); photosAutoUploadToggle.setOnPreferenceClickListener(mPhotosAutoUploadToggleListener); final Preference photosAutoUploadSources = findPreference(Pref.PHOTOS_AUTO_UPLOAD_SOURCES); photosAutoUploadSources.setOnPreferenceClickListener(mPhotosAutoUploadSourcesListener); mPhotosAutoUploadDir = (Preference) findPreference(Preferences.PHOTO_UPLOAD_DIR_KEY); mPhotosAutoUploadDir.setOnPreferenceClickListener(mPhotosAutoUploadDirListener); final String photosAutoUploadDirectory = Preferences.getPhotoUploadDirectory(); mPhotosAutoUploadDir.setDefaultValue(photosAutoUploadDirectory); mPhotosAutoUploadDir.setSummary(photosAutoUploadDirectory); final Preference uploadPhotosNow = findPreference(Pref.UPLOAD_PHOTOS_NOW); uploadPhotosNow.setOnPreferenceClickListener(mUploadPhotosNowListener); final Preference cancelAllUploads = findPreference(Pref.CANCEL_ALL_UPLOADS); cancelAllUploads.setOnPreferenceClickListener(mCancelAllUploadsListener); // General final PreferenceScreen advancedOptionsScreen = (PreferenceScreen) findPreference(Pref.ADVANCED_OPTIONS); advancedOptionsScreen.setOnPreferenceClickListener(whiteHackClick); final Preference autoRetry = findPreference(Preferences.AUTO_RETRY_FAILED); autoRetry.setOnPreferenceChangeListener(mAutoRetryListener); final Preference clearPreviewCache = findPreference(Pref.CLEAR_PREVIEW_CACHE); clearPreviewCache.setOnPreferenceClickListener(mClearPreviewCacheListener); final Preference clearThumbCache = findPreference(Pref.CLEAR_THUMB_CACHE); clearThumbCache.setOnPreferenceClickListener(mClearThumbCacheListener); final Preference removeDevice = findPreference(Pref.REMOVE_DEVICE); removeDevice.setOnPreferenceClickListener(mRemoveDeviceListener); mRetryFailed = findPreference(Pref.RETRY_FAILED); mRetryFailed.setOnPreferenceClickListener(mRetryFailedListener); mCancelFailed = findPreference(Pref.CANCEL_FAILED); mCancelFailed.setOnPreferenceClickListener(mCancelFailedListener); // Manage category. final Preference manageAccount = findPreference(Pref.MANAGE_ACCOUNT); manageAccount.setOnPreferenceClickListener(mLinkListener); final Preference supportOptions = findPreference(Pref.SUPPORT_OPTIONS); supportOptions.setOnPreferenceClickListener(mLinkListener); final Preference feedback = findPreference(Pref.FEEDBACK); feedback.setOnPreferenceClickListener(mFeedbackListener); final PreferenceScreen reportScreen = (PreferenceScreen) findPreference(Pref.REPORT_PROBLEM); reportScreen.setOnPreferenceClickListener(whiteHackClick); mCollectLogs = (CheckBoxPreference) findPreference(Pref.COLLECT_LOGS); mCollectLogs.setOnPreferenceClickListener(mCollectLogsListener); mReviewLogs = findPreference(Pref.REVIEW_LOGS); mReviewLogs.setOnPreferenceClickListener(mReviewLogsListener); mSendLogs = findPreference(Pref.SEND_LOGS); mSendLogs.setOnPreferenceClickListener(mSendLogsListener); final PreferenceScreen about = (PreferenceScreen) findPreference(Pref.ABOUT); about.setSummary(UbuntuOneFiles.getVersion()); about.setOnPreferenceClickListener(whiteHackClick); final Preference license = findPreference(Pref.LICENSE); license.setOnPreferenceClickListener(mLinkListener); final Preference changelog = findPreference(Pref.CHANGELOG); changelog.setOnPreferenceClickListener(mChangelogListener); final Preference author = findPreference(Pref.AUTHORS); author.setOnPreferenceClickListener(mLinkListener); final Preference webpage = findPreference(Pref.WEBPAGE); webpage.setOnPreferenceClickListener(mLinkListener); final Preference greendroid = findPreference(Pref.GREENDROID); greendroid.setOnPreferenceClickListener(mLinkListener); receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (UpDownService.BROADCAST_UPLOAD_INFO.equals(action)) { final String info = intent.getStringExtra(Intent.EXTRA_TEXT); if (info != null) { runOnUiThread(new Runnable() { @Override public void run() { adjustTransferPreferencesState(); Preference p = findPreference(Pref.UPLOAD_PHOTOS_NOW); if (p != null) { p.setSummary(info); } } }); } } } }; registerAutoUploadInfoReceiver(receiver); Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra(AUTOUPLOAD_SCREEN)) { openPreference(Pref.MEDIA_UPLOAD); } else if (intent.hasExtra(PURCHASE_STORAGE_SCREEN)) { openPreference(Pref.PURCHASE_STORAGE); } else if (intent.hasExtra(SHOW_RETRY_FAILED)) { // Simply shows top screen. Hilight retry failed pref? } } }
From source file:github.daneren2005.dsub.fragments.SettingsFragment.java
private PreferenceScreen addServer(final int instance) { final PreferenceScreen screen = this.getPreferenceManager().createPreferenceScreen(context); screen.setKey(Constants.PREFERENCES_KEY_SERVER_KEY + instance); screen.setOrder(instance);/*from w w w . j a v a2 s . co m*/ screen.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { SettingsFragment newFragment = new SettingsFragment(); Bundle args = new Bundle(); args.putInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, instance); newFragment.setArguments(args); replaceFragment(newFragment); return false; } }); return screen; }