List of usage examples for android.preference PreferenceScreen setTitle
public void setTitle(CharSequence title)
From source file:com.colossaldb.dnd.ui.DebugFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getPreferenceManager() == null) return;// w w w .j a v a 2 s . c o m PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity()); if (root == null) return; root.setTitle("Debug Information"); root.addPreference(getPast(getPreferenceManager())); root.addPreference(getPresent(getPreferenceManager())); root.addPreference(getFuture(getPreferenceManager())); root.addPreference(getErrors(getPreferenceManager())); setPreferenceScreen(root); }
From source file:com.colossaldb.dnd.ui.DebugFragment.java
/** * Get the past actions performed./* www . ja v a2 s . c om*/ */ Preference getPast(PreferenceManager preferenceManager) { PreferenceScreen past = preferenceManager.createPreferenceScreen(getActivity()); if (past == null) return failedPreference("Failed to create past"); past.setTitle(R.string.past); JSONArray events = AppPreferences.getInstance().getDebugEvents(); addEventsToPreferenceScreen(past, events); return past; }
From source file:com.colossaldb.dnd.ui.DebugFragment.java
/** * Get the errors./*from w w w. j a v a 2s.c o m*/ */ Preference getErrors(PreferenceManager preferenceManager) { PreferenceScreen errors = preferenceManager.createPreferenceScreen(getActivity()); if (errors == null) return failedPreference("Failed to create errors"); errors.setTitle(R.string.errors); JSONArray events = AppPreferences.getInstance().getErrorEvents(); addEventsToPreferenceScreen(errors, events); return errors; }
From source file:com.colossaldb.dnd.ui.DebugFragment.java
/** * Future scheduled events (and related information - if available) *///from ww w . j a va 2 s . c o m Preference getFuture(PreferenceManager preferenceManager) { PreferenceScreen future = preferenceManager.createPreferenceScreen(getActivity()); if (future == null) return failedPreference("Failed to create future"); future.setTitle(R.string.future); Preference nextEvent = new Preference(getActivity()); nextEvent.setTitle("Next Schedule Run"); nextEvent.setSummary(AppPreferences.getInstance().getNextScheduleRun()); future.addPreference(nextEvent); return future; }
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. com 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:com.colossaldb.dnd.ui.DebugFragment.java
/** * Current debug information for display *///from www .j av a2 s . co m Preference getPresent(PreferenceManager preferenceManager) { PreferenceScreen present = preferenceManager.createPreferenceScreen(getActivity()); if (present == null) return failedPreference("Failed to create present"); present.setTitle(R.string.present); AppPreferences pref = AppPreferences.getInstance(); Preference enabled = new Preference(getActivity()); enabled.setTitle(R.string.enabled); enabled.setSummary("" + pref.isEnabled()); present.addPreference(enabled); Preference startTime = new Preference(getActivity()); startTime.setTitle(R.string.start); startTime.setSummary(pref.getFormattedStartTime()); present.addPreference(startTime); Preference endTime = new Preference(getActivity()); endTime.setTitle(R.string.end); endTime.setSummary(pref.getFormattedEndTime()); present.addPreference(endTime); Preference ringForContacts = new Preference(getActivity()); ringForContacts.setTitle(R.string.contacts); ringForContacts.setSummary("" + pref.ringForContacts()); present.addPreference(ringForContacts); Preference ringOnRepeat = new Preference(getActivity()); ringOnRepeat.setTitle(R.string.repeat_on_ring); ringOnRepeat.setSummary("" + pref.ringOnRepeatCall()); present.addPreference(ringOnRepeat); // Add the current state // Did the user change volume? // Did we sent the ringer volume? return present; }
From source file:net.openfiretechnologies.veloxcontrol.github.tasks.GetCommitsInProjectTask.java
protected Void doInBackground(String... params) { PROJECT_ = params[0];//from w w w . ja va 2s . com 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];// w ww .j a v a2s. 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:net.freifunk.android.discover.SettingsActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_data_sync); // get data via the key ArrayList<NodeMap> nodeMapArrayList = new ArrayList<NodeMap>(MapMaster.getInstance().getMaps().values()); PreferenceCategory communities = (PreferenceCategory) findPreference("communities"); // sort by Name Collections.sort(nodeMapArrayList, new NodeMapComparator()); if (nodeMapArrayList != null && communities != null) { for (final NodeMap nm : nodeMapArrayList) { PreferenceScreen communityPreferenceScreen = getPreferenceManager() .createPreferenceScreen(SettingsActivity.this); communityPreferenceScreen.setTitle(nm.getMapName()); communityPreferenceScreen.setKey(nm.getMapName()); final CheckBoxPreference deactivateCommunityPreference = new CheckBoxPreference( SettingsActivity.this); // TODO: move Strings to resources deactivateCommunityPreference.setTitle("Community aktiv"); deactivateCommunityPreference .setSummary("deaktivieren, falls Community nicht auf der Karte angezeigt werden soll"); deactivateCommunityPreference.setKey("community_deactivate_" + nm.getMapName()); deactivateCommunityPreference.setChecked(nm.isActive()); deactivateCommunityPreference .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Database db = Database.getInstance(null); boolean newActive = newValue.toString().equals("true") ? true : false; nm.setActive(newActive); db.addNodeMap(nm); // reload if set to active if (newActive) { nm.loadNodes(); } else { nm.updateNodes(); }//w ww. j a v a2 s. c o m return true; } }); EditTextPreference editCommunityPreference = new EditTextPreference(SettingsActivity.this); // TODO: move Strings to resources editCommunityPreference.setTitle("URL bearbeiten"); editCommunityPreference.setSummary("aendern, falls eine andere Quelle genutzt werden soll."); editCommunityPreference.setKey("community_edit_" + nm.getMapName()); editCommunityPreference.setText(nm.getMapUrl()); editCommunityPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Database db = Database.getInstance(null); // remove old nodes from map nm.setActive(false); EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.UPDATE_NODES, nm)); // we should probably do this async as well db.deleteAllNodesForMap(nm); // load new nodes NodeMap newMap = new NodeMap(nm.getMapName(), (String) newValue, true); db.addNodeMap(newMap); //HashMap<String, NodeMap> nodeResult = new HashMap<String, NodeMap>(1); //nodeResult.put(nm.getMapName(), nm); newMap.updateNodes(); //EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.LOAD_NODES, nm)); //EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.UPDATE_MAP, nodeResult)); return true; } }); communityPreferenceScreen.addPreference(deactivateCommunityPreference); communityPreferenceScreen.addPreference(editCommunityPreference); communities.addPreference(communityPreferenceScreen); } } setupActionBar(); }
From source file:de.ub0r.android.callmeter.ui.prefs.PreferencesPlain.java
private void loadRules() { new AsyncTask<Void, Void, JSONObject>() { @Override//from w ww. j a v a2 s. c o m 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); }