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> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Controls\CustomButtonRenderer.cs" />
<Compile Include="Controls\ExtendedButtonRenderer.cs" /> <Compile Include="Controls\ExtendedButtonRenderer.cs" />
<Compile Include="Controls\ExtendedTabbedPageRenderer.cs" /> <Compile Include="Controls\ExtendedTabbedPageRenderer.cs" />
<Compile Include="Controls\ExtendedTableViewRenderer.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))] [assembly: ExportRenderer(typeof(ExtendedButton), typeof(ExtendedButtonRenderer))]
namespace Bit.Android.Controls namespace Bit.Android.Controls
{ {
public class ExtendedButtonRenderer : ButtonRenderer public class ExtendedButtonRenderer : CustomButtonRenderer
{ {
protected override void OnElementChanged(ElementChangedEventArgs<Button> e) protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{ {

View file

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

View file

@ -6,6 +6,7 @@ using Bit.App.Controls;
using Xamarin.Forms; using Xamarin.Forms;
using Xamarin.Forms.Platform.Android; using Xamarin.Forms.Platform.Android;
using AView = Android.Views.View; using AView = Android.Views.View;
using Android.Widget;
[assembly: ExportRenderer(typeof(ExtendedSwitchCell), typeof(ExtendedSwitchCellRenderer))] [assembly: ExportRenderer(typeof(ExtendedSwitchCell), typeof(ExtendedSwitchCellRenderer))]
namespace Bit.Android.Controls namespace Bit.Android.Controls
@ -30,6 +31,19 @@ namespace Bit.Android.Controls
{ {
View.SetMainTextColor(Color.FromHex("777777")); 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; return View;

View file

@ -38,6 +38,19 @@ namespace Bit.Android.Controls
image.SetPadding(10, 10, 30, 10); image.SetPadding(10, 10, 30, 10);
View.SetAccessoryView(image); 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; return View;

View file

@ -54,7 +54,6 @@
<Compile Include="Behaviors\RequiredValidationBehavior.cs" /> <Compile Include="Behaviors\RequiredValidationBehavior.cs" />
<Compile Include="Constants.cs" /> <Compile Include="Constants.cs" />
<Compile Include="Controls\DismissModalToolBarItem.cs" /> <Compile Include="Controls\DismissModalToolBarItem.cs" />
<Compile Include="Controls\EntryLabel.cs" />
<Compile Include="Controls\ExtendedEditor.cs" /> <Compile Include="Controls\ExtendedEditor.cs" />
<Compile Include="Controls\ExtendedButton.cs" /> <Compile Include="Controls\ExtendedButton.cs" />
<Compile Include="Controls\ExtendedNavigationPage.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 Editor = new ExtendedEditor
{ {
Keyboard = entryKeyboard, Keyboard = entryKeyboard,
HasBorder = false HasBorder = false,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Editor))
}; };
if(height.HasValue) if(height.HasValue)
@ -29,7 +30,6 @@ namespace Bit.App.Controls
if(Device.OS == TargetPlatform.Android) if(Device.OS == TargetPlatform.Android)
{ {
Editor.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
Editor.Margin = new Thickness(-4, -2, -4, -10); Editor.Margin = new Thickness(-4, -2, -4, -10);
} }

View file

@ -31,7 +31,8 @@ namespace Bit.App.Controls
HasBorder = false, HasBorder = false,
IsPassword = IsPassword, IsPassword = IsPassword,
AllowClear = true, AllowClear = true,
HorizontalOptions = LayoutOptions.FillAndExpand HorizontalOptions = LayoutOptions.FillAndExpand,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Entry))
}; };
if(useLabelAsPlaceholder) if(useLabelAsPlaceholder)
@ -78,11 +79,9 @@ namespace Bit.App.Controls
if(Device.OS == TargetPlatform.Android) if(Device.OS == TargetPlatform.Android)
{ {
Entry.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
formStackLayout.Spacing = 0;
if(!useLabelAsPlaceholder) 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 Label = new Label
{ {
LineBreakMode = LineBreakMode.TailTruncation LineBreakMode = LineBreakMode.TailTruncation,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
}; };
Detail = new Label Detail = new Label

View file

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

View file

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

View file

@ -10,7 +10,8 @@ namespace Bit.App.Controls
{ {
Text = labelText, Text = labelText,
HorizontalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.CenterAndExpand VerticalOptions = LayoutOptions.CenterAndExpand,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
}; };
StepperValueLabel = new Label StepperValueLabel = new Label
@ -19,7 +20,8 @@ namespace Bit.App.Controls
VerticalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalTextAlignment = TextAlignment.Start, HorizontalTextAlignment = TextAlignment.Start,
Text = value.ToString(), 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 Stepper = new Stepper

View file

@ -55,7 +55,7 @@ namespace Bit.App.Pages
VerticalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.End,
HorizontalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill,
Style = (Style)Application.Current.Resources["btn-primary"], 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 var loginButton = new Button

View file

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

View file

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

View file

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

View file

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

View file

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