//private TunnelInstance tunnel = TunnelInstance.Instance;

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			AddPreferencesFromResource(Resource.Layout.Settings);

			portNumberPref = (EditTextPreference) FindPreference("tunnelPort");
			deviceListPref = (ListPreference) FindPreference("bluetoothDevice");
			listenForClientsPref = (CheckBoxPreference) FindPreference("listenForClients");

			enableStreaming = (CheckBoxPreference) FindPreference("streamVideo");;
			rtspPort = (EditTextPreference) FindPreference("rtspPort");;
			videoPort = (EditTextPreference) FindPreference("videoPort");;
			resolution = (ListPreference) FindPreference("videoResolution");;
			videoQuality = (ListPreference) FindPreference("videoQuality");;
			frameRate = (ListPreference) FindPreference("frameRate");;

			portNumberPref.OnPreferenceChangeListener = this;
			deviceListPref.OnPreferenceChangeListener = this;
			listenForClientsPref.OnPreferenceChangeListener = this;

			enableStreaming.OnPreferenceChangeListener = this;
			rtspPort.OnPreferenceChangeListener = this;
			videoPort.OnPreferenceChangeListener = this;
			resolution.OnPreferenceChangeListener = this;
			videoQuality.OnPreferenceChangeListener = this;
			frameRate.OnPreferenceChangeListener = this;
		}
        protected override void OnCreate(Bundle savedInstance)
        {
            base.OnCreate(savedInstance);
            AddPreferencesFromResource(Resource.Xml.Preferences);
            mPrefRouterUrl     = (EditTextPreference)FindPreference(Constant.PrefKeyRouterUrl);
            mPrefCameraUrl     = (EditTextPreference)FindPreference(Constant.PrefKeyCameraUrl);
            mPrefRouterUrlTest = (EditTextPreference)FindPreference(Constant.PrefKeyRouterUrlTest);
            mPrefCameraUrlTest = (EditTextPreference)FindPreference(Constant.PrefKeyCameraUrlTest);

            mPrefLenOn  = (EditTextPreference)FindPreference(Constant.PrefKeyLenOn);
            mPrefLenOff = (EditTextPreference)FindPreference(Constant.PrefKeyLenOff);

            mPrefAvanzar    = (EditTextPreference)FindPreference(Constant.PrefKeyAvanzar);
            mPrefRetroceder = (EditTextPreference)FindPreference(Constant.PrefKeyRetroceder);
            mPrefIzquierda  = (EditTextPreference)FindPreference(Constant.PrefKeyIzquierda);
            mPrefDerecha    = (EditTextPreference)FindPreference(Constant.PrefKeyDerecha);
            mPrefParar      = (EditTextPreference)FindPreference(Constant.PrefKeyParar);

            txtPotenciaMotor           = (EditTextPreference)FindPreference(Constant.PrefKeyPotencia);
            txtCorreccionMotorDerecho  = (EditTextPreference)FindPreference(Constant.PrefKeyPotenciaDerecho);
            txtCorreccionMotorIzquiedo = (EditTextPreference)FindPreference(Constant.PrefKeyPotenciaIzquierdo);
            txtPotenciaGiro            = (EditTextPreference)FindPreference(Constant.PrefKeyPotenciaGiro);

            txtCommandStart = (EditTextPreference)FindPreference(Constant.PrefKeyCommandStart);
            txtCommandCorreccionMotorDerecho  = (EditTextPreference)FindPreference(Constant.PrefKeyCommandPotenciaDerecho);
            txtCommandCorreccionMotorIzquiedo = (EditTextPreference)FindPreference(Constant.PrefKeyCommandPotenciaIzquierdo);
            txtCommandPotenciaGiro            = (EditTextPreference)FindPreference(Constant.PrefKeyCommandPotenciaGiro);
            txtCommandPotenciaMotor           = (EditTextPreference)FindPreference(Constant.PrefKeyCommandPotencia);
            txtCommandServoHorizontal         = (EditTextPreference)FindPreference(Constant.PrefKeyCommandServoHorizontal);
            txtCommandServoVertical           = (EditTextPreference)FindPreference(Constant.PrefKeyCommandServoVertical);

            listGearStep = (ListPreference)FindPreference(Constant.PrefKeyGearStep);

            InitValue();
        }
Beispiel #3
0
        private void SetupErrorReportModePref(ListPreference errorReportModePref)
        {
            errorReportModePref.SetEntries(new string[]
            {
                GetString(Resource.String.ErrorReportEnable),
                GetString(Resource.String.ErrorReportAsk),
                GetString(Resource.String.ErrorReportDisable)
            });
            var entryValues = new string[]
            {
                App.ErrorReportMode.Enabled.ToString(),
                App.ErrorReportMode.AskAgain.ToString(),
                App.ErrorReportMode.Disabled.ToString(),
            };

            errorReportModePref.SetEntryValues(entryValues);
            errorReportModePref.SetDefaultValue(App.ErrorReportMode.Disabled.ToString());
            string currentValue = PreferenceManager.GetDefaultSharedPreferences(Activity)
                                  .GetString(App.PrefErrorreportmode, App.ErrorReportMode.Disabled.ToString());

            errorReportModePref.SetValueIndex(entryValues.Select((v, index) => new { value = v, index }).First(el => el.value == currentValue).index);
            errorReportModePref.PreferenceChange += (sender, args) =>
            {
                App.ErrorReportMode mode;
                Enum.TryParse((string)args.NewValue, out mode);
                App.SetErrorReportMode(Activity, mode);
            };
        }
Beispiel #4
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Add preferences from the preferences xml file
            AddPreferencesFromResource(Resource.Xml.Preferences);

            // Add Flag choice preferences
            var preferenceScreen = this.PreferenceScreen;

            for (int i = 1; i < this.Resources.GetInteger(Resource.Integer.VpnItemCount) + 1; i++)
            {
                var namePreferenceTitle = string.Format(this.Resources.GetString(Resource.String.VpnNamePreferenceTitleFormat), i);
                var namePreference      = new EditTextPreference(preferenceScreen.Context);
                namePreference.Title      = namePreferenceTitle;
                namePreference.Key        = String.Format(VeeKeePreferences.VpnNamePreferenceKeyFormat, i);
                namePreference.Persistent = true;
                preferenceScreen.AddPreference(namePreference);

                var flagPreferenceTitle = string.Format(this.Resources.GetString(Resource.String.VpnFlagKeyPreferenceTitleFormat), i);
                var flagPreference      = new ListPreference(preferenceScreen.Context);
                flagPreference.SetEntries(Resource.Array.flag_titles);
                flagPreference.SetEntryValues(Resource.Array.flag_image_names);
                flagPreference.Title      = flagPreferenceTitle;
                flagPreference.Key        = String.Format(VeeKeePreferences.VpnFlagPreferenceKeyFormat, i);;
                flagPreference.Persistent = true;
                preferenceScreen.AddPreference(flagPreference);
            }
        }
Beispiel #5
0
        //private TunnelInstance tunnel = TunnelInstance.Instance;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            AddPreferencesFromResource(Resource.Layout.Settings);

            portNumberPref       = (EditTextPreference)FindPreference("tunnelPort");
            deviceListPref       = (ListPreference)FindPreference("bluetoothDevice");
            listenForClientsPref = (CheckBoxPreference)FindPreference("listenForClients");

            enableStreaming = (CheckBoxPreference)FindPreference("streamVideo");;
            rtspPort        = (EditTextPreference)FindPreference("rtspPort");;
            videoPort       = (EditTextPreference)FindPreference("videoPort");;
            resolution      = (ListPreference)FindPreference("videoResolution");;
            videoQuality    = (ListPreference)FindPreference("videoQuality");;
            frameRate       = (ListPreference)FindPreference("frameRate");;

            portNumberPref.OnPreferenceChangeListener       = this;
            deviceListPref.OnPreferenceChangeListener       = this;
            listenForClientsPref.OnPreferenceChangeListener = this;

            enableStreaming.OnPreferenceChangeListener = this;
            rtspPort.OnPreferenceChangeListener        = this;
            videoPort.OnPreferenceChangeListener       = this;
            resolution.OnPreferenceChangeListener      = this;
            videoQuality.OnPreferenceChangeListener    = this;
            frameRate.OnPreferenceChangeListener       = this;
        }
Beispiel #6
0
        private void KeepMe()
        {
            var boolConverter   = new BooleanConverter();
            var stringConverter = new StringConverter();
            var enumConverter   = new EnumConverter(null);
            var intConverter    = new Int32Converter();

            var linearLayout = new LinearLayout(null);

            linearLayout.Visibility = ViewStates.Visible;

            var seekBar = new SeekBar(null);

            seekBar.Max      = seekBar.Max;
            seekBar.Progress = seekBar.Progress;

            var textPref = new EditTextPreference(null);

            textPref.Text    = textPref.Text;
            textPref.Enabled = textPref.Enabled;

            var switchPref = new SwitchPreference(null);

            switchPref.Checked = switchPref.Checked;
            switchPref.Enabled = switchPref.Enabled;

            var listPref = new ListPreference(null);

            listPref.Enabled = listPref.Enabled;
            listPref.Value   = listPref.Value;
        }
        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);
            }
        }
Beispiel #8
0
        public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
        {
            switch (key)
            {
            case ConfigurationParameters.WeatherUpdateFrequency:
                int interval_minutes = int.Parse(sharedPreferences.GetString(ConfigurationParameters.WeatherUpdateFrequency, "-1"));
                if (interval_minutes != -1)
                {
                    ListPreference weatherUpdateFrequency = FindPreference("weatherupdatefrequency") as ListPreference;
                    weatherUpdateFrequency.Value   = interval_minutes.ToString();
                    weatherUpdateFrequency.Summary = weatherUpdateFrequency.Entry;

                    PeriodicWorkRequest weatherPeriodicWorkRequest = PeriodicWorkRequest.Builder.From <GrabWeatherJob>(TimeSpan.FromMinutes(interval_minutes)).Build();
                    WorkManager.GetInstance(this.Activity).Enqueue(weatherPeriodicWorkRequest);
                }
                else
                {
                    WorkManager.GetInstance(this.Activity).CancelAllWork();
                }

                break;

            case ConfigurationParameters.WeatherCity:

                Preference weatherCity = FindPreference("weathercity");
                weatherCity.Summary = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherCity, string.Empty);
                break;
            }
        }
        private void InitPreferences()
        {
            //SaveSetting = ETC.sharedPreferences.Edit();

            ListPreference MainActionbarIcon = (ListPreference)FindPreference("MainActionbarIcon");

            MainActionbarIcon.SetEntries(new string[]
            {
                "RFB 1",
                "Dictionary",
                "K5",
                "RFB 2"
            });
            MainActionbarIcon.SetEntryValues(new string[]
            {
                Resource.Drawable.AppIcon_Old.ToString(),
                Resource.Drawable.AppIcon_Old2.ToString(),
                Resource.Drawable.AppIcon.ToString(),
                Resource.Drawable.AppIcon2.ToString()
            });

            /*MainActionbarIcon.PreferenceChange += delegate
             * {
             *  SaveSetting.PutString("MainActionbarIcon", MainActionbarIcon.Value);
             *  SaveSetting.Commit();
             * };*/

            SwitchPreference UnlockCensored = (SwitchPreference)FindPreference("UnlockCensored");

            UnlockCensored.Checked           = Preferences.Get("DollImageCensoredUnlock", false);
            UnlockCensored.PreferenceChange += delegate { Preferences.Set("DollImageCensoredUnlock", UnlockCensored.Checked); };
        }
Beispiel #10
0
        private void GetOfflineVersions()
        {
            var file = new Java.IO.File(Context.GetExternalFilesDir("Offline"), "tiles");

            if (!file.Exists())
            {
                file.Mkdirs();
            }

            ListPreference offlineVersions = (ListPreference)FindPreference(
                GetString(Resource.String.offline_version_key));
            List <string> list = BuildFileList(file);

            if (list.Any())
            {
                string[] entries = list.ToArray();
                offlineVersions.SetEntries(entries);
                offlineVersions.SetEntryValues(entries);
                offlineVersions.Enabled = true;
            }
            else
            {
                offlineVersions.Enabled = false;
            }
        }
Beispiel #11
0
        public void saveIconScale()
        {
            ListPreference rt = (ListPreference)PreferenceManager.FindPreference("icon_scale");

            string[] vals  = rt.GetEntryValues();
            int      index = rt.FindIndexOfValue(rt.Value);

            AppConfig.setIconScale(vals[index]);
            Log.Debug("SettingsActivity", "Icon Scale is now " + rt.Entry + "  - " + vals[index]);
        }
Beispiel #12
0
        public void saveResourceType()
        {
            ListPreference rt = (ListPreference)PreferenceManager.FindPreference("resource_type");

            string[] vals  = rt.GetEntryValues();
            int      index = rt.FindIndexOfValue(rt.Value);

            AppConfig.SelectedResource = vals[index];
            AppConfig.ResourceIndex    = index;
            Log.Debug("SettingsActivity", "Resource type is now " + rt.Entry + "  - " + vals[index]);
        }
Beispiel #13
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     PreferenceManager.SetDefaultValues(Application.Context, Resource.Xml.preferences, false);
     AddPreferencesFromResource(Resource.Xml.preferences);
     _pricePerKmPreference = (EditTextPreference) FindPreference("CustomPricePerKilometerKey");
     _consumptionPer100KmPreference = (EditTextPreference) FindPreference("ConsumptionPer100kmKey");
     _fuelTypeListPreference = (ListPreference) FindPreference("SelectedFuelTypeKey");
     _fuelPriceEditTextPreference = (EditTextPreference) FindPreference("CustomFuelPriceKey");
     _consumptionModesListPreference = (ListPreference) FindPreference("ConsumptionModeSettingKey");
     _consumptionModesListPreference.PreferenceChange += OnConsumptionModePreferenceChanged;
 }
        public static bool OnPreferenceChange(Preference preference, object newValue)
        {
            var stringValue = newValue.ToString();

            if (preference is ListPreference)
            {
                // For list preferences, look up the correct display value in
                // the preference's 'entries' list.
                ListPreference listPreference = (ListPreference)preference;
                int            index          = listPreference.FindIndexOfValue(stringValue);

                // Set the summary to reflect the new value.
                preference.Summary = index >= 0 ? listPreference.GetEntries()[index] : null;
            }
            else if (preference is RingtonePreference)
            {
                // For ringtone preferences, look up the correct display value
                // using RingtoneManager.
                if (TextUtils.IsEmpty(stringValue))
                {
                    // Empty values correspond to 'silent' (no ringtone).
                    preference.Summary = Application.Context.Resources.GetString(Resource.String.pref_group_ringtone_silent);
                }
                else
                {
                    Ringtone ringtone = RingtoneManager.GetRingtone(preference.Context, Android.Net.Uri.Parse(stringValue));

                    if (ringtone == null)
                    {
                        // Clear the summary if there was a lookup error.
                        preference.Summary = null;
                    }
                    else
                    {
                        // Set the summary to reflect the new ringtone display
                        // name.
                        preference.Summary = ringtone.GetTitle(preference.Context);
                    }
                }
            }
            else
            {
                // For all other preferences, set the summary to the value's
                // simple string representation.
                preference.Summary = stringValue;
            }
            return(true);
        }
Beispiel #15
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            settings        = RemoteSettings.Instance;
            brickController = BrickController.Instance;

            AddPreferencesFromResource(Resource.Layout.Settings);

            deviceList = (ListPreference)FindPreference("bluetoothDevice");
            brickType  = (ListPreference)FindPreference("brickType");


            leftMotor       = (ListPreference)FindPreference("leftMotor");
            rightMotor      = (ListPreference)FindPreference("rightMotor");
            additionalMotor = (ListPreference)FindPreference("additionalMotor");

            leftMotorReverse       = (CheckBoxPreference)FindPreference("reverseLeftMotor");
            rightMotorReverse      = (CheckBoxPreference)FindPreference("reverseRightMotor");
            additionalMotorReverse = (CheckBoxPreference)FindPreference("reverseAdditionalMotor");

            sendVehicleDataToMailbox = (CheckBoxPreference)FindPreference("sendVehicleDataToMailbox");
            vehicleMailbox           = (ListPreference)FindPreference("vehicleMailbox");
            vehicleAngleOffset       = (ListPreference)FindPreference("vehicleAngleOffset");

            sensorValueToSpeech = (CheckBoxPreference)FindPreference("sensorValueToSpeech");

            deviceList.OnPreferenceChangeListener = this;
            brickType.OnPreferenceChangeListener  = this;


            leftMotor.OnPreferenceChangeListener       = this;
            rightMotor.OnPreferenceChangeListener      = this;
            additionalMotor.OnPreferenceChangeListener = this;

            leftMotorReverse.OnPreferenceChangeListener       = this;
            rightMotorReverse.OnPreferenceChangeListener      = this;
            additionalMotorReverse.OnPreferenceChangeListener = this;

            sendVehicleDataToMailbox.OnPreferenceChangeListener = this;
            vehicleMailbox.OnPreferenceChangeListener           = this;

            sensorValueToSpeech.OnPreferenceChangeListener = this;

            vehicleAngleOffset.OnPreferenceChangeListener = this;
        }
Beispiel #16
0
 private void UpdatePrefSummary(Preference p)
 {
     if (p is ListPreference)
     {
         ListPreference listPref = (ListPreference)p;
         p.Summary = listPref.Entry;
     }
     if (p is EditTextPreference)
     {
         EditTextPreference editTextPref = (EditTextPreference)p;
         p.Summary = editTextPref.Text;
     }
     if (p is SeekBarPreference)
     {
         SeekBarPreference seekBarPref = (SeekBarPreference)p;
         p.Summary = Convert.ToString(seekBarPref.Progress) + "%";
     }
 }
Beispiel #17
0
        public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
        {
            Preference pref = FindPreference(key);

            if (pref is ListPreference)
            {
                ListPreference listPref = (ListPreference)pref;

                if (listPref.Key == "vechicle_mode_key")
                {
                    DirectionsService.Mode = listPref.Value;
                }
                else if (listPref.Key == "unit_system_key")
                {
                    DirectionsService.Unit = listPref.Value;
                }
            }
        }
        public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
        {
            AddPreferencesFromResource(Resource.Xml.music_widget_prefs);
            if (Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch)                       //In kitkat you can only use the RemoteController
                                                                                            //thats why you can't choose a music widget control method.
            {
                Preference musiccontrolmethod = FindPreference("musicwidgetcontrolmethod"); //Preference that's disabled by default.
                musiccontrolmethod.Selectable = true;
                musiccontrolmethod.Enabled    = true;
            }
            string         interval           = configurationManager.RetrieveAValue(ConfigurationParameters.MusicWidgetMethod, "1"); //1 is the default value, music_widget_prefs.xml
            ListPreference musicWidgetControl = FindPreference("musicwidgetcontrolmethod") as ListPreference;

            musicWidgetControl.Value   = interval;
            musicWidgetControl.Summary = musicWidgetControl.Entry;

            sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            AddPreferencesFromResource(Resource.Xml.custom_prefs);

            // This sample app uses shared preferences to maintain app restriction settings.  Your app
            // can use other methods to maintain the settings.
            mBooleanPref = FindPreference(KEY_BOOLEAN_PREF) as CheckBoxPreference;
            mChoicePref  = FindPreference(KEY_CHOICE_PREF) as ListPreference;
            mMultiPref   = FindPreference(KEY_MULTI_PREF) as MultiSelectListPreference;

            mBooleanPref.PreferenceChange += OnPreferenceChange;
            mChoicePref.PreferenceChange  += OnPreferenceChange;
            mMultiPref.PreferenceChange   += OnPreferenceChange;

            RetainInstance = true;
        }
		public override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			AddPreferencesFromResource (Resource.Xml.custom_prefs);

			// This sample app uses shared preferences to maintain app restriction settings.  Your app
			// can use other methods to maintain the settings.
			mBooleanPref = FindPreference (KEY_BOOLEAN_PREF) as CheckBoxPreference;
			mChoicePref = FindPreference (KEY_CHOICE_PREF) as ListPreference;
			mMultiPref = FindPreference (KEY_MULTI_PREF) as MultiSelectListPreference;

			mBooleanPref.PreferenceChange += OnPreferenceChange;
			mChoicePref.PreferenceChange += OnPreferenceChange;
			mMultiPref.PreferenceChange += OnPreferenceChange;

			RetainInstance = true;
		}
Beispiel #21
0
            protected override Preference CreatePreference(PropertyInfo property)
            {
                if (property.Name == nameof(Config.IconSetUri))
                {
                    IconSetPreference = new ListPreference(Activity);

                    IconSetPreference.Key   = property.Name;
                    IconSetPreference.Title = property.GetCustomAttribute <DisplayNameAttribute>()?.DisplayName;

                    IconSetPreference.SetEntries(Config.DefaultIconSets.Keys.Concat("Other icon set").ToArray());
                    IconSetPreference.SetEntryValues(Config.DefaultIconSets.Values.Select(u => u.ToString()).Concat("").ToArray());

                    IconSetPreference.PreferenceChange += IconSetPreference_PreferenceChange;

                    return(IconSetPreference);
                }

                return(base.CreatePreference(property));
            }
Beispiel #22
0
        public bool OnPreferenceChange(Preference preference, Java.Lang.Object newValue)
        {
            string stringValue = newValue.ToString();

            if (Utils.ObjectUtility.CheckInherit(preference.GetType(), typeof(ListPreference)))
            {
                ListPreference listPreference = (ListPreference)preference;
                int            index          = listPreference.FindIndexOfValue(stringValue);

                // Set the summary to reflect the new value.
                preference.Summary = index >= 0 ? listPreference.GetEntries()[index] : null;
            }
            else if (Utils.ObjectUtility.CheckInherit(preference.GetType(), typeof(RingtonePreference)))
            {
                if (Android.Text.TextUtils.IsEmpty(stringValue))
                {
                    // Empty values correspond to 'silent' (no ringtone).
                    preference.SetSummary(Resource.String.pref_ringtone_silent);
                }
                else
                {
                    Ringtone ringtone = RingtoneManager.GetRingtone(preference.Context, Android.Net.Uri.Parse(stringValue));

                    if (ringtone == null)
                    {
                        // Clear the summary if there was a lookup error.
                        preference.Summary = null;
                    }
                    else
                    {
                        // Set the summary to reflect the new ringtone display name.
                        string name = ringtone.GetTitle(preference.Context);
                        preference.Summary = name;
                    }
                }
            }
            else
            {
                preference.Summary = stringValue;
            }

            return(true);
        }
Beispiel #23
0
        public override async void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
        {
            AddPreferencesFromResource(Resource.Xml.preferences);

            allLangs = (await LanguageChoiceManager.GetLanguageChoices()).OrderBy((lang) => lang.Code).ToList();

            string[] langIds   = allLangs.Select((lang) => lang.Id.ToString()).ToArray();
            string[] langNames = allLangs.Select((lang) => lang.Endonym).ToArray();

            CultureInfo currentCulture = StringResources.Culture ?? Localise.GetCurrentCultureInfo();

            int appCurrentLangVal = allLangs.FindIndex((obj) => obj.Code == currentCulture.TwoLetterISOLanguageName);

            if (appCurrentLangVal == -1)
            {
                appCurrentLangVal = 1;
            }

            ListPreference appLangPref = (ListPreference)FindPreference("appLanguagePref");

            appLangPref.Title = StringResources.settings_chooseAppLanguage;
            appLangPref.SetEntries(langNames);
            appLangPref.SetEntryValues(langIds);
            appLangPref.SetValueIndex(appCurrentLangVal);
            appLangPref.PreferenceChange += AppLangPrefChanged;

            int convoDefaultVal = allLangs.FindIndex((obj) => obj.Id == Session.ActiveUser.Lang);

            ListPreference convoLangPref = (ListPreference)FindPreference("convoLanguagePref");

            convoLangPref.Title = StringResources.settings_chooseConvoLanguage;
            convoLangPref.SetEntries(langNames);
            convoLangPref.SetEntryValues(langIds);
            convoLangPref.SetValueIndex(convoDefaultVal);
            convoLangPref.PreferenceChange += ConvoLangPrefChanged;

            Preference logOutPref = FindPreference("logOutPref");

            logOutPref.Title            = StringResources.settings_logout;
            logOutPref.PreferenceClick += LogOutPref_PreferenceClick;
        }
        public override void OnBackPressed()
        {
            string KEY_API = "API";

            if (FragmentManager.FindFragmentById(Android.Resource.Id.Content) is SettingsFragment fragment)
            {
                ListPreference keyPref = fragment.FindPreference(KEY_API) as ListPreference;
                if (Settings.UsePersonalKey && String.IsNullOrWhiteSpace(Settings.API_KEY) && WeatherData.WeatherManager.IsKeyRequired(keyPref.Value))
                {
                    // Set keyentrypref color to red
                    Toast.MakeText(this, Resource.String.message_enter_apikey, ToastLength.Long).Show();
                    if (fragment.View is SwipeDismissFrameLayout dismissLayout)
                    {
                        //dismissLayout.Reset();
                    }
                    return;
                }
            }

            base.OnBackPressed();
        }
Beispiel #25
0
        public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
        {
            PreferenceManager.SharedPreferencesName = "weatherpreferences";
            PreferenceManager.SharedPreferencesMode = (int)FileCreationMode.Private;
            AddPreferencesFromResource(Resource.Xml.weather_widget_prefs);
            string city = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherCity, string.Empty);

            if (city != string.Empty)
            {
                Preference weatherCity = FindPreference("weathercity");
                weatherCity.Summary = city;
            }
            string country = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherCountryCode, string.Empty);

            if (country == string.Empty)
            {
                TelephonyManager tm          = (TelephonyManager)Activity.GetSystemService(Context.TelephonyService);
                string           countryCode = tm.NetworkCountryIso;
                configurationManager.SaveAValue(ConfigurationParameters.WeatherCountryCode, countryCode);
            }
            country = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherCountryCode, string.Empty);
            if (country != string.Empty)
            {
                Preference weatherCountry = FindPreference("weathercountrycode");
                weatherCountry.Summary = country;
            }
            string interval = configurationManager.RetrieveAValue(ConfigurationParameters.WeatherUpdateFrequency, "-1");

            if (interval != "-1")
            {
                ListPreference weatherUpdateFrequency = FindPreference("weatherupdatefrequency") as ListPreference;
                weatherUpdateFrequency.Value   = interval;
                weatherUpdateFrequency.Summary = weatherUpdateFrequency.Entry;
            }

            sharedPreferences.RegisterOnSharedPreferenceChangeListener(this);
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            AddPreferencesFromResource(Resource.Xml.preferences);

            // Re-use the change handlers for the application settings
            FindPreference(GetString(Resource.String.keyfile_key)).PreferenceChange += OnRememberKeyFileHistoryChanged;
            FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += OnShowUnlockedNotificationChanged;
            FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += OnShowUnlockedNotificationChanged;
            FindPreference(GetString(Resource.String.DebugLog_key)).PreferenceChange     += OnDebugLogChanged;
            FindPreference(GetString(Resource.String.DebugLog_send_key)).PreferenceClick += OnSendDebug;
            PrepareNoDonatePreference(Activity, FindPreference(GetString(Resource.String.NoDonateOption_key)));
            PrepareNoDonationReminderPreference(Activity, ((PreferenceScreen)FindPreference(GetString(Resource.String.display_prefs_key))), FindPreference(GetString(Resource.String.NoDonationReminder_key)));

            FindPreference(GetString(Resource.String.design_key)).PreferenceChange += (sender, args) => Activity.Recreate();

            Database db = App.Kp2a.GetDb();

            if (db.Loaded)
            {
                ListPreference kdfPref = (ListPreference)FindPreference(GetString(Resource.String.kdf_key));
                kdfPref.SetEntries(KdfPool.Engines.Select(eng => eng.Name).ToArray());
                string[] kdfValues = KdfPool.Engines.Select(eng => eng.Uuid.ToHexString()).ToArray();
                kdfPref.SetEntryValues(kdfValues);
                kdfPref.SetValueIndex(kdfValues.Select((v, i) => new { kdf = v, index = i }).First(el => el.kdf == db.KpDatabase.KdfParameters.KdfUuid.ToHexString()).index);
                kdfPref.PreferenceChange += OnKdfChange;

                aesRounds         = FindPreference(GetString(Resource.String.rounds_key));
                argon2rounds      = FindPreference("argon2rounds");
                argon2memory      = FindPreference("argon2memory");
                argon2parallelism = FindPreference("argon2parallelism");

                aesRounds.PreferenceChange         += (sender, e) => UpdateKdfSummary(e.Preference);
                argon2rounds.PreferenceChange      += (sender, e) => UpdateKdfSummary(e.Preference);
                argon2memory.PreferenceChange      += (sender, e) => UpdateKdfSummary(e.Preference);
                argon2parallelism.PreferenceChange += (sender, e) => UpdateKdfSummary(e.Preference);

                UpdateKdfScreen();

                PrepareDefaultUsername(db);
                PrepareDatabaseName(db);
                PrepareMasterPassword();
                PrepareTemplates(db);

                ListPreference algorithmPref = (ListPreference)FindPreference(GetString(Resource.String.algorithm_key));
                algorithmPref.SetEntries(CipherPool.GlobalPool.Engines.Select(eng => eng.DisplayName).ToArray());
                string[] algoValues = CipherPool.GlobalPool.Engines.Select(eng => eng.CipherUuid.ToHexString()).ToArray();
                algorithmPref.SetEntryValues(algoValues);
                algorithmPref.SetValueIndex(algoValues.Select((v, i) => new { kdf = v, index = i }).First(el => el.kdf == db.KpDatabase.DataCipherUuid.ToHexString()).index);
                algorithmPref.PreferenceChange += AlgorithmPrefChange;
                algorithmPref.Summary           =
                    CipherPool.GlobalPool.GetCipher(App.Kp2a.GetDb().KpDatabase.DataCipherUuid).DisplayName;
                UpdateImportDbPref();
                UpdateImportKeyfilePref();
            }

            try
            {
                //depending on Android version, we offer to use a transparent icon for QuickUnlock or use the notification priority (since API level 16)
                Preference hideQuickUnlockTranspIconPref = FindPreference(GetString(Resource.String.QuickUnlockIconHidden_key));
                Preference hideQuickUnlockIconPref       = FindPreference(GetString(Resource.String.QuickUnlockIconHidden16_key));
                var        quickUnlockScreen             = ((PreferenceScreen)FindPreference(GetString(Resource.String.QuickUnlock_prefs_key)));
                if ((int)Android.OS.Build.VERSION.SdkInt >= 16)
                {
                    quickUnlockScreen.RemovePreference(hideQuickUnlockTranspIconPref);
                    FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)).PreferenceChange += (sender, args) => App.Kp2a.UpdateOngoingNotification();
                    hideQuickUnlockIconPref.PreferenceChange += delegate { App.Kp2a.UpdateOngoingNotification(); };
                }
                else
                {
                    //old version: only show transparent quickUnlock and no option to hide unlocked icon:
                    quickUnlockScreen.RemovePreference(hideQuickUnlockIconPref);
                    FindPreference(GetString(Resource.String.QuickUnlockIconHidden_key)).PreferenceChange +=
                        delegate { App.Kp2a.UpdateOngoingNotification(); };

                    ((PreferenceScreen)FindPreference(GetString(Resource.String.display_prefs_key))).RemovePreference(
                        FindPreference(GetString(Resource.String.ShowUnlockedNotification_key)));
                }
            }
            catch (Exception ex)
            {
                Kp2aLog.LogUnexpectedError(ex);
            }



            //AppSettingsActivity.PrepareKeyboardSwitchingPreferences(this);
            _switchPrefManager = new KeyboardSwitchPrefManager(this);
            PrepareSeparateNotificationsPreference();

            FindPreference("IconSetKey").PreferenceChange += (sender, args) =>
            {
                if (App.Kp2a.GetDb() != null)
                {
                    App.Kp2a.GetDb().DrawableFactory.Clear();
                }
            };

            Preference cachingPreference = FindPreference(GetString(Resource.String.UseOfflineCache_key));

            cachingPreference.PreferenceChange += OnUseOfflineCacheChanged;
        }
 public static string BindValue(this ListPreference listPreference)
 => MvxAndroidPropertyBinding.ListPreference_Value;
 public MvxListPreferenceTargetBinding(ListPreference preference)
     : base(preference)
 {
 }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			settings = RemoteSettings.Instance;
			brickController = BrickController.Instance;

			AddPreferencesFromResource(Resource.Layout.Settings);

			deviceList = (ListPreference) FindPreference("bluetoothDevice");
			brickType = (ListPreference) FindPreference("brickType");


			leftMotor = (ListPreference) FindPreference("leftMotor");
			rightMotor = (ListPreference) FindPreference("rightMotor");
			additionalMotor = (ListPreference) FindPreference("additionalMotor");

			leftMotorReverse = (CheckBoxPreference) FindPreference("reverseLeftMotor");
			rightMotorReverse = (CheckBoxPreference) FindPreference("reverseRightMotor");
			additionalMotorReverse = (CheckBoxPreference) FindPreference("reverseAdditionalMotor");

			sendVehicleDataToMailbox = (CheckBoxPreference) FindPreference("sendVehicleDataToMailbox");
			vehicleMailbox = (ListPreference) FindPreference("vehicleMailbox");
			vehicleAngleOffset = (ListPreference) FindPreference("vehicleAngleOffset");

			sensorValueToSpeech = (CheckBoxPreference) FindPreference("sensorValueToSpeech");

			deviceList.OnPreferenceChangeListener = this;
			brickType.OnPreferenceChangeListener = this;


			leftMotor.OnPreferenceChangeListener = this;
			rightMotor.OnPreferenceChangeListener = this;
			additionalMotor.OnPreferenceChangeListener = this;

			leftMotorReverse.OnPreferenceChangeListener = this;
			rightMotorReverse.OnPreferenceChangeListener = this;
			additionalMotorReverse.OnPreferenceChangeListener = this;

			sendVehicleDataToMailbox.OnPreferenceChangeListener = this;
			vehicleMailbox.OnPreferenceChangeListener = this;

			sensorValueToSpeech.OnPreferenceChangeListener = this;
			
			vehicleAngleOffset.OnPreferenceChangeListener = this;
			
		}
        //@SuppressWarnings("deprecation")
        protected override void onCreate(Bundle savedInstanceState)
        {
            if (Build.VERSION.SdkInt < 11)
                requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // added for actionbarcompat

            base.OnCreate(savedInstanceState);

            this.activity = this;
            SyncManager.setActivity(this);
            SyncManager.setHandler(this.preferencesMessageHandler);

            addPreferencesFromResource(Resource.xml.preferences);

            // Fill the Preferences fields
            baseSize = FindPreference<EditTextPreference>(Preferences.Key.BASE_TEXT_SIZE.getName());
            defaultSort = FindPreference<ListPreference>(Preferences.Key.SORT_ORDER.getName());
            syncServer = FindPreference<EditTextPreference>(Preferences.Key.SYNC_SERVER.getName());
            syncService = FindPreference<ListPreference>(Preferences.Key.SYNC_SERVICE.getName());
            sdLocation = FindPreference<EditTextPreference>(Preferences.Key.SD_LOCATION.getName());
            clearSearchHistory = FindPreference<Preference>(Preferences.Key.CLEAR_SEARCH_HISTORY.getName());
            delNotes = FindPreference<Preference>(Preferences.Key.DEL_ALL_NOTES.getName());
            delRemoteNotes = FindPreference<Preference>(Preferences.Key.DEL_REMOTE_NOTES.getName());
            backupNotes = FindPreference<Preference>(Preferences.Key.BACKUP_NOTES.getName());
            autoBackup = FindPreference<Preference>(Preferences.Key.AUTO_BACKUP_NOTES.getName());

            // Set the default values if nothing Exists
            setDefaults();

            // Fill the services combo list
            fillServices();

            // Fill the services combo list
            fillSortOrders();

            // Enable or disable the server field depending on the selected sync service
            setServer(syncService.getValue());

            //			syncService.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            //
            //				public bool onPreferenceChange(Preference preference, Object newValue) {
            //					string selectedSyncServiceKey = (string)newValue;
            //
            //					// did the selection change?
            //					if (!syncService.getValue().contentEquals(selectedSyncServiceKey)) {
            //						TLog.d(TAG, "preference change triggered");
            //
            //						syncServiceChanged(selectedSyncServiceKey);
            //					}
            //					return true;
            //				}
            //			});

            // force reauthentication if the sync server changes
            //			syncServer.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            //
            //				public bool onPreferenceChange(Preference preference,
            //						Object serverUri) {
            //
            //					if (serverUri == null) {
            //						Toast.MakeText(PreferencesActivity.this,
            //								GetString(Resource.String.prefServerEmpty),
            //								ToastLength.Short).Show();
            //						return false;
            //					}
            //
            //					if (!URLUtil.isValidUrl(serverUri.ToString())){
            //						noValidEntry(serverUri.ToString());
            //						return false;
            //					}
            //					syncServer.setSummary((string)serverUri);
            //
            //					// TODO is this necessary? hasn't it changed already?
            //					Preferences.putstring(Preferences.Key.SYNC_SERVER, (string)serverUri);
            //
            //					reauthenticate();
            //					return true;
            //				}
            //
            //			});

            // Change the Folder Location
            //			sdLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            //
            //				public bool onPreferenceChange(Preference preference, Object locationUri) {
            //
            //					if (locationUri.equals(Preferences.GetString(Preferences.Key.SD_LOCATION))) {
            //						return false;
            //					}
            //					if ((locationUri.ToString().contains("\t")) || (locationUri.ToString().contains("\n"))) {
            //						noValidEntry(locationUri.ToString());
            //						return false;
            //					}
            //
            //					File path = new File(Environment.getExternalStorageDirectory()
            //							+ "/" + locationUri + "/");
            //
            //					if(!path.Exists()) {
            //						TLog.w(TAG, "Folder {0} does not exist.", path);
            //						folderNotExisting(path.ToString());
            //						return false;
            //					}
            //
            //					Preferences.putstring(Preferences.Key.SD_LOCATION, locationUri.ToString());
            //					TLog.d(TAG, "Changed Folder to: " + path.ToString());
            //
            //					Tomdroid.NOTES_PATH = path.ToString();
            //					sdLocation.setSummary(Tomdroid.NOTES_PATH);
            //
            //					resetLocalDatabase();
            //					return true;
            //				}
            //			});

            //delete Search History
            //			clearSearchHistory.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            //		        public bool onPreferenceClick(Preference preference) {
            //		            SearchRecentSuggestions suggestions = new SearchRecentSuggestions(PreferencesActivity.this,
            //		                    SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
            //		            suggestions.clearHistory();
            //
            //		        	Toast.MakeText(getBaseContext(),
            //	                        GetString(Resource.String.deletedSearchHistory),
            //	                        Toast.LENGTH_LONG).Show();
            //		        	TLog.d(TAG, "Deleted search history.");
            //
            //		        	return true;
            //		        }
            //		    });

            //			baseSize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            //				public bool onPreferenceChange(Preference preference, Object newValue) {
            //					try {
            //						Float.parseFloat((string)newValue);
            //						Preferences.putstring(Preferences.Key.BASE_TEXT_SIZE, (string)newValue);
            //					}
            //					catch(Exception e) {
            //			        	Toast.MakeText(getBaseContext(),
            //		                        GetString(Resource.String.illegalTextSize),
            //		                        Toast.LENGTH_LONG).Show();
            //			        	TLog.e(TAG, "Illegal text size in preferences");
            //			        	return false;
            //					}
            //					baseSize.setSummary((string)newValue);
            //					return true;
            //				}
            //			});
            //			defaultSort.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            //
            //				public bool onPreferenceChange(Preference preference, Object newValue) {
            //					string value = (string) newValue;
            //					if(value.equals("sort_title"))
            //						defaultSort.setSummary(GetString(Resource.String.sortByTitle));
            //					else
            //						defaultSort.setSummary(GetString(Resource.String.sortByDate));
            //					return true;
            //				}
            //			});
            //			delNotes.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            //
            //		        public bool onPreferenceClick(Preference preference) {
            //		        	ShowDialog(DIALOG_DELETE);
            //					return true;
            //				}
            //			});

            //			delRemoteNotes.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            //
            //		        public bool onPreferenceClick(Preference preference) {
            //		        	ShowDialog(DIALOG_DEL_REMOTE);
            //					return true;
            //				}
            //			});
            //
            //
            //			backupNotes.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            //
            //		        public bool onPreferenceClick(Preference preference) {
            //		        	ShowDialog(DIALOG_BACKUP);
            //
            //					return true;
            //				}
            //			});
        }
    public override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        //getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        // Load the preferences from an XML resource
        AddPreferencesFromResource(Resource.Xml.preferences);

        // Get the Preference Category which we want to add the ListPreference
        ListPreference customListPref = (ListPreference)FindPreference("pref_template");

        MainActivity parentActivity = (MainActivity)Activity;

        // Retrieve SimulScan default templates from the system
        RetrieveTemplates();

        if (customListPref != null)
        {
            List <string> entries     = new List <string>();
            List <string> entryValues = new List <string>();

            string path = Environment.ExternalStorageDirectory.ToString() + "/simulscan/templates";
            Log.Debug(TAG, "Path: " + path);
            File f = new File(path);

            File [] file = f.ListFiles();
            if (file != null)
            {
                for (int i = 0; i < file.Length; i++)
                {
                    Log.Debug(TAG, "FileName:" + file[i].Name);
                    //Log.d("Files", "value:" + file[i].getAbsolutePath());
                    entries.Add(file[i].Name);
                    entryValues.Add(i.ToString());
                }
            }
            else
            {
                Log.Debug(TAG, "Cant find folder");
            }

            if (entries.Count == 0)
            {
                entries.Add(NO_TEMPLATE_FOUND);
                entryValues.Add("");
            }
            customListPref.SetEntries(entries.ToArray());
            customListPref.SetEntryValues(entryValues.ToArray());

            //customListPref.setPersistent(true);

            ISharedPreferences prefs = PreferenceScreen.SharedPreferences;
            int lastTemplatePos      = prefs.GetInt(SETTINGS_LAST_TEMPLATE_POS, 0);
            if (lastTemplatePos >= entries.Count)
            {
                lastTemplatePos = 0;
            }
            customListPref.SetValueIndex(lastTemplatePos);
            customListPref.Summary = entries[lastTemplatePos];


            if (entryValues[lastTemplatePos].CompareTo("") != 0)
            {
                parentActivity.localSettings.fileList          = new List <File>(file);
                parentActivity.localSettings.selectedFileIndex = lastTemplatePos;
            }
        }

        EditTextPreference pref1 = (EditTextPreference)FindPreference("timeout_identification");

        parentActivity.localSettings.identificationTimeout = int.Parse(pref1.Text);
        EditTextPreference pref2 = (EditTextPreference)FindPreference("timeout_processing");

        parentActivity.localSettings.processingTimeout = int.Parse(pref2.Text);
        CheckBoxPreference pref3 = (CheckBoxPreference)FindPreference("ui_result_confirmation");

        parentActivity.localSettings.enableResultConfirmation = pref3.Checked;
        CheckBoxPreference pref4 = (CheckBoxPreference)FindPreference("auto_capture");

        parentActivity.localSettings.enableAutoCapture = pref4.Checked;
        CheckBoxPreference pref5 = (CheckBoxPreference)FindPreference("debug");

        parentActivity.localSettings.enableDebugMode = pref5.Checked;
        CheckBoxPreference pref6 = (CheckBoxPreference)FindPreference("feedback_audio");

        parentActivity.localSettings.enableFeedbackAudio = pref6.Checked;
        CheckBoxPreference pref7 = (CheckBoxPreference)FindPreference("feedback_haptic");

        parentActivity.localSettings.enableHaptic = pref7.Checked;
        CheckBoxPreference pref8 = (CheckBoxPreference)FindPreference("feedback_led");

        parentActivity.localSettings.enableLED = pref8.Checked;
    }
    public void OnSharedPreferenceChanged(ISharedPreferences prefs, string key)
    {
        MainActivity parentActivity = (MainActivity)Activity;

        if (key.CompareTo(Resources.GetString(Resource.String.pref_key)) == 0)
        {
            ListPreference connectionPref = (ListPreference)FindPreference(key);
            Log.Debug(TAG, "Template PreferenceChanged: " + connectionPref.Value);
            parentActivity.localSettings.selectedFileIndex = int.Parse(connectionPref.Value);
            connectionPref.Summary = connectionPref.Entry;
            //save last template used

            /*ISharedPreferences iprefs = null;
             * iprefs.Edit();
             * iprefs = (ISharedPreferences)prefs.PutInt(SETTINGS_LAST_TEMPLATE_POS, parentActivity.localSettings.selectedFileIndex);
             * prefs.Apply();*/

            ISharedPreferencesEditor editor = (ISharedPreferencesEditor)prefs.Edit();
            editor.PutInt(SETTINGS_LAST_TEMPLATE_POS, parentActivity.localSettings.selectedFileIndex);
            editor.Apply();
        }
        else if (key.CompareTo("timeout_identification") == 0)
        {
            EditTextPreference connectionPref = (EditTextPreference)FindPreference(key);
            Log.Debug(TAG, "Identification PreferenceChanged: " + connectionPref.Text);

            int idto = parentActivity.localSettings.identificationTimeout;

            try {
                idto = int.Parse(connectionPref.Text);
                if (idto < 5000)
                {
                    idto = 5000;
                }
            }
            catch (IllegalFormatException ex)
            {
                Log.Error(TAG, "Invalid identification timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid identification timeout value", ToastLength.Long).Show();
            }
            catch (System.OverflowException ex)
            {
                Log.Error(TAG, "Invalid identification timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid identification timeout value", ToastLength.Long).Show();
            }

            connectionPref.Text = idto.ToString();
            parentActivity.localSettings.identificationTimeout = idto;
        }
        else if (key.CompareTo("timeout_processing") == 0)
        {
            EditTextPreference connectionPref = (EditTextPreference)FindPreference(key);
            Log.Debug(TAG, "Processing PreferenceChanged: " + connectionPref.Text);

            int processingTimeout = parentActivity.localSettings.processingTimeout;;

            try
            {
                processingTimeout = int.Parse(connectionPref.Text);
            }
            catch (IllegalFormatException ex)
            {
                Log.Error(TAG, "Invalid processing timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid processing timeout value", ToastLength.Long).Show();
            }
            catch (System.OverflowException ex)
            {
                Log.Error(TAG, "Invalid processing timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid processing timeout value", ToastLength.Long).Show();
            }
            connectionPref.Text = processingTimeout.ToString();
            parentActivity.localSettings.processingTimeout = processingTimeout;
        }
        else if (key.CompareTo("ui_result_confirmation") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "result confrmation PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableResultConfirmation = connectionPref.Checked;
        }
        else if (key.CompareTo("auto_capture") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Auto capture PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableAutoCapture = connectionPref.Checked;
        }
        else if (key.CompareTo("debug") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Debug PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableDebugMode = connectionPref.Checked;
        }
        else if (key.CompareTo("feedback_audio") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Audio PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableFeedbackAudio = connectionPref.Checked;
        }
        else if (key.CompareTo("feedback_haptic") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Haptic PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableHaptic = connectionPref.Checked;
        }
        else if (key.CompareTo("feedback_led") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "LED PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableLED = connectionPref.Checked;
        }
    }
        protected override void OnCreate(Bundle bundle)
        {
            SetTheme(PreferenceManager.GetDefaultSharedPreferences(ApplicationContext).GetInt("ThemeStyle", Resource.Style.Theme_Sherlock));

            base.OnCreate(bundle);

            this.AddPreferencesFromResource(Resource.Layout.PreferencesLayout);

            cp = (CheckBoxPreference)FindPreference("dualWebviews");
            slp = (ListPreference)FindPreference("listSecondLanguage");

            CheckBoxPreference notesReplace = (CheckBoxPreference)FindPreference("notesReplace");
            CheckBoxPreference allowHighlighting = (CheckBoxPreference)FindPreference("allowHighlighting");
            CheckBoxPreference recordEveryHighlight = (CheckBoxPreference)FindPreference("recordEveryHighlight");

            //notesReplace.Enabled = false;
            //notesReplace.Selectable = false;
            //notesReplace.SetDefaultValue(false);
            //allowHighlighting.Enabled = false;
            //allowHighlighting.Selectable = false;
            //allowHighlighting.SetDefaultValue(false);
            //recordEveryHighlight.Enabled = false;
            //recordEveryHighlight.Selectable = false;
            //recordEveryHighlight.SetDefaultValue(false);
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);

                AddPreferencesFromResource(Resource.Xml.SettingsPrefs);

                Wo_Main_Settings.Shared_Data = PreferenceManager.SharedPreferences;

                PreferenceCategory mCategory = (PreferenceCategory)FindPreference("category_General");

                EditProfile         = FindPreference("editprofile_key");
                BlockedUsers        = FindPreference("blocked_key");
                Account_Pref        = FindPreference("editAccount_key");
                Password_Pref       = FindPreference("editpassword_key");
                General_Invite_Pref = FindPreference("invite_key");
                General_Call_Pref   = FindPreference("Call_key");

                if (!AppSettings.Enable_Audio_Video_Call)
                {
                    mCategory.RemovePreference(General_Call_Pref);
                }


                if (!AppSettings.Invitation_System)
                {
                    mCategory.RemovePreference(General_Invite_Pref);
                }


                Support_Report_Pref        = FindPreference("Report_key");
                Support_Help_Pref          = FindPreference("help_key");
                Support_Logout_Pref        = FindPreference("logout_key");
                Support_deleteaccount_Pref = FindPreference("deleteaccount_key");

                Lang_Pref     = (ListPreference)FindPreference("Lang_key");
                About_Me_Pref = (EditTextPreference)FindPreference("about_me_key");

                //Privacy
                Privacy_Follow_Pref   = (ListPreference)FindPreference("whocanfollow_key");
                Privacy_Message_Pref  = (ListPreference)FindPreference("whocanMessage_key");
                Privacy_Birthday_Pref = (ListPreference)FindPreference("whocanseemybirthday_key");

                Notifcation_Popup_Pref     = (SwitchPreference)FindPreference("notifications_key");
                Notifcation_PlaySound_Pref = (CheckBoxPreference)FindPreference("checkBox_PlaySound_key");

                //Add Click event to Preferences
                EditProfile.Intent         = new Intent(Application.Context, typeof(MyProfile_Activity));
                BlockedUsers.Intent        = new Intent(Application.Context, typeof(BlockedUsers_Activity));
                Account_Pref.Intent        = new Intent(Application.Context, typeof(My_Account_Activity));
                Password_Pref.Intent       = new Intent(Application.Context, typeof(Password_Activity));
                General_Invite_Pref.Intent = new Intent(Application.Context, typeof(Invite_Friends_Activity));

                //Update Preferences data on Load
                OnSharedPreferenceChanged(Wo_Main_Settings.Shared_Data, "about_me_key");
                OnSharedPreferenceChanged(Wo_Main_Settings.Shared_Data, "whocanfollow_key");
                OnSharedPreferenceChanged(Wo_Main_Settings.Shared_Data, "whocanMessage_key");
                OnSharedPreferenceChanged(Wo_Main_Settings.Shared_Data, "whocanseemybirthday_key");
                OnSharedPreferenceChanged(Wo_Main_Settings.Shared_Data, "notifications_key");
                OnSharedPreferenceChanged(Wo_Main_Settings.Shared_Data, "checkBox_PlaySound_key");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #35
0
 private void UpdateListPreferenceSummary(ListPreference listPreference)
 {
     listPreference.Summary = listPreference.Entry;
 }
            public override void OnCreate(Bundle savedInstanceState)
            {
                base.OnCreate(savedInstanceState);
                AddPreferencesFromResource(Resource.Xml.pref_general);

                apiCategory = (PreferenceCategory)FindPreference(CATEGORY_API);

                FindPreference(KEY_ABOUTAPP).PreferenceClick += (object sender, Preference.PreferenceClickEventArgs e) =>
                {
                    // Display the fragment as the main content.
                    FragmentManager.BeginTransaction()
                    .Replace(Android.Resource.Id.Content, new AboutAppFragment())
                    .AddToBackStack(null)
                    .Commit();
                };

                followGps = (SwitchPreference)FindPreference(KEY_FOLLOWGPS);
                followGps.PreferenceChange += (object sender, Preference.PreferenceChangeEventArgs e) =>
                {
                    SwitchPreference pref = e.Preference as SwitchPreference;
                    if ((bool)e.NewValue)
                    {
                        if (Activity.CheckSelfPermission(Manifest.Permission.AccessFineLocation) != Permission.Granted &&
                            Activity.CheckSelfPermission(Manifest.Permission.AccessCoarseLocation) != Permission.Granted)
                        {
                            RequestPermissions(new String[] { Manifest.Permission.AccessCoarseLocation, Manifest.Permission.AccessFineLocation },
                                               PERMISSION_LOCATION_REQUEST_CODE);
                            return;
                        }
                    }
                };

                keyEntry = (KeyEntryPreference)FindPreference(KEY_APIKEY);
                keyEntry.BeforeDialogCreated += (object sender, EventArgs e) =>
                {
                    keyEntry?.UpdateAPI(providerPref.Value);
                };

                keyEntry.PositiveButtonClick += async(sender, e) =>
                {
                    String key = keyEntry.APIKey;

                    String API = providerPref.Value;
                    if (await WeatherData.WeatherManager.IsKeyValid(key, API))
                    {
                        Settings.API_KEY = key;
                        Settings.API     = API;

                        Settings.KeyVerified = true;
                        UpdateKeySummary();

                        keyEntry.Dialog.Dismiss();
                    }
                };

                personalKeyPref = (SwitchPreference)FindPreference(KEY_USEPERSONALKEY);
                personalKeyPref.PreferenceChange += (object sender, Preference.PreferenceChangeEventArgs e) =>
                {
                    var pref = e.Preference as SwitchPreference;
                    if ((bool)e.NewValue)
                    {
                        if (apiCategory.FindPreference(KEY_APIKEY) == null)
                        {
                            apiCategory.AddPreference(keyEntry);
                        }
                        if (apiCategory.FindPreference(KEY_APIREGISTER) == null)
                        {
                            apiCategory.AddPreference(registerPref);
                        }
                        keyEntry.Enabled = true;
                    }
                    else
                    {
                        var selectedWProv = WeatherData.WeatherManager.GetProvider(providerPref.Value);

                        if (!String.IsNullOrWhiteSpace(selectedWProv.GetAPIKey()))
                        {
                            // We're using our own (verified) keys
                            Settings.KeyVerified = true;
                            Settings.API         = providerPref.Value;
                        }

                        keyEntry.Enabled = false;
                        apiCategory.RemovePreference(keyEntry);
                        apiCategory.RemovePreference(registerPref);
                    }
                };

                var providers = WeatherData.WeatherAPI.APIs;

                providerPref = (ListPreference)FindPreference(KEY_API);
                providerPref.SetEntries(providers.Select(provider => provider.Display).ToArray());
                providerPref.SetEntryValues(providers.Select(provider => provider.Value).ToArray());
                providerPref.Persistent        = false;
                providerPref.PreferenceChange += (object sender, Preference.PreferenceChangeEventArgs e) =>
                {
                    var pref          = e.Preference as ListPreference;
                    var selectedWProv = WeatherData.WeatherManager.GetProvider(e.NewValue.ToString());

                    if (selectedWProv.KeyRequired)
                    {
                        if (String.IsNullOrWhiteSpace(selectedWProv.GetAPIKey()))
                        {
                            personalKeyPref.Checked = Settings.UsePersonalKey = true;
                            personalKeyPref.Enabled = false;
                            keyEntry.Enabled        = false;
                            apiCategory.RemovePreference(keyEntry);
                            apiCategory.RemovePreference(registerPref);
                        }
                        else
                        {
                            personalKeyPref.Enabled = true;
                        }

                        if (!Settings.UsePersonalKey)
                        {
                            // We're using our own (verified) keys
                            Settings.KeyVerified = true;
                            keyEntry.Enabled     = false;
                            apiCategory.RemovePreference(keyEntry);
                            apiCategory.RemovePreference(registerPref);
                        }
                        else
                        {
                            keyEntry.Enabled = true;

                            if (apiCategory.FindPreference(KEY_APIKEY) == null)
                            {
                                apiCategory.AddPreference(keyEntry);
                            }
                            if (apiCategory.FindPreference(KEY_APIREGISTER) == null)
                            {
                                apiCategory.AddPreference(registerPref);
                            }
                        }

                        if (apiCategory.FindPreference(KEY_USEPERSONALKEY) == null)
                        {
                            apiCategory.AddPreference(personalKeyPref);
                        }

                        // Reset to old value if not verified
                        if (!Settings.KeyVerified)
                        {
                            Settings.API = pref.Value;
                        }
                        else
                        {
                            Settings.API = e.NewValue.ToString();
                        }

                        var providerEntry = providers.Find(provider => provider.Value == e.NewValue.ToString());
                        UpdateKeySummary(providerEntry.Display);
                        UpdateRegisterLink(providerEntry.Value);
                    }
                    else
                    {
                        Settings.KeyVerified    = false;
                        keyEntry.Enabled        = false;
                        personalKeyPref.Enabled = false;

                        Settings.API = e.NewValue.ToString();
                        // Clear API KEY entry to avoid issues
                        Settings.API_KEY = String.Empty;

                        apiCategory.RemovePreference(personalKeyPref);
                        apiCategory.RemovePreference(keyEntry);
                        apiCategory.RemovePreference(registerPref);
                        UpdateKeySummary();
                        UpdateRegisterLink();
                    }
                };

                registerPref = FindPreference(KEY_APIREGISTER);
                registerPref.PreferenceClick += RegisterPref_PreferenceClick;

                // Set key as verified if API Key is req for API and its set
                if (WeatherData.WeatherManager.GetInstance().KeyRequired)
                {
                    keyEntry.Enabled = true;

                    if (!String.IsNullOrWhiteSpace(Settings.API_KEY) && !Settings.KeyVerified)
                    {
                        Settings.KeyVerified = true;
                    }

                    if (String.IsNullOrWhiteSpace(WeatherData.WeatherManager.GetInstance().GetAPIKey()))
                    {
                        personalKeyPref.Checked = Settings.UsePersonalKey = true;
                        personalKeyPref.Enabled = false;
                        keyEntry.Enabled        = false;
                        apiCategory.RemovePreference(keyEntry);
                        apiCategory.RemovePreference(registerPref);
                    }
                    else
                    {
                        personalKeyPref.Enabled = true;
                    }

                    if (!Settings.UsePersonalKey)
                    {
                        // We're using our own (verified) keys
                        Settings.KeyVerified = true;
                        keyEntry.Enabled     = false;
                        apiCategory.RemovePreference(keyEntry);
                        apiCategory.RemovePreference(registerPref);
                    }
                    else
                    {
                        keyEntry.Enabled = true;

                        if (apiCategory.FindPreference(KEY_APIKEY) == null)
                        {
                            apiCategory.AddPreference(keyEntry);
                        }
                        if (apiCategory.FindPreference(KEY_APIREGISTER) == null)
                        {
                            apiCategory.AddPreference(registerPref);
                        }
                    }
                }
                else
                {
                    keyEntry.Enabled        = false;
                    personalKeyPref.Enabled = false;
                    apiCategory.RemovePreference(personalKeyPref);
                    apiCategory.RemovePreference(keyEntry);
                    apiCategory.RemovePreference(registerPref);
                    Settings.KeyVerified = false;
                }

                UpdateKeySummary();
                UpdateRegisterLink();

                syncPreference = (ListPreference)FindPreference(KEY_DATASYNC);
                syncPreference.PreferenceChange += (object sender, Preference.PreferenceChangeEventArgs e) =>
                {
                    int newValue = int.Parse(e.NewValue.ToString());

                    ListPreference pref = e.Preference as ListPreference;
                    pref.Summary = pref.GetEntries()[newValue];

                    EnableSyncedSettings((WearableDataSync)newValue == WearableDataSync.Off);
                };
                syncPreference.Summary = syncPreference.GetEntries()[int.Parse(syncPreference.Value)];
                EnableSyncedSettings(Settings.DataSync == WearableDataSync.Off);

                connStatusPref     = FindPreference(KEY_CONNSTATUS);
                connStatusReceiver = new ConnectionStatusReceiver();
                connStatusReceiver.ConnectionStatusChanged += (status) =>
                {
                    switch (status)
                    {
                    case WearConnectionStatus.Disconnected:
                        connStatusPref.Summary          = GetString(Resource.String.status_disconnected);
                        connStatusPref.PreferenceClick -= ConnStatusPref_PreferenceClick;
                        break;

                    case WearConnectionStatus.Connecting:
                        connStatusPref.Summary          = GetString(Resource.String.status_connecting);
                        connStatusPref.PreferenceClick -= ConnStatusPref_PreferenceClick;
                        break;

                    case WearConnectionStatus.AppNotInstalled:
                        connStatusPref.Summary          = GetString(Resource.String.status_notinstalled);
                        connStatusPref.PreferenceClick += ConnStatusPref_PreferenceClick;
                        break;

                    case WearConnectionStatus.Connected:
                        connStatusPref.Summary          = GetString(Resource.String.status_connected);
                        connStatusPref.PreferenceClick -= ConnStatusPref_PreferenceClick;
                        break;

                    default:
                        break;
                    }
                };
            }
Beispiel #37
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            AddPreferencesFromResource(Resource.Xml.preferences);

            // Re-use the change handlers for the application settings
            FindPreference(GetString(Resource.String.keyfile_key)).PreferenceChange += OnRememberKeyFileHistoryChanged;
            var unlockedNotificationPref = FindPreference(GetString(Resource.String.ShowUnlockedNotification_key));

            unlockedNotificationPref.PreferenceChange += OnShowUnlockedNotificationChanged;
            if ((int)Build.VERSION.SdkInt >= 26)
            {
                //use system notification channels to control notification visibility
                unlockedNotificationPref.Parent.RemovePreference(unlockedNotificationPref);
            }


            FindPreference(GetString(Resource.String.DebugLog_key)).PreferenceChange     += OnDebugLogChanged;
            FindPreference(GetString(Resource.String.DebugLog_send_key)).PreferenceClick += OnSendDebug;

            UpdateAutofillPref();

            var autofillPref = FindPreference(GetString(Resource.String.AutoFill_prefs_key));

            if (autofillPref != null)
            {
                autofillPref.PreferenceClick += (sender, args) =>
                {
                    var intent = new Intent(Settings.ActionRequestSetAutofillService);
                    if (((AutofillManager)Activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager))))
                        .HasEnabledAutofillServices)
                    {
                        intent.SetData(Android.Net.Uri.Parse("package:" + Context.PackageName + "notexisting")); //if we use our package name, the activity won't launch
                    }
                    else
                    {
                        intent.SetData(Android.Net.Uri.Parse("package:" + Context.PackageName));
                    }

                    try
                    {
                        Context.StartActivity(intent);
                    }
                    catch (ActivityNotFoundException e)
                    {
                        //this exception was reported by many Huawei users
                        Kp2aLog.LogUnexpectedError(e);
                        new AlertDialog.Builder(Context)
                        .SetTitle(Resource.String.autofill_enable)
                        .SetMessage(Resource.String.autofill_enable_failed)
                        .SetPositiveButton(Resource.String.ok, (o, eventArgs) => { })
                        .Show();
                    }
                    catch (Exception e)
                    {
                        Kp2aLog.LogUnexpectedError(e);
                    }
                };
            }


            PrepareNoDonatePreference(Activity, FindPreference(GetString(Resource.String.NoDonateOption_key)));
            PrepareNoDonationReminderPreference(Activity, ((PreferenceScreen)FindPreference(GetString(Resource.String.display_prefs_key))), FindPreference(GetString(Resource.String.NoDonationReminder_key)));

            FindPreference(GetString(Resource.String.design_key)).PreferenceChange += (sender, args) => Activity.Recreate();

            Database db = App.Kp2a.CurrentDb;

            if (db != null)
            {
                ListPreference kdfPref = (ListPreference)FindPreference(GetString(Resource.String.kdf_key));
                kdfPref.SetEntries(KdfPool.Engines.Select(eng => eng.Name).ToArray());
                string[] kdfValues = KdfPool.Engines.Select(eng => eng.Uuid.ToHexString()).ToArray();
                kdfPref.SetEntryValues(kdfValues);
                kdfPref.SetValueIndex(kdfValues.Select((v, i) => new { kdf = v, index = i }).First(el => el.kdf == db.KpDatabase.KdfParameters.KdfUuid.ToHexString()).index);
                kdfPref.PreferenceChange += OnKdfChange;

                aesRounds         = FindPreference(GetString(Resource.String.rounds_key));
                argon2rounds      = FindPreference("argon2rounds");
                argon2memory      = FindPreference("argon2memory");
                argon2parallelism = FindPreference("argon2parallelism");

                aesRounds.PreferenceChange         += (sender, e) => UpdateKdfSummary(e.Preference);
                argon2rounds.PreferenceChange      += (sender, e) => UpdateKdfSummary(e.Preference);
                argon2memory.PreferenceChange      += (sender, e) => UpdateKdfSummary(e.Preference);
                argon2parallelism.PreferenceChange += (sender, e) => UpdateKdfSummary(e.Preference);

                UpdateKdfScreen();

                PrepareDefaultUsername(db);
                PrepareDatabaseName(db);
                PrepareMasterPassword();
                PrepareTemplates(db);

                ListPreference algorithmPref = (ListPreference)FindPreference(GetString(Resource.String.algorithm_key));
                algorithmPref.SetEntries(CipherPool.GlobalPool.Engines.Select(eng => eng.DisplayName).ToArray());
                string[] algoValues = CipherPool.GlobalPool.Engines.Select(eng => eng.CipherUuid.ToHexString()).ToArray();
                algorithmPref.SetEntryValues(algoValues);
                algorithmPref.SetValueIndex(algoValues.Select((v, i) => new { kdf = v, index = i }).First(el => el.kdf == db.KpDatabase.DataCipherUuid.ToHexString()).index);
                algorithmPref.PreferenceChange += AlgorithmPrefChange;
                algorithmPref.Summary           =
                    CipherPool.GlobalPool.GetCipher(App.Kp2a.CurrentDb.KpDatabase.DataCipherUuid).DisplayName;
                UpdateImportDbPref();
                UpdateImportKeyfilePref();
            }

            try
            {
                //depending on Android version, we offer to use a transparent icon for QuickUnlock or use the notification priority (since API level 16)
                Preference hideQuickUnlockTranspIconPref = FindPreference(GetString(Resource.String.QuickUnlockIconHidden_key));
                Preference hideQuickUnlockIconPref       = FindPreference(GetString(Resource.String.QuickUnlockIconHidden16_key));
                var        quickUnlockScreen             = ((PreferenceScreen)FindPreference(GetString(Resource.String.QuickUnlock_prefs_key)));
                if ((int)Android.OS.Build.VERSION.SdkInt >= 26)
                {
                    //use notification channels
                    quickUnlockScreen.RemovePreference(hideQuickUnlockTranspIconPref);
                    quickUnlockScreen.RemovePreference(hideQuickUnlockIconPref);
                }
                else if ((int)Android.OS.Build.VERSION.SdkInt >= 16)
                {
                    quickUnlockScreen.RemovePreference(hideQuickUnlockTranspIconPref);
                    unlockedNotificationPref.PreferenceChange += (sender, args) => App.Kp2a.UpdateOngoingNotification();
                    hideQuickUnlockIconPref.PreferenceChange  += delegate { App.Kp2a.UpdateOngoingNotification(); };
                }
                else
                {
                    //old version: only show transparent quickUnlock and no option to hide unlocked icon:
                    quickUnlockScreen.RemovePreference(hideQuickUnlockIconPref);
                    FindPreference(GetString(Resource.String.QuickUnlockIconHidden_key)).PreferenceChange +=
                        delegate { App.Kp2a.UpdateOngoingNotification(); };

                    ((PreferenceScreen)FindPreference(GetString(Resource.String.display_prefs_key))).RemovePreference(
                        unlockedNotificationPref);
                }
            }
            catch (Exception ex)
            {
                Kp2aLog.LogUnexpectedError(ex);
            }



            //AppSettingsActivity.PrepareKeyboardSwitchingPreferences(this);
            _switchPrefManager = new KeyboardSwitchPrefManager(this);
            PrepareSeparateNotificationsPreference();

            FindPreference("IconSetKey").PreferenceChange += (sender, args) =>
            {
                if (App.Kp2a.CurrentDb != null)
                {
                    App.Kp2a.CurrentDb.DrawableFactory.Clear();
                }
            };

            Preference cachingPreference = FindPreference(GetString(Resource.String.UseOfflineCache_key));

            cachingPreference.PreferenceChange += OnUseOfflineCacheChanged;
        }