protected override void OnUserLeaveHint() { base.OnUserLeaveHint(); if (GlobalVars.myDetail != null) { if (!string.IsNullOrEmpty(GlobalVars.myDetail.SalesmanId)) { saveDetails(GlobalVars.myDetail); } else { if (mysetting.Contains("id")) { GlobalVars.myDetail = new Salesman(mysetting.GetString("id", ""), mysetting.GetString("name", ""), mysetting.GetString("address", ""), mysetting.GetString("phone", ""), mysetting.GetString("username", "")); } } } else { if (mysetting.Contains("id")) { GlobalVars.myDetail = new Salesman(mysetting.GetString("id", ""), mysetting.GetString("name", ""), mysetting.GetString("address", ""), mysetting.GetString("phone", ""), mysetting.GetString("username", "")); } } }
bool CheckCascadeFile(String face, String eye, out String faceFile, out String eyeFile) { #if __ANDROID__ ISharedPreferences preference = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context); String appVersion = Android.App.Application.Context.PackageManager.GetPackageInfo(Android.App.Application.Context.PackageName, Android.Content.PM.PackageInfoFlags.Activities).VersionName; if (!preference.Contains("cascade-data-version") || !preference.GetString("cascade-data-version", null).Equals(appVersion) || !(preference.Contains("cascade-eye-data-path") || preference.Contains("cascade-face-data-path"))) { AndroidFileAsset.OverwriteMethod overwriteMethod = AndroidFileAsset.OverwriteMethod.AlwaysOverwrite; FileInfo eyeFileTmp = AndroidFileAsset.WritePermanantFileAsset(Android.App.Application.Context, eye, "cascade", overwriteMethod); FileInfo faceFileTmp = AndroidFileAsset.WritePermanantFileAsset(Android.App.Application.Context, face, "cascade", overwriteMethod); //save data path ISharedPreferencesEditor editor = preference.Edit(); editor.PutString("cascade-data-version", appVersion); editor.PutString("cascade-eye-data-path", eyeFileTmp.FullName); editor.PutString("cascade-face-data-path", faceFileTmp.FullName); editor.Commit(); } eyeFile = preference.GetString("cascade-eye-data-path", null); faceFile = preference.GetString("cascade-face-data-path", null); return(File.Exists(eyeFile) && File.Exists(faceFile)); #else faceFile = face; eyeFile = eye; return(true); #endif }
public bool?GetBool(string key) { if (_preferenceManager.Contains(key)) { return(_preferenceManager.GetBoolean(key, false)); } return(null); }
/// <summary> /// Removes the stored data about which date is currently selected /// </summary> void forgetCurrentSelection() { if (pref.Contains("DateSelectedID")) { editor = pref.Edit(); editor.Remove("DateSelectedID"); editor.Apply(); } }
protected override void OnCreate(Bundle savedInstanceState) { rsaProvider = PemKeyUtils.GetRSAProviderFromPemString(key); base.OnCreate(savedInstanceState); shp = Application.Context.GetSharedPreferences("ewosettings", FileCreationMode.Append); edtr = shp.Edit(); if (!shp.Contains("Area")) { edtr.PutString("Area", ""); edtr.Commit(); } if (!shp.Contains("name")) { edtr.PutString("name", "invalid"); edtr.Commit(); } if (!shp.Contains("token")) { edtr.PutString("token", "invalid"); edtr.Commit(); } if (!shp.Contains("record_id")) { edtr.PutString("record_id", "not_found"); edtr.Commit(); } if (shp.GetString("record_id", "not_found") != "not_found") { StartActivity(typeof(MainActivity)); } SetContentView(Resource.Layout.InitailSettings); tv1 = FindViewById <TextView>(Resource.Id.textView1); ed1 = FindViewById <EditText>(Resource.Id.tokenEdit); phoneText = FindViewById <EditText>(Resource.Id.phoneEdit); valText = FindViewById <EditText>(Resource.Id.validEditText); emailText = FindViewById <EditText>(Resource.Id.emailEdit); tokenID = FindViewById <TextView>(Resource.Id.tokenID); tv2 = FindViewById <TextView>(Resource.Id.textView2); tv4 = FindViewById <TextView>(Resource.Id.textView4); tv5 = FindViewById <TextView>(Resource.Id.textView5); tv6 = FindViewById <TextView>(Resource.Id.textView6); tv7 = FindViewById <TextView>(Resource.Id.textView7); tv8 = FindViewById <TextView>(Resource.Id.textView8); userName = FindViewById <TextView>(Resource.Id.userNameText); userDept = FindViewById <TextView>(Resource.Id.depText); b1 = FindViewById <Button>(Resource.Id.button1); b3 = FindViewById <Button>(Resource.Id.button3); b2 = FindViewById <Button>(Resource.Id.button2); b3.Click += requestValidation; b2.Click += B2_Click; b1.Click += B1_Click; switchUI(true); // Create your application here }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); MobileAds.Initialize(this, "ca-app-pub-5131184764831509~8873327557"); ShowBannerAd(); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); ISharedPreferencesEditor editor = prefs.Edit(); day = DataProvider.getdayInfo(this); length = day.Length - 1; mButton = FindViewById <Button>(Resource.Id.button1); mButton.Click += (sender, e) => { editor.Clear(); editor.Apply(); Intent I = new Intent(this, typeof(MainActivity)); StartActivity(I); Finish(); }; DatePickerChangeHandler datePickerChangeHandler = new DatePickerChangeHandler(this); DP = FindViewById <DatePicker>(Resource.Id.datePicker1); DTNow = DateTime.Now; DP.Init(DTNow.Year, DTNow.Month - 1, DTNow.Day, datePickerChangeHandler); IndexofDay = DTNow.Month == 9 ? (DTNow.Day - 1) % length : DTNow.Month == 10 ? (DTNow.Day + 1) % length : DTNow.Month == 11 ? (DTNow.Day + 4) % length : DTNow.Month == 12 ? (DTNow.Day + 6) % length : length; myHeader = DataProvider.getInfo(this); myChild = new List <string>(); myChild.Add(day[IndexofDay]); mExListView = FindViewById <ExpandableListView>(Resource.Id.EListView); adapter = new EListViewAdapter(this, myHeader, myChild); mExListView.SetAdapter(adapter); mExListView.ExpandGroup(0); mExListView.ChildClick += (sender, e) => { if (prefs.Contains("QKG 3") || prefs.Contains("QKG 4")) { ChildData = DataProvider.getChildInfo(myHeader[day[IndexofDay]][e.ChildPosition], day[IndexofDay], this); } else { ChildData = DataProvider.getChildInfo(myHeader[day[IndexofDay]][e.ChildPosition], this); } RegisterForContextMenu(mExListView); OpenContextMenu(mExListView); }; }
public object Read(string key) { object r = null; if (_sCont.Contains(key)) { r = _sCont.All [key]; } return(r); }
protected int?GetInt(string key) { if (!prefs.Contains(key)) { return(null); } else { return(prefs.GetInt(key, 0)); } }
private static string GetTempUnit() { if (!preferences.Contains(KEY_USECELSIUS)) { return(Fahrenheit); } else if (preferences.GetBoolean(KEY_USECELSIUS, false)) { return(Celsius); } return(Fahrenheit); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); OnButtonClick += delegate { AppPreference appPreference = new AppPreference(); using (Image <Bgr, Byte> image = PickImage("lena.jpg")) { ISharedPreferences preference = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); String appVersion = PackageManager.GetPackageInfo(PackageName, Android.Content.PM.PackageInfoFlags.Activities).VersionName; if (!preference.Contains("cascade-data-version") || !preference.GetString("cascade-data-version", null).Equals(appVersion) || !(preference.Contains("cascade-eye-data-path") || preference.Contains("cascade-face-data-path"))) { AndroidFileAsset.OverwriteMethod overwriteMethod = AndroidFileAsset.OverwriteMethod.AlwaysOverwrite; FileInfo eyeFile = AndroidFileAsset.WritePermanantFileAsset(this, "haarcascade_eye.xml", "cascade", overwriteMethod); FileInfo faceFile = AndroidFileAsset.WritePermanantFileAsset(this, "haarcascade_frontalface_default.xml", "cascade", overwriteMethod); //save tesseract data path ISharedPreferencesEditor editor = preference.Edit(); editor.PutString("cascade-data-version", appVersion); editor.PutString("cascade-eye-data-path", eyeFile.FullName); editor.PutString("cascade-face-data-path", faceFile.FullName); editor.Commit(); } string eyeXml = preference.GetString("cascade-eye-data-path", null); string faceXml = preference.GetString("cascade-face-data-path", null); long time; List <Rectangle> faces = new List <Rectangle>(); List <Rectangle> eyes = new List <Rectangle>(); bool tryUseOpenCL = appPreference.UseOpenCL; DetectFace.Detect(image.Mat, faceXml, eyeXml, faces, eyes, false, tryUseOpenCL, out time); SetMessage(String.Format("Detected with {1} in {0} milliseconds.", time, CvInvoke.UseOpenCL ? "OpenCL" : "CPU")); foreach (Rectangle rect in faces) { image.Draw(rect, new Bgr(System.Drawing.Color.Red), 2); } foreach (Rectangle rect in eyes) { image.Draw(rect, new Bgr(System.Drawing.Color.Blue), 2); } SetImageBitmap(image.ToBitmap()); } }; }
/** * @param key The name of the preference to remove. * @see Editor#remove(String) */ public static void remove(string key) { ISharedPreferences prefs = getPreferences(); var editor = prefs.Edit(); if (prefs.Contains(key + LENGTH_SUFFIX)) { // Workaround for pre-HC's lack of StringSets int stringSetLength = prefs.GetInt(key + LENGTH_SUFFIX, -1); if (stringSetLength >= 0) { editor.Remove(key + LENGTH_SUFFIX); for (int i = 0; i < stringSetLength; i++) { editor.Remove(key + LEFT_MOUNT + i + RIGHT_MOUNT); } } } editor.Remove(key); if (Build.VERSION.SdkInt < Build.VERSION_CODES.Gingerbread) { editor.Commit(); } else { editor.Apply(); } }
/** * @param key The name of the preference to retrieve. * @param defValue Value to return if this preference does not exist. * @return Returns the preference values if they exist, or defValues. Throws ClassCastException if there is a * preference with this name that is not a Set. * @see SharedPreferences#getStringSet(String, Set) */ public static ICollection <string> getStringSet(string key, HashSet <string> defValue) { ISharedPreferences prefs = getPreferences(); if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Honeycomb) { return(prefs.GetStringSet(key, defValue)); } else { if (prefs.Contains(key + LENGTH_SUFFIX)) { HashSet <string> set = new HashSet <string>(); // Workaround for pre-HC's lack of StringSets int stringSetLength = prefs.GetInt(key + LENGTH_SUFFIX, -1); if (stringSetLength >= 0) { for (int i = 0; i < stringSetLength; i++) { prefs.GetString(key + LEFT_MOUNT + i + RIGHT_MOUNT, null); } } return(set); } } return(defValue); }
private void SaveButton_Click(object sender, EventArgs e) { shp = Application.Context.GetSharedPreferences("ewosettings", FileCreationMode.Append); edtr = shp.Edit(); if (!shp.Contains("drafts")) { drafts = new List <EWO>(); edtr.PutString("drafts", JsonConvert.SerializeObject(drafts)); edtr.Commit(); } else { drafts = JsonConvert.DeserializeObject <List <EWO> >(shp.GetString("drafts", JsonConvert.SerializeObject(new List <EWO>()))); } if (drafts.Exists(x => x.id == ewoObj.id)) { drafts.Remove(drafts.Find(x => x.id == ewoObj.id)); } drafts.Insert(0, ewoObj); edtr.PutString("drafts", JsonConvert.SerializeObject(drafts)); edtr.Commit(); Intent intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTask); intent.AddFlags(ActivityFlags.NewTask); StartActivity(intent); }
//------------------------------------------------------------------------------ static public string GetLocalStringValue(string sKey #if __ANDROID__ , ISharedPreferences prefs = null #endif // __ANDROID__ ) { #if __ANDROID__ if (prefs == null) { Context context = Application.Context; prefs = PreferenceManager.GetDefaultSharedPreferences(context); } string sValue = null; if (prefs.Contains(sKey)) { sValue = prefs.GetString(sKey, null); } return(sValue); #endif // __ANDROID__ #if __IOS__ var prefs = NSUserDefaults.StandardUserDefaults; string sValue = prefs.StringForKey(sKey); return(sValue); #endif // __IOS__ }
private static int GetNormalUnlocksCount(ISharedPreferences preferences) { if (GetMonitoringDayCount() == 7 && preferences.Contains($"{ScreenUtils.UnlocksDayNumber}{_lastDayUnlocked}")) { NormalCount = preferences.GetInt($"{ScreenUtils.UnlocksDayNumber}{_lastDayUnlocked}", DefaultUnlocksCount); } else { var s = 0; var k = 0; for (var i = 1; i <= 7; i++) { var un = preferences.GetInt($"{ScreenUtils.UnlocksDayNumber}{i}", -1); if (un > 0) { s += un; k++; } } NormalCount = k > 0 ? (int)Math.Ceiling((double)s / k) : DefaultUnlocksCount; } NormalCount = Math.Max(NormalCount, preferences.GetInt(ScreenUtils.UnlocksNewNormalCount, NormalCount)); return(NormalCount); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Splash); core = new LoginCore(); //Delays await Task.Delay(5000); await Task.Factory.StartNew(() => { //Revisar si hay preferencias guardadas Context mContext = Application.Context; ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(mContext); if (prefs.Contains("correo")) { String sesion_red = prefs.GetString("red_social", ""); if (sesion_red.Equals("facebook")) { String sesion_correo = prefs.GetString("correo", ""); String sesion_nombre = prefs.GetString("nombre", ""); Revisar_login(sesion_correo, sesion_nombre, "facebook"); } if (sesion_red.Equals("correo")) { String sesion_correo = prefs.GetString("correo", ""); String sesion_nombre = prefs.GetString("nombre", ""); Revisar_login(sesion_correo, sesion_nombre, "correo"); } } else { Intent intent = new Intent(this, typeof(MainActivity)); StartActivity(intent); } }); }
private static void CheckContains(this ISharedPreferences sharedPref, string key) { if (!sharedPref.Contains(key)) { throw new KeyNotFoundException($"Has not found key {key} in ISharedPreferences instance"); } }
private bool checkTestNeeded() { System.String resolution = mWidth + "x" + mHeight + "-"; // Forces the test if (DEBUG || mPreferences == null) { return(true); } // If the sdk has changed on the phone, or the version of the test // it has to be run again if (mPreferences.Contains(PREF_PREFIX + resolution + "lastSdk")) { int lastSdk = mPreferences.GetInt(PREF_PREFIX + resolution + "lastSdk", 0); int lastVersion = mPreferences.GetInt(PREF_PREFIX + resolution + "lastVersion", 0); if ((int)Build.VERSION.SdkInt > lastSdk || VERSION > lastVersion) { return(true); } } else { return(true); } return(false); }
public void AndroidPushNotification(object sender, FirebasePushNotificationDataEventArgs p) { try { ISharedPreferences pref = GetSharedPreferences("MEI_UserPreferences", FileCreationMode.Private); if (pref.Contains("MEI_UserNotificaiton")) { if (pref.GetBoolean("MEI_UserNotificaiton", true) && !string.IsNullOrEmpty(pref.GetString("MEI_UserData", String.Empty))) { var message = App.HtmlToPlainText(p.Data["message"].ToString()); var header = p.Data["header"].ToString(); var imageURL = p.Data["image"].ToString(); if (imageURL == "" || imageURL.ToLower().Contains("pdf")) { SendNotification(message, header); } else { SendNotification(message, header, imageURL); } } } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
/// <summary> /// Re-synchronizes local preferences from the Data API if no such sync has yet been run. /// </summary> /// <param name="context">The context of the preferences whose values are to be synced.</param> /// <param name="settings">A <see cref="ISharedPreferences"/> instance from which to retrieve /// values of the preferences. /// </param> public static void ResyncIfNeeded(Context context, ISharedPreferences settings) { if (!settings.Contains(PrefListener.KEY_SYNC_DONE)) { new PrefListener(context, settings).ResyncLocal(); } }
protected override void OnCreate(Bundle savedInstanceState) { // ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; base.OnCreate(savedInstanceState); try { Xamarin.Essentials.Platform.Init(this, savedInstanceState); Forms.Init(this, savedInstanceState); FormsMaps.Init(this, savedInstanceState); Forms.SetTitleBarVisibility(this, AndroidTitleBarVisibility.Never); App ap = new MEI.App(); LoadApplication(ap); //this.ActionBar.Hide(); CachedImageRenderer.Init(enableFastRenderer: true); RoundedBoxViewRenderer.Init(); RequestPermissions(permisons, 0); App.ScreenWidth = (int)Resources.DisplayMetrics.WidthPixels; App.ScreenHeight = (int)Resources.DisplayMetrics.HeightPixels; App.CopyToClipBoard = CopyText; App.createContact = CreateContact; App.localPushNotification = LocalNotification; App.SaveUser = SaveUserID; App.GetUserEvent = SetGetUser; App.AppVersion = ApplicationContext.PackageManager.GetPackageInfo(ApplicationContext.PackageName, 0).VersionName; App.cropImage = CropImage; App.ResetUser = ResetUserID; App.closeApp = CloseApp; App.SetDomainData = SetDomainData; App.SetNotificaiton = SetNotification; App.resetRoundView = ResetRoundView; App.SetNotificationSounds = SetNotificationSound; App.SetUserData = SetUserData; App.PushNotification = AndroidPushNotification; App.AddEventReminder = SetCurrentEventReminder; ISharedPreferences pref = GetSharedPreferences("MEI_UserPreferences", FileCreationMode.Private); bool hasDirectory = pref.Contains("DomainDirectory"); if (!hasDirectory) { ISharedPreferencesEditor editor = pref.Edit(); editor.Clear(); editor.Apply(); editor.PutBoolean("DomainDirectory", App.NotificationSounds); editor.Apply(); } GetDomainData(); GetNotification(); GetUserData(); GetNotificationSound(); //FirebasePushNotificationManager.ProcessIntent(this, Intent); ap.StartApp(); } catch (Exception e) { Console.WriteLine(e.ToString()); Log.Debug("Creation Error", "Error in creating Application.."); } }
static public string GetSavedIP() { if (!prefs.Contains("ip")) { return(null); } return(prefs.GetString("ip", "")); }
public void Remove(string key) { if (preferences.Contains(key)) { var editor = preferences.Edit(); editor.Remove(key); editor.Commit(); } }
public string isLogged(object sender, EventArgs e) { ISharedPreferences pref = GetSharedPreferences("MEI_UserPreferences", FileCreationMode.Private); if (pref.Contains("MEI_UserID")) { return(pref.GetString("MEI_UserID", String.Empty)); } return(String.Empty); }
private static bool IsKeyVerified() { if (!wuSharedPrefs.Contains(KEY_APIKEY_VERIFIED)) { return(false); } else { return(wuSharedPrefs.GetBoolean(KEY_APIKEY_VERIFIED, false)); } }
protected override void OnCreate(Bundle savedInstanceState) { ISharedPreferences dadosLocais = GetSharedPreferences("arquivo1", Android.Content.FileCreationMode.WorldWriteable); var conferelogin = dadosLocais.GetString("login1", "sim"); var numero1 = dadosLocais.GetString("numero", ""); var ra1 = dadosLocais.GetString("ra", ""); var nascimento1 = dadosLocais.GetString("nascimento", ""); if (dadosLocais.Contains("sim")) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Login); StartActivity(typeof(MainActivity)); Finish(); } else { var context = this.ApplicationContext; var isOnline = NetworkConnection.IsNetworkConnected(context); if (isOnline) { DBConnect.Conecta_Banco(this); Toast.MakeText(this, "Conectado com sucesso!", ToastLength.Short).Show(); } else { AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Status da Conexão"); alert.SetMessage("Falha na conexão, cheque sua conexão por favor!"); alert.SetButton("OK", (c, ev) => { Finish(); }); alert.Show(); } base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Login); Button button = FindViewById <Button>(Resource.Id.buttonLogin); button.Click += Button_Click; EditText login = FindViewById <EditText>(Resource.Id.editTextLogin); EditText ra = FindViewById <EditText>(Resource.Id.editTextLogin1); EditText nascimento = FindViewById <EditText>(Resource.Id.editTextLogin2); nascimento.AddTextChangedListener(new Mask(nascimento, "##/##/####")); } }
public string GetDataFromSharedPrefs() { string stringToReturn = "no data found"; ISharedPreferences prefs = context.GetSharedPreferences("MyPreferences", FileCreationMode.Private); if (prefs.Contains("DateUpdated")) { stringToReturn = prefs.GetString("DateUpdated", "No data here !!"); } return(stringToReturn); }
public override void OnNewToken(string token) { var context = Application.Context; ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context); if (!prefs.Contains("DeviceToken")) { var editor = prefs.Edit(); editor.PutString("DeviceToken", token); editor.Apply(); } }
public void GetNotificationSound() { ISharedPreferences pref = GetSharedPreferences("MEI_UserPreferences", FileCreationMode.Private); if (pref.Contains("MEI_UserNotificaitonSounds")) { App.NotificationSounds = pref.GetBoolean("MEI_UserNotificaitonSounds", true); } else { SetNotificationSound(this, null); } }
public void GetUserData() { ISharedPreferences pref = GetSharedPreferences("MEI_UserPreferences", FileCreationMode.Private); if (pref.Contains("MEI_UserData")) { App.userProfileData = pref.GetString("MEI_UserData", String.Empty); } else { App.userProfileData = String.Empty; } }