Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        private void UpdateAutofillPref()
        {
            var autofillScreen            = FindPreference(GetString(Resource.String.AutoFill_prefs_screen_key));
            var autofillPref              = FindPreference(GetString(Resource.String.AutoFill_prefs_key));
            var autofillDisabledPref      = FindPreference(GetString(Resource.String.AutofillDisabledQueriesPreference_key));
            var autofillSavePref          = FindPreference(GetString(Resource.String.OfferSaveCredentials_key));
            var autofillInlineSuggestions = FindPreference(GetString(Resource.String.InlineSuggestions_key));
            var noAutofillDisablingPref   = FindPreference(GetString(Resource.String.NoAutofillDisabling_key));
            var autofillNoDalVerification = FindPreference(GetString(Resource.String.NoDalVerification_key));

            if (autofillPref == null)
            {
                return;
            }
            if ((Android.OS.Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.O) ||
                !((AutofillManager)Activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager))))
                .IsAutofillSupported)
            {
                var passwordAccessScreen =
                    (PreferenceScreen)FindPreference(Activity.GetString(Resource.String.password_access_prefs_key));
                passwordAccessScreen.RemovePreference(autofillScreen);
            }
            else
            {
                if (((AutofillManager)Activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager))))
                    .HasEnabledAutofillServices)
                {
                    autofillDisabledPref.Enabled      = true;
                    autofillSavePref.Enabled          = true;
                    autofillNoDalVerification.Enabled = true;
                    autofillInlineSuggestions.Enabled = true;
                    noAutofillDisablingPref.Enabled   = true;
                    autofillPref.Summary = Activity.GetString(Resource.String.plugin_enabled);
                    autofillPref.Intent  = new Intent(Intent.ActionView);
                    autofillPref.Intent.SetData(Android.Net.Uri.Parse("https://philippc.github.io/keepass2android/OreoAutoFill.html"));
                }
                else
                {
                    autofillNoDalVerification.Enabled = false;
                    autofillDisabledPref.Enabled      = false;
                    autofillSavePref.Enabled          = false;
                    noAutofillDisablingPref.Enabled   = false;
                    autofillInlineSuggestions.Enabled = false;
                    autofillPref.Summary = Activity.GetString(Resource.String.not_enabled);
                }
                if ((int)Android.OS.Build.VERSION.SdkInt < 30)
                {
                    autofillInlineSuggestions.Summary = Activity.GetString(Resource.String.requires_android11);
                    CheckBoxPreference cbp = autofillInlineSuggestions as CheckBoxPreference;
                    if (cbp != null)
                    {
                        cbp.Checked = false;
                    }
                    autofillInlineSuggestions.Enabled = false;
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Settings.Instance.Load();

            // Create your application here
            AddPreferencesFromResource(Resource.Layout.Settings);

            prefBlacklist = FindPreference("pref_blacklist");
            prefReorder   = FindPreference("pref_reorder");

            prefDisableHomeDetect = (CheckBoxPreference)FindPreference("pref_disablecheck");
            prefWallpaperUrl      = (EditTextPreference)FindPreference("pref_WallpaperUrl");

            prefBlacklist.PreferenceClick += delegate {
                StartActivity(typeof(SettingsAppShowHideActivity));
            };
            prefReorder.PreferenceClick += delegate {
                StartActivity(typeof(ReorderActivity));
            };

            // Start the intent service, it will decide to stop itself or not
            prefDisableHomeDetect.PreferenceChange += (sender, e) =>
                                                      StartService(new Intent(this, typeof(ExcuseMeService)));

            prefWallpaperUrl.PreferenceChange += (sender, e) => {
                AndHUD.Shared.Show(this, "Downloading Wallpaper...");

                var url = prefWallpaperUrl.EditText.Text;

                if (url.IndexOf("http://") == -1)
                {
                    url = string.Concat("http://", url);
                }

                Task.Run(() => {
                    try {
                        var http     = new System.Net.WebClient();
                        var bytes    = http.DownloadData(url);
                        var filename = Settings.GetWallpaperPath();
                        System.IO.File.WriteAllBytes(filename, bytes);
                    } catch (Exception ex) {
                        Settings.Instance.WallpaperUrl = string.Empty;
                        //Toast.MakeText (this, "Failed to Download Wallpaper", ToastLength.Long).Show ();
                        Log.Error("Downloading Wallpaper Failed", ex);
                    }

                    AndHUD.Shared.Dismiss(this);
                });
            };
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            AddPreferencesFromResource(Resource.Layout.Settings);

            prefBlacklist          = FindPreference("pref_blacklist");
            prefReorder            = FindPreference("pref_reorder");
            prefHideLabels         = (CheckBoxPreference)FindPreference("pref_hidelabels");
            prefAppNameFontSize    = (EditTextPreference)FindPreference("pref_applabelfontsize");
            prefHideLogo           = (CheckBoxPreference)FindPreference("pref_hidelogo");
            prefHideDividerLine    = (CheckBoxPreference)FindPreference("pref_hidedivider");
            prefHideDate           = (CheckBoxPreference)FindPreference("pref_hidedate");
            prefHideTime           = (CheckBoxPreference)FindPreference("pref_hidetime");
            prefTwentyFourHourTime = (CheckBoxPreference)FindPreference("pref_twentyfourhourtime");
            prefDisableHomeDetect  = (CheckBoxPreference)FindPreference("pref_disablecheck");

            prefAppNameFontSize.EditText.InputType = Android.Text.InputTypes.ClassNumber;

            prefBlacklist.PreferenceClick += delegate {
                StartActivity(typeof(SettingsAppShowHideActivity));
            };
            prefReorder.PreferenceClick += delegate {
                StartActivity(typeof(ReorderActivity));
//
//				AlertDialog dlg = null;
//				var bld = new AlertDialog.Builder(this);
//
//				bld.SetTitle ("Re-Order Apps");
//				bld.SetMessage ("To re-order apps on the home screen, select the app you want to re-order, then long click the item.  This will put the app into re-order mode.  You can now move the app around until you are happy with its position, and select the item again once to exit re-order mode");
//				bld.SetNegativeButton("OK", delegate {
//					dlg.Dismiss();
//				});
//
//				dlg = bld.Create();
//				dlg.Show();
            };

            prefAppNameFontSize.PreferenceChange    += SaveHandler;
            prefHideLabels.PreferenceChange         += SaveHandler;
            prefHideLogo.PreferenceChange           += SaveHandler;
            prefHideDividerLine.PreferenceChange    += SaveHandler;
            prefHideDate.PreferenceChange           += SaveHandler;
            prefHideTime.PreferenceChange           += SaveHandler;
            prefTwentyFourHourTime.PreferenceChange += SaveHandler;
            prefDisableHomeDetect.PreferenceChange  += SaveHandler;
        }
 //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;
         }
     }
 }
Ejemplo n.º 6
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;
        }
        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 KeyboardSwitchPrefManager(PreferenceFragment fragment)
            {
                var act = fragment.Activity;

                this._act      = act;
                this._fragment = fragment;
                this._screen   = (PreferenceScreen)_fragment.FindPreference(act.GetString(Resource.String.keyboardswitch_prefs_key));

                var keyboardSwapPref = _fragment.FindPreference("get_keyboardswap");
                var pm    = act.PackageManager;
                var intnt = Keepass2android.Kbbridge.ImeSwitcher.GetLaunchIntentForKeyboardSwap(act);

                if ((intnt != null) && pm.QueryIntentActivities(intnt, 0).Any())
                {
                    _screen.RemovePreference(keyboardSwapPref);
                }
                else
                {
                    keyboardSwapPref.PreferenceClick += (sender, args) =>
                    {
                        Util.GotoUrl(act, act.GetString(Resource.String.MarketURL) + "keepass2android.plugin.keyboardswap2");
                    };
                }

                _switchPref       = (CheckBoxPreference)_fragment.FindPreference("kp2a_switch_rooted");
                _openKp2aAutoPref =
                    (CheckBoxPreference)_fragment.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomatically_key));
                _openOnlyOnSearchPref =
                    (CheckBoxPreference)
                    _fragment.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key));
                _switchBackPref =
                    (CheckBoxPreference)_fragment.FindPreference(act.GetString(Resource.String.AutoSwitchBackKeyboard_key));

                EnableSwitchPreferences(_switchPref.Checked);

                _switchPref.PreferenceChange += (sender, args) =>
                {
                    bool switchOnRooted = (bool)args.NewValue;
                    EnableSwitchPreferences(switchOnRooted);
                };
            }
        public object SelectTemplate(object itemObj, object container)
        {
            var item = (PreferenceModel)itemObj;

            if (item == null)
            {
                return(null);
            }
            var        preference = (Preference)container;
            Preference result;

            using (var set = new BindingSet <PreferenceModel>())
            {
                if (item.IsCheckbox)
                {
                    var checkBoxPref = new CheckBoxPreference(preference.Context)
                    {
                        Key = item.Key
                    };
                    result = checkBoxPref;
                    set.Bind(checkBoxPref, () => p => p.Checked)
                    .To(() => (m, ctx) => m.Value)
                    .TwoWay();
                }
                else
                {
                    var editTextPref = new EditTextPreference(preference.Context)
                    {
                        Key = item.Key
                    };
                    result = editTextPref;
                    set.Bind(editTextPref, () => p => p.Text)
                    .To(() => (m, ctx) => m.Value)
                    .TwoWay();
                    set.Bind(editTextPref, () => p => p.Summary)
                    .ToSelf(() => (m, ctx) => m.Text);
                }
                set.Bind(result, () => p => p.Title).To(() => (m, ctx) => m.Title);
            }
            return(result);
        }
Ejemplo n.º 10
0
        private void PopulateAvailableWidgetsList()
        {
            var availableWidgetsCategory = (PreferenceScreen)FindPreference("GlobalSettings.AvailableWidgets");

            foreach (var widgetModel in SmeedeeApp.Instance.AvailableWidgets)
            {
                if (widgetModel.Type == typeof(StartPageWidget))
                {
                    continue;
                }

                var checkBox = new CheckBoxPreference(this)
                {
                    Checked = widgetModel.Enabled,
                    Title   = widgetModel.Name,
                    Summary = widgetModel.StaticDescription,
                    Key     = widgetModel.Name,
                };
                availableWidgetsCategory.AddPreference(checkBox);
            }
        }
        private void InitComponent()
        {
            try
            {
                MainSettings.SharedData = PreferenceManager.SharedPreferences;
                PreferenceManager.SharedPreferences.RegisterOnSharedPreferenceChangeListener(this);

                NotifcationPopupPref     = (SwitchPreferenceCompat)FindPreference("notifications_key");
                NotifcationPlaySoundPref = (CheckBoxPreference)FindPreference("checkBox_PlaySound_key");
                ChatHeadsPref            = (SwitchPreferenceCompat)FindPreference("chatheads_key");

                //Update Preferences data on Load
                OnSharedPreferenceChanged(MainSettings.SharedData, "notifications_key");

                NotifcationPopupPref.IconSpaceReserved = false;
                ChatHeadsPref.IconSpaceReserved        = false;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
            public KeyboardSwitchPrefManager(PreferenceFragment fragment)
            {
                var act = fragment.Activity;

                this._act      = act;
                this._fragment = fragment;

                _switchPref       = (CheckBoxPreference)_fragment.FindPreference("kp2a_switch_rooted");
                _openKp2aAutoPref =
                    (CheckBoxPreference)_fragment.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomatically_key));
                _openOnlyOnSearchPref =
                    (CheckBoxPreference)
                    _fragment.FindPreference(act.GetString(Resource.String.OpenKp2aKeyboardAutomaticallyOnlyAfterSearch_key));
                _switchBackPref =
                    (CheckBoxPreference)_fragment.FindPreference(act.GetString(Resource.String.AutoSwitchBackKeyboard_key));
                _screen = (PreferenceScreen)_fragment.FindPreference(act.GetString(Resource.String.keyboardswitch_prefs_key));
                EnableSwitchPreferences(_switchPref.Checked);

                _switchPref.PreferenceChange += (sender, args) =>
                {
                    bool switchOnRooted = (bool)args.NewValue;
                    EnableSwitchPreferences(switchOnRooted);
                };
            }
        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);
            }
        }
    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;
        }
    }
    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;
    }
Ejemplo n.º 16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            AddPreferencesFromResource(Resource.Xml.settings);

            ListPreference listPreference = (ListPreference)FindPreference(PreferenceTypes.K_ROUTE_TYPE);

            listPreference.PreferenceChange += (s, e) =>
            {
                listPreference.Value = e.NewValue.ToString();
                e.Preference.Summary = listPreference.Entry;
                e.Handled            = false;
            };

            ListPreference listDistanceFormat = (ListPreference)FindPreference(PreferenceTypes.K_DISTANCE_UNIT);

            if (listDistanceFormat.Value == null)
            {
                listDistanceFormat.SetValueIndex(0);
            }

            ListPreference listSpeedWarningsOutTown = (ListPreference)FindPreference(PreferenceTypes.K_OUT_TOWN_SPEED_WARNING);
            ListPreference listSpeedWarningsInTown  = (ListPreference)FindPreference(PreferenceTypes.K_IN_TOWN_SPEED_WARNING);

            listDistanceFormat.PreferenceChange += (s, e) =>
            {// Set the value as the new value
                listDistanceFormat.Value = (e.NewValue.ToString());
                // Get the entry which corresponds to the current value and set as summary
                e.Preference.Summary = (listDistanceFormat.Entry);
                if (e.Preference.Summary.Equals("Miles/Feet") || e.Preference.Summary.Equals("Miles/Yards"))
                {
                    listSpeedWarningsInTown.SetEntries(new string[] { "5mi/h", "10mi/h", "15mi/h", "20mi/h", "25mi/h" });
                    listSpeedWarningsInTown.SetEntryValues(new string[] { "0", "1", "2", "3", "4" });
                    listSpeedWarningsOutTown.SetEntries(new string[] { "5mi/h", "10mi/h", "15mi/h", "20mi/h", "25mi/h" });
                    listSpeedWarningsOutTown.SetEntryValues(new string[] { "0", "1", "2", "3", "4" });
                }
                else if (e.Preference.Summary.Equals("Kilometers/Meters"))
                {
                    listSpeedWarningsInTown.SetEntries(new string[] { "5km/h", "10km/h", "15km/h", "20km/h", "25km/h" });
                    listSpeedWarningsInTown.SetEntryValues(new string[] { "0", "1", "2", "3", "4" });
                    listSpeedWarningsOutTown.SetEntries(new string[] { "5km/h", "10km/h", "15km/h", "20km/h", "25km/h" });
                    listSpeedWarningsOutTown.SetEntryValues(new string[] { "0", "1", "2", "3", "4" });
                }

                e.Handled = false;
            };

            ListPreference listNavigationType = (ListPreference)FindPreference(PreferenceTypes.K_NAVIGATION_TYPE);

            if (listNavigationType.Value == null)
            {
                listNavigationType.SetValueIndex(1);
            }

            listNavigationType.PreferenceChange += (s, e) =>
            {// Set the value as the new value
                listNavigationType.Value = e.NewValue.ToString();
                // Get the entry which corresponds to the current value and set as summary
                e.Preference.Summary = listNavigationType.Entry;
                e.Handled            = false;
            };


            if (listDistanceFormat.Summary.Equals("Kilometers/Meters"))
            {
                listSpeedWarningsInTown.SetEntries(new string[] { "5km/h", "10km/h", "15km/h", "20km/h", "25km/h" });
                listSpeedWarningsInTown.SetEntryValues(new string[] { "0", "1", "2", "3", "4" });
            }
            else
            {
                listSpeedWarningsInTown.SetEntries(new string[] { "5mi/h", "10mi/h", "15mi/h", "20mi/h", "25mi/h" });
                listSpeedWarningsInTown.SetEntryValues(new string[] { "0", "1", "2", "3", "4" });
            }
            if (listSpeedWarningsInTown.Value == null)
            {
                listSpeedWarningsInTown.SetValueIndex(3);
            }

            listSpeedWarningsInTown.PreferenceChange += (s, e) =>
            {// Set the value as the new value
                listSpeedWarningsInTown.Value = e.NewValue.ToString();
                // Get the entry which corresponds to the current value and set as summary
                e.Preference.Summary = listSpeedWarningsInTown.Entry;
                e.Handled            = false;
            };

            if (listDistanceFormat.Summary.Equals("Kilometers/Meters"))
            {
                listSpeedWarningsOutTown.SetEntries(new string[] { "5km/h", "10km/h", "15km/h", "20km/h", "25km/h" });
                listSpeedWarningsOutTown.SetEntryValues(new string[] { "0", "1", "2", "3", "4" });
            }
            else
            {
                listSpeedWarningsOutTown.SetEntries(new string[] { "5mi/h", "10mi/h", "15mi/h", "20mi/h", "25mi/h" });
                listSpeedWarningsOutTown.SetEntryValues(new string[] { "0", "1", "2", "3", "4" });
            }
            if (listSpeedWarningsOutTown.Value == null)
            {
                listSpeedWarningsOutTown.SetValueIndex(3);
            }

            listSpeedWarningsOutTown.PreferenceChange += (s, e) =>
            {// Set the value as the new value
                listSpeedWarningsOutTown.Value = (e.NewValue.ToString());
                // Get the entry which corresponds to the current value and set as summary
                e.Preference.Summary = listSpeedWarningsOutTown.Entry;
                e.Handled            = false;
            };

            CheckBoxPreference checkBoxDayNight = (CheckBoxPreference)FindPreference(PreferenceTypes.K_AUTO_DAY_NIGHT);

            checkBoxDayNight.PreferenceChange += (s, e) =>
            {
                Log.Debug("MyApp", "Pref " + e.Preference.Key + " changed to " + e.NewValue.ToString());
                e.Handled = true;
            };

            CheckBoxPreference checkBoxTollRoads = (CheckBoxPreference)FindPreference(PreferenceTypes.K_AVOID_TOLL_ROADS);

            checkBoxTollRoads.PreferenceChange += (s, e) =>
            {
                Log.Debug("MyApp", "Pref " + e.Preference.Key + " changed to " + e.NewValue.ToString());
                e.Handled = true;
            };

            CheckBoxPreference checkBoxFerries = (CheckBoxPreference)FindPreference(PreferenceTypes.K_AVOID_FERRIES);

            checkBoxFerries.PreferenceChange += (s, e) => { Log.Debug("MyApp", "Pref " + e.Preference.Key + " changed to " + e.NewValue.ToString()); };

            CheckBoxPreference checkBoxHighways = (CheckBoxPreference)FindPreference(PreferenceTypes.K_AVOID_HIGHWAYS);

            checkBoxHighways.PreferenceChange += (s, e) => { Log.Debug("MyApp", "Pref " + e.Preference.Key + " changed to " + e.NewValue.ToString()); };

            CheckBoxPreference checkBoxFreeDrive = (CheckBoxPreference)FindPreference(PreferenceTypes.K_FREE_DRIVE);

            checkBoxFreeDrive.PreferenceChange += (s, e) => { Log.Debug("MyApp", "Pref " + e.Preference.Key + " changed to " + e.NewValue.ToString()); };
        }