List of usage examples for android.content SharedPreferences getInt
int getInt(String key, int defValue);
From source file:com.piusvelte.sonet.SonetService.java
@Override public void onCreate() { super.onCreate(); // handle version changes int currVer = 0; try {//from w w w . j a v a 2 s .c o m currVer = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (!sp.contains(getString(R.string.key_version)) || (currVer > sp.getInt(getString(R.string.key_version), 0))) { sp.edit().putInt(getString(R.string.key_version), currVer).commit(); Eidos.requestBackup(this); } mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mConnectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); mSonetCrypto = SonetCrypto.getInstance(getApplicationContext()); // check the instant upload settings startService(Sonet.getPackageIntent(getApplicationContext(), SonetUploader.class)); }
From source file:com.piusvelte.sonet.core.SonetService.java
@Override public void onCreate() { super.onCreate(); // handle version changes int currVer = 0; try {// w w w . j a v a 2 s . co m currVer = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (!sp.contains(getString(R.string.key_version)) || (currVer > sp.getInt(getString(R.string.key_version), 0))) { sp.edit().putInt(getString(R.string.key_version), currVer).commit(); try { BackupManager.dataChanged(this); } catch (Throwable t) { Log.d(TAG, "backupagent not supported"); } } mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mConnectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); mSonetCrypto = SonetCrypto.getInstance(getApplicationContext()); // check the instant upload settings startService(Sonet.getPackageIntent(getApplicationContext(), SonetUploader.class)); }
From source file:com.shafiq.myfeedle.core.MyfeedleService.java
@Override public void onCreate() { super.onCreate(); // handle version changes int currVer = 0; try {/*from www.j a v a 2 s . c o m*/ currVer = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (!sp.contains(getString(R.string.key_version)) || (currVer > sp.getInt(getString(R.string.key_version), 0))) { sp.edit().putInt(getString(R.string.key_version), currVer).commit(); try { BackupManager.dataChanged(this); } catch (Throwable t) { Log.d(TAG, "backupagent not supported"); } } mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mConnectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); mMyfeedleCrypto = MyfeedleCrypto.getInstance(getApplicationContext()); // check the instant upload settings startService(Myfeedle.getPackageIntent(getApplicationContext(), MyfeedleUploader.class)); }
From source file:com.Beat.RingdroidEditActivity.java
void showServerPrompt(final boolean userInitiated) { final SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); final SpannableString message = new SpannableString(getResources().getText(R.string.server_prompt)); Linkify.addLinks(message, Linkify.ALL); final AlertDialog dialog = new AlertDialog.Builder(RingdroidEditActivity.this) .setTitle(R.string.server_title).setMessage(message) .setPositiveButton(R.string.server_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_YES); prefsEditor.commit(); if (userInitiated) { finish();// w w w . jav a2s. c om } else { sendStatsToServerAndFinish(); } } }).setNeutralButton(R.string.server_later, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int allowServerCheckIndex = prefs.getInt(PREF_STATS_SERVER_CHECK, 2); int successCount = prefs.getInt(PREF_SUCCESS_COUNT, 0); SharedPreferences.Editor prefsEditor = prefs.edit(); if (userInitiated) { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, successCount + 2); } else { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, allowServerCheckIndex * 2); } prefsEditor.commit(); finish(); } }).setNegativeButton(R.string.server_never, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_NO); if (userInitiated) { // If the user initiated, err on the safe side and disable // sending crash reports too. There's no way to turn them // back on now aside from clearing data from this app, but // it doesn't matter, we don't need error reports from every // user ever. 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:de.vanita5.twittnuker.util.Utils.java
public static HttpClientWrapper getImageLoaderHttpClient(final Context context) { if (context == null) return null; final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); final int timeoutMillis = prefs.getInt(KEY_CONNECTION_TIMEOUT, 10000) * 1000; final Proxy proxy = getProxy(context); final String userAgent = generateBrowserUserAgent(); final HostAddressResolverFactory resolverFactory = new TwidereHostResolverFactory( TwittnukerApplication.getInstance(context)); return getHttpClient(context, timeoutMillis, true, proxy, resolverFactory, userAgent, false); }
From source file:de.vanita5.twittnuker.util.Utils.java
public static Twitter getTwitterInstance(final Context context, final long accountId, final boolean includeEntities, final boolean includeRetweets, final boolean apacheHttp, final String mediaProvider, final String mediaProviderAPIKey) { if (context == null) return null; final TwittnukerApplication app = TwittnukerApplication.getInstance(context); final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); final int connection_timeout = prefs.getInt(KEY_CONNECTION_TIMEOUT, 10) * 1000; final boolean enableGzip = prefs.getBoolean(KEY_GZIP_COMPRESSING, true); final boolean ignoreSSLError = prefs.getBoolean(KEY_IGNORE_SSL_ERROR, false); final boolean enableProxy = prefs.getBoolean(KEY_ENABLE_PROXY, false); // Here I use old consumer key/secret because it's default key for older // versions/*from w w w. jav a 2 s .com*/ final String where = Where.equals(new Column(Accounts.ACCOUNT_ID), accountId).getSQL(); final Cursor c = ContentResolverUtils.query(context.getContentResolver(), Accounts.CONTENT_URI, Accounts.COLUMNS, where.toString(), null, null); if (c == null) return null; try { if (!c.moveToFirst()) return null; final ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setHostAddressResolverFactory(new TwidereHostResolverFactory(app)); if (apacheHttp) { cb.setHttpClientFactory(new TwidereHttpClientFactory(app)); } cb.setHttpConnectionTimeout(connection_timeout); setUserAgent(context, cb); cb.setGZIPEnabled(enableGzip); cb.setIgnoreSSLError(ignoreSSLError); if (enableProxy) { final String proxy_host = prefs.getString(KEY_PROXY_HOST, null); final int proxy_port = ParseUtils.parseInt(prefs.getString(KEY_PROXY_PORT, "-1")); if (!isEmpty(proxy_host) && proxy_port > 0) { cb.setHttpProxyHost(proxy_host); cb.setHttpProxyPort(proxy_port); } } final String prefConsumerKey = prefs.getString(KEY_CONSUMER_KEY, TWITTER_CONSUMER_KEY_2); final String prefConsumerSecret = prefs.getString(KEY_CONSUMER_SECRET, TWITTER_CONSUMER_SECRET_2); final String apiUrlFormat = c.getString(c.getColumnIndex(Accounts.API_URL_FORMAT)); final String consumerKey = trim(c.getString(c.getColumnIndex(Accounts.CONSUMER_KEY))); final String consumerSecret = trim(c.getString(c.getColumnIndex(Accounts.CONSUMER_SECRET))); final boolean sameOAuthSigningUrl = c.getInt(c.getColumnIndex(Accounts.SAME_OAUTH_SIGNING_URL)) == 1; if (!isEmpty(apiUrlFormat)) { cb.setRestBaseURL(getApiUrl(apiUrlFormat, "api", "/1.1/")); cb.setOAuthBaseURL(getApiUrl(apiUrlFormat, "api", "/oauth/")); cb.setUploadBaseURL(getApiUrl(apiUrlFormat, "upload", "/1.1/")); if (!sameOAuthSigningUrl) { cb.setSigningRestBaseURL(DEFAULT_SIGNING_REST_BASE_URL); cb.setSigningOAuthBaseURL(DEFAULT_SIGNING_OAUTH_BASE_URL); cb.setSigningUploadBaseURL(DEFAULT_SIGNING_UPLOAD_BASE_URL); } } if (!isEmpty(mediaProvider)) { cb.setMediaProvider(mediaProvider); } if (!isEmpty(mediaProviderAPIKey)) { cb.setMediaProviderAPIKey(mediaProviderAPIKey); } cb.setIncludeEntitiesEnabled(includeEntities); cb.setIncludeRTsEnabled(includeRetweets); switch (c.getInt(c.getColumnIndexOrThrow(Accounts.AUTH_TYPE))) { case Accounts.AUTH_TYPE_OAUTH: case Accounts.AUTH_TYPE_XAUTH: { if (!isEmpty(consumerKey) && !isEmpty(consumerSecret)) { cb.setOAuthConsumerKey(consumerKey); cb.setOAuthConsumerSecret(consumerSecret); } else if (!isEmpty(prefConsumerKey) && !isEmpty(prefConsumerSecret)) { cb.setOAuthConsumerKey(prefConsumerKey); cb.setOAuthConsumerSecret(prefConsumerSecret); } else { cb.setOAuthConsumerKey(TWITTER_CONSUMER_KEY_2); cb.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET_2); } final String token = c.getString(c.getColumnIndexOrThrow(Accounts.OAUTH_TOKEN)); final String tokenSecret = c.getString(c.getColumnIndexOrThrow(Accounts.OAUTH_TOKEN_SECRET)); if (isEmpty(token) || isEmpty(tokenSecret)) return null; cb.setOAuthAccessToken(token); cb.setOAuthAccessTokenSecret(tokenSecret); return new TwitterFactory(cb.build()).getInstance(new AccessToken(token, tokenSecret)); } case Accounts.AUTH_TYPE_BASIC: { final String screenName = c.getString(c.getColumnIndexOrThrow(Accounts.SCREEN_NAME)); final String username = c.getString(c.getColumnIndexOrThrow(Accounts.BASIC_AUTH_USERNAME)); final String loginName = username != null ? username : screenName; final String password = c.getString(c.getColumnIndexOrThrow(Accounts.BASIC_AUTH_PASSWORD)); if (isEmpty(loginName) || isEmpty(password)) return null; return new TwitterFactory(cb.build()).getInstance(new BasicAuthorization(loginName, password)); } case Accounts.AUTH_TYPE_TWIP_O_MODE: { return new TwitterFactory(cb.build()).getInstance(new TwipOModeAuthorization()); } default: { return null; } } } finally { c.close(); } }
From source file:com.dngames.mobilewebcam.PhotoSettings.java
@Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { if (key == "cam_refresh") { int new_refresh = getEditInt(mContext, prefs, "cam_refresh", 60); String msg = "Camera refresh set to " + new_refresh + " seconds!"; if (MobileWebCam.gIsRunning) { if (!mNoToasts && new_refresh != mRefreshDuration) { try { Toast.makeText(mContext.getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); } catch (RuntimeException e) { e.printStackTrace(); }//from w w w . ja va2 s . co m } } else if (new_refresh != mRefreshDuration) { MobileWebCam.LogI(msg); } } // get all preferences for (Field f : getClass().getFields()) { { BooleanPref bp = f.getAnnotation(BooleanPref.class); if (bp != null) { try { f.setBoolean(this, prefs.getBoolean(bp.key(), bp.val())); } catch (Exception e) { Log.e("MobileWebCam", "Exception: " + bp.key() + " <- " + bp.val()); e.printStackTrace(); } } } { EditIntPref ip = f.getAnnotation(EditIntPref.class); if (ip != null) { try { int eval = getEditInt(mContext, prefs, ip.key(), ip.val()) * ip.factor(); if (ip.max() != Integer.MAX_VALUE) eval = Math.min(eval, ip.max()); if (ip.min() != Integer.MIN_VALUE) eval = Math.max(eval, ip.min()); f.setInt(this, eval); } catch (Exception e) { e.printStackTrace(); } } } { IntPref ip = f.getAnnotation(IntPref.class); if (ip != null) { try { int eval = prefs.getInt(ip.key(), ip.val()) * ip.factor(); if (ip.max() != Integer.MAX_VALUE) eval = Math.min(eval, ip.max()); if (ip.min() != Integer.MIN_VALUE) eval = Math.max(eval, ip.min()); f.setInt(this, eval); } catch (Exception e) { // handle wrong set class e.printStackTrace(); Editor edit = prefs.edit(); edit.remove(ip.key()); edit.putInt(ip.key(), ip.val()); edit.commit(); try { f.setInt(this, ip.val()); } catch (IllegalArgumentException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } } } } { EditFloatPref fp = f.getAnnotation(EditFloatPref.class); if (fp != null) { try { float eval = getEditFloat(mContext, prefs, fp.key(), fp.val()); if (fp.max() != Float.MAX_VALUE) eval = Math.min(eval, fp.max()); if (fp.min() != Float.MIN_VALUE) eval = Math.max(eval, fp.min()); f.setFloat(this, eval); } catch (Exception e) { e.printStackTrace(); } } } { StringPref sp = f.getAnnotation(StringPref.class); if (sp != null) { try { f.set(this, prefs.getString(sp.key(), getDefaultString(mContext, sp))); } catch (Exception e) { e.printStackTrace(); } } } } mCustomImageScale = Enum.valueOf(ImageScaleMode.class, prefs.getString("custompicscale", "CROP")); mAutoStart = prefs.getBoolean("autostart", false); mCameraStartupEnabled = prefs.getBoolean("cam_autostart", true); mShutterSound = prefs.getBoolean("shutter", true); mDateTimeColor = GetPrefColor(prefs, "datetime_color", "#FFFFFFFF", Color.WHITE); mDateTimeShadowColor = GetPrefColor(prefs, "datetime_shadowcolor", "#FF000000", Color.BLACK); mDateTimeBackgroundColor = GetPrefColor(prefs, "datetime_backcolor", "#80FF0000", Color.argb(0x80, 0xFF, 0x00, 0x00)); mDateTimeBackgroundLine = prefs.getBoolean("datetime_fillline", true); mDateTimeX = prefs.getInt("datetime_x", 98); mDateTimeY = prefs.getInt("datetime_y", 98); mDateTimeAlign = Paint.Align.valueOf(prefs.getString("datetime_imprintalign", "RIGHT")); mDateTimeFontScale = (float) prefs.getInt("datetime_fontsize", 6); mTextColor = GetPrefColor(prefs, "text_color", "#FFFFFFFF", Color.WHITE); mTextShadowColor = GetPrefColor(prefs, "text_shadowcolor", "#FF000000", Color.BLACK); mTextBackgroundColor = GetPrefColor(prefs, "text_backcolor", "#80FF0000", Color.argb(0x80, 0xFF, 0x00, 0x00)); mTextBackgroundLine = prefs.getBoolean("text_fillline", true); mTextX = prefs.getInt("text_x", 2); mTextY = prefs.getInt("text_y", 2); mTextAlign = Paint.Align.valueOf(prefs.getString("text_imprintalign", "LEFT")); mTextFontScale = (float) prefs.getInt("infotext_fontsize", 6); mTextFontname = prefs.getString("infotext_fonttypeface", ""); mStatusInfoColor = GetPrefColor(prefs, "statusinfo_color", "#FFFFFFFF", Color.WHITE); mStatusInfoShadowColor = GetPrefColor(prefs, "statusinfo_shadowcolor", "#FF000000", Color.BLACK); mStatusInfoX = prefs.getInt("statusinfo_x", 2); mStatusInfoY = prefs.getInt("statusinfo_y", 98); mStatusInfoAlign = Paint.Align.valueOf(prefs.getString("statusinfo_imprintalign", "LEFT")); mStatusInfoBackgroundColor = GetPrefColor(prefs, "statusinfo_backcolor", "#00000000", Color.TRANSPARENT); mStatusInfoFontScale = (float) prefs.getInt("statusinfo_fontsize", 6); mStatusInfoBackgroundLine = prefs.getBoolean("statusinfo_fillline", false); mGPSColor = GetPrefColor(prefs, "gps_color", "#FFFFFFFF", Color.WHITE); mGPSShadowColor = GetPrefColor(prefs, "gps_shadowcolor", "#FF000000", Color.BLACK); mGPSX = prefs.getInt("gps_x", 98); mGPSY = prefs.getInt("gps_y", 2); mGPSAlign = Paint.Align.valueOf(prefs.getString("gps_imprintalign", "RIGHT")); mGPSBackgroundColor = GetPrefColor(prefs, "gps_backcolor", "#00000000", Color.TRANSPARENT); mGPSFontScale = (float) prefs.getInt("gps_fontsize", 6); mGPSBackgroundLine = prefs.getBoolean("gps_fillline", false); mImprintPictureX = prefs.getInt("imprint_picture_x", 0); mImprintPictureY = prefs.getInt("imprint_picture_y", 0); mNightAutoConfigEnabled = prefs.getBoolean("night_auto_enabled", false); mSetNightConfiguration = prefs.getBoolean("cam_nightconfiguration", false); // override night camera parameters (read again with postfix) getCurrentNightSettings(); mFilterPicture = false; //***prefs.getBoolean("filter_picture", false); mFilterType = getEditInt(mContext, prefs, "filter_sel", 0); if (mImprintPicture) { if (mImprintPictureURL.length() == 0) { // sdcard image File path = new File(Environment.getExternalStorageDirectory() + "/MobileWebCam/"); if (path.exists()) { synchronized (gImprintBitmapLock) { if (gImprintBitmap != null) gImprintBitmap.recycle(); gImprintBitmap = null; File file = new File(path, "imprint.png"); try { FileInputStream in = new FileInputStream(file); gImprintBitmap = BitmapFactory.decodeStream(in); in.close(); } catch (IOException e) { Toast.makeText(mContext, "Error: unable to read imprint bitmap " + file.getName() + "!", Toast.LENGTH_SHORT).show(); gImprintBitmap = null; } catch (OutOfMemoryError e) { Toast.makeText(mContext, "Error: imprint bitmap " + file.getName() + " too large!", Toast.LENGTH_LONG).show(); gImprintBitmap = null; } } } } else { DownloadImprintBitmap(); } synchronized (gImprintBitmapLock) { if (gImprintBitmap == null) { // last resort: resource default try { gImprintBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.imprint); } catch (OutOfMemoryError e) { Toast.makeText(mContext, "Error: default imprint bitmap too large!", Toast.LENGTH_LONG) .show(); gImprintBitmap = null; } } } } mNoToasts = prefs.getBoolean("no_messages", false); mFullWakeLock = prefs.getBoolean("full_wakelock", true); switch (getEditInt(mContext, prefs, "camera_mode", 1)) { case 0: mMode = Mode.MANUAL; break; case 2: mMode = Mode.HIDDEN; break; case 3: mMode = Mode.BACKGROUND; break; case 1: default: mMode = Mode.NORMAL; break; } }
From source file:com.droid.app.fotobot.FotoBot.java
/** * ? SharedPreferences/* ww w . ja va 2 s .c o m*/ */ public void LoadSettings() { /******* Create SharedPreferences *******/ SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); sound_mute = pref.getBoolean("Sound_Mute", false); Network_Channel = pref.getString("Network_Channel", "Both"); Network_Connection_Method = pref.getString("Network_Connection_Method", "Method 1"); Use_WiFi = pref.getBoolean("Use_WiFi", true); // getting boolean Use_Mobile_Data = pref.getBoolean("Use_Mobile_Data", true); // getting boolean Use_Flash = pref.getBoolean("Use_Flash", false); make_photo_fc = pref.getBoolean("Use_Fc", false); make_photo_bc = pref.getBoolean("Use_Bc", true); bc_image_attach = pref.getBoolean("Bc_Image_Attach", true); fc_image_attach = pref.getBoolean("Fc_Image_Attach", true); bc_video_attach = pref.getBoolean("Bc_Video_Attach", true); fc_video_attach = pref.getBoolean("Fc_Video_Attach", true); bc_image_delete = pref.getBoolean("Bc_Image_Delete", false); fc_image_delete = pref.getBoolean("Fc_Image_Delete", false); bc_video_delete = pref.getBoolean("Bc_Video_Delete", false); fc_video_delete = pref.getBoolean("Fc_Video_Delete", false); make_video_fc = pref.getBoolean("Make_Video_Fc", false); make_video_bc = pref.getBoolean("Make_Video_Bc", false); JPEG_Compression = pref.getInt("JPEG_Compression", 50); use_autofocus = pref.getBoolean("Use_Autofocus", true); time_for_focusing = pref.getInt("Time_For_Focusing", 1); Camera_Name = pref.getString("Camera_Name", "default"); Photo_Frequency = pref.getInt("Photo_Frequency", 300); video_recording_time = pref.getInt("Video_Recording_Time", 5); bc_current_video_profile = pref.getString("Bc_Current_Video_Profile", "QUALITY_LOW"); fc_current_video_profile = pref.getString("Fc_Current_Video_Profile", "QUALITY_LOW"); process_delay = pref.getInt("process_delay", 5); Image_Scale = pref.getString("Image_Scale", "1"); Image_Size = pref.getString("Image_Size", "1024x768"); fc_Image_Size = pref.getString("fc_Image_Size", "320x240"); EMail_Sender = pref.getString("EMail_Sender", "fotobot@gmail.com"); EMail_Sender_Password = pref.getString("EMail_Sender_Password", "passwd"); EMail_Recepient = pref.getString("EMail_Recepient", "recipient@mail.ru"); Log_Font_Size = pref.getInt("Log_Font_Size", 12); Config_Font_Size = pref.getInt("Config_Font_Size", 14); Photo_Post_Processing_Method = pref.getString("Photo_Post_Processing_Method", "Software"); show_start_tip = pref.getBoolean("Show_Start_Tip", true); SMTP_Host = pref.getString("SMTP_Host", "smtp.gmail.com"); SMTP_Port = pref.getString("SMTP_Port", "465"); loglength = pref.getInt("Log_Length", 1024); log_line_number = pref.getInt("FLog_Length", 150); wake_up_interval = pref.getInt("Wake_Up_Interval", 60); network_up_delay = pref.getInt("Network_Up_Delay", 15); attach_log = pref.getBoolean("Attach_Log", false); Attached_Info_Detailisation = pref.getString("Attached_Info_Detailisation", "Normal"); log_size = pref.getInt("Log_Size", 50); work_dir = pref.getString("Work_Dir", "/data/data/com.droid.app.fotobot/files"); storage_type = pref.getString("Storage_Type", "Internal"); network = pref.getBoolean("Network", false); launched_first_time = pref.getBoolean("Launched_First_Time", true); sms_passwd = pref.getString("SMS_Password", "passwd"); advanced_settings = pref.getBoolean("Advanced_Settings", false); automatic_mode = pref.getBoolean("Automatic_Mode", false); delete_foto = pref.getBoolean("Delete_Foto", false); isCharging_sms = pref.getBoolean("IsCharging_SMS", false); sms_voltage_alert = pref.getBoolean("SMS_Voltage_Alert", false); sms_voltage_alert_number = pref.getString("SMS_Voltage_Alert_Nmuber", "+11234567890"); bc_image_ftp_upload = pref.getBoolean("Bc_Image_FTP_Upload", true); fc_image_ftp_upload = pref.getBoolean("Fc_Image_FTP_Upload", true); bc_video_ftp_upload = pref.getBoolean("Bc_Video_FTP_Upload", true); fc_video_ftp_upload = pref.getBoolean("Fc_Video_FTP_Upload", true); FTP_server = pref.getString("FTP_Server", "ftp.server.com"); FTP_port = pref.getString("FTP_Port", "21"); FTP_username = pref.getString("FTP_Username", "login"); FTP_password = pref.getString("FTP_Password", "passwd"); Upload_Method = pref.getString("Upload_Method", "FTP"); useMail = pref.getBoolean("Use_Mail", false); useFTP = pref.getBoolean("Use_FTP", false); }
From source file:com.ichi2.anki.AbstractFlashcardViewer.java
protected SharedPreferences restorePreferences() { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); mPrefHideDueCount = preferences.getBoolean("hideDueCount", false); mUseInputTag = preferences.getBoolean("useInputTag", false) && (CompatHelper.getSdkVersion() >= 15); mShowTypeAnswerField = (!preferences.getBoolean("writeAnswersDisable", false)) && !mUseInputTag; // On newer Androids, ignore this setting, which sholud be hidden in the prefs anyway. mDisableClipboard = preferences.getString("dictionary", "0").equals("0"); mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false); // mDeckFilename = preferences.getString("deckFilename", ""); mNightMode = preferences.getBoolean("invertedColors", false); mPrefFullscreenReview = Integer.parseInt(preferences.getString("fullscreenMode", "0")) > 0; mCardZoom = preferences.getInt("cardZoom", 100); mImageZoom = preferences.getInt("imageZoom", 100); mRelativeButtonSize = preferences.getInt("answerButtonSize", 100); mInputWorkaround = preferences.getBoolean("inputWorkaround", false); mSpeakText = preferences.getBoolean("tts", false); mPrefSafeDisplay = preferences.getBoolean("safeDisplay", false); mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false); mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20); mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60); mScrollingButtons = preferences.getBoolean("scrolling_buttons", false); mDoubleScrolling = preferences.getBoolean("double_scrolling", false); mPrefCenterVertically = preferences.getBoolean("centerVertically", false); mGesturesEnabled = AnkiDroidApp.initiateGestures(preferences); if (mGesturesEnabled) { mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9")); mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0")); mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8")); mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17")); mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7")); mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3")); mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6")); mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12")); mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2")); mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11")); }/*w w w. j a va2s . c o m*/ if (mLongClickWorkaround) { mGestureLongclick = GESTURE_LOOKUP; } if (preferences.getBoolean("keepScreenOn", false)) { this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } // These are preferences we pull out of the collection instead of SharedPreferences try { mShowNextReviewTime = getCol().getConf().getBoolean("estTimes"); mShowRemainingCardCount = getCol().getConf().getBoolean("dueCounts"); } catch (JSONException e) { throw new RuntimeException(); } return preferences; }
From source file:org.getlantern.firetweet.util.Utils.java
public static HttpClientWrapper getDefaultHttpClient(final Context context) { if (context == null) return null; final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); final int timeoutMillis = prefs.getInt(KEY_CONNECTION_TIMEOUT, 10000) * 1000; final Proxy proxy = getProxy(context); final String userAgent = generateBrowserUserAgent(); final HostAddressResolverFactory resolverFactory = new FiretweetHostResolverFactory( FiretweetApplication.getInstance(context)); return getHttpClient(context, timeoutMillis, true, proxy, resolverFactory, userAgent, false); }