Bug Fixes & Layout

main
Paul Schneider 9 years ago
parent 446207f17b
commit 435c084fe2
11 changed files with 181 additions and 92 deletions

@ -297,6 +297,7 @@ namespace XLabs.Forms
base.OnStop();
}
}
/// <summary>
@ -334,8 +335,10 @@ namespace XLabs.Forms
this.AppContext.Stop += (o, e) => this.OnClosing();
this.AppContext.Pause += (o, e) => this.OnSuspended();
this.AppContext.Resume += (o, e) => this.OnResumed();
this.AppDataDirectory = Environment.ExternalStorageDirectory.AbsolutePath;
this.AppDataDirectory = Environment.ExternalStorageDirectory.AbsolutePath;
this.Orientation = AppContext.RequestedOrientation == Android.Content.PM.ScreenOrientation.Portrait ?
Enums.Orientation.Portrait : Enums.Orientation.None;
if (initServices)
{
DependencyService.Register<TextToSpeechService>();

@ -55,8 +55,8 @@ namespace BookAStar.Droid
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.SetTitleBarVisibility(Xamarin.Forms.AndroidTitleBarVisibility.Never);
SetPersistent(true);
// global::Xamarin.Forms.Forms.SetTitleBarVisibility(Xamarin.Forms.AndroidTitleBarVisibility.Never);
//var tb = FindViewById<Android.Support.V7.Widget.Toolbar>(ToolbarResource);
// FIXME tb is null
@ -73,7 +73,8 @@ namespace BookAStar.Droid
IXFormsApp<XFormsCompatApplicationDroid> app =null;
if (!Resolver.IsSet)
{
this.SetIoc();
var xfapp = new XFormsCompatAppDroid();
this.SetIoc(xfapp);
}
else
{
@ -93,8 +94,8 @@ namespace BookAStar.Droid
}
};
LoadApplication(new BookAStar.App(this));
var fapp = new BookAStar.App(this);
LoadApplication(fapp);
// TabLayoutResource = Resource.Layout.Tabbar;
// ToolbarResource = Resource.Layout.Toolbar;
/*
@ -108,11 +109,10 @@ namespace BookAStar.Droid
}
private void SetIoc()
private SimpleContainer SetIoc(XFormsCompatAppDroid app)
{
var resolverContainer = new SimpleContainer();
var app = new XFormsCompatAppDroid();
app.Init(this);
@ -133,6 +133,7 @@ namespace BookAStar.Droid
t => new SQLiteSimpleCache(new SQLitePlatformAndroid(),
new SQLiteConnectionString(pathToDatabase, true), t.Resolve<IJsonSerializer>()));
Resolver.SetResolver(resolverContainer.GetResolver());
return resolverContainer;
}
public bool EnablePushNotifications(bool enable)
@ -425,18 +426,25 @@ namespace BookAStar.Droid
public T Resolve<T>()
{
throw new NotImplementedException();
return (T) Resolver.Resolve(typeof(T));
}
public object Resolve(Type t)
{
throw new NotImplementedException();
return Resolver.Resolve(t);
}
public void Init(App context, bool initServices = true)
protected override void OnSaveInstanceState(Bundle outState)
{
base.OnSaveInstanceState(outState);
}
public override void OnStateNotSaved()
{
base.OnStateNotSaved();
}
public override void OnRestoreInstanceState(Bundle savedInstanceState, PersistableBundle persistentState)
{
throw new NotImplementedException();
base.OnRestoreInstanceState(savedInstanceState, persistentState);
}
}
}

@ -6,6 +6,7 @@ using BookAStar.Droid;
using System;
using Java.Interop;
using System.ComponentModel;
using Android.Views;
[assembly: Xamarin.Forms.ExportRenderer(typeof(MarkdownView), typeof(MarkdownViewRenderer))]
namespace BookAStar.Droid
@ -28,8 +29,12 @@ namespace BookAStar.Droid
if (hybridWebViewRenderer != null && hybridWebViewRenderer.TryGetTarget(out hybridRenderer))
{
hybridRenderer.Element.Markdown = data;
MarkdownViewRenderer.OnPageFinished(hybridRenderer.Element,
hybridRenderer.EditorView);
}
}
}
public class MarkdownViewRenderer : ViewRenderer<MarkdownView, WebView>
@ -39,12 +44,30 @@ namespace BookAStar.Droid
private MarkdownDeep.Markdown markdown = new MarkdownDeep.Markdown();
const string JavaScriptFunction = "function invokeCSharpAction(data){jsBridge.invokeAction(data);}";
public WebView EditorView
{
get
{
return editorView;
}
}
public static async void OnPageFinished(MarkdownView xview, WebView view)
{
int i = 10;
while (view.ContentHeight == 0 && i-- > 0) // wait here till content is rendered
await System.Threading.Tasks.Task.Delay(100);
xview.BatchBegin();
xview.HeightRequest = view.ContentHeight;
xview.BatchCommit();
}
private void SetMDEditorText(string text)
{
editorTemplate.Model = (text == null) ? null : markdown.Transform(text);
var html = editorTemplate.GenerateString();
editorView.LoadDataWithBaseURL("file:///android_asset/",
EditorView.LoadDataWithBaseURL("file:///android_asset/",
html, "text/html", "utf-8", null);
OnPageFinished(Element, editorView);
}
protected override void OnElementChanged(ElementChangedEventArgs<MarkdownView> e)
@ -63,7 +86,7 @@ namespace BookAStar.Droid
// Subscribe
var viewclient = new MarkdownWebViewClient(
md => { e.NewElement.Markdown = md; });
editorView.SetWebViewClient(viewclient);
EditorView.SetWebViewClient(viewclient);
Control.AddJavascriptInterface(new JSBridge(this), "jsBridge");
SetMDEditorText(e.NewElement.Markdown);
InjectJS(JavaScriptFunction);
@ -81,33 +104,40 @@ namespace BookAStar.Droid
private WebView CreateNativeControl()
{
editorView = new WebView(Context);
editorView.Settings.BuiltInZoomControls = true;
editorView.Settings.JavaScriptEnabled = true;
editorView.Settings.LoadsImagesAutomatically = true;
editorView.Settings.SetAppCacheEnabled(true);
editorView.Settings.AllowContentAccess = true;
editorView.Settings.AllowFileAccess = true;
editorView.Settings.AllowFileAccessFromFileURLs = true;
editorView.Settings.AllowUniversalAccessFromFileURLs = true;
editorView.Settings.BlockNetworkImage = false;
editorView.Settings.BlockNetworkLoads = false;
editorView.Settings.DomStorageEnabled = true;
EditorView.Settings.BuiltInZoomControls = false;
EditorView.Settings.JavaScriptEnabled = true;
EditorView.Settings.LoadsImagesAutomatically = true;
EditorView.Settings.SetAppCacheEnabled(true);
EditorView.Settings.AllowContentAccess = true;
EditorView.Settings.AllowFileAccess = true;
EditorView.Settings.AllowFileAccessFromFileURLs = true;
EditorView.Settings.AllowUniversalAccessFromFileURLs = true;
EditorView.Settings.BlockNetworkImage = false;
EditorView.Settings.BlockNetworkLoads = false;
EditorView.Settings.DomStorageEnabled = true;
// editorView.SetMinimumHeight(300);
return editorView;
return EditorView;
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Markdown")
// FIXME no impact...
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
SetMDEditorText(((MarkdownView)Element).Markdown);
}
base.OnElementPropertyChanged(sender, e);
MeasureSpecMode widthMode = MeasureSpec.GetMode(widthMeasureSpec);
MeasureSpecMode heightMode = MeasureSpec.GetMode(heightMeasureSpec);
int widthSize = MeasureSpec.GetSize(widthMeasureSpec);
int heightSize = MeasureSpec.GetSize(heightMeasureSpec);
int pxHeight = (int)ContextExtensions.ToPixels(Context, Element.HeightRequest);
int pxWidth = (int)ContextExtensions.ToPixels(Context, Element.WidthRequest);
var measuredWidth = widthMode != MeasureSpecMode.Exactly ? (widthMode != MeasureSpecMode.AtMost ? pxHeight : Math.Min(pxHeight, widthSize)) : widthSize;
var measuredHeight = heightMode != MeasureSpecMode.Exactly ? (heightMode != MeasureSpecMode.AtMost ? pxWidth : Math.Min(pxWidth, heightSize)) : heightSize;
SetMeasuredDimension(measuredWidth, measuredHeight< Element.HeightRequest ? (int) Element.HeightRequest : measuredHeight);
}
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
/*
protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
{
base.OnMeasure(widthMeasureSpec, editorView.ContentHeight);
Element.Layout(new Xamarin.Forms.Rectangle(0, 0, ContextExtensions.FromPixels(Context, right - left), ContextExtensions.FromPixels(Context, bottom - top)));
base.OnLayout(changed, left, top, right, bottom);
}
*/
}
}

@ -4952,8 +4952,8 @@ namespace BookAStar.Droid
// aapt resource value: 0x7f0c00b3
public const int subtitles = 2131493043;
// aapt resource value: 0x7f0c00b6
public const int surface_view = 2131493046;
// aapt resource value: 0x7f0c00b5
public const int surface_view = 2131493045;
// aapt resource value: 0x7f0c0019
public const int tabMode = 2131492889;
@ -4985,9 +4985,6 @@ namespace BookAStar.Droid
// aapt resource value: 0x7f0c0053
public const int title_template = 2131492947;
// aapt resource value: 0x7f0c00b5
public const int toolbar = 2131493045;
// aapt resource value: 0x7f0c003d
public const int top = 2131492925;

@ -1,8 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
tools:context=".MainActivity"
app:layout_scrollFlags="scroll|enterAlways"
/>

@ -1,14 +1,8 @@
using BookAStar.Helpers;
using BookAStar.Interfaces;
using BookAStar.Interfaces;
using BookAStar.Model;
using BookAStar.Model.Workflow;
using BookAStar.Pages;
using BookAStar.ViewModels;
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Xamarin.Forms;
using XLabs.Forms.Mvvm;
using XLabs.Forms.Pages;
@ -17,6 +11,8 @@ using XLabs.Ioc;
using XLabs.Platform.Mvvm;
using XLabs.Platform.Services;
using XLabs.Settings;
using XLabs;
using XLabs.Enums;
/*
Glyphish icons from
@ -56,14 +52,59 @@ namespace BookAStar
return;
}
Configure(app);
app.Closing += (o, e) => Debug.WriteLine("Application Closing");
app.Error += (o, e) => Debug.WriteLine("Application Error");
app.Initialize += (o, e) => Debug.WriteLine("Application Initialized");
app.Resumed += (o, e) => Debug.WriteLine("Application Resumed");
app.Rotation += (o, e) => Debug.WriteLine("Application Rotated");
app.Startup += (o, e) => Debug.WriteLine("Application Startup");
app.Suspended += (o, e) => Debug.WriteLine("Application Suspended");
app.Closing += OnClosing;
app.Error += OnError;
app.Initialize += OnInitialize;
app.Resumed += OnAppResumed;
app.Rotation += OnRotation;
app.Startup += OnStartup;
app.Suspended += OnSuspended;
}
// omg
private void OnError(object sender, EventArgs e)
{
}
// Called on rotation after OnSuspended
private void OnClosing(object sender, EventArgs e)
{
}
// FIXME Not called
private void OnInitialize(object sender, EventArgs e)
{
}
// called on app startup, not on rotation
private void OnStartup(object sender, EventArgs e)
{
// TODO special starup pages as
// notification details or wizard setup page
}
// Called on rotation
private void OnSuspended(object sender, EventArgs e)
{
// TODO the navigation stack persistence (save)
}
// called on app startup, after OnStartup, not on rotation
private void OnAppResumed(object sender, EventArgs e)
{
// TODO the navigation stack persistence (restore)
base.OnResume();
}
// FIXME Not called ... see OnSuspended
private void OnRotation(object sender, EventArgs<Orientation> e)
{
// TODO the navigation stack persistence (restore?)
}
public static GenericConfigSettingsMgr ConfigManager { protected set; get; }
private void Configure(IXFormsApp app)
@ -84,13 +125,19 @@ namespace BookAStar
public App(IPlatform instance)
{
// This declaration became obsolete by introduction
// of the XLabs App that
// refers this instance with
// its application context property
// and is obtained using the `Resolver`
PlatformSpecificInstance = instance;
// Xaml
InitializeComponent();
// Static properties construction
Init();
// Builds the Main page
BuildMainPage();
NavigationPage.SetHasNavigationBar(MainPage, false);
NavigationPage.SetHasBackButton(MainPage, false);
}
BookQueriesPage bQueriesPage;
@ -149,13 +196,11 @@ namespace BookAStar
navPage.ToolbarItems.Add(tiSetts);
*/
this.MainPage = masterDetail;
Resolver.Resolve<IDependencyContainer>()
.Register<INavigationService>(t => new NavigationService(masterDetail.Detail.Navigation))
;
}
public void PostDeviceInfo()
{
var res = PlatformSpecificInstance.InvokeApi(
@ -171,7 +216,7 @@ namespace BookAStar
}
// TODO système de persistance de l'état de l'appli
/*
/// <summary>
/// Shows a page asynchronously by locating the default constructor, creating the page,
/// the pushing it onto the navigation stack.
@ -192,7 +237,7 @@ namespace BookAStar
await parentPage.Navigation.PushAsync(page);
break;
}
}
}*/
}
}

@ -1,4 +1,5 @@
using BookAStar.Helpers;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -80,6 +81,7 @@ namespace BookAStar.Model.Auth.Account
OnPropertyChanged("Avatar");
}
}
[JsonIgnore]
public ImageSource AvatarSource
{
get

@ -24,7 +24,6 @@
<ListView.ItemTemplate HeightRequest="60" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<lc:GesturesContentView>
<Grid Padding="5"
ColumnSpacing="10"
RowSpacing="2" >
@ -34,12 +33,6 @@
</Label>
</Grid>
<lb:Gestures.Interests>
<lb:GestureCollection>
<lb:GestureInterest GestureType="Swipe" Direction="Left" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding UserName}"/>
</lb:GestureCollection>
</lb:Gestures.Interests>
</lc:GesturesContentView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>

@ -15,18 +15,20 @@
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView>
<StackLayout Padding="10,10,10,10">
<StackLayout Orientation="Horizontal" Padding="10,10,10,10">
<Label Text="{Binding Client.UserName}" LineBreakMode="WordWrap"></Label>
<Label Text="{Binding Query.Location.Address}" LineBreakMode="WordWrap"></Label>
<Label Text="{Binding Query.EventDate, StringFormat='{0:dddd d MMMM yyyy à hh:mm}'}" LineBreakMode="WordWrap"></Label>
<StackLayout Orientation="Horizontal" Padding="10,10,10,10" View.VerticalOptions="CenterAndExpand">
<Label Text="{Binding Client.UserName}" LineBreakMode="WordWrap" View.VerticalOptions="CenterAndExpand"></Label>
<Label Text="{Binding Query.Location.Address}" LineBreakMode="WordWrap" View.VerticalOptions="CenterAndExpand"></Label>
<Label Text="{Binding Query.EventDate, StringFormat='{0:dddd d MMMM yyyy à hh:mm}'}" LineBreakMode="WordWrap" View.VerticalOptions="CenterAndExpand"></Label>
</StackLayout>
<views:MarkdownView x:Name="mdview"
Edited="OnDescriptionChanged"
Modified="OnDescriptionChanged"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand" MinimumHeightRequest="160" HeightRequest="250"
View.VerticalOptions="CenterAndExpand"
Markdown="{Binding Description, Mode=TwoWay}"
MinimumHeightRequest="160"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=.6}"
@ -35,8 +37,7 @@
Factor=1}"
></views:MarkdownView>
<ListView RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=.2}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}">
<ListView HeightRequest="80" View.VerticalOptions="End">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
@ -50,4 +51,5 @@
<Label FormattedText="{Binding FormattedTotal}"/>
<Button Text="Valider ce devis"></Button>
</StackLayout>
</ScrollView>
</ContentPage>

@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using XLabs.Forms.Services;
using XLabs.Ioc;
using XLabs.Platform.Services;
@ -28,14 +29,16 @@ namespace BookAStar.Pages
{
base.OnBindingContextChanged();
// FIXME WAZA
if (BindingContext != null)
if (BindingContext != null) {
mdview.Markdown = ((EstimateViewModel)BindingContext).Description;
}
}
protected void OnDescriptionChanged (object sender, EventArgs e)
{
// FIXME Why the Binding don't work?
((EstimateViewModel)BindingContext).Description = mdview.Markdown;
InvalidateMeasure();
}
protected void OnNewCommanLine(object sender, EventArgs e)
@ -43,7 +46,7 @@ namespace BookAStar.Pages
var com = new BillingLine();
Resolver.Resolve<INavigationService>().NavigateTo<EditBillingLinePage>(
true,
new object[] { new BillingLineViewModel((Estimate)this.BindingContext,com) } );
new object[] { new BillingLineViewModel(((EstimateViewModel)this.BindingContext).Data,com) } );
}
}

@ -23,20 +23,21 @@ namespace BookAStar.Views
{
return markdown;
}
set {
set
{
if (markdown != value)
if (Edited != null)
{
markdown = value;
Edited.Invoke(this, new EventArgs());
if (Modified != null)
{
Modified.Invoke(this, new EventArgs());
return;
}
markdown = value;
}
}
}
public event EventHandler<EventArgs> Edited;
public event EventHandler<EventArgs> Modified;
protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
{

Loading…