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(); }
protected override void ShowDialog(Bundle state) { if (GetEntries() == null || GetEntryValues() == null) { throw new IllegalStateException("ListPreference requires an entries array and an entryValues array."); } int preselect = FindIndexOfValue(Value); MaterialDialog.Builder builder = (new MaterialDialog.Builder(context)).SetTitle(DialogTitle).SetContent(DialogMessage).SetIcon(DialogIcon).SetNegativeText(NegativeButtonText).SetItems(GetEntries()).SetAutoDismiss(true).SetItemsCallbackSingleChoice(preselect, new ListCallbackSingleChoiceAnonymousInnerClassHelper(this)); // immediately close the dialog after selection View contentView = OnCreateDialogView(); if (contentView != null) { OnBindDialogView(contentView); builder.SetCustomView(contentView, false); } else { builder.SetContent(DialogMessage); } mDialog = builder.Show(); }
protected override void ShowDialog(Bundle state) { IList <int> indices = new List <int>(); foreach (string s in Values) { int index = FindIndexOfValue(s); if (index >= 0) { indices.Add(FindIndexOfValue(s)); } } MaterialDialog.Builder builder = (new MaterialDialog.Builder(context)).SetTitle(DialogTitle).SetContent(DialogMessage).SetIcon(DialogIcon).SetNegativeText(NegativeButtonText).SetPositiveText(PositiveButtonText).SetItems(GetEntries()).SetItemsCallbackMultiChoice(indices.ToArray(), new ListCallbackMultiChoiceAnonymousInnerClassHelper(this)).SetDismissListener(this); View contentView = OnCreateDialogView(); if (contentView != null) { OnBindDialogView(contentView); builder.SetCustomView(contentView, false); } else { builder.SetContent(DialogMessage); } mDialog = builder.Show(); }
protected override void ShowDialog(Bundle state) { MaterialDialog.Builder builder = new MaterialDialog.Builder(context) .SetTitle(DialogTitle) .SetContent(DialogMessage) .SetIcon(DialogIcon) .SetDismissListener(this) .SetCallback(new ButtonCallback { Neutral = (x) => { OnClick(x, (int)DialogButtonType.Neutral); }, Negative = (x) => { OnClick(x, (int)DialogButtonType.Negative); }, Positive = (x) => { OnClick(x, (int)DialogButtonType.Positive); } }) .SetPositiveText(PositiveButtonText) .SetNegativeText(NegativeButtonText) .SetAutoDismiss(true); View contentView = OnCreateDialogView(); if (contentView != null) { OnBindDialogView(contentView); builder.SetCustomView(contentView, false); } else { builder.SetContent(DialogMessage); } try { PreferenceManager pm = PreferenceManager; Java.Lang.Reflect.Method method = pm.Class.GetDeclaredMethod( "registerOnActivityDestroyListener", Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener))); method.Accessible = true; method.Invoke(pm, this); } catch (Exception) { } mDialog = builder.Build(); if (state != null) { mDialog.OnRestoreInstanceState(state); } mDialog.Show(); }
protected override void ShowDialog(Bundle state) { MaterialDialog.Builder builder = new MaterialDialog.Builder(context) .SetTitle(DialogTitle) .SetContent(DialogMessage) .SetIcon(DialogIcon) .SetDismissListener(this) .SetCallback(new ButtonCallback { Neutral = (x) => { OnClick(x,(int)DialogButtonType.Neutral); }, Negative = (x) => { OnClick(x, (int)DialogButtonType.Negative); }, Positive = (x) => { OnClick(x, (int)DialogButtonType.Positive); } }) .SetPositiveText(PositiveButtonText) .SetNegativeText(NegativeButtonText) .SetAutoDismiss(true); View contentView = OnCreateDialogView(); if (contentView != null) { OnBindDialogView(contentView); builder.SetCustomView(contentView, false); } else { builder.SetContent(DialogMessage); } try { PreferenceManager pm = PreferenceManager; Java.Lang.Reflect.Method method = pm.Class.GetDeclaredMethod( "registerOnActivityDestroyListener", Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener))); method.Accessible = true; method.Invoke(pm, this); } catch (Exception) { } mDialog = builder.Build(); if (state != null) mDialog.OnRestoreInstanceState(state); mDialog.Show(); }
////////////////////////////////////////////////////////////////////////// // DIALOG Section ////////////////////////////////////////////////////////////////////////// public void ShowPresentationDialog(Context context, string title, string content, bool external = false) { LayoutInflater inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService); View view = inflater.Inflate(Resource.Layout.DialogWebView, null); WebView presentationWebView = view.FindViewById <WebView>(Resource.Id.dialogWebView); StorehouseWebViewClient client = new StorehouseWebViewClient(external); presentationWebView.SetWebViewClient(client); presentationWebView.Settings.JavaScriptEnabled = true; presentationWebView.Settings.BuiltInZoomControls = true; presentationWebView.VerticalScrollBarEnabled = false; presentationWebView.Settings.DefaultFontSize = GetWebViewTextSize(App.STATE.SeekBarTextSize); if (content.StartsWith("http")) { presentationWebView.LoadUrl(content); } else { presentationWebView.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null); } MaterialDialog dialog = null; MaterialDialog.Builder popup = new MaterialDialog.Builder(context); popup.SetCustomView(view, false); popup.SetNegativeText("X", (o, args) => { // Close dialog }); App.STATE.Activity.RunOnUiThread(() => { dialog = popup.Show(); // Set dialog width to width of screen WindowManagerLayoutParams layoutParams = new WindowManagerLayoutParams(); layoutParams.CopyFrom(dialog.Window.Attributes); layoutParams.Width = WindowManagerLayoutParams.MatchParent; dialog.Window.Attributes = layoutParams; }); }
protected override void ShowDialog(Bundle state) { MaterialDialog.Builder mBuilder = (new MaterialDialog.Builder(Context)).SetTitle(DialogTitle).SetIcon(DialogIcon).SetPositiveText(PositiveButtonText).SetNegativeText(NegativeButtonText).SetCallback(callback).SetContent(DialogMessage); View layout = LayoutInflater.From(Context).Inflate(Resource.Layout.md_stub_input, null); OnBindDialogView(layout); if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { EditText.Background.SetColorFilter(mColor, PorterDuff.Mode.SrcAtop); } TextView message = (TextView)layout.FindViewById(Android.Resource.Id.Message); if (DialogMessage != null && DialogMessage.ToString().Length > 0) { message.Visibility = ViewStates.Visible; message.Text = DialogMessage; } else { message.Visibility = ViewStates.Gone; } mBuilder.SetCustomView(layout, false); MaterialDialog mDialog = mBuilder.Build(); if (state != null) { mDialog.OnRestoreInstanceState(state); } RequestInputMethod(mDialog); mDialog.SetOnDismissListener(this); mDialog.Show(); }
public virtual Builder SetView(View view) { builder.SetCustomView(view, false); return(this); }
protected override void ShowDialog(Bundle state) { var mBuilder = new MaterialDialog.Builder(Context) .SetTitle(DialogTitle) .SetIcon(DialogIcon) .SetPositiveText(PositiveButtonText) .SetNegativeText(NegativeButtonText) .SetDismissListener(this) .SetCallback(new ButtonCallback { Positive = (x) => { OnClick(x, (int)DialogButtonType.Positive); String value = mEditText.Text; if (CallChangeListener(value) && Persistent) Text = value; }, Neutral = (x) => { OnClick(x, (int)DialogButtonType.Neutral); }, Negative = (x) => { OnClick(x, (int)DialogButtonType.Negative); } }) .SetDismissListener(this); View layout = LayoutInflater.From(Context).Inflate(Resource.Layout.sino_droid_md_stub_inputpref, null); OnBindDialogView(layout); MDTintHelper.SetTint(mEditText, mColor); TextView message = layout.FindViewById<TextView>(Android.Resource.Id.Message); if (DialogMessage != null && DialogMessage.Length > 0) { message.Visibility = ViewStates.Visible; message.Text = DialogMessage; } else { message.Visibility = ViewStates.Gone; } mBuilder.SetCustomView(layout, false); try { var pm = PreferenceManager; Java.Lang.Reflect.Method method = pm.Class.GetDeclaredMethod( "registerOnActivityDestroyListener", Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener))); method.Accessible = true; method.Invoke(pm, this); } catch (Exception) { } mDialog = mBuilder.Build(); if (state != null) mDialog.OnRestoreInstanceState(state); RequestInputMethod(mDialog); mDialog.Show(); }
protected override void ShowDialog(Bundle state) { List <int> indices = new List <int>(); foreach (String s in Values) { int index = FindIndexOfValue(s); if (index >= 0) { indices.Add(FindIndexOfValue(s)); } } MaterialDialog.Builder builder = new MaterialDialog.Builder(context) .SetTitle(DialogTitle) .SetContent(DialogMessage) .SetIcon(DialogIcon) .SetNegativeText(NegativeButtonText) .SetPositiveText(PositiveButtonText) .SetCallback(new ButtonCallback() { Neutral = (x) => { OnClick(x, (int)DialogButtonType.Neutral); }, Negative = (x) => { OnClick(x, (int)DialogButtonType.Negative); }, Positive = (x) => { OnClick(x, (int)DialogButtonType.Positive); } }) .SetItems(GetEntries()) .SetItemsCallbackMultiChoice(indices.ToArray(), new ListCallbackMultiChoice { Selection = (dialog, which, text) => { OnClick(null, (int)DialogButtonType.Positive); dialog.Dismiss(); ISet <String> values = new HashSet <String>(); foreach (int i in which) { values.Add(GetEntryValues()[i]); } if (CallChangeListener((Java.Lang.Object)values)) { Values = values; } return(true); } }).SetDismissListener(this); View contentView = OnCreateDialogView(); if (contentView != null) { OnBindDialogView(contentView); builder.SetCustomView(contentView, false); } else { builder.SetContent(DialogMessage); } try { PreferenceManager pm = PreferenceManager; Method method = pm.Class.GetDeclaredMethod( "registerOnActivityDestroyListener", Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener))); method.Accessible = true; method.Invoke(pm, this); } catch (Exception) { } mDialog = builder.Build(); if (state != null) { mDialog.OnRestoreInstanceState(state); } mDialog.Show(); }
protected override void ShowDialog(Bundle state) { var mBuilder = new MaterialDialog.Builder(Context) .SetTitle(DialogTitle) .SetIcon(DialogIcon) .SetPositiveText(PositiveButtonText) .SetNegativeText(NegativeButtonText) .SetDismissListener(this) .SetCallback(new ButtonCallback { Positive = (x) => { OnClick(x, (int)DialogButtonType.Positive); String value = mEditText.Text; if (CallChangeListener(value) && Persistent) { Text = value; } }, Neutral = (x) => { OnClick(x, (int)DialogButtonType.Neutral); }, Negative = (x) => { OnClick(x, (int)DialogButtonType.Negative); } }) .SetDismissListener(this); View layout = LayoutInflater.From(Context).Inflate(Resource.Layout.sino_droid_md_stub_inputpref, null); OnBindDialogView(layout); MDTintHelper.SetTint(mEditText, mColor); TextView message = layout.FindViewById <TextView>(Android.Resource.Id.Message); if (DialogMessage != null && DialogMessage.Length > 0) { message.Visibility = ViewStates.Visible; message.Text = DialogMessage; } else { message.Visibility = ViewStates.Gone; } mBuilder.SetCustomView(layout, false); try { var pm = PreferenceManager; Java.Lang.Reflect.Method method = pm.Class.GetDeclaredMethod( "registerOnActivityDestroyListener", Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener))); method.Accessible = true; method.Invoke(pm, this); } catch (Exception) { } mDialog = mBuilder.Build(); if (state != null) { mDialog.OnRestoreInstanceState(state); } RequestInputMethod(mDialog); mDialog.Show(); }
private void ShowChapterPrompt(string storehouse, WOLPublication pub, NavStruct article) { LayoutInflater inflater = (LayoutInflater)Activity.GetSystemService(Context.LayoutInflaterService); View view = inflater.Inflate(Resource.Layout.DialogChapterSelect, null); HeaderFooterGridView gridview = view.FindViewById <HeaderFooterGridView>(Resource.Id.chapterSelectGridView); gridview.SetSelector(Android.Resource.Color.Transparent); List <WOLArticle> articles; List <ISpanned> titles; if (LibraryMode == Library.Bible) { gridview.NumColumns = -1; gridview.StretchMode = StretchMode.NoStretch; string bookNumber = article.Book.ToString() + "."; articles = JwStore.QueryArticleChapterTitles(PublicationType.Bible, storehouse) .Where(a => a.ArticleNumber.StartsWith(bookNumber)).ToList(); titles = articles.Select(a => Html.FromHtml(a.ArticleTitle.ToString().Split(new[] { ' ' }).Last())).ToList(); if (titles.Count == 1) { LoadArticle(article); return; } } else if (LibraryMode == Library.Insight) { gridview.NumColumns = 2; gridview.StretchMode = StretchMode.StretchColumnWidth; articles = JwStore.QueryArticleChapterTitles(PublicationType.Insight, storehouse) .Where(i => i.ArticleGroup.Equals(pub.Group)) .ToList(); titles = articles.Select(a => Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>").Split('<')[0] + "<br/><i>" + a.ArticleLocation + "</i>")).ToList(); } else { gridview.NumColumns = 1; gridview.StretchMode = StretchMode.StretchColumnWidth; articles = JwStore.QueryArticleChapterTitles(pub.Code, storehouse) .ToList(); titles = articles.Select(a => Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>").Split('<')[0] + "<br/><i>" + a.ArticleLocation + "</i>")).ToList(); if (titles.Count == 1) { LoadArticle(article); return; } } MaterialDialog dialog = null; gridview.Adapter = new ArticleButtonAdapter(Activity, titles.ToArray()); gridview.ItemClick += (s, args) => { dialog.Dismiss(); article = NavStruct.Parse(articles[args.Position].ArticleNumber); LoadArticle(article); }; MaterialDialog.Builder popup = new MaterialDialog.Builder(Activity); popup.SetCustomView(view, false); popup.SetTitle(pub.Name.Replace("\n", "<br/>").Split('<')[0]); popup.SetNegativeText("X"); dialog = popup.Show(); }
public void ShowChapterPrompt() { string title = gridViewTitle.Text; LayoutInflater inflater = (LayoutInflater)Activity.GetSystemService(Context.LayoutInflaterService); View view = inflater.Inflate(Resource.Layout.DialogChapterSelect, null); HeaderFooterGridView grid = view.FindViewById <HeaderFooterGridView>(Resource.Id.chapterSelectGridView); grid.SetSelector(Android.Resource.Color.Transparent); if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { grid.ChoiceMode = ChoiceMode.Single; } List <ISpanned> articles; if (library == Library.Bible) { // Chapter numbers only articles = primaryChapters.Select(a => Html.FromHtml(a.ToString().Split(new[] { ' ' }).Last())).ToList(); grid.StretchMode = StretchMode.NoStretch; grid.NumColumns = -1; } else if (library == Library.Insight) { // Article titles articles = primaryChapters; grid.StretchMode = StretchMode.StretchColumnWidth; grid.NumColumns = 2; } else { // Article titles articles = primaryChapters; grid.StretchMode = StretchMode.StretchColumnWidth; grid.NumColumns = 1; } // If one article, do nothing if (articles.Count == 1) { return; } MaterialDialog dialog = null; grid.Adapter = new ArticleButtonAdapter(Activity, articles.ToArray()); grid.ItemClick += SelectChapter; grid.ItemClick += delegate { dialog.Dismiss(); }; int index = GetNavigationIndex(); if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { grid.SetItemChecked(index, true); } grid.SetSelection(index); MaterialDialog.Builder popup = new MaterialDialog.Builder(Activity); popup.SetCustomView(view, false); popup.SetTitle(title.Replace("\n", "<br/>").Split('<')[0]); popup.SetNegativeText("X"); dialog = popup.Show(); }
protected override void ShowDialog(Bundle state) { if (GetEntries() == null || GetEntryValues() == null) { throw new InvalidOperationException( "ListPreference requires an entries array and an entryValues array."); } int preselect = FindIndexOfValue(Value); MaterialDialog.Builder builder = new MaterialDialog.Builder(context) .SetTitle(DialogTitle) .SetContent(DialogMessage) .SetIcon(DialogIcon) .SetDismissListener(this) .SetCallback(new ButtonCallback() { Neutral = (x) => { OnClick(x, (int)DialogButtonType.Neutral); }, Negative = (x) => { OnClick(x, (int)DialogButtonType.Negative); }, Positive = (x) => { OnClick(x, (int)DialogButtonType.Positive); } }) .SetNegativeText(NegativeButtonText) .SetItems(GetEntries()) .SetAutoDismiss(true) .SetItemsCallbackSingleChoice(preselect, new ListCallbackSingleChoice { Selection = (dialog, itemView, which, text) => { OnClick(null, (int)DialogButtonType.Positive); if (which >= 0 && GetEntryValues() != null) { try { Field clickedIndex = this.Class.GetDeclaredField("mClickedDialogEntryIndex"); clickedIndex.Accessible = true; clickedIndex.Set(this, which); } catch (Exception e) { throw e; } } return true; } }); View contentView = OnCreateDialogView(); if (contentView != null) { OnBindDialogView(contentView); builder.SetCustomView(contentView, false); } else { builder.SetContent(DialogMessage); } try { PreferenceManager pm = PreferenceManager; Method method = pm.Class.GetDeclaredMethod( "registerOnActivityDestroyListener", Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener))); method.Accessible = true; method.Invoke(pm, this); } catch (Exception) { } mDialog = builder.Build(); if (state != null) mDialog.OnRestoreInstanceState(state); mDialog.Show(); }
protected override void ShowDialog(Bundle state) { List<int> indices = new List<int>(); foreach (String s in Values) { int index = FindIndexOfValue(s); if (index >= 0) indices.Add(FindIndexOfValue(s)); } MaterialDialog.Builder builder = new MaterialDialog.Builder(context) .SetTitle(DialogTitle) .SetContent(DialogMessage) .SetIcon(DialogIcon) .SetNegativeText(NegativeButtonText) .SetPositiveText(PositiveButtonText) .SetCallback(new ButtonCallback() { Neutral = (x) => { OnClick(x, (int)DialogButtonType.Neutral); }, Negative = (x) => { OnClick(x, (int)DialogButtonType.Negative); }, Positive = (x) => { OnClick(x, (int)DialogButtonType.Positive); } }) .SetItems(GetEntries()) .SetItemsCallbackMultiChoice(indices.ToArray(), new ListCallbackMultiChoice { Selection = (dialog, which, text) => { OnClick(null, (int)DialogButtonType.Positive); dialog.Dismiss(); ISet<String> values = new HashSet<String>(); foreach (int i in which) { values.Add(GetEntryValues()[i]); } if (CallChangeListener((Java.Lang.Object)values)) Values = values; return true; } }).SetDismissListener(this); View contentView = OnCreateDialogView(); if (contentView != null) { OnBindDialogView(contentView); builder.SetCustomView(contentView, false); } else { builder.SetContent(DialogMessage); } try { PreferenceManager pm = PreferenceManager; Method method = pm.Class.GetDeclaredMethod( "registerOnActivityDestroyListener", Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener))); method.Accessible = true; method.Invoke(pm, this); } catch (Exception) { } mDialog = builder.Build(); if (state != null) mDialog.OnRestoreInstanceState(state); mDialog.Show(); }
protected override void ShowDialog(Bundle state) { if (GetEntries() == null || GetEntryValues() == null) { throw new InvalidOperationException( "ListPreference requires an entries array and an entryValues array."); } int preselect = FindIndexOfValue(Value); MaterialDialog.Builder builder = new MaterialDialog.Builder(context) .SetTitle(DialogTitle) .SetContent(DialogMessage) .SetIcon(DialogIcon) .SetDismissListener(this) .SetCallback(new ButtonCallback() { Neutral = (x) => { OnClick(x, (int)DialogButtonType.Neutral); }, Negative = (x) => { OnClick(x, (int)DialogButtonType.Negative); }, Positive = (x) => { OnClick(x, (int)DialogButtonType.Positive); } }) .SetNegativeText(NegativeButtonText) .SetItems(GetEntries()) .SetAutoDismiss(true) .SetItemsCallbackSingleChoice(preselect, new ListCallbackSingleChoice { Selection = (dialog, itemView, which, text) => { OnClick(null, (int)DialogButtonType.Positive); if (which >= 0 && GetEntryValues() != null) { try { Field clickedIndex = this.Class.GetDeclaredField("mClickedDialogEntryIndex"); clickedIndex.Accessible = true; clickedIndex.Set(this, which); } catch (Exception e) { throw e; } } return(true); } }); View contentView = OnCreateDialogView(); if (contentView != null) { OnBindDialogView(contentView); builder.SetCustomView(contentView, false); } else { builder.SetContent(DialogMessage); } try { PreferenceManager pm = PreferenceManager; Method method = pm.Class.GetDeclaredMethod( "registerOnActivityDestroyListener", Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener))); method.Accessible = true; method.Invoke(pm, this); } catch (Exception) { } mDialog = builder.Build(); if (state != null) { mDialog.OnRestoreInstanceState(state); } mDialog.Show(); }