public override void OnBackPressed()
        {
            Stack <Fragment> stack = stacks[(int)App.STATE.CurrentLibrary];

            if (stack.Count > 0)
            {
                if (stack.Count == 1)
                {
                    drawer.SetDrawerLockMode(DrawerLayout.LockModeLockedClosed, nav);
                }
                base.OnBackPressed();
            }
            else
            {
                MaterialDialog         dialog = null;
                MaterialDialog.Builder popup  = new MaterialDialog.Builder(this);
                popup.SetTitle("Exit Application?");
                popup.SetPositiveText("Yes", (o, e) =>
                {
                    base.OnBackPressed();
                });
                popup.SetNegativeText("No");

                dialog = popup.Show();
            }
        }
Beispiel #2
0
        public void ShowFontSizeDialog()
        {
            SeekBar seek = new SeekBar(Activity);

            seek.Max              = 10;
            seek.Progress         = App.STATE.SeekBarTextSize;
            seek.ProgressChanged += (o, e) =>
            {
                int size = App.FUNCTIONS.GetWebViewTextSize(e.Progress);

                SetWebViewTextSize(size);

                // Set font size globally
                App.STATE.SeekBarTextSize = e.Progress;

                // Save font size to preferences
                var prefs = PreferenceManager.GetDefaultSharedPreferences(Activity);
                prefs.Edit().PutInt("WebViewBaseFontSize", e.Progress).Commit();
            };

            MaterialDialog dialog = null;

            MaterialDialog.Builder popup = new MaterialDialog.Builder(Activity);
            popup.SetCustomView(seek, false);
            popup.SetTitle("Text Size");
            popup.SetPositiveText("X");

            dialog = popup.Show();
        }
Beispiel #3
0
        public void ShowCharacterLearningDialog(Context context, LearningCharacter character, WebView webview)
        {
            SQLiteConnection database = new SQLiteConnection(App.LearningCharactersPath);

            database.CreateTable <LearningCharacter>();

            var  table  = database.Table <LearningCharacter>();
            bool exists = table.Any(x => x.Chinese.Equals(character.Chinese) && x.Pinyin.Equals(character.Pinyin));

            string buttonTitle = (exists) ? "REMOVE" : "ADD";

            MaterialDialog.Builder popup = new MaterialDialog.Builder(context);
            popup.SetTitle(character.Chinese + " " + character.Pinyin);
            popup.SetContent(character.English);
            popup.SetPositiveText(buttonTitle, (o, e) =>
            {
                if (!exists)
                {
                    database.Insert(character);
                }
                if (exists)
                {
                    var query = (from c in table
                                 where (c.Chinese.ToLower().Equals(character.Chinese.ToLower()) && c.Pinyin.ToLower().Equals(character.Pinyin.ToLower()))
                                 select c).ToList().FirstOrDefault();

                    database.Delete(query);
                }
                string js = "javascript:ToggleEnglish();";
                webview.LoadUrl(js);
            });

            App.STATE.Activity.RunOnUiThread(() =>
            {
                popup.Show();
            });
        }
 public virtual Builder SetPositiveButton(int textId, IDialogInterfaceOnClickListener listener)
 {
     builder.SetPositiveText(textId);
     positiveDialogListener = listener;
     return(this);
 }