public void OnSharedPreferenceChanged (ISharedPreferences sharedPreferences, string key) { Preference pref = FindPreference (key); if (pref == prefHoursNotifications) { prefHoursNotifications.Summary = string.Format (Resources.GetString (Resource.String.settings_interval_description), Resources.GetStringArray(Resource.Array.hours).GetValue(int.Parse(prefs.GetString ("prefHoursNotifications", "4"))-1)); } }
public static void SaveCookie(ISharedPreferences sharedPreferences, string cookieKey, Cookie cookie) { var editor = sharedPreferences.Edit(); var cookieValueItems = new List<string>(); var itemFormat = "{0}:{1}"; cookieValueItems.Clear(); cookieValueItems.Add(string.Format(itemFormat, "Domain", cookie.Domain)); cookieValueItems.Add(string.Format(itemFormat, "Name", cookie.Name)); cookieValueItems.Add(string.Format(itemFormat, "Value", cookie.Value)); cookieValueItems.Add(string.Format(itemFormat, "Expires", cookie.Expires.ToString())); cookieValueItems.Add(string.Format(itemFormat, "Comment", cookie.Comment)); cookieValueItems.Add(string.Format(itemFormat, "CommentUri", cookie.CommentUri != null ? cookie.CommentUri.AbsoluteUri : null)); cookieValueItems.Add(string.Format(itemFormat, "Discard", cookie.Discard)); cookieValueItems.Add(string.Format(itemFormat, "HttpOnly", cookie.HttpOnly)); cookieValueItems.Add(string.Format(itemFormat, "Path", cookie.Path)); cookieValueItems.Add(string.Format(itemFormat, "Port", cookie.Port)); cookieValueItems.Add(string.Format(itemFormat, "Secure", cookie.Secure)); cookieValueItems.Add(string.Format(itemFormat, "Version", cookie.Version)); editor.PutString(cookieKey, string.Join("|", cookieValueItems.ToArray())); editor.Commit(); var logger = DependencyResolver.Resolve<ILoggerFactory>().Create(typeof(CookieManager)); logger.InfoFormat("Saved Cookie. Domain:{0}, Name:{1}, Value:{2}, Expires:{3}", cookie.Domain, cookie.Name, cookie.Value, cookie.Expires); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView(Resource.Layout.main_activity); mAddGeofencesButton = FindViewById<Button>(Resource.Id.add_geofences_button); mRemoveGeofencesButton = FindViewById<Button>(Resource.Id.remove_geofences_button); mAddGeofencesButton.Click += AddGeofencesButtonHandler; mRemoveGeofencesButton.Click += RemoveGeofencesButtonHandler; mGeofenceList = new List<IGeofence>(); mGeofencePendingIntent = null; mSharedPreferences = GetSharedPreferences(Constants.SHARED_PREFERENCES_NAME, FileCreationMode.Private); mGeofencesAdded = mSharedPreferences.GetBoolean(Constants.GEOFENCES_ADDED_KEY, false); SetButtonsEnabledState(); PopulateGeofenceList(); BuildGoogleApiClient(); }
public override void OnCreate () { base.OnCreate (); prefs = GetSharedPreferences (USER_PREFS, FileCreationMode.Private); userName = prefs.GetString (KEY_USERNAME, null); }
public void OnSharedPreferenceChanged (ISharedPreferences sharedPreferences, string key) { Console.WriteLine ("Preference Changed: " + key); switch (key) { case "prefshowxamarin": settings.ShowXamarinLogo = sharedPreferences.GetBoolean (key, true); break; case "pref24hourclock": settings.Use24Clock = sharedPreferences.GetBoolean (key, false); break; case "prefshowdayofweek": settings.ShowDayOfWeek = sharedPreferences.GetBoolean (key, true); break; case "prefshowdate": settings.ShowDate = sharedPreferences.GetBoolean (key, true); break; } settings.Save (); Console.WriteLine ("Settings> " + settings); var evt = OnSettingsChanged; if (evt != null) evt (settings); }
public override void OnCreate() { base.OnCreate(); Instance = this; // Load preferences Preferences = GetSharedPreferences(SettingsFilename, FileCreationMode.Private); // Default offline mode D3Context.Instance.FetchMode = (Preferences.GetBoolean(SettingsOnlinemode, false) ? FetchMode.Online : FetchMode.OnlineIfMissing); // Checks if some migration operations are needed var upToDateVersion = Preferences.GetInt(UpToDateVersion, 1); if (upToDateVersion < 20) { new MigrationTo20().DoMigration(); } // Always start D3Api with cache available var dataProvider = new CacheableDataProvider(new HttpRequestDataProvider()) { FetchMode = D3Context.Instance.FetchMode }; D3Api.DataProvider = dataProvider; // Set english locale by default D3Api.Locale = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; }
public Settings(ISharedPreferences preferences, string systemLanguage, InfobaseManager.Infobase infobase) { _preferences = preferences; Language = systemLanguage; _name = infobase.Name; BaseUrl = infobase.BaseUrl; ApplicationString = infobase.ApplicationString; FtpPort = infobase.FtpPort; string lastUrl = _preferences.GetString("url", string.Empty); if (BaseUrl == lastUrl) { UserName = _preferences.GetString("user", infobase.UserName); Password = _preferences.GetString("password", infobase.Password); } else { UserName = infobase.UserName; Password = infobase.Password; } ClearCacheOnStart = infobase.IsActive && _preferences.GetBoolean("clearCache", ForceClearCache); infobase.IsActive = true; infobase.IsAutorun = true; WriteSettings(); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView(Resource.Layout.Filter); prefs = PreferenceManager.GetDefaultSharedPreferences(this); RadioButton radio_gps = FindViewById<RadioButton>(Resource.Id.radioButton1); RadioButton radio_fb = FindViewById<RadioButton>(Resource.Id.radioButton2); prefs = PreferenceManager.GetDefaultSharedPreferences(this); string localizationSetting = prefs.GetString("localization",""); if (localizationSetting == "facebook") { radio_fb.Checked = true; radio_gps.Checked = false; } else { radio_fb.Checked = false; radio_gps.Checked = true; } radio_gps.Click += RadioButtonClick; radio_fb.Click += RadioButtonClick; Button backButton = FindViewById<Button>(Resource.Id.button1); backButton.Click += (object sender, EventArgs e) => { Intent intent = new Intent (this, typeof(MainActivity)); StartActivityForResult (intent, 0); }; }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { if (key != "clearCache" && key != "anonymousAccess") { string value = sharedPreferences.GetString(key, string.Empty); FillSummary(key, value); if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true)) { ISharedPreferencesEditor editor = sharedPreferences.Edit(); editor.PutBoolean("clearCache", true); editor.Commit(); MakeToast(D.NEED_TO_REBOOT_FULL); } if (key == "application") MakeToast(D.NEED_TO_REBOOT); } else { MakeToast(D.NEED_TO_REBOOT_FULL); } BitBrowserApp.Current.SyncSettings(); }
private SharedPreferencesHelper() { _favPrefs = Application.Context.GetSharedPreferences ("FavoriteVideos", FileCreationMode.Private); _watchListPrefs = Application.Context.GetSharedPreferences ("WatchListVideos", FileCreationMode.Private); _likedVidsPrefs = Application.Context.GetSharedPreferences ("LikedVideos", FileCreationMode.Private); _dislikedVidsPrefs = Application.Context.GetSharedPreferences ("DislikedVideos", FileCreationMode.Private); _watchedVidsPrefs = Application.Context.GetSharedPreferences ("WatchedVideos", FileCreationMode.Private); }
internal OtherSettings(ISharedPreferences sharedPrefs) { ConnectTimeout = int.Parse(sharedPrefs.GetString("pref_timeout_connect", "10000")); ConnectCheckInterval = int.Parse(sharedPrefs.GetString("pref_interval_check_connect", "200")); ToastLevel = (ToastLevel)int.Parse(sharedPrefs.GetString("pref_toasts_level", "2")); IgnoreSslCertErrors = sharedPrefs.GetBoolean("pref_ignore_ssl_errors", true); StartUrl = sharedPrefs.GetString("pref_start_url", null); }
public MyDrawerToggle(AppCompatActivity host, DrawerLayout drawerLayout, int openedResource, int closedResource,ISharedPreferences pref) : base(host, drawerLayout, openedResource, closedResource) { _mHostActivity = host; _mOpenedResource = openedResource; _mClosedResource = closedResource; _pref = pref; }
public static ISharedPreferences GetPref(Context context) { if (pref == null) { pref = PreferenceManager.GetDefaultSharedPreferences(context); } return pref; }
public JPushUtil (Context _context) { context = _context; handler = new Handler(DealMessage); //或得共享实例变量 sp_userinfo = context.GetSharedPreferences(Global.SHAREDPREFERENCES_USERINFO,FileCreationMode.Private); sp_jpushInfo = context.GetSharedPreferences (Global.SHAREDPREFERENCES_JPUSH, FileCreationMode.Private); }
public InfobasesScreen(BaseScreen activity, ISharedPreferences prefs, InfobaseSelected resultCallback) : base(activity, null) { _prefs = prefs; _resultCallback = resultCallback; _manager = InfobaseManager.Current; }
protected override void OnHandleIntent(Intent intent) { lastIntent = intent; Bundle extras = intent.Extras; GoogleCloudMessaging gcm = GoogleCloudMessaging.GetInstance(this); string messageType = gcm.GetMessageType(intent); if(!extras.IsEmpty) { userPrefs = PreferenceManager.GetDefaultSharedPreferences(this); if(GoogleCloudMessaging.MessageTypeSendError.Equals(messageType)) { AndroidUtils.SendNotification("Speeching Error", "Error while sending message: " + extras.ToString(), typeof(MainActivity), this); } else if(GoogleCloudMessaging.MessageTypeDeleted.Equals(messageType)) { AndroidUtils.SendNotification("Speeching Messages", "Deleted messages on the server", typeof(MainActivity), this); } else if(GoogleCloudMessaging.MessageTypeMessage.Equals(messageType)) { string notifType = extras.GetString("notifType"); lastType = notifType; PrepClient(); // Choose what to do depending on the message type switch (notifType) { case "notification" : if (userPrefs.GetBoolean("prefNotifMessage", true)) { // The user wants to receive notifications AndroidUtils.SendNotification(extras.GetString("title"), extras.GetString("message"), typeof(LoginActivity), this); } break; case "locationReminder" : if (userPrefs.GetBoolean("prefNotifMessage", true)) { // The user wants to receive notifications ShowReminder(); } break; case "newFences" : if (userPrefs.GetBoolean("prefNotifGeofence", true)) { // The user wants to have geofences enabled BuildFences(extras.GetString("fences")); } break; case "newActivities" : FetchNewContent(); break; } } } }
private ISharedPreferences GetPrefs() { if (prefs == null) { prefs = GetSharedPreferences("ACT_" + guide.Id, FileCreationMode.MultiProcess); } return prefs; }
void DisplayCurrentPreferenceValues(ISharedPreferences sharedPreferences) { Preference pilotName = FindPreference("pref_pilotname"); string curPilotName = sharedPreferences.GetString("pref_pilotname", ""); if (curPilotName == "") { curPilotName = "Enter your pilot name"; } pilotName.Summary = curPilotName; }
public static bool GetPreferenceAsBool(Context context, string preferenceKey) { if (_sharedPreferences == null) { _sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); } var value = _sharedPreferences.GetBoolean(preferenceKey, false); return value; }
public static string GetPreferenceAsString(Context context, string preferenceKey) { if (_sharedPreferences == null) { _sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); } var value = _sharedPreferences.GetString(preferenceKey, string.Empty); return value; }
public static AppPreferences Create(ISharedPreferences prefs) { return new AndroidAppPreferences(prefs) { FirtsTimeRunning = prefs.GetBoolean(AppPreferences.FirstTimeKey, true), Ip = prefs.GetString(AppPreferences.IpKey, ""), Port = prefs.GetInt(AppPreferences.PortKey, 0), UseSounds = prefs.GetBoolean(AppPreferences.UseSoundsKey, true), UseCache = prefs.GetBoolean(AppPreferences.UseCacheKey, true) }; }
public void StorePreferences(ISharedPreferences spr) { var prefsEditor = spr.Edit(); prefsEditor.PutInt("TableOf", TableOf); prefsEditor.PutString("strRandomQuestions", RandomQuestions.ToString()); prefsEditor.PutInt("UpperLimit", UpperLimit); prefsEditor.PutInt("CounterMin", CounterMin); prefsEditor.PutInt("CounterMax", CounterMax); prefsEditor.Commit(); }
public static long GetPreferenceAsLong(Context context, string preferenceKey) { if (_sharedPreferences == null) { _sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); } var value = _sharedPreferences.GetString(preferenceKey, "0"); long returnVal = long.TryParse(value, out returnVal) ? returnVal : 0; return returnVal; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); RequestWindowFeature (WindowFeatures.CustomTitle); SetContentView (Resource.Layout.Setting); Window.SetFeatureInt (WindowFeatures.CustomTitle, Resource.Layout.custom_title_bar); //或得共享实例变量 sp_userinfo = this.GetSharedPreferences(Global.SHAREDPREFERENCES_USERINFO,FileCreationMode.Private); InitView (); // Create your application here }
public void OnSharedPreferenceChanged (ISharedPreferences sharedPreferences, string key) { switch (key) { case Helpers.Settings.WeightKey: this.SetWeight (); break; case Helpers.Settings.CadenceKey: this.SetCadence (); break; } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); RequestWindowFeature (WindowFeatures.CustomTitle); // Create your application here SetContentView(Resource.Layout.RegisterResultLayout); Window.SetFeatureInt (WindowFeatures.CustomTitle, Resource.Layout.custom_title_bar); sp_userinfo = this.GetSharedPreferences(Global.SHAREDPREFERENCES_USERINFO,FileCreationMode.Private); _jpushUtil = new JPushUtil (this); InitView (); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); ConnectivityManager connectivityManager = (ConnectivityManager) GetSystemService(ConnectivityService); NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo; Button loginButton = FindViewById<Button>(Resource.Id.loginButton); Button filteButton = FindViewById<Button> (Resource.Id.button1); prefs = PreferenceManager.GetDefaultSharedPreferences(this); _locationManager = GetSystemService (Context.LocationService) as LocationManager; Criteria criteriaForLocationService = new Criteria { Accuracy = Accuracy.Fine }; acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true); filteButton.Click += (object sender, EventArgs e) => { Intent intent = new Intent (this, typeof(FilterActivity)); StartActivityForResult (intent, 0); }; loginButton.Click += (object sender, EventArgs e) => { bool isOnline = (activeConnection != null) && activeConnection.IsConnected; bool wifiIsOnline = (connectivityManager.GetNetworkInfo(ConnectivityType.Wifi)).IsConnected; if (isOnline || wifiIsOnline) { if (!string.IsNullOrEmpty (prefs.GetString ("token", ""))) { Intent intent = new Intent (this, typeof(SearchActivity)); StartActivityForResult (intent, 0); } else { auth = Global.LogIn (); auth.Completed += auth_Completed; StartActivity (auth.GetUI (this)); } } else { AlertDialog.Builder alert = new AlertDialog.Builder (this); alert.SetTitle ("Internet connection error"); alert.SetMessage ("Turn wifi or mobile data on"); alert.SetPositiveButton ("Ok", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //Set to default theme. SetTheme(Resource.Style.Theme_Dark); //Set the view to the "main" layout resource. SetContentView(Resource.Layout.Main); //Get shared preferences for later deciding if ShowcaseView is neccessary or not. prefs = PreferenceManager.GetDefaultSharedPreferences(this); //If enviroemnt OS is Marshmallow or newer. if (Generic.CanMakeSmores()) { //Check for microphone permission. //int hasPermission = (int)CheckSelfPermission(Manifest.Permission.RecordAudio); Permission permissionState = PackageManager.CheckPermission( Manifest.Permission.RecordAudio, Manifest.Permission_group.Microphone); if (permissionState != Permission.Granted) { Generic.ShowMsgBox_OK(this, GetString(Resource.String.AudioRecordPermissionAlertTitle), GetString(Resource.String.AudioRecordPermissionAlertMsg)); RequestPermissions(new string[] { Manifest.Permission.RecordAudio }, REQUEST_CODE_ASK_PERMISSIONS); } } //Start the appropriate activity for each of the buttons on click event. ImageButton btnTuner = FindViewById<ImageButton>(Resource.Id.btnTuner); btnTuner.Click += delegate { StartActivity(typeof(TunerActivity)); }; ImageButton btnTutor = FindViewById<ImageButton>(Resource.Id.btnTutor); btnTutor.Click += delegate { StartActivity(typeof(TutorActivity)); }; ImageButton btnPlayer = FindViewById<ImageButton>(Resource.Id.btnPlayer); btnPlayer.Click += delegate { StartActivity(typeof(PlayerActivity)); }; ImageButton btnRecorder = FindViewById<ImageButton>(Resource.Id.btnRecorder); btnRecorder.Click += delegate { StartActivity(typeof(RecorderActivity)); }; }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { Preference pref = FindPreference (key); if (pref.GetType () == typeof(ListPreference)) { var listPref = (ListPreference)pref; pref.Summary = listPref.Entry; } else { pref.Summary = sharedPreferences.GetString (key,""); } var prefEditor = sharedPreferences.Edit (); prefEditor.PutString (key,sharedPreferences.GetString (key,"")); prefEditor.Commit (); }
public override void SetUp() { var salt = new byte[] { 104, 12, 112, 82, 85, 10, 11, 61, 15, 54, 44, 66, 117, 89, 64, 110, 53, 123, 33 }; // Prepare PreferenceObfuscator instance sp = Context.GetSharedPreferences(Filename, FileCreationMode.Private); string deviceId = Settings.Secure.GetString(Context.ContentResolver, Settings.Secure.AndroidId); IObfuscator o = new AesObfuscator(salt, Context.PackageName, deviceId); op = new PreferenceObfuscator(sp, o); // Populate with test data op.PutString("testString", "Hello world"); op.Commit(); }