List of usage examples for android.content SharedPreferences getInt
int getInt(String key, int defValue);
From source file:com.aimfire.main.MainActivity.java
private void checkPreferences() { SharedPreferences settings = getSharedPreferences(getString(R.string.settings_file), Context.MODE_PRIVATE); if (settings != null) { /*//from w ww .j a v a 2s .c om * whether we show introduction at app startup */ mShowIntro = settings.getBoolean(MainConsts.SHOW_INTRO_PREFS_KEY, true); /* * TODO: survey activity crashes because it uses attributes as color which is not * allowed before API level 21 (see here: http://stackoverflow.com/questions/27986204/ * cant-convert-to-color-type-0x2-error-when-inflating-layout-in-fragment-but-onl). * temporarily disallow survey activity for API < 21 before we find a fix */ if (!sLaunchCountInc && (Build.VERSION.SDK_INT >= 21)) { sLaunchCountInc = true; mLaunchCount = settings.getInt(MainConsts.LAUNCH_COUNT_PREFS_KEY, -1); mLaunchCount++; if ((mLaunchCount == 0) && !isFirstInstall()) { /* * show survey if user just upgraded (from a version that doesn't have the * survey) and launch for the first time */ mShowSurvey = true; } else { /* * show survey if * 1. this app is launched PROMPT_SURVEY_LAUNCH_COUNT times. or * 2. we have prompted before, and user asks to prompt later, and launch times * modulo PROMPT_SURVEY_LAUNCH_COUNT is 0 */ boolean canShowSurvey = settings.getBoolean(MainConsts.SHOW_SURVEY_PREFS_KEY, true); if (canShowSurvey && (mLaunchCount % MainConsts.PROMPT_SURVEY_LAUNCH_COUNT == 0)) { mShowSurvey = true; } } } /* * we show intro after first install. write to registry so we don't do it again. * * Offline Mode = true - we will use P2P for everything * Offline Mode = false - we will use cloud for initial discovery and messaging, and * P2P for file transfer * * set DEMO_MODE_PREFS_KEY here, for other activities and AimfireService to pick up. * to test non-offline mode, set DEMO_MODE_PREFS_KEY below to false */ SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(MainConsts.SHOW_INTRO_PREFS_KEY, false); editor.putBoolean(MainConsts.DEMO_MODE_PREFS_KEY, true); editor.putInt(MainConsts.LAUNCH_COUNT_PREFS_KEY, mLaunchCount); editor.commit(); if (mShowIntro) { return; } int latestCode = settings.getInt(MainConsts.LATEST_VERSION_CODE_KEY, -1); int currCode = -1; PackageInfo pInfo; try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); currCode = pInfo.versionCode; } catch (NameNotFoundException e) { if (BuildConfig.DEBUG) Log.e(TAG, "parseVerTxt: couldn't get current version" + e.getMessage()); return; } if (latestCode > currCode) { mUpgradeAvailable = true; } } }
From source file:com.almalence.opencam.ApplicationScreen.java
protected void onApplicationStart() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); int cameraSelected = prefs.getInt(ApplicationScreen.sCameraModePref, 0); if (cameraSelected == CameraController.getNumberOfCameras() - 1) { prefs.edit().putInt(ApplicationScreen.sCameraModePref, 0).commit(); ApplicationScreen.getGUIManager().setCameraModeGUI(0); }//from w w w . j ava 2 s .c o m CameraController.onStart(); ApplicationScreen.getGUIManager().onStart(); ApplicationScreen.getPluginManager().onStart(); }
From source file:com.Beat.RingdroidEditActivity.java
private void handleFatalError(final CharSequence errorInternalName, final CharSequence errorString, final Exception exception) { Log.i("Ringdroid", "handleFatalError"); SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); int failureCount = prefs.getInt(PREF_ERROR_COUNT, 0); final SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_ERROR_COUNT, failureCount + 1); prefsEditor.commit();/* w ww.j ava 2 s .c o m*/ // Check if we already have a pref for whether or not we can // contact the server. int serverAllowed = prefs.getInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_UNKNOWN); if (serverAllowed == SERVER_ALLOWED_NO) { Log.i("Ringdroid", "ERR: SERVER_ALLOWED_NO"); // Just show a simple "write error" message showFinalAlert(exception, errorString); return; } if (serverAllowed == SERVER_ALLOWED_YES) { Log.i("Ringdroid", "SERVER_ALLOWED_YES"); new AlertDialog.Builder(RingdroidEditActivity.this).setTitle(R.string.alert_title_failure) .setMessage(errorString) .setPositiveButton(R.string.alert_ok_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { sendErrToServerAndFinish(errorInternalName, exception); return; } }).setCancelable(false).show(); return; } // The number of times the user must have had a failure before // we'll ask them. Defaults to 1, and each time they click "Later" // we double and add 1. final int allowServerCheckIndex = prefs.getInt(PREF_ERR_SERVER_CHECK, 1); if (failureCount < allowServerCheckIndex) { Log.i("Ringdroid", "failureCount " + failureCount + " is less than " + allowServerCheckIndex); // Just show a simple "write error" message showFinalAlert(exception, errorString); return; } final SpannableString message = new SpannableString( errorString + ". " + getResources().getText(R.string.error_server_prompt)); Linkify.addLinks(message, Linkify.ALL); AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.alert_title_failure) .setMessage(message).setPositiveButton(R.string.server_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { prefsEditor.putInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_YES); prefsEditor.commit(); sendErrToServerAndFinish(errorInternalName, exception); } }).setNeutralButton(R.string.server_later, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { prefsEditor.putInt(PREF_ERR_SERVER_CHECK, 1 + allowServerCheckIndex * 2); Log.i("Ringdroid", "Won't check again until " + (1 + allowServerCheckIndex * 2) + " errors."); prefsEditor.commit(); finish(); } }).setNegativeButton(R.string.server_never, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { prefsEditor.putInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_NO); prefsEditor.commit(); finish(); } }).setCancelable(false).show(); // Make links clicky ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.Beat.RingdroidEditActivity.java
private void afterSavingRingtone(CharSequence title, String outPath, File outFile, int duration) { long length = outFile.length(); if (length <= 512) { outFile.delete();//from w w w . ja va 2 s. c o m new AlertDialog.Builder(this).setTitle(R.string.alert_title_failure) .setMessage(R.string.too_small_error).setPositiveButton(R.string.alert_ok_button, null) .setCancelable(false).show(); return; } // Create the database record, pointing to the existing file path long fileSize = outFile.length(); String mimeType = "audio/mpeg"; String artist = "" + getResources().getText(R.string.artist_name); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, outPath); values.put(MediaStore.MediaColumns.TITLE, title.toString()); values.put(MediaStore.MediaColumns.SIZE, fileSize); values.put(MediaStore.MediaColumns.MIME_TYPE, mimeType); values.put(MediaStore.Audio.Media.ARTIST, artist); values.put(MediaStore.Audio.Media.DURATION, duration); values.put(MediaStore.Audio.Media.IS_RINGTONE, mNewFileKind == FileSaveDialog.FILE_KIND_RINGTONE); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, mNewFileKind == FileSaveDialog.FILE_KIND_NOTIFICATION); values.put(MediaStore.Audio.Media.IS_ALARM, mNewFileKind == FileSaveDialog.FILE_KIND_ALARM); values.put(MediaStore.Audio.Media.IS_MUSIC, mNewFileKind == FileSaveDialog.FILE_KIND_MUSIC); // Insert it into the database Uri uri = MediaStore.Audio.Media.getContentUriForPath(outPath); final Uri newUri = getContentResolver().insert(uri, values); setResult(RESULT_OK, new Intent().setData(newUri)); // Update a preference that counts how many times we've // successfully saved a ringtone or other audio SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); int successCount = prefs.getInt(PREF_SUCCESS_COUNT, 0); SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_SUCCESS_COUNT, successCount + 1); prefsEditor.commit(); // If Ringdroid was launched to get content, just return if (mWasGetContentIntent) { sendStatsToServerIfAllowedAndFinish(); return; } // There's nothing more to do with music or an alarm. Show a // success message and then quit. if (mNewFileKind == FileSaveDialog.FILE_KIND_MUSIC || mNewFileKind == FileSaveDialog.FILE_KIND_ALARM) { Toast.makeText(this, R.string.save_success_message, Toast.LENGTH_SHORT).show(); sendStatsToServerIfAllowedAndFinish(); return; } // If it's a notification, give the user the option of making // this their default notification. If they say no, we're finished. if (mNewFileKind == FileSaveDialog.FILE_KIND_NOTIFICATION) { new AlertDialog.Builder(RingdroidEditActivity.this).setTitle(R.string.alert_title_success) .setMessage(R.string.set_default_notification) .setPositiveButton(R.string.alert_yes_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { RingtoneManager.setActualDefaultRingtoneUri(RingdroidEditActivity.this, RingtoneManager.TYPE_NOTIFICATION, newUri); sendStatsToServerIfAllowedAndFinish(); } }).setNegativeButton(R.string.alert_no_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { sendStatsToServerIfAllowedAndFinish(); } }).setCancelable(false).show(); return; } // If we get here, that means the type is a ringtone. There are // three choices: make this your default ringtone, assign it to a // contact, or do nothing. final Handler handler = new Handler() { public void handleMessage(Message response) { int actionId = response.arg1; switch (actionId) { case R.id.button_make_default: RingtoneManager.setActualDefaultRingtoneUri(RingdroidEditActivity.this, RingtoneManager.TYPE_RINGTONE, newUri); Toast.makeText(RingdroidEditActivity.this, R.string.default_ringtone_success_message, Toast.LENGTH_SHORT).show(); sendStatsToServerIfAllowedAndFinish(); break; case R.id.button_choose_contact: chooseContactForRingtone(newUri); break; default: case R.id.button_do_nothing: sendStatsToServerIfAllowedAndFinish(); break; } } }; Message message = Message.obtain(handler); AfterSaveActionDialog dlog = new AfterSaveActionDialog(this, message); dlog.show(); }
From source file:com.Beat.RingdroidEditActivity.java
private void sendStatsToServerIfAllowedAndFinish() { Log.i("Ringdroid", "sendStatsToServerIfAllowedAndFinish"); final SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); // Check if we already have a pref for whether or not we can // contact the server. int serverAllowed = prefs.getInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_UNKNOWN); if (serverAllowed == SERVER_ALLOWED_NO) { Log.i("Ringdroid", "SERVER_ALLOWED_NO"); finish();//from ww w . j a v a 2s .c o m return; } if (serverAllowed == SERVER_ALLOWED_YES) { Log.i("Ringdroid", "SERVER_ALLOWED_YES"); sendStatsToServerAndFinish(); return; } // Number of times the user has successfully saved a sound. int successCount = prefs.getInt(PREF_SUCCESS_COUNT, 0); // The number of times the user must have successfully saved // a sound before we'll ask them. Defaults to 2, and doubles // each time they click "Later". final int allowServerCheckIndex = prefs.getInt(PREF_STATS_SERVER_CHECK, 2); if (successCount < allowServerCheckIndex) { Log.i("Ringdroid", "successCount " + successCount + " is less than " + allowServerCheckIndex); finish(); return; } showServerPrompt(false); }
From source file:com.Beat.RingdroidEditActivity.java
/** * If the exception is not null, will send the stack trace. *//*from w ww. j ava 2s . co m*/ void sendToServer(String serverUrl, CharSequence errType, Exception exception) { if (mTitle == null) return; Log.i("Ringdroid", "sendStatsToServer"); boolean isSuccess = (exception == null); StringBuilder postMessage = new StringBuilder(); String ringdroidVersion = "unknown"; try { ringdroidVersion = getPackageManager().getPackageInfo(getPackageName(), -1).versionName; } catch (android.content.pm.PackageManager.NameNotFoundException e) { } postMessage.append("ringdroid_version="); postMessage.append(URLEncoder.encode(ringdroidVersion)); postMessage.append("&android_version="); postMessage.append(URLEncoder.encode(Build.VERSION.RELEASE)); postMessage.append("&unique_id="); postMessage.append(getUniqueId()); postMessage.append("&accurate_seek="); postMessage.append(mCanSeekAccurately); if (isSuccess) { postMessage.append("&title="); postMessage.append(URLEncoder.encode(mTitle)); if (mArtist != null) { postMessage.append("&artist="); postMessage.append(URLEncoder.encode(mArtist)); } if (mAlbum != null) { postMessage.append("&album="); postMessage.append(URLEncoder.encode(mAlbum)); } if (mGenre != null) { postMessage.append("&genre="); postMessage.append(URLEncoder.encode(mGenre)); } postMessage.append("&year="); postMessage.append(mYear); postMessage.append("&filename="); postMessage.append(URLEncoder.encode(mFilename)); // The user's real location is not actually sent, this is just // vestigial code from an old experiment. double latitude = 0.0; double longitude = 0.0; postMessage.append("&user_lat="); postMessage.append(URLEncoder.encode("" + latitude)); postMessage.append("&user_lon="); postMessage.append(URLEncoder.encode("" + longitude)); SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); int successCount = prefs.getInt(PREF_SUCCESS_COUNT, 0); postMessage.append("&success_count="); postMessage.append(URLEncoder.encode("" + successCount)); postMessage.append("&bitrate="); postMessage.append(URLEncoder.encode("" + mSoundFile.getAvgBitrateKbps())); postMessage.append("&channels="); postMessage.append(URLEncoder.encode("" + mSoundFile.getChannels())); String md5; try { md5 = mSoundFile.computeMd5OfFirst10Frames(); } catch (Exception e) { md5 = ""; } postMessage.append("&md5="); postMessage.append(URLEncoder.encode(md5)); } else { // Error case postMessage.append("&err_type="); postMessage.append(errType); postMessage.append("&err_str="); postMessage.append(URLEncoder.encode(getStackTrace(exception))); postMessage.append("&src_filename="); postMessage.append(URLEncoder.encode(mFilename)); if (mDstFilename != null) { postMessage.append("&dst_filename="); postMessage.append(URLEncoder.encode(mDstFilename)); } } if (mSoundFile != null) { double framesToSecs = 0.0; double sampleRate = mSoundFile.getSampleRate(); if (sampleRate > 0.0) { framesToSecs = mSoundFile.getSamplesPerFrame() * 1.0 / sampleRate; } double songLen = framesToSecs * mSoundFile.getNumFrames(); postMessage.append("&songlen="); postMessage.append(URLEncoder.encode("" + songLen)); postMessage.append("&sound_type="); postMessage.append(URLEncoder.encode(mSoundFile.getFiletype())); double clipStart = mStartPos * framesToSecs; double clipLen = (mEndPos - mStartPos) * framesToSecs; postMessage.append("&clip_start="); postMessage.append(URLEncoder.encode("" + clipStart)); postMessage.append("&clip_len="); postMessage.append(URLEncoder.encode("" + clipLen)); } String fileKindName = FileSaveDialog.KindToName(mNewFileKind); postMessage.append("&clip_kind="); postMessage.append(URLEncoder.encode(fileKindName)); Log.i("Ringdroid", postMessage.toString()); try { int TIMEOUT_MILLISEC = 10000; // = 10 seconds HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC); HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC); HttpClient client = new DefaultHttpClient(httpParams); HttpPost request = new HttpPost(serverUrl); request.setEntity(new ByteArrayEntity(postMessage.toString().getBytes("UTF8"))); Log.i("Ringdroid", "Executing request"); HttpResponse response = client.execute(request); Log.i("Ringdroid", "Response: " + response.toString()); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.mobiletin.inputmethod.indic.LatinIME.java
@Override public void showSuggestionStrip(final SuggestedWords sourceSuggestedWords) { SharedPreferences prefs = getSharedPreferences("TranslationPref", MODE_PRIVATE); int idName = prefs.getInt("pos", 0); //0 is the default value. SuggestedWords suggestedWords = sourceSuggestedWords.isEmpty() ? SuggestedWords.EMPTY : sourceSuggestedWords;//from w w w. ja v a 2s . c o m if (idName == 0) { DBDictionary dbManager = new DBDictionary(this); List<DictionaryModel> dictionaryModelList = new ArrayList<>(); if (sourceSuggestedWords.mTypedWord != null && sourceSuggestedWords.mTypedWord.length() > 0) { dictionaryModelList = dbManager.getUrduDicFromEnglishWord(sourceSuggestedWords.mTypedWord, 1); } if (dictionaryModelList.size() == 0) { if (sourceSuggestedWords.mTypedWord != null && sourceSuggestedWords.mTypedWord.length() > 0) { String url = "http://www.google.com/inputtools/request?ime=transliteration%5Fen%5Fur&text=" + sourceSuggestedWords.mTypedWord + "&num=5&cp=0&cs=0&ie=utf-8&oe=utf-8&nocache=1355671585459"; if (isInternetOn()) { goForOnlineSuggetions(url); // new GoogleTransaltor().execute(url); if (sourceSuggestedWords.mTypedWord != null && sourceSuggestedWords.mTypedWord.length() > 0) { dictionaryModelList = dbManager .getUrduDicFromEnglishWord(sourceSuggestedWords.mTypedWord, 1); } } } } final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>(); for (int i = 0; i < dictionaryModelList.size(); i++) { //Spliting String form comma String str = dictionaryModelList.get(i).getSUGGESTIONS(); Log.e("Suggest", "" + str); String[] animalsArray = str.trim().split(","); for (String name : animalsArray) { suggestionsList.add(new SuggestedWordInfo(name, SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_HARDCODED, Dictionary.DICTIONARY_HARDCODED, SuggestedWordInfo.NOT_AN_INDEX, SuggestedWordInfo.NOT_A_CONFIDENCE)); } } suggestedWords = new SuggestedWords(suggestionsList, suggestionsList, false, false, false, SuggestedWords.INPUT_STYLE_NONE, SuggestedWords.NOT_A_SEQUENCE_NUMBER); } if (SuggestedWords.EMPTY == suggestedWords) { setNeutralSuggestionStrip(); } else { setSuggestedWords(suggestedWords); } // Cache the auto-correction in accessibility code so we can speak it if the user // touches a key that will insert it. AccessibilityUtils.getInstance().setAutoCorrection(suggestedWords, sourceSuggestedWords.mTypedWord); }
From source file:com.futurologeek.smartcrossing.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.activity_settings); instance = this; SharedPreferences preferences = getSharedPreferences(Constants.shared, Context.MODE_PRIVATE); editor = preferences.edit();/*w w w.j av a 2s . co m*/ signOut = (Preference) findPreference("log_out"); units = (CheckBoxPreference) findPreference("unit"); camFocus = (CheckBoxPreference) findPreference("cam_focus"); radius = (SeekBarPreference) findPreference("radius"); libs = (Preference) findPreference("libs"); libs.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent i = new Intent(SettingsActivity.this, LicensesActivity.class); startActivity(i); return true; } }); signOut.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { new signOut().execute(); return true; } }); // units.setChecked(preferences.getBoolean("isKM",false)); if (units.isChecked()) { units.setSummary(getResources().getString(R.string.mile)); radius.setMeasurementUnit(getResources().getString(R.string.mile)); radius.setMaxValue(100); radius.setCurrentValue((int) (radius.getCurrentValue() / 1.60)); } else { units.setSummary(getResources().getString(R.string.km)); radius.setMeasurementUnit(getResources().getString(R.string.km)); radius.setMaxValue(160); radius.setCurrentValue((int) (radius.getCurrentValue() * 1.60)); } //camFocus.setChecked(preferences.getBoolean("isPoint",true)); if (camFocus.isChecked()) { camFocus.setSummary(getResources().getString(R.string.P_all)); } else { camFocus.setSummary(getResources().getString(R.string.near_points)); } radius.setCurrentValue(preferences.getInt("radius", 30)); radius.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { editor.putInt("radius", (int) newValue); editor.apply(); Log.d("VALIU", String.valueOf(newValue)); return true; } }); units.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { units.setChecked(false); units.setChecked(true); preference.setSummary(getResources().getString(R.string.mile)); radius.setMeasurementUnit(getResources().getString(R.string.mile)); radius.setMaxValue(100); radius.setCurrentValue((int) (radius.getCurrentValue() / 1.60)); editor.putInt("radius", radius.getCurrentValue()); editor.apply(); } else { preference.setSummary(getResources().getString(R.string.km)); units.setChecked(true); units.setChecked(false); radius.setMeasurementUnit(getResources().getString(R.string.km)); radius.setMaxValue(160); radius.setCurrentValue((int) (radius.getCurrentValue() * 1.60)); editor.putInt("radius", radius.getCurrentValue()); editor.apply(); } editor.putBoolean("isKM", !(Boolean) newValue); editor.commit(); return true; } }); camFocus.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { preference.setSummary(getResources().getString(R.string.P_all)); } else { preference.setSummary(getResources().getString(R.string.near_points)); } editor.putBoolean("isPoint", (Boolean) newValue); editor.commit(); return true; } }); }
From source file:com.dngames.mobilewebcam.PhotoSettings.java
public static String DumpSettings(Context context, SharedPreferences prefs) { StringBuilder s = new StringBuilder(); Map<String, Object[]> all = new HashMap<String, Object[]>(); for (Field f : PhotoSettings.class.getFields()) { {//from ww w . ja v a2 s .c o m BooleanPref bp = f.getAnnotation(BooleanPref.class); if (bp != null) { String key = bp.key(); boolean val = prefs.getBoolean(key, bp.val()); all.put(key, new Object[] { val, bp.help() }); if (bp.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getBoolean(key, bp.val()); all.put(key, new Object[] { val, bp.help() }); } } } { StringPref sp = f.getAnnotation(StringPref.class); if (sp != null) { String key = sp.key(); String val = prefs.getString(key, getDefaultString(context, sp)); all.put(key, new Object[] { val, sp.help() }); if (sp.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getString(key, getDefaultString(context, sp)); all.put(key, new Object[] { val, sp.help() }); } } } { EditIntPref ip = f.getAnnotation(EditIntPref.class); if (ip != null) { String key = ip.key(); String val = prefs.getString(key, "" + ip.val()); all.put(ip.key(), new Object[] { val, ip.help() }); if (ip.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getString(key, "" + ip.val()); all.put(key, new Object[] { val, ip.help() }); } } } { IntPref ip = f.getAnnotation(IntPref.class); if (ip != null) { String key = ip.key(); int val = prefs.getInt(key, ip.val()); all.put(ip.key(), new Object[] { val, ip.help() }); if (ip.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getInt(key, ip.val()); all.put(key, new Object[] { val, ip.help() }); } } } { EditFloatPref fp = f.getAnnotation(EditFloatPref.class); if (fp != null) { String key = fp.key(); String val = prefs.getString(key, "" + fp.val()); all.put(fp.key(), new Object[] { val, fp.help() }); if (fp.night()) { key = key + PhotoSettings.NIGHTPOSTFIX; val = prefs.getString(key, "" + fp.val()); all.put(key, new Object[] { val, fp.help() }); } } } } for (Map.Entry<String, ?> p : all.entrySet()) { Object[] vals = (Object[]) p.getValue(); if (((String) vals[1]).length() > 0) s.append("// " + vals[1] + "\n"); s.append(p.getKey() + ":" + vals[0] + "\n"); } return s.toString(); }
From source file:com.aimfire.gallery.GalleryActivity.java
private void loadDisplayPrefs() { SharedPreferences settings = getSharedPreferences(getString(R.string.settings_file), Context.MODE_PRIVATE); if (settings != null) { mDisplaySwap = settings.getBoolean(MainConsts.DISPLAY_SWAP_PREFS_KEY, false); mDisplayColor = settings.getBoolean(MainConsts.DISPLAY_COLOR_PREFS_KEY, true); mDisplayMode = DisplayMode.values()[settings.getInt(MainConsts.DISPLAY_MODE_PREFS_KEY, DisplayMode.Anaglyph.getValue())]; }//from w w w . j a v a2s. co m }