From 35480aaffc1e1c2758390b54b144b06da77b3ff9 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 9 Jan 2017 18:08:27 +0100 Subject: [PATCH 1/4] implements a ctor --- .../EstimatePages/BookQueriesPage.xaml.cs | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/BookAStar/BookAStar/Pages/EstimatePages/BookQueriesPage.xaml.cs b/BookAStar/BookAStar/Pages/EstimatePages/BookQueriesPage.xaml.cs index 2fe06982..909d3ca2 100644 --- a/BookAStar/BookAStar/Pages/EstimatePages/BookQueriesPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/EstimatePages/BookQueriesPage.xaml.cs @@ -14,16 +14,30 @@ namespace BookAStar.Pages public BookQueriesPage() { InitializeComponent(); - var model = new BookQueriesViewModel(); - model.RefreshQueries = - new Command( () => { - DataManager.Instance.BookQueries.Execute(null); - this.list.EndRefresh(); - }); - + BindingContext = new BookQueriesViewModel(); + } + + public BookQueriesPage(BookQueriesViewModel model) + { + InitializeComponent(); BindingContext = model; } + protected override void OnBindingContextChanged() + { + BookQueriesViewModel model = (BookQueriesViewModel) BindingContext; + if (model!=null) + { + model.RefreshQueries = + new Command(() => + { + DataManager.Instance.BookQueries.Execute(null); + this.list.EndRefresh(); + }); + } + base.OnBindingContextChanged(); + } + private void OnViewDetail(object sender, ItemTappedEventArgs e) { var item = e.Item as BookQueryViewModel; From 8e5934c2b1933cec1821d375db0dc04b1435d5d1 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 9 Jan 2017 18:14:40 +0100 Subject: [PATCH 2/4] trying to customize the webview context menu ... With no success. --- .../BookAStar.Droid/BookAStar.Droid.csproj | 9 ++- .../BookAStar.Droid/Markdown/MDContextMenu.cs | 73 +++++++++++++++++++ .../BookAStar.Droid/Markdown/MDWebView.cs | 28 +++++++ .../Markdown/MarkdownViewRenderer.cs | 20 ++++- .../Resources/menu/md_menu.axml | 33 +++++++++ .../Resources/values/strings.xml | 13 ++++ 6 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 BookAStar/BookAStar.Droid/Markdown/MDContextMenu.cs create mode 100644 BookAStar/BookAStar.Droid/Markdown/MDWebView.cs create mode 100644 BookAStar/BookAStar.Droid/Resources/menu/md_menu.axml diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj index a1d532a7..9903e7bc 100644 --- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj +++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj @@ -343,6 +343,8 @@ + + @@ -374,6 +376,9 @@ Designer + + Designer + @@ -383,7 +388,9 @@ - + + Designer + Designer diff --git a/BookAStar/BookAStar.Droid/Markdown/MDContextMenu.cs b/BookAStar/BookAStar.Droid/Markdown/MDContextMenu.cs new file mode 100644 index 00000000..d5196466 --- /dev/null +++ b/BookAStar/BookAStar.Droid/Markdown/MDContextMenu.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Android.App; +using Android.Content; +using Android.OS; +using Android.Runtime; +using Android.Views; +using Android.Widget; +using Android.Support.V7.App; +using XLabs.Ioc; +using XLabs.Platform.Mvvm; +using XLabs.Forms; +using static Android.Views.View; + +namespace BookAStar.Droid.Markdown +{ + class MDContextMenu : AppCompatDialog + { + private ActionMode mActionMode = null; + public MDContextMenu(Context context) : base(context) + { + + } + public override void OnActionModeStarted(ActionMode mode) + { + if (mActionMode == null) + { + mActionMode = mode; + var menu = mode.Menu; + // Remove the default menu items (select all, copy, paste, search) + menu.Clear(); + + // If you want to keep any of the defaults, + // remove the items you don't want individually: + // menu.removeItem(android.R.id.[id_of_item_to_remove]) + + // Inflate your own menu items + mode.MenuInflater.Inflate(Resource.Menu.md_menu, menu); + + } + mActionMode = mode; + base.OnActionModeStarted(mode); + } + public override void OnActionModeFinished(ActionMode mode) + { + base.OnActionModeFinished(mode); + } + protected override void OnCreate(Bundle savedInstanceState) + { + base.OnCreate(savedInstanceState); + } + public void OnCreateContextMenu(IContextMenu menu, View v, IContextMenuContextMenuInfo menuInfo) + { + /* if (menuInfo!=null) + { + var info = menuInfo.ToString(); + } + menu.Add(0, 0, 0, "test"); + var subMenu = menu.AddSubMenu( + 0, 1, 1, "..."); + subMenu.Add(0, 3, 0, "nkjnkjn"); + var app = Resolver.Resolve() as IXFormsApp; + + var mgr = ClipboardManager.FromContext(app.AppContext); + if (mgr.HasText) + menu.Add(0, 0, 0, "Coller!");*/ + //base.OnCreateContextMenu(menu, v, menuInfo); + } + } +} \ No newline at end of file diff --git a/BookAStar/BookAStar.Droid/Markdown/MDWebView.cs b/BookAStar/BookAStar.Droid/Markdown/MDWebView.cs new file mode 100644 index 00000000..c567807d --- /dev/null +++ b/BookAStar/BookAStar.Droid/Markdown/MDWebView.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Android.App; +using Android.Content; +using Android.OS; +using Android.Runtime; +using Android.Views; +using Android.Widget; +using Android.Webkit; + +namespace BookAStar.Droid.Markdown +{ + class MDWebView : WebView + { + public MDWebView (Context context) : base (context) + { + } + + public override ActionMode StartActionMode(ActionMode.ICallback callback) + { + return base.StartActionMode(callback); + } + + } +} \ No newline at end of file diff --git a/BookAStar/BookAStar.Droid/Markdown/MarkdownViewRenderer.cs b/BookAStar/BookAStar.Droid/Markdown/MarkdownViewRenderer.cs index 9480e863..7ebdfef9 100644 --- a/BookAStar/BookAStar.Droid/Markdown/MarkdownViewRenderer.cs +++ b/BookAStar/BookAStar.Droid/Markdown/MarkdownViewRenderer.cs @@ -12,6 +12,11 @@ using Android.Views; namespace BookAStar.Droid { using Markdown; + using XLabs.Forms; + using XLabs.Ioc; + using XLabs.Platform.Mvvm; + using static View; + public class MarkdownViewRenderer : ViewRenderer { private WebView editorView; @@ -35,7 +40,9 @@ namespace BookAStar.Droid { if (view == null || xview == null) return; var vch = view.ContentHeight; - xview.HeightRequest = vch > xview.MinimumHeightRequest ? vch : xview.MinimumHeightRequest; + // var oldH = xview.Height; + var newH = vch > xview.MinimumHeightRequest ? vch : xview.MinimumHeightRequest; + xview.HeightRequest = newH; } protected override void OnElementChanged(ElementChangedEventArgs e) @@ -73,7 +80,7 @@ namespace BookAStar.Droid Control.LoadUrl(string.Format("javascript: {0}", script)); } } - + MDContextMenu contextMenu; private WebView CreateNativeControl() { editorView = new WebView(Context); @@ -93,9 +100,18 @@ namespace BookAStar.Droid EditorView.Settings.DomStorageEnabled = true; EditorView.AddJavascriptInterface(new JsBridgeMarkdown(this), "jsBridge"); EditorView.ViewTreeObserver.PreDraw += ViewTreeObserver_PreDraw; + //var app = Resolver.Resolve() as IXFormsApp; + //contextMenu = new MDContextMenu(app.AppContext); + //EditorView.SetOnCreateContextMenuListener(contextMenu); + return EditorView; } + private void EditorView_Touch(object sender, TouchEventArgs e) + { + + } + private void ViewTreeObserver_PreDraw(object sender, ViewTreeObserver.PreDrawEventArgs e) { AdjustHeightRequest(Element, Control); diff --git a/BookAStar/BookAStar.Droid/Resources/menu/md_menu.axml b/BookAStar/BookAStar.Droid/Resources/menu/md_menu.axml new file mode 100644 index 00000000..a6f00e51 --- /dev/null +++ b/BookAStar/BookAStar.Droid/Resources/menu/md_menu.axml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/BookAStar/BookAStar.Droid/Resources/values/strings.xml b/BookAStar/BookAStar.Droid/Resources/values/strings.xml index a4a8abad..2699fd6f 100644 --- a/BookAStar/BookAStar.Droid/Resources/values/strings.xml +++ b/BookAStar/BookAStar.Droid/Resources/values/strings.xml @@ -17,6 +17,19 @@ 325408689282 Comptes Booking Star Comptes Booking Star + + Copier + Coller + + Caractère + Gras + Italique + Sousligné + + Paragraphe + Titre + Sous-titre + Comptes From 18927daab949072d67abde15462befa95439dd0a Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 9 Jan 2017 18:15:00 +0100 Subject: [PATCH 3/4] WIP home --- BookAStar/BookAStar/Pages/HomePage.xaml | 41 +++++++------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/BookAStar/BookAStar/Pages/HomePage.xaml b/BookAStar/BookAStar/Pages/HomePage.xaml index d366c5b2..f195f1ac 100644 --- a/BookAStar/BookAStar/Pages/HomePage.xaml +++ b/BookAStar/BookAStar/Pages/HomePage.xaml @@ -16,43 +16,20 @@ - + - - - - -