private void OnKdfChange(object sender, Preference.PreferenceChangeEventArgs preferenceChangeEventArgs) { var db = App.Kp2a.GetDb(); var previousKdfParams = db.KpDatabase.KdfParameters; Kp2aLog.Log("previous kdf: " + KdfPool.Get(db.KpDatabase.KdfParameters.KdfUuid) + " " + db.KpDatabase.KdfParameters.KdfUuid.ToHexString()); db.KpDatabase.KdfParameters = KdfPool.Get( new PwUuid(MemUtil.HexStringToByteArray((string)preferenceChangeEventArgs.NewValue))) .GetDefaultParameters(); Kp2aLog.Log("--new kdf: " + KdfPool.Get(db.KpDatabase.KdfParameters.KdfUuid) + " " + db.KpDatabase.KdfParameters.KdfUuid.ToHexString()); SaveDb save = new SaveDb(Activity, App.Kp2a, new ActionOnFinish((success, message) => { if (!success) { db.KpDatabase.KdfParameters = previousKdfParams; Toast.MakeText(Activity, message, ToastLength.Long).Show(); return; } UpdateKdfScreen(); })); ProgressTask pt = new ProgressTask(App.Kp2a, Activity, save); pt.Run(); }
//Notification >> Popup private void NotifcationPopupPrefOnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { switch (eventArgs.Handled) { case true: { var etp = (SwitchPreferenceCompat)sender; var value = eventArgs.NewValue.ToString(); etp.Checked = bool.Parse(value); switch (etp.Checked) { case true: UserDetails.NotificationPopup = true; OneSignalNotification.RegisterNotificationDevice(); break; default: UserDetails.NotificationPopup = false; OneSignalNotification.Un_RegisterNotificationDevice(); break; } break; } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
//Notification >> Popup private void NotificationPopupPref_OnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { if (eventArgs.Handled) { var etp = (SwitchPreference)sender; var value = eventArgs.NewValue.ToString(); etp.Checked = bool.Parse(value); if (etp.Checked) { OneSignalNotification.RegisterNotificationDevice(); } else { OneSignalNotification.Un_RegisterNotificationDevice(); } } } catch (Exception e) { Crashes.TrackError(e); } }
private void NotifcationPlaySoundPrefOnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { switch (eventArgs.Handled) { case true: { var etp = (CheckBoxPreference)sender; var value = eventArgs.NewValue.ToString(); etp.Checked = bool.Parse(value); UserDetails.SoundControl = etp.Checked switch { true => true, _ => false }; break; } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void Privacy_Follow_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { try { if (e.Handled) { ListPreference etp = (ListPreference)sender; var value = e.NewValue.ToString(); var valueAsText = etp.GetEntries()[Int32.Parse(value)]; etp.Summary = valueAsText; S_WhoCanFollowMe = value; if (IMethods.CheckConnectivity()) { var dataPrivacy = new Dictionary <string, string> { { "follow_privacy", S_WhoCanFollowMe }, }; var data = Global.Update_User_Data(dataPrivacy) .ConfigureAwait(false); } else { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Error_check_internet_connection), ToastLength.Long).Show(); } } } catch (Exception exception) { Console.WriteLine(exception); } }
//Lang private void Lang_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { try { if (e.Handled) { Android.Preferences.ListPreference etp = (Android.Preferences.ListPreference)sender; var value = e.NewValue; Wo_Main_Settings.SetApplicationLang(value.ToString()); Toast.MakeText(_activityContext, this.GetText(Resource.String.Lbl_Closed_App), ToastLength.Long).Show(); Intent intent = new Intent(_activityContext, typeof(SpalshScreen_Activity)); intent.AddCategory(Intent.CategoryHome); intent.SetAction(Intent.ActionMain); intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask); _activityContext.StartActivity(intent); _activityContext.FinishAffinity(); } } catch (Exception exception) { Console.WriteLine(exception); } }
public void OnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { if (e.Preference == mBooleanPref) { mBooleanEntry.SelectedState = (bool)e.NewValue; } else if (e.Preference == mChoicePref) { mChoiceEntry.SelectedString = (string)e.NewValue; } else if (e.Preference == mMultiPref) { String[] selectedStrings = new String [((IList <string>)e.NewValue).Count]; int i = 0; foreach (String value in (IList <string>)e.NewValue) { selectedStrings[i++] = value; } mMultiEntry.SetAllSelectedStrings(selectedStrings); } // Saves all the app restriction configuration changes from the custom activity. Intent intent = new Intent(Activity.Intent); intent.PutParcelableArrayListExtra(Intent.ExtraRestrictionsList, new List <IParcelable> (mRestrictions)); Activity.SetResult(Result.Ok, intent); }
void OnRememberKeyFileHistoryChanged(object sender, Preference.PreferenceChangeEventArgs eventArgs) { if (!(bool)eventArgs.NewValue) { App.Kp2a.FileDbHelper.DeleteAllKeys(); } }
private void IconSetPreference_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { string selectedValue = e.NewValue.ToString(); if (string.IsNullOrEmpty(selectedValue)) { Intent getIntent = new Intent(Intent.ActionGetContent); getIntent.SetType("image/*"); Intent pickIntent = new Intent(Intent.ActionPick, MediaStore.Images.Media.ExternalContentUri); pickIntent.SetType("image/*"); Intent chooserIntent = Intent.CreateChooser(getIntent, "Select an icon set"); chooserIntent.PutExtra(Intent.ExtraInitialIntents, new Intent[] { pickIntent }); Activity.StartActivityForResult(chooserIntent, PICK_IMAGE); } else { Uri iconSetUri = Uri.Parse(selectedValue); GoOnTapApplication.Config.IconSetUri = iconSetUri; GoOnTapApplication.Config.IconSetBytes = null; // Refresh interface int index = Config.DefaultIconSets.Values.IndexOf(u => u.ToString() == iconSetUri?.ToString()); e.Preference.Summary = index == -1 ? iconSetUri?.Path : Config.DefaultIconSets.Keys.ElementAt(index); (e.Preference as ListPreference).SetValueIndex(index == -1 ? Config.DefaultIconSets.Count : index); } }
//Lang private void LangPref_OnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { if (eventArgs.Handled) { var etp = (ListPreference)sender; var value = eventArgs.NewValue; Settings.Lang = value.ToString(); WowTime_Main_Settings.SetApplicationLang(Activity, Settings.Lang); Toast.MakeText(ActivityContext, GetText(Resource.String.Lbl_Application_Restart), ToastLength.Long).Show(); var intent = new Intent(Activity, typeof(SpalshScreen_Activity)); intent.AddCategory(Intent.CategoryHome); intent.SetAction(Intent.ActionMain); intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask); Activity.StartActivity(intent); Activity.FinishAffinity(); Settings.Lang = value.ToString(); } } catch (Exception e) { Crashes.TrackError(e); } }
private void OnUseOfflineCacheChanged(object sender, Preference.PreferenceChangeEventArgs e) { if (!(bool)e.NewValue) { AlertDialog.Builder builder = new AlertDialog.Builder(Activity); builder.SetTitle(GetString(Resource.String.ClearOfflineCache_title)); builder.SetMessage(GetString(Resource.String.ClearOfflineCache_question)); builder.SetPositiveButton(App.Kp2a.GetResourceString(UiStringKey.yes), (o, args) => { try { App.Kp2a.ClearOfflineCache(); } catch (Exception ex) { Kp2aLog.LogUnexpectedError(ex); Toast.MakeText(Application.Context, ex.Message, ToastLength.Long).Show(); } } ); builder.SetNegativeButton(App.Kp2a.GetResourceString(UiStringKey.no), (o, args) => { ((CheckBoxPreference)e.Preference).Checked = true; } ); builder.SetCancelable(false); Dialog dialog = builder.Create(); dialog.Show(); } }
//Notification >> Popup private void NotifcationPopupPrefOnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { if (eventArgs.Handled) { var etp = (SwitchPreferenceCompat)sender; var value = eventArgs.NewValue.ToString(); etp.Checked = bool.Parse(value); if (etp.Checked) { UserDetails.NotificationPopup = true; OneSignalNotification.RegisterNotificationDevice(); } else { UserDetails.NotificationPopup = false; OneSignalNotification.Un_RegisterNotificationDevice(); } } } catch (Exception e) { Console.WriteLine(e); } }
protected void HandlePreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { if (e.Preference == Preference) { FireValueChanged(e.NewValue); e.Handled = true; } }
//Share my location with public private void PrivacyShareMyLocationPref_OnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { if (eventArgs.Handled) { var dataUser = ListUtils.MyProfileList?.FirstOrDefault(); var etp = (SwitchPreferenceCompat)sender; var value = eventArgs.NewValue.ToString(); etp.Checked = bool.Parse(value); if (etp.Checked) //Yes >> value = 1 { if (dataUser != null) { dataUser.ShareMyLocation = "1"; var sqLiteDatabase = new SqLiteDatabase(); sqLiteDatabase.Insert_Or_Update_To_MyProfileTable(dataUser); } SShareMyLocationPref = "1"; } else //No >> value = 0 { if (dataUser != null) { dataUser.ShareMyLocation = "0"; var sqLiteDatabase = new SqLiteDatabase(); sqLiteDatabase.Insert_Or_Update_To_MyProfileTable(dataUser); } SShareMyLocationPref = "0"; } if (Methods.CheckConnectivity()) { var dataPrivacy = new Dictionary <string, string> { { "share_my_location", SShareMyLocationPref } }; PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Global.Update_User_Data(dataPrivacy) }); } else { Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long) .Show(); } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
//Share my location with public private void PrivacyShareMyLocationPref_OnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { if (eventArgs.Handled) { var datauser = Classes.MyProfileList.FirstOrDefault(a => a.user_id == UserDetails.User_id); var etp = (SwitchPreference)sender; var value = eventArgs.NewValue.ToString(); etp.Checked = bool.Parse(value); if (etp.Checked) { if (datauser != null) { datauser.share_my_location = "1"; } S_ShareMyLocation_Pref = "1"; } else { if (datauser != null) { datauser.share_my_location = "0"; } S_ShareMyLocation_Pref = "0"; } if (datauser != null) { datauser.share_my_location = S_ShareMyLocation_Pref; } if (IMethods.CheckConnectivity()) { var dataPrivacy = new Dictionary <string, string> { { "share_my_location", S_ShareMyLocation_Pref } }; var data = Client.Global.Update_User_Data(st, dataPrivacy).ConfigureAwait(false); } else { Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long) .Show(); } } } catch (Exception e) { Crashes.TrackError(e); } }
private void OnDebugLogChanged(object sender, Preference.PreferenceChangeEventArgs e) { if ((bool)e.NewValue) { Kp2aLog.CreateLogFile(); } else { Kp2aLog.FinishLogFile(); } }
/// <summary> /// Validates the value of the Post Interval when changed /// </summary> /// <param name="sender">Sender Object</param> /// <param name="e">PreferenceChangeEventArgs object</param> public void onPostIntervalEditTextChanged(object sender, Preference.PreferenceChangeEventArgs e) { int value = Int32.Parse(e.NewValue.ToString()); if (value <= 0) { // Notify the user Toast.MakeText(Android.App.Application.Context, INVALID_POST_INTERVAL, ToastLength.Short).Show(); e.Handled = false; } }
private void StayActive_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { var value = (bool)e.NewValue; if (value) { Activity.Window.AddFlags(WindowManagerFlags.KeepScreenOn); } else { Activity.Window.ClearFlags(WindowManagerFlags.KeepScreenOn); } }
void handlePreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { var listPreference = e.Preference as ListPreference; int val = 0; if (listPreference != null && int.TryParse(e.NewValue.ToString(), out val)) { listPreference.Summary = listPreference.GetEntries()[val]; } else { e.Preference.Summary = e.NewValue.ToString(); } }
//Notifcation >> Popup private void Notifcation_Popup_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { if (e.Handled) { SwitchPreference etp = (SwitchPreference)sender; var value = e.NewValue.ToString(); etp.Checked = Boolean.Parse(value); if (etp.Checked) { OneSignalNotification.RegisterNotificationDevice(); } else { OneSignalNotification.Un_RegisterNotificationDevice(); } } }
//Notification >> Play Sound private void Notifcation_PlaySound_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { if (e.Handled) { CheckBoxPreference etp = (CheckBoxPreference)sender; var value = e.NewValue.ToString(); etp.Checked = Boolean.Parse(value); if (etp.Checked) { S_SoundControl = true; } else { S_SoundControl = false; } } }
//Who can see my birthday private void PrivacyCanSeeMyBirthdayPref_OnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { if (eventArgs.Handled) { var etp = (ListPreference)sender; var value = eventArgs.NewValue.ToString(); var valueAsText = etp.GetEntries()[int.Parse(value)]; etp.Summary = valueAsText; S_CanSeeMyBirthday_Pref = value; if (IMethods.CheckConnectivity()) { var datauser = Classes.MyProfileList.FirstOrDefault(a => a.user_id == UserDetails.User_id); if (datauser != null) { datauser.birth_privacy = S_CanSeeMyBirthday_Pref; } var dataPrivacy = new Dictionary <string, string> { { "birth_privacy", S_CanSeeMyBirthday_Pref } }; var data = Client.Global.Update_User_Data(st, dataPrivacy).ConfigureAwait(false); } else { Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long) .Show(); } } } catch (Exception e) { Crashes.TrackError(e); } }
void SaveHandler(object sender, Preference.PreferenceChangeEventArgs e) { if (sender == prefHideLabels) { Settings.Instance.HideLabels = !prefHideLabels.Checked; } if (sender == prefHideLogo) { Settings.Instance.HideFiredTVLogo = !prefHideLogo.Checked; } if (sender == prefHideDividerLine) { Settings.Instance.HideHomeDividerLine = !prefHideDividerLine.Checked; } if (sender == prefHideDate) { Settings.Instance.HideDate = !prefHideDate.Checked; } if (sender == prefTwentyFourHourTime) { Settings.Instance.TwentyFourHourTime = !prefTwentyFourHourTime.Checked; } if (sender == prefHideTime) { Settings.Instance.HideTime = !prefHideTime.Checked; } if (sender == prefAppNameFontSize) { var size = 16; int.TryParse(prefAppNameFontSize.EditText.Text, out size); Settings.Instance.LabelFontSize = size; } if (sender == prefDisableHomeDetect) { Settings.Instance.DisableHomeDetection = !prefDisableHomeDetect.Checked; StartService(new Intent(this, typeof(ExcuseMeService))); } Settings.Save(); }
private void TempLang_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { var editor = prefs.Edit(); if (e.Preference.Key == "temp_key") { editor.PutString("temp_key", e.NewValue.ToString()); editor.Commit(); } else if (e.Preference.Key == "lang_key") { editor.PutString("lang_key", e.NewValue.ToString()); editor.Commit(); AppHelper.UpdateLocale(this); this.Recreate(); } temp.Summary = GetString(Resource.String.current_pref) + prefs.GetString("temp_key", GetString(Resource.String.default_temp)); lang.Summary = GetString(Resource.String.current_pref) + prefs.GetString("lang_key", GetString(Resource.String.default_lang)); }
private void AppLangPrefChanged(object sender, Preference.PreferenceChangeEventArgs e) { int newLangVal = -1; int.TryParse((string)e.NewValue, out newLangVal); LanguageChoice chosen = allLangs.FirstOrDefault((lang) => lang.Id == newLangVal); if (newLangVal != -1 && chosen != null && chosen.Code != StringResources.Culture?.TwoLetterISOLanguageName) { StringResources.Culture = new CultureInfo(chosen.Code); Session.ActiveUser.AppLang = chosen.Id; Queries.SaveActiveUser(); // Refreshing the fragment we are in does not change text, so must be set manually. ((ListPreference)FindPreference("convoLanguagePref")).Title = StringResources.settings_chooseConvoLanguage; ((ListPreference)FindPreference("appLanguagePref")).Title = StringResources.settings_chooseAppLanguage; FindPreference("logOutPref").Title = StringResources.settings_logout; ((MainActivity)Activity).RefreshFragments(); ((MainActivity)Activity).LoadNavigationTitles(); Localise.SetLayoutDirectionByPreference(this.Activity); } }
private void AlgorithmPrefChange(object sender, Preference.PreferenceChangeEventArgs preferenceChangeEventArgs) { var db = App.Kp2a.GetDb(); var previousCipher = db.KpDatabase.DataCipherUuid; db.KpDatabase.DataCipherUuid = new PwUuid(MemUtil.HexStringToByteArray((string)preferenceChangeEventArgs.NewValue)); SaveDb save = new SaveDb(Activity, App.Kp2a, new ActionOnFinish((success, message) => { if (!success) { db.KpDatabase.DataCipherUuid = previousCipher; Toast.MakeText(Activity, message, ToastLength.Long).Show(); return; } preferenceChangeEventArgs.Preference.Summary = CipherPool.GlobalPool.GetCipher(db.KpDatabase.DataCipherUuid).DisplayName; })); ProgressTask pt = new ProgressTask(App.Kp2a, Activity, save); pt.Run(); }
private void OnUseOfflineCacheChanged(object sender, Preference.PreferenceChangeEventArgs e) { //ensure the user gets a matching database if (App.Kp2a.GetDb().Loaded&& !App.Kp2a.GetDb().Ioc.IsLocalFile()) { App.Kp2a.LockDatabase(false); } if (!(bool)e.NewValue) { AlertDialog.Builder builder = new AlertDialog.Builder(Activity); builder.SetTitle(GetString(Resource.String.ClearOfflineCache_title)); builder.SetMessage(GetString(Resource.String.ClearOfflineCache_question)); builder.SetPositiveButton(App.Kp2a.GetResourceString(UiStringKey.yes), (o, args) => { try { App.Kp2a.ClearOfflineCache(); } catch (Exception ex) { Kp2aLog.LogUnexpectedError(ex); Toast.MakeText(Application.Context, ex.Message, ToastLength.Long).Show(); } } ); builder.SetNegativeButton(App.Kp2a.GetResourceString(UiStringKey.no), (o, args) => { } ); builder.SetCancelable(false); Dialog dialog = builder.Create(); dialog.Show(); } }
//ChatHeads private void ChatHeadsPrefOnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { try { if (e.Handled) { SwitchPreferenceCompat etp = (SwitchPreferenceCompat)sender; var value = e.NewValue.ToString(); etp.Checked = bool.Parse(value); UserDetails.ChatHead = etp.Checked; if (UserDetails.ChatHead && !InitFloating.CanDrawOverlays(ActivityContext)) { Intent intent = new Intent(Settings.ActionManageOverlayPermission, Uri.Parse("package:" + Application.Context.PackageName)); ActivityContext.StartActivityForResult(intent, InitFloating.ChatHeadDataRequestCode); } } } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
//About private void About_Me_Pref_PreferenceChange(object sender, Preference.PreferenceChangeEventArgs e) { try { EditTextPreference etp = (EditTextPreference)sender; var value = etp.EditText.Text; etp.Summary = value; var datauser = Classes.MyProfileList.FirstOrDefault(a => a.user_id == UserDetails.User_id); if (datauser != null) { datauser.about = etp.EditText.Text; S_About = etp.EditText.Text; } if (IMethods.CheckConnectivity()) { var dataPrivacy = new Dictionary <string, string> { { "about", value }, }; var data = Global.Update_User_Data(dataPrivacy) .ConfigureAwait(false); } else { Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Error_check_internet_connection), ToastLength.Long).Show(); } } catch (Exception exception) { Console.WriteLine(exception); } }
private void NotifcationPlaySoundPrefOnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs) { try { if (eventArgs.Handled) { var etp = (CheckBoxPreference)sender; var value = eventArgs.NewValue.ToString(); etp.Checked = bool.Parse(value); if (etp.Checked) { UserDetails.SoundControl = true; } else { UserDetails.SoundControl = false; } } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }