Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Tizen] Cleanup XF.Platform.Tizen #4080

Merged
merged 1 commit into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace Xamarin.Forms.Platform.Tizen
public class ImageCellRenderer : TextCellRenderer
{
const int _defaultHeight = 55;
Dictionary<EvasObject, Native.Image> _realizedViews = new Dictionary<EvasObject, Native.Image>();

public ImageCellRenderer() : this(Device.Idiom == TargetIdiom.Watch ? "1icon_2text" : "default")
{
Expand Down
4 changes: 1 addition & 3 deletions Xamarin.Forms.Platform.Tizen/Forms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,9 @@ static void SetupInit(CoreApplication application)
// In .NETCore, AppDomain feature is not supported.
// The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually.
// The assembly of the executing application and referenced assemblies of it are added into the list here.
// TODO: AppDomain is comming back in NETStandard2.0. This logic should be changed at that time.
TizenPlatformServices.AppDomain.CurrentDomain.RegisterAssemblyRecursively(application.GetType().GetTypeInfo().Assembly);

Device.PlatformServices = new TizenPlatformServices(); ;
Device.PlatformServices = new TizenPlatformServices();
if (Device.info != null)
{
((TizenDeviceInfo)Device.info).Dispose();
Expand All @@ -233,7 +232,6 @@ static void SetupInit(CoreApplication application)
});
}

// TODO: We should consider various tizen profiles such as TV, Wearable and so on.
string profile = ((TizenDeviceInfo)Device.Info).Profile;
if (profile == "mobile")
{
Expand Down
4 changes: 2 additions & 2 deletions Xamarin.Forms.Platform.Tizen/FormsApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ public async void LoadApplication(Application application)

if (null == MainWindow)
{
throw new NullReferenceException("MainWindow is not prepared. This method should be called in OnCreated().");
throw new InvalidOperationException("MainWindow is not prepared. This method should be called in OnCreated().");
}

if (null == application)
{
throw new ArgumentNullException("application");
throw new ArgumentNullException(nameof(application));
}
_application = application;
Application.Current = application;
Expand Down
36 changes: 3 additions & 33 deletions Xamarin.Forms.Platform.Tizen/GestureDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ namespace Xamarin.Forms.Platform.Tizen
{
internal class GestureDetector
{
IDictionary<EGestureType, List<GestureHandler>> _handlerCache = new Dictionary<EGestureType, List<GestureHandler>>();
readonly IDictionary<EGestureType, List<GestureHandler>> _handlerCache = new Dictionary<EGestureType, List<GestureHandler>>();

readonly IVisualElementRenderer _renderer;
GestureLayer _gestureLayer;
double _doubleTapTime = 0;
double _longTapTime = 0;
int _horizontalSwipeTime = 0;
int _verticalSwipeTime = 0;
bool _inputTransparent = false;
bool _isEnabled = true;
bool _isEnabled;

View View => _renderer.Element as View;

Expand Down Expand Up @@ -74,7 +72,7 @@ public void Clear()
{
foreach (var handler in handlers)
{
(handler as GestureHandler).PropertyChanged -= OnGestureRecognizerPropertyChanged;
handler.PropertyChanged -= OnGestureRecognizerPropertyChanged;
}
}
_handlerCache.Clear();
Expand Down Expand Up @@ -474,34 +472,6 @@ void OnLongTapCompleted(EGestureType type, object data)
}
}

void OnFlickStarted(EGestureType type, object data)
{
var lineData = (GestureLayer.LineData)data;
_horizontalSwipeTime = Convert.ToInt32(lineData.HorizontalSwipeTimestamp);
_verticalSwipeTime = Convert.ToInt32(lineData.VerticalSwipeTimestamp);
OnGestureStarted(type, data);
}

void OnFlickCompleted(EGestureType type, object data)
{
var lineData = (GestureLayer.LineData)data;
_horizontalSwipeTime = Convert.ToInt32(lineData.HorizontalSwipeTimestamp - _horizontalSwipeTime);
_verticalSwipeTime = Convert.ToInt32(lineData.VerticalSwipeTimestamp - _verticalSwipeTime);
var cache = _handlerCache;

if (cache.ContainsKey(type))
{
foreach (var handler in cache[type])
{
if ((handler.Timeout * 1000) >= _horizontalSwipeTime ||
(handler.Timeout * 1000) >= _verticalSwipeTime)
(handler as IGestureController)?.SendCompleted(View, data);
else
(handler as IGestureController)?.SendCanceled(View, data);
}
}
}

#endregion GestureCallback

GestureHandler CreateHandler(IGestureRecognizer recognizer)
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Platform.Tizen/GestureHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected GestureHandler(IGestureRecognizer recognizer)
Recognizer.PropertyChanged += OnRecognizerPropertyChanged;
}

public virtual event PropertyChangedEventHandler PropertyChanged;
public event PropertyChangedEventHandler PropertyChanged;

protected abstract void OnStarted(View sender, object data);

Expand Down
47 changes: 12 additions & 35 deletions Xamarin.Forms.Platform.Tizen/Log/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,25 @@ namespace Xamarin.Forms.Platform.Tizen
/// </summary>
public static class Log
{
static String _tag = "Xamarin";

static ILogger _logger = IsTizen() ? (ILogger)new DlogLogger() : (ILogger)new ConsoleLogger();

/// <summary>
/// Gets or sets the log tag.
/// </summary>
public static String Tag
{
get
{
return _tag;
}
set
{
_tag = value;
}
}
public static string Tag { get; set; } = "Xamarin";

/// <summary>
/// Gets or sets the logger used to report messages.
/// It's DlogLogger on a Tizen platform, ConsoleLogger on any other.
/// </summary>
public static ILogger Logger
{
get
{
return _logger;
}
set
{
_logger = value;
}
}
/// <summary>
/// Gets or sets the logger used to report messages.
/// It's DlogLogger on a Tizen platform, ConsoleLogger on any other.
/// </summary>
public static ILogger Logger { get; set; } = IsTizen() ? (ILogger)new DlogLogger() : (ILogger)new ConsoleLogger();

public static void Debug(string message,
Guardian _ = default(Guardian),
[CallerFilePath] string file = "",
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
_logger.Debug(_tag, message, file, func, line);
Logger.Debug(Tag, message, file, func, line);
}

public static void Debug<T0>(string message,
Expand Down Expand Up @@ -203,7 +180,7 @@ public static void Verbose(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
_logger.Verbose(_tag, message, file, func, line);
Logger.Verbose(Tag, message, file, func, line);
}

public static void Verbose<T0>(string message,
Expand Down Expand Up @@ -357,7 +334,7 @@ public static void Info(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
_logger.Info(_tag, message, file, func, line);
Logger.Info(Tag, message, file, func, line);
}

public static void Info<T0>(string message,
Expand Down Expand Up @@ -511,7 +488,7 @@ public static void Warn(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
_logger.Warn(_tag, message, file, func, line);
Logger.Warn(Tag, message, file, func, line);
}

public static void Warn<T0>(string message,
Expand Down Expand Up @@ -665,7 +642,7 @@ public static void Error(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
_logger.Error(_tag, message, file, func, line);
Logger.Error(Tag, message, file, func, line);
}

public static void Error<T0>(string message,
Expand Down Expand Up @@ -819,7 +796,7 @@ public static void Fatal(string message,
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
_logger.Fatal(_tag, message, file, func, line);
Logger.Fatal(Tag, message, file, func, line);
}

public static void Fatal<T0>(string message,
Expand Down
1 change: 0 additions & 1 deletion Xamarin.Forms.Platform.Tizen/Native/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ protected virtual void ApplyButton(ButtonPosition position, EButton button)
part = "button2";
break;

case ButtonPosition.Negative:
default:
part = "button1";
break;
Expand Down
11 changes: 6 additions & 5 deletions Xamarin.Forms.Platform.Tizen/Native/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace Xamarin.Forms.Platform.Tizen.Native
/// </summary>
public class Entry : EEntry, IMeasurable, IBatchable
{
static readonly int s_VariationNormal = 0;
static readonly int s_VariationSignedAndDecimal = 3;
const int VariationNormal = 0;
const int VariationSignedAndDecimal = 3;

/// <summary>
/// Holds the formatted text of the entry.
Expand Down Expand Up @@ -395,7 +395,8 @@ string GetInternalText()
/// <param name="keyboard">Keyboard type to be used.</param>
void ApplyKeyboard(Keyboard keyboard)
{
SetInternalKeyboard(_keyboard = keyboard);
_keyboard = keyboard;
SetInternalKeyboard(keyboard);
}

/// <summary>
Expand All @@ -414,13 +415,13 @@ void SetInternalKeyboard(Keyboard keyboard)
SetInputPanelEnabled(true);
SetInputPanelLayout(InputPanelLayout.NumberOnly);
// InputPanelVariation is used to allow using deciaml point.
InputPanelVariation = s_VariationSignedAndDecimal;
InputPanelVariation = VariationSignedAndDecimal;
}
else
{
SetInputPanelEnabled(true);
SetInputPanelLayout((InputPanelLayout)keyboard);
InputPanelVariation = s_VariationNormal;
InputPanelVariation = VariationNormal;
}
}

Expand Down
10 changes: 5 additions & 5 deletions Xamarin.Forms.Platform.Tizen/Native/ListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,21 @@ public void SetHasUnevenRows(bool hasUnevenRows)
/// <summary>
/// Adds elements to the list and defines its presentation based on Cell type.
/// </summary>
/// <param name="_source">IEnumerable on Cell collection.</param>
/// <param name="source">IEnumerable on Cell collection.</param>
/// <param name="beforeCell">Cell before which new items will be placed.
/// Null value may also be passed as this parameter, which results in appending new items to the end.
/// </param>
public void AddSource(IEnumerable _source, Cell beforeCell = null)
public void AddSource(IEnumerable source, Cell beforeCell = null)
{
foreach (var data in _source)
foreach (var data in source)
{
GroupList groupList = data as GroupList;
if (groupList != null)
{
AddGroupItem(groupList, beforeCell);
foreach (var item in groupList)
{
AddItem(item as Cell, groupList.HeaderContent);
AddItem(item, groupList.HeaderContent);
}
}
else
Expand Down Expand Up @@ -451,7 +451,7 @@ protected virtual CellRenderer GetCellRenderer(Cell cell, bool isGroup = false)
if (renderer == null)
{
Log.Error("Cell type is not handled: {0}", cell.GetType());
throw new ArgumentNullException("Unsupported cell type");
throw new ArgumentException("Unsupported cell type");
}

renderer.SetGroupMode(isGroup);
Expand Down
7 changes: 2 additions & 5 deletions Xamarin.Forms.Platform.Tizen/Native/Scroller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native
public class Scroller : EScroller
{
TaskCompletionSource<bool> _animationTaskComplateSource;
SmartEvent _scrollAnimationStart, _scrollAnimationStop;
bool _isAnimation = false;

public Scroller(EvasObject parent) : base(parent)
Expand All @@ -17,10 +16,8 @@ public Scroller(EvasObject parent) : base(parent)
protected override void OnRealized()
{
base.OnRealized();
_scrollAnimationStart = new SmartEvent(this, RealHandle, "scroll,anim,start");
_scrollAnimationStop = new SmartEvent(this, RealHandle, "scroll,anim,stop");
_scrollAnimationStart.On += (s, e) => _isAnimation = true;
_scrollAnimationStop.On += (s, e) =>
new SmartEvent(this, RealHandle, "scroll,anim,start").On += (s, e) => _isAnimation = true;
new SmartEvent(this, RealHandle, "scroll,anim,stop").On += (s, e) =>
{
if (_animationTaskComplateSource != null)
{
Expand Down
8 changes: 1 addition & 7 deletions Xamarin.Forms.Platform.Tizen/Native/Span.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,11 @@ public Span()
internal string GetMarkupText()
{
StringBuilder sb = new StringBuilder();

sb.AppendFormat("<span ");

sb.Append("<span ");
sb = PrepareFormattingString(sb);

sb.Append(">");

sb.Append(GetDecoratedText());

sb.Append("</span>");

return sb.ToString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class NativeValueConverterService : INativeValueConverterService
public bool ConvertTo(object value, Type toType, out object nativeValue)
{
nativeValue = null;
if (typeof(EObject).IsInstanceOfType(value) && toType.IsAssignableFrom(typeof(View)))
if ((value is EObject) && toType.IsAssignableFrom(typeof(View)))
{
nativeValue = ((EObject)value).ToView();
return true;
Expand Down
6 changes: 2 additions & 4 deletions Xamarin.Forms.Platform.Tizen/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public class DefaultPlatform : BindableObject, ITizenPlatform, INavigation
bool _disposed;
Native.Dialog _pageBusyDialog;
int _pageBusyCount;
Naviframe _internalNaviframe;
readonly Naviframe _internalNaviframe;

HashSet<EvasObject> _alerts = new HashSet<EvasObject>();
readonly HashSet<EvasObject> _alerts = new HashSet<EvasObject>();

public event EventHandler<RootNativeViewChangedEventArgs> RootNativeViewChanged;

Expand Down Expand Up @@ -120,8 +120,6 @@ internal DefaultPlatform(EvasObject parent)

public bool HasAlpha { get; set; }

Action BackPressedAction { get; set; }

Task CurrentModalNavigationTask { get; set; }
TaskCompletionSource<bool> CurrentTaskCompletionSource { get; set; }
IPageController CurrentPageController => _navModel.CurrentPage as IPageController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Xamarin.Forms.Platform.Tizen.Renderers
{
public class MasterDetailContainer : ElmSharp.Box
public class MasterDetailContainer : ElmSharp.Box, IDisposable
{
MasterDetailPage _parent;
readonly MasterDetailPage _parent;
readonly bool _isMaster;

VisualElement _childView;
bool _disposed;
bool _isMaster;
bool _hasAppearedToParent;

IPageController PageController => ChildView as IPageController;
Expand Down
Loading