fixes #2167 still set the TextView.Gravity property baed on the Horizontal Alignment (#2743)

This commit is contained in:
Shane Neuville 2018-05-17 02:21:24 -06:00 коммит произвёл Stephane Delcroix
Родитель 65e122c61d
Коммит 732f4d5a99
5 изменённых файлов: 12 добавлений и 8 удалений

Просмотреть файл

@ -92,7 +92,7 @@ namespace Xamarin.Forms.Platform.Android
void UpdateHorizontalTextAlignment()
{
var entryCell = (EntryCell)Cell;
_view.EditText.UpdateHorizontalAlignment(entryCell.HorizontalTextAlignment);
_view.EditText.UpdateHorizontalAlignment(entryCell.HorizontalTextAlignment, _view.Context.HasRtlSupport());
}
void UpdateIsEnabled()

Просмотреть файл

@ -3,6 +3,7 @@ using System.Runtime.CompilerServices;
using Android.Content;
using Android.Util;
using Android.Views.InputMethods;
using AApplicationInfoFlags = Android.Content.PM.ApplicationInfoFlags;
namespace Xamarin.Forms.Platform.Android
{
@ -38,6 +39,9 @@ namespace Xamarin.Forms.Platform.Android
return (float)Math.Round(dp * s_displayDensity);
}
public static bool HasRtlSupport(this Context self) =>
(self.ApplicationInfo.Flags & AApplicationInfoFlags.SupportsRtl) == AApplicationInfoFlags.SupportsRtl;
internal static double GetThemeAttributeDp(this Context self, int resource)
{
using (var value = new TypedValue())

Просмотреть файл

@ -33,9 +33,9 @@ namespace Xamarin.Forms.Platform.Android
view.LayoutDirection = ALayoutDirection.Ltr;
}
internal static void UpdateHorizontalAlignment(this EditText view, TextAlignment alignment)
internal static void UpdateHorizontalAlignment(this EditText view, TextAlignment alignment, bool hasRtlSupport)
{
if ((int)Build.VERSION.SdkInt < 17)
if ((int)Build.VERSION.SdkInt < 17 || !hasRtlSupport)
view.Gravity = alignment.ToHorizontalGravityFlags();
else
view.TextAlignment = alignment.ToTextAlignment();

Просмотреть файл

@ -36,7 +36,7 @@ namespace Xamarin.Forms.Platform.Android
bool TextView.IOnEditorActionListener.OnEditorAction(TextView v, ImeAction actionId, KeyEvent e)
{
// Fire Completed and dismiss keyboard for hardware / physical keyboards
if (actionId == ImeAction.Done || actionId == _currentInputImeFlag || (actionId == ImeAction.ImeNull && e.KeyCode == Keycode.Enter && e.Action == KeyEventActions.Up) )
if (actionId == ImeAction.Done || actionId == _currentInputImeFlag || (actionId == ImeAction.ImeNull && e.KeyCode == Keycode.Enter && e.Action == KeyEventActions.Up))
{
Control.ClearFocus();
v.HideKeyboard();
@ -76,7 +76,7 @@ namespace Xamarin.Forms.Platform.Android
if (e.OldElement == null)
{
var textView = CreateNativeControl();
textView.AddTextChangedListener(this);
textView.SetOnEditorActionListener(this);
textView.OnKeyboardBackPressed += OnKeyboardBackPressed;
@ -183,7 +183,7 @@ namespace Xamarin.Forms.Platform.Android
void UpdateAlignment()
{
Control.UpdateHorizontalAlignment(Element.HorizontalTextAlignment);
Control.UpdateHorizontalAlignment(Element.HorizontalTextAlignment, Context.HasRtlSupport());
}
void UpdateColor()
@ -232,7 +232,7 @@ namespace Xamarin.Forms.Platform.Android
{
Control?.ClearFocus();
}
void UpdateMaxLength()
{
var currentFilters = new List<IInputFilter>(Control?.GetFilters() ?? new IInputFilter[0]);

Просмотреть файл

@ -141,7 +141,7 @@ namespace Xamarin.Forms.Platform.Android
if (_editText == null)
return;
_editText.UpdateHorizontalAlignment(Element.HorizontalTextAlignment);
_editText.UpdateHorizontalAlignment(Element.HorizontalTextAlignment, Context.HasRtlSupport());
}
void UpdateCancelButtonColor()