/// <summary> /// Retrieves application settings of types bool, float, int, long, ICollection<string> and string /// </summary> /// <param name="key">Settings Key</param> /// <returns>Application Settings of types bool, float, int, long, ICollection<string> or string</returns> public T GetSetting <T>(string key) { if (typeof(T) == typeof(bool)) { return((T)(object)_sharedPreferences.GetBoolean(key, false)); } else if (typeof(T) == typeof(float)) { return((T)(object)_sharedPreferences.GetFloat(key, float.MinValue)); } else if (typeof(T) == typeof(int)) { return((T)(object)_sharedPreferences.GetInt(key, int.MinValue)); } else if (typeof(T) == typeof(long)) { return((T)(object)_sharedPreferences.GetFloat(key, long.MinValue)); } else if (typeof(T) == typeof(ICollection <string>)) { return((T)(object)_sharedPreferences.GetStringSet(key, null)); } else { return((T)(object)_sharedPreferences.GetString(key, String.Empty)); } }
private void SyncData() { ISharedPreferences sharedPref = Activity.GetSharedPreferences("favorite_stations", FileCreationMode.Private); ICollection <string> favorite_stations = sharedPref.GetStringSet("favorite_stations", new List <string>()); syncThread = new Thread(new ThreadStart(() => { List <ListViewItemStation> items; Station[] stations; var data = RestClient.GetStationsData(); if (data != null) { stations = data.Data; items = new List <ListViewItemStation>(); for (int i = 0; i < stations.Length; i++) { if (favorite_stations.Contains(stations[i].StationName)) { items.Add(new ListViewItemStation(i, stations[i], true)); } else { items.Add(new ListViewItemStation(i, stations[i], false)); } } Activity.RunOnUiThread(() => { adapter.AddData(items); adapter.NotifyDataSetChanged(); }); } })); syncThread.Start(); }
public static ICollection <String> GetAllPersonIds(String personGroupId, Context context) { ISharedPreferences personIdSet = context.GetSharedPreferences(personGroupId + "PersonIdSet", FileCreationMode.Private); return(personIdSet.GetStringSet("PersonIdSet", new HashSet <String>())); }
private bool CheckScanNo(string kamotsu_no) { try { // 移動元と移動先のマテハンが同じの場合 motokamotuList = prefs.GetStringSet("kamotuList", new List <string>()).ToList(); if (motokamotuList.FindIndex(x => x == kamotsu_no) != -1) { ShowDialog("エラー", "同一のマテハンです。", () => { }); return(false); } // 貨物番号に紐づく情報を取得する kamotuInfo = WebService.RequestIdou033(souko_cd, kitaku_cd, kamotsu_no); // 得意先、届先が一致するかを確認する if ((kamotuInfo.tokuisaki_cd == prefs.GetString("tmptokui_cd", "") && kamotuInfo.todokesaki_cd == prefs.GetString("tmptodoke_cd", "")) || prefs.GetString("tmptokui_cd", "") == "") { // Do nothing } else { ShowDialog("エラー", "届先が異なります。", () => { }); return(false); } // 便情報が一致するかを確認する if (txtKosu.Text != "0") { // 便チェック if (prefs.GetString("bin_no", "0") != kamotuInfo.torikomi_bin) { ShowDialog("エラー", "便が異なります。", () => { }); return(false); } } } catch { ShowDialog("エラー", "例外エラーが発生しました。", () => { }); Log.Debug(TAG, "CheckScanNo メソッドでエラー発生"); return(false); } return(true); }
public void LoadData(Context context) { _context = context; ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context); var categoriesAsCollection = prefs.GetStringSet("Categories", GetDefaultCategories()); Categories.Clear(); foreach (var i in categoriesAsCollection) { Categories.Add(Enum.Parse <PoiCategory>(i)); } IsViewAngleCorrection = prefs.GetBoolean("IsViewAngleCorrection", false); CorrectionViewAngleHorizontal = prefs.GetFloat("CorrectionViewAngleHorizontal", 0); CorrectionViewAngleVertical = prefs.GetFloat("CorrectionViewAngleVertical", 0); AltitudeFromElevationMap = prefs.GetBoolean("AltitudeFromElevationMap", true); AutoElevationProfile = prefs.GetBoolean("AutoElevationProfile", true); PrivacyPolicyApprovementLevel = prefs.GetInt("PrivacyPolicyApprovementLevel", 0); { var isTutorialNeeded = prefs.GetBoolean("ShowTutorialMainActivity", true); SetTutorialNeeded(TutorialPart.MainActivity, isTutorialNeeded); } { var isTutorialNeeded = prefs.GetBoolean("ShowTutorialPhotoEditActivity", true); SetTutorialNeeded(TutorialPart.PhotoEditActivity, isTutorialNeeded); } { var isTutorialNeeded = prefs.GetBoolean("ShowTutorialPhotoShowActivity", true); SetTutorialNeeded(TutorialPart.PhotoShowActivity, isTutorialNeeded); } CameraResolutionSelected = new Android.Util.Size(prefs.GetInt("CameraResolutionWidth", 0), prefs.GetInt("CameraResolutionHeight", 0)); CameraId = prefs.GetString("CameraId", null); string lan = prefs.GetString("Language", ""); if (!Enum.TryParse <Language>(lan, out Language)) { Language = PoiCountryHelper.GetDefaultLanguage(); } _applicationRatingCompleted = prefs.GetBoolean("ApplicationRatingCompleted", false); string applicationRatingQuestionDateAsString = prefs.GetString("ApplicationRatingQuestionDate", null); if (DateTime.TryParse(applicationRatingQuestionDateAsString, out var applicationRatingQuestionDateAsDate)) { _applicationRatingQuestionDate = applicationRatingQuestionDateAsDate; } ShowElevationProfile = AutoElevationProfile; }
public static bool isDelivered(Context context, String purchasetoken) { ISharedPreferences sharedPreferences = context.GetSharedPreferences(DATA_NAME, FileCreationMode.Private); ICollection <string> stringSet = sharedPreferences.GetStringSet(PURCHASETOKEN_KEY, null); if (stringSet != null && stringSet.Contains(purchasetoken)) { return(true); } return(false); }
protected SortedSet <string> GetLeaguesFromSharedPreference(ISharedPreferences prefs) { SortedSet <string> leagues = new SortedSet <string>(); foreach (var country in Enum.GetValues(typeof(CountriesEnum)).Cast <CountriesEnum>()) { leagues.UnionWith(prefs.GetStringSet(country.ToString().ToLower(), new List <string>()).ToList()); } return(leagues); }
private static LessonRemindTime ParseLessonRemindTimes(ISharedPreferences preferences) { IEnumerable <String> values = preferences.GetStringSet("LessonRemindTimes", null); if (values == null) { return(LessonRemindTime.Never); } return((LessonRemindTime)(values.Select(v => Int32.Parse(v)).Sum())); }
protected async override void OnCreate(Bundle bundle) { //Generic onCreate for the activity base.OnCreate(bundle); //Gesture management gestureDetector = createGestureDetector(this); //Stops Glass from turning the screen off Window.AddFlags(WindowManagerFlags.KeepScreenOn); //Creates the AudioManager for the tap responses audioManager = (AudioManager)GetSystemService(Context.AudioService); //Load hashtag history using preferences prefs = GetSharedPreferences("tweets", 0); HashSet <String> defaultPrefs = new HashSet <String>(); defaultPrefs.Add("YOlO"); var tempHashtagPrefs = prefs.GetStringSet("hashtags", defaultPrefs); foreach (var x in tempHashtagPrefs) { hashtagPrefs.Add(x); } //Create title card cards = new List <Card>(); AddCard("YOLO (for Glass", "Tap to load cards"); //Set up card scroller scroller = new CardScrollView(this); scroller.Adapter = adapter; //Handles touchpad tap scroller.ItemClick += (system, e) => tweetRefresh(); //Twitter auth and setup var tht = new TwitterHashtags.TwitterHashtags(); auth = await tht.doAuth(); //Activate the view SetContentView(scroller); }
/// <summary> /// Save the running in the parameter. /// </summary> public void SaveRunning(RunningData running) { ISharedPreferences runningTracker = Application.Context.GetSharedPreferences("RunningTracker", FileCreationMode.Private); ICollection <string> stringICollection = runningTracker.GetStringSet("Runnings", null); List <string> runningsString = new List <string>(); if (stringICollection != null) { runningsString = stringICollection.ToList(); } runningsString.Add(JsonConvert.SerializeObject(running)); ISharedPreferencesEditor runningTrackerEditor = runningTracker.Edit(); runningTrackerEditor.PutStringSet("Runnings", runningsString); runningTrackerEditor.Commit(); }
/// <summary> /// Returns the previous saved runnings. /// </summary> public List <RunningData> LoadPreviousRunnings() { ISharedPreferences runningTracker = Application.Context.GetSharedPreferences("RunningTracker", FileCreationMode.Private); ICollection <string> stringICollection = runningTracker.GetStringSet("Runnings", null); List <RunningData> runnings = new List <RunningData>(); if (stringICollection != null) { List <string> stringList = stringICollection.ToList(); foreach (string element in stringList) { runnings.Add(JsonConvert.DeserializeObject <RunningData>(element)); } } runnings.Sort((a, b) => DateTime.Compare(a.StartDateTime, b.StartDateTime)); return(runnings); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); cards = new List <Card>(); scroller = new CardScrollView(this); // Set our view from the GDK Card API prefs = GetSharedPreferences("tweets", 0); HashSet <String> defaultPrefs = new HashSet <String>(); defaultPrefs.Add("YOlO"); var tempHashtagPrefs = prefs.GetStringSet("hashtags", defaultPrefs); foreach (var hashtag in tempHashtagPrefs) { AddCard(hashtag, ""); } scroller.Adapter = adapter; scroller.ItemClick += (system, e) => { Card cardz = (Card)adapter.GetItem(e.Position); string z = cardz.Text; MainActivity.SetHashtag(z); Finish(); }; SetContentView(scroller); // Create your application here }
public override void OnReceive(Context context, Intent intent) { try { data = context.GetSharedPreferences("project_alarm", FileCreationMode.Private); if (data != null) { ICollection <string> alarmStrings = data.GetStringSet("alarms", null); alarmService = new AlarmService(); if (alarmStrings != null) { foreach (string a in alarmStrings) { alarmService.Alarms.Add(AlarmFactory.StringToAlarm(a)); } alarmService.Alarms.Sort(); AlarmMngr.StartAlarm(alarmService.GetNextEnabledAlarm(), context); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
protected override void OnResume() { base.OnResume(); if (!gotActivityResult) { ICollection <string> alarmStrings = data.GetStringSet("alarms", null); alarmService.Alarms.Clear(); if (alarmStrings != null) { foreach (string a in alarmStrings) { alarmService.Alarms.Add(AlarmFactory.StringToAlarm(a)); } alarmService.Alarms.Sort(); alarmsListViewAdapter.NotifyDataSetChanged(); UpdateAlarmManager(); } } else { gotActivityResult = false; } }
private void setNewAlarm() { try { ISharedPreferences data = GetSharedPreferences("project_alarm", FileCreationMode.Private); if (data != null) { ICollection <string> alarmStrings = data.GetStringSet("alarms", null); AlarmService alarmService = new AlarmService(); if (alarmStrings != null) { foreach (string a in alarmStrings) { string timeString = Regex.Match(a, @"Time=([^(,|\])]*)").Groups [1].Value; string enabledString = Regex.Match(a, @"Enabled=([^(,|\])]*)").Groups [1].Value; char[] daysCharArray = (Regex.Match(a, @"Days=([^(,|\])]*)").Groups [1].Value).ToCharArray(); Console.WriteLine("alarms: " + a + "regexstring: " + timeString + ", " + enabledString.ToLower()); bool[] days = new bool[7]; for (int i = 0; i < 7; i++) { if (daysCharArray[i].Equals('1')) { days [i] = true; } } alarmService.Alarms.Add(new Alarm(TimeSpan.Parse(timeString), Convert.ToBoolean(enabledString)) { Days = days }); } alarmService.Alarms.Sort(); AlarmMngr.StartAlarm(alarmService.GetNextEnabledAlarm(), this); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public ICollection <string> ReadStrings(Context context, string key, ICollection <string> defaultValue) { ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context); return(prefs.GetStringSet(key, defaultValue)); }
public static ICollection <string> GetSelectedCategories() { return(_mPreferences.GetStringSet("selected_categories", _allCategories)); }
private IEnumerable <string> getSavedNotificationIds() => sharedPreferences.GetStringSet(ScheduledNotificationsStorageKey, new List <string>()) .ToImmutableList();
public ICollection <string> GetStringCollection(string Name) { return(prefManager.GetStringSet(Name, null)); }
public void Refresh() { var properties = GetType().GetProperties(); foreach (var prop in properties) { var attribute = (PreferenceAttribute)prop.GetCustomAttributes(typeof(PreferenceAttribute), false).First(); var ptype = prop.PropertyType; if (ptype == typeof(string)) { prop.SetValue(this, preferences.GetString(attribute.Key, (string)(attribute.DefaultValue ?? default(string)))); } else if (typeof(ICollection <string>).IsAssignableFrom(ptype)) { prop.SetValue(this, preferences.GetStringSet(attribute.Key, (ICollection <string>)(attribute.DefaultValue ?? default(ICollection <string>)))); } else if (ptype == typeof(bool)) { prop.SetValue(this, preferences.GetBoolean(attribute.Key, (bool)(attribute.DefaultValue ?? default(bool)))); } else if (ptype == typeof(float)) { prop.SetValue(this, preferences.GetFloat(attribute.Key, (float)(attribute.DefaultValue ?? default(float)))); } else if (ptype == typeof(int)) { prop.SetValue(this, preferences.GetInt(attribute.Key, (int)(attribute.DefaultValue ?? default(int)))); } else if (ptype == typeof(long)) { prop.SetValue(this, preferences.GetLong(attribute.Key, (long)(attribute.DefaultValue ?? default(long)))); } else { prop.SetValue(this, JsonConvert.DeserializeObject(preferences.GetString(attribute.Key, string.Empty))); } } var fields = GetType().GetFields(); foreach (var field in fields) { var attribute = (PreferenceAttribute)field.GetCustomAttributes(typeof(PreferenceAttribute), false).First(); var ftype = field.FieldType; if (ftype == typeof(string)) { field.SetValue(this, preferences.GetString(attribute.Key, (string)(attribute.DefaultValue ?? default(string)))); } else if (typeof(ICollection <string>).IsAssignableFrom(ftype)) { field.SetValue(this, preferences.GetStringSet(attribute.Key, (ICollection <string>)(attribute.DefaultValue ?? default(ICollection <string>)))); } else if (ftype == typeof(bool)) { field.SetValue(this, preferences.GetBoolean(attribute.Key, (bool)(attribute.DefaultValue ?? default(bool)))); } else if (ftype == typeof(float)) { field.SetValue(this, preferences.GetFloat(attribute.Key, (float)(attribute.DefaultValue ?? default(float)))); } else if (ftype == typeof(int)) { field.SetValue(this, preferences.GetInt(attribute.Key, (int)(attribute.DefaultValue ?? default(int)))); } else if (ftype == typeof(long)) { field.SetValue(this, preferences.GetLong(attribute.Key, (long)(attribute.DefaultValue ?? default(long)))); } else { field.SetValue(this, JsonConvert.DeserializeObject(preferences.GetString(attribute.Key, string.Empty))); } } }
public List <string> GetPrefStrings(String key) { return(_sharedPrefs == null ? new List <string>() : _sharedPrefs.GetStringSet(key, new List <string>()).ToList()); }
ICollection <string> GetAllAutofillDataStringSet() { return(Prefs.GetStringSet(CLIENT_FORM_DATA_KEY, new HashSet <String>())); }
public override View GetView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater)context .GetSystemService(Context.LayoutInflaterService); var view = inflater.Inflate(Resource.Layout.stationListViewItem, parent, false); var tvstationname = view.FindViewById <TextView>(Resource.Id.tvStationName); var tvstationAddress = view.FindViewById <TextView>(Resource.Id.tvStationAddress); var tvactivedevicenumber = view.FindViewById <TextView>(Resource.Id.tvOcuppiedSpotsNumber); var tvValue = view.FindViewById <TextView>(Resource.Id.tvValue); var ivsettings = view.FindViewById <ImageView>(Resource.Id.imageviewAddToFavourites); var img_favorite = view.FindViewById <ImageView>(Resource.Id.imageviewAddToFavourites); var imageviewActive = view.FindViewById <ImageView>(Resource.Id.imageviewActive); if (itemList[position].is_favorite) { img_favorite.SetImageResource(Resource.Drawable.favouriteselected_48); } else { img_favorite.SetImageResource(Resource.Drawable.favourite_50); } ListViewItemStation station = itemList[position]; if (station.station.Status != "Functionala" && station.station.StatusType != "Online") { imageviewActive.SetImageResource(Resource.Drawable.in_active); } if (favorite) { img_favorite.SetImageResource(Resource.Drawable.favouriteselected_48); img_favorite.Click += delegate { ISharedPreferences sharedPref = activity.GetSharedPreferences("favorite_stations", FileCreationMode.Private); ICollection <string> favorite_stations = sharedPref.GetStringSet("favorite_stations", new List <string>()); ISharedPreferencesEditor editor = sharedPref.Edit(); List <string> new_favorite_stations = new List <string>(); new_favorite_stations.AddRange(favorite_stations); new_favorite_stations.Remove(station.station.StationName); editor.PutStringSet("favorite_stations", new_favorite_stations); editor.Commit(); itemList.Remove(station); this.NotifyDataSetChanged(); }; } else { img_favorite.Click += delegate { ISharedPreferences sharedPref = activity.GetSharedPreferences("favorite_stations", FileCreationMode.Private); ICollection <string> favorite_stations = sharedPref.GetStringSet("favorite_stations", new List <string>()); ISharedPreferencesEditor editor = sharedPref.Edit(); List <string> new_favorite_stations = new List <string>(); new_favorite_stations.AddRange(favorite_stations); new_favorite_stations.Add(station.station.StationName); editor.PutStringSet("favorite_stations", new_favorite_stations); editor.Commit(); itemList.Find(x => x.station == station.station).is_favorite = true; this.NotifyDataSetChanged(); }; } tvstationname.Text = itemList[position].station.StationName; tvstationAddress.Text = itemList[position].station.Address; tvactivedevicenumber.Text = "Bikes " + itemList[position].station.OcuppiedSpots.ToString(); tvValue.Text = "Parking " + itemList[position].station.EmptySpots.ToString(); return(view); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.fragment_tsumikae_Idou_moto, container, false); prefs = PreferenceManager.GetDefaultSharedPreferences(Context); editor = prefs.Edit(); txtCase = view.FindViewById <TextView>(Resource.Id.txt_tsumikae_case); txtOricon = view.FindViewById <TextView>(Resource.Id.txt_tsumikae_oricon); txtIdosu = view.FindViewById <TextView>(Resource.Id.txt_tsumikae_idosu); txtMail = view.FindViewById <TextView>(Resource.Id.txt_tsumikae_mail); txtSonota = view.FindViewById <TextView>(Resource.Id.txt_tsumikae_sonota); txtFuteikei = view.FindViewById <TextView>(Resource.Id.txt_tsumikae_futeikei); txtHansoku = view.FindViewById <TextView>(Resource.Id.txt_tsumikae_hansoku); txtTc = view.FindViewById <TextView>(Resource.Id.txt_tsumikae_tc); txtKosu = view.FindViewById <TextView>(Resource.Id.txt_tsumikae_kosu); // 連続バーコード読み取り時に使う変数初期化 editor.PutString("tmptokui_cd", ""); editor.PutString("tmptodoke_cd", ""); editor.Apply(); // 確定ボタン btnConfirm = view.FindViewById <BootstrapButton>(Resource.Id.confirmButton); btnConfirm.Click += delegate { if (menuFlag == 1) { Bundle bundle = new Bundle(); bundle.PutString("motoInfo", JsonConvert.SerializeObject(motoMateInfo)); StartFragment(FragmentManager, typeof(TsumikaeIdouSakiFragment), bundle); } else if (menuFlag == 3) { editor.PutString("from_gyomu", "3"); editor.Apply(); Bundle bundle = new Bundle(); bundle.PutString("motoInfo", JsonConvert.SerializeObject(motoMateInfo)); StartFragment(FragmentManager, typeof(TsumikaeIdouMatehanFragment), bundle); } }; // マテハンボタン btnMate = view.FindViewById <BootstrapButton>(Resource.Id.mateButton); btnMate.Click += delegate { Bundle bundle = new Bundle(); bundle.PutString("motoInfo", JsonConvert.SerializeObject(motoMateInfo)); editor.PutString("from_gyomu", "1"); editor.Apply(); StartFragment(FragmentManager, typeof(TsumikaeIdouMatehanFragment), bundle); }; // 初期値設定 SetTitle("移動元マテハン"); souko_cd = prefs.GetString("souko_cd", ""); kitaku_cd = prefs.GetString("kitaku_cd", ""); menuFlag = prefs.GetInt("menuFlag", 1); // メニュー区分 txtCase.Text = "0"; txtOricon.Text = "0"; txtIdosu.Text = "0"; txtMail.Text = "0"; txtSonota.Text = "0"; txtFuteikei.Text = "0"; txtHansoku.Text = "0"; txtTc.Text = "0"; txtKosu.Text = "0"; kamotuList = new List <string>(); motomateCdList = prefs.GetStringSet("motoMateCdList", new List <string>()).ToList(); motoMateInfo = new List <Ido>(); btnConfirm.Enabled = false; btnMate.Enabled = false; if (menuFlag != 1) { btnMate.Visibility = ViewStates.Gone; } return(view); }