Android font size adjustments

This commit is contained in:
Kyle Spearrin 2016-08-22 18:59:15 -04:00
parent aa880264e3
commit 610789fd6d
20 changed files with 76 additions and 28 deletions

View file

@ -291,6 +291,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\CustomButtonRenderer.cs" />
<Compile Include="Controls\ExtendedButtonRenderer.cs" />
<Compile Include="Controls\ExtendedTabbedPageRenderer.cs" />
<Compile Include="Controls\ExtendedTableViewRenderer.cs" />

View file

@ -0,0 +1,26 @@
using System;
using System.ComponentModel;
using Bit.Android.Controls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(Button), typeof(CustomButtonRenderer))]
namespace Bit.Android.Controls
{
public class CustomButtonRenderer : ButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
base.OnElementChanged(e);
if(Control.TextSize == (float)Device.GetNamedSize(NamedSize.Default, typeof(Button)))
{
Control.TextSize = (float)Device.GetNamedSize(NamedSize.Medium, typeof(Button));
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
}
}
}

View file

@ -8,7 +8,7 @@ using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(ExtendedButton), typeof(ExtendedButtonRenderer))]
namespace Bit.Android.Controls
{
public class ExtendedButtonRenderer : ButtonRenderer
public class ExtendedButtonRenderer : CustomButtonRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{

View file

@ -16,7 +16,7 @@ namespace Bit.Android.Controls
var view = (ExtendedPicker)Element;
Control.TextSize = (float)Device.GetNamedSize(NamedSize.Small, typeof(Picker));
Control.TextSize = (float)Device.GetNamedSize(NamedSize.Medium, typeof(Picker));
SetBorder(view);
}

View file

@ -6,6 +6,7 @@ using Bit.App.Controls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using AView = Android.Views.View;
using Android.Widget;
[assembly: ExportRenderer(typeof(ExtendedSwitchCell), typeof(ExtendedSwitchCellRenderer))]
namespace Bit.Android.Controls
@ -30,6 +31,19 @@ namespace Bit.Android.Controls
{
View.SetMainTextColor(Color.FromHex("777777"));
}
if(View.ChildCount > 1)
{
var layout = View.GetChildAt(1) as LinearLayout;
if(layout != null && layout.ChildCount > 0)
{
var textView = layout.GetChildAt(0) as TextView;
if(textView != null)
{
textView.TextSize = (float)Device.GetNamedSize(NamedSize.Medium, typeof(Label));
}
}
}
}
return View;

View file

@ -38,6 +38,19 @@ namespace Bit.Android.Controls
image.SetPadding(10, 10, 30, 10);
View.SetAccessoryView(image);
}
if(View.ChildCount > 1)
{
var layout = View.GetChildAt(1) as LinearLayout;
if(layout != null && layout.ChildCount > 0)
{
var textView = layout.GetChildAt(0) as TextView;
if(textView != null)
{
textView.TextSize = (float)Device.GetNamedSize(NamedSize.Medium, typeof(Label));
}
}
}
}
return View;

View file

@ -54,7 +54,6 @@
<Compile Include="Behaviors\RequiredValidationBehavior.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Controls\DismissModalToolBarItem.cs" />
<Compile Include="Controls\EntryLabel.cs" />
<Compile Include="Controls\ExtendedEditor.cs" />
<Compile Include="Controls\ExtendedButton.cs" />
<Compile Include="Controls\ExtendedNavigationPage.cs" />

View file

@ -1,13 +0,0 @@
using Xamarin.Forms;
namespace Bit.App.Controls
{
public class EntryLabel : Label
{
public EntryLabel()
{
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
TextColor = Color.FromHex("777777");
}
}
}

View file

@ -10,7 +10,8 @@ namespace Bit.App.Controls
Editor = new ExtendedEditor
{
Keyboard = entryKeyboard,
HasBorder = false
HasBorder = false,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Editor))
};
if(height.HasValue)
@ -29,7 +30,6 @@ namespace Bit.App.Controls
if(Device.OS == TargetPlatform.Android)
{
Editor.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
Editor.Margin = new Thickness(-4, -2, -4, -10);
}

View file

@ -31,7 +31,8 @@ namespace Bit.App.Controls
HasBorder = false,
IsPassword = IsPassword,
AllowClear = true,
HorizontalOptions = LayoutOptions.FillAndExpand
HorizontalOptions = LayoutOptions.FillAndExpand,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Entry))
};
if(useLabelAsPlaceholder)
@ -78,11 +79,9 @@ namespace Bit.App.Controls
if(Device.OS == TargetPlatform.Android)
{
Entry.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
formStackLayout.Spacing = 0;
if(!useLabelAsPlaceholder)
{
Entry.Margin = new Thickness(-4, -2, -4, -10);
Entry.Margin = new Thickness(-11, 0, -11, -5);
}
}

View file

@ -8,7 +8,8 @@ namespace Bit.App.Controls
{
Label = new Label
{
LineBreakMode = LineBreakMode.TailTruncation
LineBreakMode = LineBreakMode.TailTruncation,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
};
Detail = new Label

View file

@ -37,7 +37,7 @@ namespace Bit.App.Controls
Value = new Label
{
Text = valueText,
FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)),
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
LineBreakMode = LineBreakMode.TailTruncation
};

View file

@ -14,7 +14,7 @@ namespace Bit.App.Controls
HorizontalTextAlignment = TextAlignment.Center,
FontSize = 35,
FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier")
};
};
Entry = new ExtendedEntry
{

View file

@ -10,7 +10,8 @@ namespace Bit.App.Controls
{
Text = labelText,
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.CenterAndExpand
VerticalOptions = LayoutOptions.CenterAndExpand,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
};
StepperValueLabel = new Label
@ -19,7 +20,8 @@ namespace Bit.App.Controls
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalTextAlignment = TextAlignment.Start,
Text = value.ToString(),
Style = (Style)Application.Current.Resources["text-muted"]
Style = (Style)Application.Current.Resources["text-muted"],
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
};
Stepper = new Stepper

View file

@ -55,7 +55,7 @@ namespace Bit.App.Pages
VerticalOptions = LayoutOptions.End,
HorizontalOptions = LayoutOptions.Fill,
Style = (Style)Application.Current.Resources["btn-primary"],
FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Button))
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button))
};
var loginButton = new Button

View file

@ -26,6 +26,7 @@ namespace Bit.App.Pages
var versionLabel = new Label
{
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Text = $@"Version {_appInfoService.Version} ({_appInfoService.Build})
© 8bit Solutions LLC 2015-{DateTime.Now.Year}",
HorizontalTextAlignment = TextAlignment.Center

View file

@ -407,6 +407,7 @@ namespace Bit.App.Pages
{
Label = new Label
{
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
VerticalOptions = LayoutOptions.CenterAndExpand,
LineBreakMode = LineBreakMode.TailTruncation,
Text = labelText

View file

@ -95,6 +95,7 @@ namespace Bit.App.Pages
{
var label = new Label
{
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
LineBreakMode = LineBreakMode.TailTruncation,
Text = labelText
};

View file

@ -180,6 +180,7 @@ namespace Bit.App.Pages
var label = new Label
{
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
Text = "Length",
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.CenterAndExpand
@ -193,6 +194,7 @@ namespace Bit.App.Pages
Value = new Label
{
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
HorizontalOptions = LayoutOptions.End,
VerticalOptions = LayoutOptions.CenterAndExpand,
Style = (Style)Application.Current.Resources["text-muted"]

View file

@ -418,6 +418,7 @@ namespace Bit.App.Pages
var label = new Label
{
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
VerticalTextAlignment = TextAlignment.Center,
VerticalOptions = LayoutOptions.CenterAndExpand,
Style = (Style)Application.Current.Resources["text-muted"]