private void UpdateNotification(string key, List <League> filteredLeagues)
        {
            var startsPreference = PreferenceScreen.FindPreference(key) as MultiSelectListPreference;

            startsPreference.SetEntryValues(filteredLeagues.Select(l => l.Id.ToString()).ToArray());
            startsPreference.SetEntries(filteredLeagues.Select(l => l.Name).ToArray());
        }
Esempio n. 2
0
 protected virtual void InitializePreferences(PreferenceScreen preferenceScreen, int preferencesResId)
 {
     preferenceScreen.SetBindingMemberValue(AttachedMembers.Object.Parent, Target);
     SetPreferenceParent(preferenceScreen);
     using (XmlReader reader = preferenceScreen.Context.Resources.GetXml(preferencesResId))
     {
         var document = new XmlDocument();
         document.Load(reader);
         var xDocument = XDocument.Parse(document.InnerXml);
         foreach (var descendant in xDocument.Descendants())
         {
             var bindAttr = descendant
                            .Attributes()
                            .FirstOrDefault(xAttribute => xAttribute.Name.LocalName.Equals("bind", StringComparison.OrdinalIgnoreCase));
             if (bindAttr == null)
             {
                 continue;
             }
             var attribute = descendant.Attribute(XName.Get("key", "http://schemas.android.com/apk/res/android"));
             if (attribute == null)
             {
                 Tracer.Error("Preference {0} must have a key to use it with bindings", descendant);
                 continue;
             }
             var preference = preferenceScreen.FindPreference(attribute.Value);
             BindingServiceProvider.BindingProvider.CreateBindingsFromString(preference, bindAttr.Value);
         }
     }
     SetPreferenceListener();
 }
Esempio n. 3
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var UoW = new UnitOfWork();

            Leagues = UoW.LeagueRepo.GetAllLeague();

            var countriesCategory = PreferenceScreen.FindPreference("countriesCategory") as PreferenceCategory;

            foreach (var country in countries)
            {
                MultiSelectListPreference listPreference = new MultiSelectListPreference(Activity);
                listPreference.Title = Resources.GetString(Resources.GetIdentifier(country.ToLower(), "string", "com.resitomi.floorball"));
                listPreference.Key   = country.ToLower();

                var listItems = Leagues.Where(l => l.Country.ToString() == country);
                listPreference.SetEntryValues(listItems.Select(l => l.Id.ToString()).ToArray());
                listPreference.SetEntries(listItems.Select(l => l.Name).ToArray());

                countriesCategory.AddPreference(listPreference);
            }

            var pref = PreferenceManager.GetDefaultSharedPreferences(Activity);
        }
Esempio n. 4
0
        public bool OnPreferenceStartScreen(PreferenceFragmentCompat caller, PreferenceScreen pref)
        {
            var ft = SupportFragmentManager.BeginTransaction();

            PreferenceFragmentCompat fragment;

            if (pref.Key == "leaguesSettings")
            {
                fragment = ChooseLeaguesSettingsFragment.Instance(Leagues);
            }
            else
            {
                fragment = ChooseNotificationsSettingsFragment.Instance();
            }

            Bundle args = new Bundle();

            args.PutString(PreferenceFragmentCompat.ArgPreferenceRoot, pref.Key);
            fragment.Arguments = args;
            ft.Replace(Resource.Id.content_frame, fragment, pref.Key).AddToBackStack(null).Commit();

            SetDrawerState(false);

            return(true);
        }
        public override bool OnPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
        {
            Type cls = null;
            var title = preference.Title;

			if (title.Equals(GetString(Resource.String.left_and_right)))
				cls = typeof(LeftAndRightActivity);

//            if (title.Equals(GetString(Resource.String.properties)))
//                cls = typeof(PropertiesActivity);
//            else if (title.Equals(GetString(Resource.String.attach)))
//                cls = typeof(AttachExample);
//            else if (title.Equals(GetString(Resource.String.changing_fragments)))
//                cls = typeof(FragmentChangeActivity);
//            else if (title.Equals(GetString(Resource.String.left_and_right)))
//                cls = typeof(LeftAndRightActivity);
//            else if (title.Equals(GetString(Resource.String.responsive_ui)))
//                cls = typeof(ResponsiveUIActivity);
//            else if (title.Equals(GetString(Resource.String.viewpager)))
//                cls = typeof(ViewPagerActivity);
//            else if (title.Equals(GetString(Resource.String.title_bar_slide)))
//                cls = typeof(SlidingTitleBar);
//            else if (title.Equals(GetString(Resource.String.title_bar_content)))
//                cls = typeof(SlidingContent);
//            else if (title.Equals(GetString(Resource.String.anim_zoom)))
//                cls = typeof(ZoomAnimation);
//            else if (title.Equals(GetString(Resource.String.anim_scale)))
//                cls = typeof(ScaleAnimation);
//            else if (title.Equals(GetString(Resource.String.anim_slide)))
//                cls = typeof(SlideAnimation);

            var intent = new Intent(this, cls);
            StartActivity(intent);
            return true;
        }
Esempio n. 6
0
        public override bool OnPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
        {
            if (preference.Key == "dropbox_login")
            {
                OnDropboxLoginLogout();
            }
            else if (preference.Key == "cloud_resume_playback_enabled")
            {

            }
            else if (preference.Key == "cloud_sync_playlists")
            {
                
            }
            else if (preference.Key == "cloud_sync_presets")
            {
                
            }
            else if (preference.Key == "cloud_sync_wifi_only")
            {
                
            }

            return base.OnPreferenceTreeClick(preferenceScreen, preference);
        }
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);

            MRequestFocus = delegate {
                mList.FocusableViewAvailable(mList);
            };

            mHandler = new MyPreferenceFragmentHandler(this);

            if (mHavePrefs)
            {
                BindPreferences();
            }

            mInitDone = true;

            if (savedInstanceState != null)
            {
                Bundle container = savedInstanceState.GetBundle(PREFERENCES_TAG);
                if (container != null)
                {
                    PreferenceScreen preferenceScreen = PreferenceScreen;
                    if (preferenceScreen != null)
                    {
                        preferenceScreen.RestoreHierarchyState(container);
                    }
                }
            }
        }
 /**
  * {@inheritDoc}
  */
 public bool OnPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
 {
     if (Activity is IOnPreferenceStartFragmentCallback)
     {
         return(((IOnPreferenceStartFragmentCallback)Activity).OnPreferenceStartFragment(this, preference));
     }
     return(false);
 }
Esempio n. 9
0
        public override void OnNavigateToScreen(PreferenceScreen preferenceScreen)
        {
            base.OnNavigateToScreen(preferenceScreen);

            Activity.SupportFragmentManager.BeginTransaction()
            .AddToBackStack(null)
            .Replace(Resource.Id.content_frame, Instantiate(preferenceScreen.Key))
            .Commit();
        }
        private void PrepareNoDonationReminderPreference(Activity ctx, PreferenceScreen screen, Preference preference)
        {
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(ctx);

            if (!prefs.GetBoolean("DismissedDonateReminder", false))
            {
                screen.RemovePreference(preference);
            }
        }
Esempio n. 11
0
        public void SignedIn()
        {
            AccountPreference accountPreference = (AccountPreference)PreferenceScreen.FindPreference("account");

            accountPreference.Title   = "Logged in as:";
            accountPreference.Summary = MainActivity.account.DisplayName;
            accountPreference.OnSignedIn();
            MainActivity.instance.InvalidateOptionsMenu();
        }
 /// <summary>
 /// {@inheritDoc}
 /// </summary>
 public virtual bool OnPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
 {
     //if (preference.getFragment() != null &&
     if (Activity is IOnPreferenceStartFragmentCallback)
     {
         return(((IOnPreferenceStartFragmentCallback)Activity).OnPreferenceStartFragment(this, preference));
     }
     return(false);
 }
Esempio n. 13
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     AddPreferencesFromResource(Resource.Xml.preferences);
     PreferenceManager.SetDefaultValues(this, Resource.Xml.preferences, false);
     for (int i = 0; i < PreferenceScreen.PreferenceCount; i++)
     {
         InitSummary(PreferenceScreen.GetPreference(i));
     }
 }
Esempio n. 14
0
        public override bool OnPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
        {
            Type cls   = null;
            var  title = preference.Title;

            if (title.Equals(GetString(Resource.String.properties)))
            {
                cls = typeof(PropertiesActivity);
            }
            else if (title.Equals(GetString(Resource.String.attach)))
            {
                cls = typeof(AttachExample);
            }
            else if (title.Equals(GetString(Resource.String.changing_fragments)))
            {
                cls = typeof(FragmentChangeActivity);
            }
            else if (title.Equals(GetString(Resource.String.left_and_right)))
            {
                cls = typeof(LeftAndRightActivity);
            }
            else if (title.Equals(GetString(Resource.String.responsive_ui)))
            {
                cls = typeof(ResponsiveUIActivity);
            }
            else if (title.Equals(GetString(Resource.String.viewpager)))
            {
                cls = typeof(ViewPagerActivity);
            }
            else if (title.Equals(GetString(Resource.String.title_bar_slide)))
            {
                cls = typeof(SlidingTitleBar);
            }
            else if (title.Equals(GetString(Resource.String.title_bar_content)))
            {
                cls = typeof(SlidingContent);
            }
            else if (title.Equals(GetString(Resource.String.anim_zoom)))
            {
                cls = typeof(ZoomAnimation);
            }
            else if (title.Equals(GetString(Resource.String.anim_scale)))
            {
                cls = typeof(ScaleAnimation);
            }
            else if (title.Equals(GetString(Resource.String.anim_slide)))
            {
                cls = typeof(SlideAnimation);
            }

            var intent = new Intent(this, cls);

            StartActivity(intent);
            return(true);
        }
Esempio n. 15
0
        public bool OnPreferenceStartScreen(PreferenceFragmentCompat caller, PreferenceScreen pref)
        {
            var fragment = new SettingsView();
            var args     = new Bundle();

            args.PutString(ArgPreferenceRoot, pref.Key);
            fragment.Arguments = args;
            this.Activity.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.frame_schedule, fragment, pref.Key)
            .AddToBackStack(pref.Key).Commit();
            return(true);
        }
        /**
         * Sets the root of the preference hierarchy that this fragment is showing.
         *
         * @param preferenceScreen The root {@link PreferenceScreen} of the preference hierarchy.
         */

        public void SetPreferenceScreen(PreferenceScreen preferenceScreen)
        {
            if (PreferenceManagerCompat.SetPreferences(mPreferenceManager, preferenceScreen) && preferenceScreen != null)
            {
                mHavePrefs = true;
                if (mInitDone)
                {
                    PostBindPreferences();
                }
            }
        }
Esempio n. 17
0
 /**
  * Sets the root of the preference hierarchy.
  *
  * @param preferenceScreen The root {@link PreferenceScreen} of the preference hierarchy.
  * @return Whether the {@link PreferenceScreen} given is different than the previous.
  */
 public static bool SetPreferences(PreferenceManager manager, PreferenceScreen screen)
 {
     try {
         Class  cl = Java.Lang.Class.FromType(typeof(PreferenceManager));
         Method m  = cl.GetDeclaredMethod("setPreferences", Class.FromType(typeof(PreferenceScreen)));
         m.Accessible = true;
         return((bool)m.Invoke(manager, screen));
     } catch (System.Exception e) {
         Console.WriteLine(TAG + " Couldn't call PreferenceManager.setPreferences by reflection " + e.Message);
     }
     return(false);
 }
Esempio n. 18
0
            protected override void OnAddPreferences(PreferenceScreen preferenceScreen)
            {
                base.OnAddPreferences(preferenceScreen);

                // Add about button
                Preference aboutPreference = new Preference(Context);

                aboutPreference.Title            = "About";
                aboutPreference.Summary          = "App info and credits";
                aboutPreference.PreferenceClick += AboutPreference_PreferenceClick;
                preferenceScreen.AddPreference(aboutPreference);
            }
        public static void InitializePreferences(PreferenceScreen preferenceScreen, int preferencesResId, object parent)
        {
            preferenceScreen.SetBindingMemberValue(AttachedMembers.Object.Parent, parent);
            SetPreferenceParent(preferenceScreen);

            List <KeyValuePair <string, string> > bindings;

            if (!PreferenceBindMapping.TryGetValue(preferencesResId, out bindings))
            {
                bindings = new List <KeyValuePair <string, string> >();
                using (var reader = preferenceScreen.Context.Resources.GetXml(preferencesResId))
                {
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                            string bind = null;
                            for (int attInd = 0; attInd < reader.AttributeCount; attInd++)
                            {
                                reader.MoveToAttribute(attInd);
                                if (reader.Name == "bind")
                                {
                                    bind = reader.Value;
                                    break;
                                }
                            }
                            reader.MoveToElement();
                            var key = reader.GetAttribute("key", "http://schemas.android.com/apk/res/android");
                            if (string.IsNullOrEmpty(bind))
                            {
                                break;
                            }
                            if (string.IsNullOrEmpty(key))
                            {
                                Tracer.Error("Preference {0} must have a key to use it with bindings", reader.Name);
                                break;
                            }
                            bindings.Add(new KeyValuePair <string, string>(key, bind));
                            break;
                        }
                    }
                }
                PreferenceBindMapping[preferencesResId] = bindings;
            }

            foreach (var map in bindings)
            {
                var preference = preferenceScreen.FindPreference(map.Key);
                BindingServiceProvider.BindingProvider.CreateBindingsFromString(preference, map.Value);
            }
        }
Esempio n. 20
0
 /**
  * Inflates a preference hierarchy from the preference hierarchies of
  * {@link Activity Activities} that match the given {@link Intent}. An
  * {@link Activity} defines its preference hierarchy with meta-data using
  * the {@link #METADATA_KEY_PREFERENCES} key.
  * <p>
  * If a preference hierarchy is given, the new preference hierarchies will
  * be merged in.
  *
  * @param queryIntent The intent to match activities.
  * @param rootPreferences Optional existing hierarchy to merge the new
  *            hierarchies into.
  * @return The root hierarchy (if one was not provided, the new hierarchy's
  *         root).
  */
 public static PreferenceScreen InflateFromIntent(PreferenceManager manager, Intent intent, PreferenceScreen screen)
 {
     try {
         Class  cl = Java.Lang.Class.FromType(typeof(PreferenceManager));
         Method m  = cl.GetDeclaredMethod("inflateFromIntent", Class.FromType(typeof(Intent)), Class.FromType(typeof(PreferenceScreen)));
         m.Accessible = true;
         PreferenceScreen prefScreen = (PreferenceScreen)m.Invoke(manager, intent, screen);
         return(prefScreen);
     } catch (System.Exception e) {
         Console.WriteLine(TAG + " Couldn't call PreferenceManager.inflateFromIntent by reflection " + e.Message);
     }
     return(null);
 }
Esempio n. 21
0
 /**
  * Inflates a preference hierarchy from XML. If a preference hierarchy is
  * given, the new preference hierarchies will be merged in.
  *
  * @param context The context of the resource.
  * @param resId The resource ID of the XML to inflate.
  * @param rootPreferences Optional existing hierarchy to merge the new
  *            hierarchies into.
  * @return The root hierarchy (if one was not provided, the new hierarchy's
  *         root).
  * @hide
  */
 public static PreferenceScreen InflateFromResource(PreferenceManager manager, Activity activity, int resId, PreferenceScreen screen)
 {
     try {
         Class  cl = Java.Lang.Class.FromType(typeof(PreferenceManager));
         Method m  = cl.GetDeclaredMethod("inflateFromResource", Class.FromType(typeof(Context)), Java.Lang.Integer.Type, Class.FromType(typeof(PreferenceScreen)));
         m.Accessible = true;
         PreferenceScreen prefScreen = (PreferenceScreen)m.Invoke(manager, activity, resId, screen);
         return(prefScreen);
     } catch (System.Exception e) {
         Console.WriteLine(TAG + " Couldn't call PreferenceManager.inflateFromResource by reflection " + e.Message);
     }
     return(null);
 }
        public override void OnSaveInstanceState(Bundle outState)
        {
            base.OnSaveInstanceState(outState);

            PreferenceScreen preferenceScreen = PreferenceScreen;

            if (preferenceScreen != null)
            {
                Bundle container = new Bundle();
                preferenceScreen.SaveHierarchyState(container);
                outState.PutBundle(PREFERENCES_TAG, container);
            }
        }
        private void TogglePreferences()
        {
            var isTeacher = AndroidDependencyContainer.Instance.ScheduleSettings.IsUserTeacher;

            if (isTeacher)
            {
                PreferenceScreen.RemovePreference(groupNumberPreference);
                PreferenceScreen.AddPreference(teacherNamePreference);
            }
            else
            {
                PreferenceScreen.RemovePreference(teacherNamePreference);
                PreferenceScreen.AddPreference(groupNumberPreference);
            }
        }
        private void BindPreferences()
        {
            PreferenceScreen preferenceScreen = PreferenceScreen;

            if (preferenceScreen != null)
            {
                preferenceScreen.Bind(GetListView());
            }

            if (Build.VERSION.SdkInt <= BuildVersionCodes.GingerbreadMr1)
            {
                // Workaround android bug for SDK 10 and below - see
                // https://github.com/android/platform_frameworks_base/commit/2d43d283fc0f22b08f43c6db4da71031168e7f59
                GetListView().ItemClick += (sender, e) =>
                {
                    int position = e.Position;

                    // If the list has headers, subtract them from the index.
                    if (e.Parent is ListView)
                    {
                        position -= ((ListView)e.Parent).HeaderViewsCount;
                    }

                    Java.Lang.Object item = preferenceScreen.RootAdapter.GetItem(position);
                    if (!(item is Preference))
                    {
                        return;
                    }

                    Preference preference = (Preference)item;
                    try
                    {
                        Method performClick = Java.Lang.Class.FromType(typeof(Preference)).GetDeclaredMethod("performClick", Java.Lang.Class.FromType(typeof(PreferenceScreen)));
                        performClick.Accessible = true;
                        performClick.Invoke(preference, preferenceScreen);
                    }
                    catch (InvocationTargetException ex)
                    {
                    }
                    catch (IllegalAccessException ex)
                    {
                    }
                    catch (NoSuchMethodException ex)
                    {
                    }
                };
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            AddPreferencesFromResource(Resource.Menu.settings);
            var pref = (EditTextPreference)PreferenceScreen.FindPreference("prefIPAddress");

            pref.PreferenceChange += (obj, args) =>
            {
                bool result = true;
                System.Net.IPAddress address;

                if ((string)args.NewValue != String.Empty && !System.Net.IPAddress.TryParse((string)args.NewValue, out address))
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(ApplicationContext);
                    builder.SetTitle("Invalid IP Address");
                    builder.SetMessage("The entered IP address was not valid");
                    builder.SetPositiveButton("OK", (o, e) => { });
                    builder.Show();
                    result = false;
                }

                args.Handled = result;
            };

            pref = (EditTextPreference)PreferenceScreen.FindPreference("prefPort");

            pref.PreferenceChange += (obj, args) =>
            {
                bool   result = true;
                ushort port;

                if ((string)args.NewValue != String.Empty && !ushort.TryParse((string)args.NewValue, out port))
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(ApplicationContext);
                    builder.SetTitle("Invalid Port");
                    builder.SetMessage("The entered port was not valid");
                    builder.SetPositiveButton("OK", (o, e) => { });
                    builder.Show();
                    result = false;
                }

                args.Handled = result;
            };
        }
Esempio n. 26
0
        public override bool OnPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
        {
            System.Diagnostics.Debug.WriteLine("We are in the on preference portion");
            switch (preference.Key)
            {
            case "wifi_preferance":
                SettingsData.WiFiOnly = ((CheckBoxPreference)preference).Checked;
                break;

            case "runawaytimer_preference":
                SettingsData.ForgottenTmrThsMin = int.Parse(((EditTextPreference)preference).Text);
                break;

            case "interrupt_preference":
                SettingsData.MaxContIntTimeMin = int.Parse(((EditTextPreference)preference).Text);
                break;
            }
            return(base.OnPreferenceTreeClick(preferenceScreen, preference));
        }
        public void BindPreferences()
        {
            PreferenceScreen preferenceScreen = PreferenceScreen;

            if (preferenceScreen != null)
            {
                preferenceScreen.Bind(GetListView());
            }

            if (Build.VERSION.SdkInt <= BuildVersionCodes.GingerbreadMr1)
            {
                // Workaround android bug for SDK 10 and below - see
                // https://github.com/android/platform_frameworks_base/commit/2d43d283fc0f22b08f43c6db4da71031168e7f59

                GetListView().ItemClick += (object sender, Android.Widget.AdapterView.ItemClickEventArgs e) => {
                    // If the list has headers, subtract them from the index.
                    int pos = e.Position;
                    if (sender is ListView)
                    {
                        pos -= ((ListView)sender).HeaderViewsCount;
                    }

                    Java.Lang.Object item = PreferenceScreen.RootAdapter.GetItem(pos);
                    if (!(item is Preference))
                    {
                        return;
                    }

                    Preference preference = (Preference)item;
                    try {
                        Method performClick = Class.FromType(typeof(Preference)).Class.GetDeclaredMethod("performClick", Class.FromType(typeof(PreferenceScreen)));
                        performClick.Accessible = true;
                        performClick.Invoke(preference, preferenceScreen);
                    } catch (InvocationTargetException e1) {
                        Console.WriteLine(Tag + " " + e1.Message);
                    } catch (IllegalAccessException e2) {
                        Console.WriteLine(Tag + " " + e2.Message);
                    } catch (NoSuchMethodException e3) {
                        Console.WriteLine(Tag + " " + e3.Message);
                    }
                };
            }
        }
            public override bool OnPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)
            {
                if (preference != null && preference.Intent != null)
                {
                    RemoteIntent.StartRemoteActivity(Activity, preference.Intent
                                                     .SetAction(Intent.ActionView)
                                                     .AddCategory(Intent.CategoryBrowsable),
                                                     null);

                    // Show open on phone animation
                    new Android.Support.Wearable.Views.ConfirmationOverlay()
                    .SetType(Android.Support.Wearable.Views.ConfirmationOverlay.OpenOnPhoneAnimation)
                    .SetMessage(Activity.GetString(Resource.String.message_openedonphone))
                    .ShowAbove(View);

                    return(true);
                }

                return(base.OnPreferenceTreeClick(preferenceScreen, preference));
            }
            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);
                };
            }
        protected override View OnCreateView(ViewGroup parent)
        {
            parent.SetPadding(0, 0, 0, 0);

            LayoutInflater inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
            View           layout   = inflater.Inflate(Resource.Layout.toolbar, parent, false);

            Toolbar toolbar = (Toolbar)layout.FindViewById <Toolbar>(Resource.Id.mytoolbar);

            toolbar.SetNavigationIcon(Resource.Drawable.ic_arrow_back_white_24dp);
            toolbar.Title            = Title;
            toolbar.NavigationClick += (sender, args) =>
            {
                PreferenceScreen prefScreen = (PreferenceScreen)PreferenceManager.FindPreference(Key);
                if (prefScreen == null)
                {
                    throw new Exception("didn't find preference " + Key);
                }
                prefScreen.Dialog.Dismiss();
            };

            return(layout);
        }
Esempio n. 31
0
        public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
        {
            instance = this;
            SetPreferencesFromResource(Resource.Layout.AboutPreferences, rootKey);

            //OpenSource click
            Preference openSource = PreferenceScreen.FindPreference("view_opensource");

            openSource.IconSpaceReserved = false;
            openSource.PreferenceClick  += (s, e) =>
            {
                Preferences.instance.SupportFragmentManager.BeginTransaction().Replace(Android.Resource.Id.ListContainer, new OpenSourceViewer()).AddToBackStack(null).Commit();
            };

            //Website click
            Preference website = PreferenceScreen.FindPreference("website");

            website.IconSpaceReserved = false;
            website.PreferenceClick  += (s, e) =>
            {
                Intent intent = new Intent(Intent.ActionView);
                intent.SetData(Uri.Parse("https://www.raccoon-sdg.fr"));
                StartActivity(intent);
            };

            //Github click
            Preference github = PreferenceScreen.FindPreference("github");

            github.IconSpaceReserved = false;
            github.PreferenceClick  += (s, e) =>
            {
                Intent intent = new Intent(Intent.ActionView);
                intent.SetData(Uri.Parse("https://github.com/AnonymusRaccoon/Opus"));
                StartActivity(intent);
            };
        }
Esempio n. 32
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            AppHelper.UpdateLocale(this);

            if (AppHelper.allCities == null || AppHelper.allCities.Count == 0)
            {
                AppHelper.LoadCities();
            }

            AddPreferencesFromResource(Resource.Layout.PrefLayout);
            prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            city  = PreferenceScreen.FindPreference("city_key");
            temp  = PreferenceScreen.FindPreference("temp_key");
            lang  = PreferenceScreen.FindPreference("lang_key");

            city.Summary = GetString(Resource.String.current_pref) + prefs.GetString("city_key", GetString(Resource.String.default_city));
            temp.Summary = GetString(Resource.String.current_pref) + prefs.GetString("temp_key", GetString(Resource.String.default_temp));
            lang.Summary = GetString(Resource.String.current_pref) + prefs.GetString("lang_key", GetString(Resource.String.default_lang));

            temp.PreferenceChange += TempLang_PreferenceChange;
            lang.PreferenceChange += TempLang_PreferenceChange;
            city.PreferenceClick  += City_PreferenceClick;
        }
		/**
     * Sets the root of the preference hierarchy that this fragment is showing.
     *
     * @param preferenceScreen The root {@link PreferenceScreen} of the preference hierarchy.
     */

		public void SetPreferenceScreen (PreferenceScreen preferenceScreen)
		{
			
			if (PreferenceManagerCompat.SetPreferences (mPreferenceManager, preferenceScreen) && preferenceScreen != null) {
				mHavePrefs = true;
				if (mInitDone) {
					PostBindPreferences ();
				}
			}
		}
		/**
     * {@inheritDoc}
     */
		public bool OnPreferenceTreeClick (PreferenceScreen preferenceScreen, Preference preference)
		{
			if (Activity is IOnPreferenceStartFragmentCallback) {
				return ((IOnPreferenceStartFragmentCallback)Activity).OnPreferenceStartFragment (this, preference);
			}
			return false;
		}
Esempio n. 35
0
            public KeyboardSwitchPrefManager(PreferenceActivity act)
            {
                this._act = act;

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

                _switchPref.PreferenceChange += (sender, args) =>
                {
                    bool switchOnRooted = (bool)args.NewValue;
                    EnableSwitchPreferences(switchOnRooted);
                };
            }
		/**
     * Inflates a preference hierarchy from the preference hierarchies of
     * {@link Activity Activities} that match the given {@link Intent}. An
     * {@link Activity} defines its preference hierarchy with meta-data using
     * the {@link #METADATA_KEY_PREFERENCES} key.
     * <p>
     * If a preference hierarchy is given, the new preference hierarchies will
     * be merged in.
     * 
     * @param queryIntent The intent to match activities.
     * @param rootPreferences Optional existing hierarchy to merge the new
     *            hierarchies into.
     * @return The root hierarchy (if one was not provided, the new hierarchy's
     *         root).
     */
		public	static PreferenceScreen InflateFromIntent (PreferenceManager manager, Intent intent, PreferenceScreen screen)
		{

			try {
				Class cl = Java.Lang.Class.FromType (typeof(PreferenceManager));
				Method m = cl.GetDeclaredMethod ("inflateFromIntent", Class.FromType (typeof(Intent)), Class.FromType (typeof(PreferenceScreen)));
				m.Accessible = true;
				PreferenceScreen prefScreen = (PreferenceScreen)m.Invoke (manager, intent, screen);
				return prefScreen;
			} catch (System.Exception e) {
				Console.WriteLine (TAG + " Couldn't call PreferenceManager.inflateFromIntent by reflection " + e.Message);
			}
			return null;
		}
		/**
     * Inflates a preference hierarchy from XML. If a preference hierarchy is
     * given, the new preference hierarchies will be merged in.
     * 
     * @param context The context of the resource.
     * @param resId The resource ID of the XML to inflate.
     * @param rootPreferences Optional existing hierarchy to merge the new
     *            hierarchies into.
     * @return The root hierarchy (if one was not provided, the new hierarchy's
     *         root).
     * @hide
     */
		public	static PreferenceScreen InflateFromResource (PreferenceManager manager, Activity activity, int resId, PreferenceScreen screen)
		{
			try {
				Class cl = Java.Lang.Class.FromType (typeof(PreferenceManager));
				Method m = cl.GetDeclaredMethod ("inflateFromResource", Class.FromType (typeof(Context)), Java.Lang.Integer.Type, Class.FromType (typeof(PreferenceScreen)));
				m.Accessible = true;
				PreferenceScreen prefScreen = (PreferenceScreen)m.Invoke (manager, activity, resId, screen);
				return prefScreen;
			} catch (System.Exception e) {
				Console.WriteLine (TAG + " Couldn't call PreferenceManager.inflateFromResource by reflection " + e.Message);
			}
			return null;
		}
		/**
     * Sets the root of the preference hierarchy.
     * 
     * @param preferenceScreen The root {@link PreferenceScreen} of the preference hierarchy.
     * @return Whether the {@link PreferenceScreen} given is different than the previous. 
     */
		public	static bool SetPreferences (PreferenceManager manager, PreferenceScreen screen)
		{
			try {
				Class cl = Java.Lang.Class.FromType (typeof(PreferenceManager));
				Method m = cl.GetDeclaredMethod ("setPreferences", Class.FromType (typeof(PreferenceScreen)));
				m.Accessible = true;
				return ((bool)m.Invoke (manager, screen));
			} catch (System.Exception e) {
				Console.WriteLine (TAG + " Couldn't call PreferenceManager.setPreferences by reflection " + e.Message);
			}
			return false;
		}