From 409a8ccea4f26cd7ca4db8e2549e81aac09121a2 Mon Sep 17 00:00:00 2001 From: woohyun Date: Fri, 12 Jun 2020 14:25:28 +0900 Subject: [PATCH] [NUI] replace field declaration with property (#1701) This would fix CA1051 warnings which indicates that "Do not declare visible instance fields". --- src/Tizen.NUI.Components/Controls/Button.cs | 2 +- src/Tizen.NUI.Components/Controls/CheckBox.cs | 4 ++-- src/Tizen.NUI.Components/Controls/CheckBoxGroup.cs | 12 ++++++------ src/Tizen.NUI.Components/Controls/Control.cs | 6 +++--- src/Tizen.NUI.Components/Controls/DropDown.cs | 4 ++-- .../Controls/FlexibleView/FlexibleView.cs | 4 ++-- .../Controls/ImageScrollBar.cs | 2 +- src/Tizen.NUI.Components/Controls/Popup.cs | 2 +- src/Tizen.NUI.Components/Controls/Progress.cs | 15 +++++++-------- src/Tizen.NUI.Components/Controls/RadioButton.cs | 4 ++-- .../Controls/RadioButtonGroup.cs | 6 +++--- .../Controls/ScrollableBase.cs | 12 ++++++++---- src/Tizen.NUI.Components/Controls/SelectButton.cs | 11 +++++++---- src/Tizen.NUI.Components/Controls/SelectGroup.cs | 22 ++++++++++++---------- src/Tizen.NUI.Components/Controls/Slider.cs | 2 +- src/Tizen.NUI.Components/Controls/Switch.cs | 2 +- src/Tizen.NUI.Components/Controls/Tab.cs | 2 +- src/Tizen.NUI.Components/Controls/Toast.cs | 6 ++---- src/Tizen.NUI.Components/Utils/StyleManager.cs | 2 +- src/Tizen.NUI.Wearable/src/public/WearableList.cs | 2 +- 20 files changed, 64 insertions(+), 58 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/Button.cs b/src/Tizen.NUI.Components/Controls/Button.cs index 13526bb..1d478d7 100755 --- a/src/Tizen.NUI.Components/Controls/Button.cs +++ b/src/Tizen.NUI.Components/Controls/Button.cs @@ -1175,7 +1175,7 @@ namespace Tizen.NUI.Components /// 8 protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { - ButtonStyle buttonStyle = StyleManager.Instance.GetViewStyle(style) as ButtonStyle; + ButtonStyle buttonStyle = StyleManager.Instance.GetViewStyle(StyleName) as ButtonStyle; if (buttonStyle != null) { Style.CopyFrom(buttonStyle); diff --git a/src/Tizen.NUI.Components/Controls/CheckBox.cs b/src/Tizen.NUI.Components/Controls/CheckBox.cs index a5a6bac..acb5f1e 100755 --- a/src/Tizen.NUI.Components/Controls/CheckBox.cs +++ b/src/Tizen.NUI.Components/Controls/CheckBox.cs @@ -58,11 +58,11 @@ namespace Tizen.NUI.Components { get { - return itemGroup as CheckBoxGroup; + return base.ItemGroup as CheckBoxGroup; } internal set { - itemGroup = value; + base.ItemGroup = value; } } } diff --git a/src/Tizen.NUI.Components/Controls/CheckBoxGroup.cs b/src/Tizen.NUI.Components/Controls/CheckBoxGroup.cs index 20f8678..bf3a9bc 100755 --- a/src/Tizen.NUI.Components/Controls/CheckBoxGroup.cs +++ b/src/Tizen.NUI.Components/Controls/CheckBoxGroup.cs @@ -84,7 +84,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public CheckBox GetItem(int index) { - return itemGroup[index] as CheckBox; + return ItemGroup[index] as CheckBox; } /// @@ -97,9 +97,9 @@ namespace Tizen.NUI.Components public int[] GetCheckedIndices() { List selectedItemsList = new List(); - for (int i = 0; i < itemGroup.Count; i++) + for (int i = 0; i < ItemGroup.Count; i++) { - if (itemGroup[i].IsSelected) + if (ItemGroup[i].IsSelected) { selectedItemsList.Add(i); } @@ -120,7 +120,7 @@ namespace Tizen.NUI.Components { List selectedList = new List(); - foreach (CheckBox check in itemGroup) + foreach (CheckBox check in ItemGroup) { if (check.IsSelected) { @@ -140,7 +140,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public bool IsCheckedAll() { - foreach (CheckBox cb in itemGroup) + foreach (CheckBox cb in ItemGroup) { if (!cb.IsSelected) { @@ -159,7 +159,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public void CheckAll(bool state) { - foreach (CheckBox cb in itemGroup) + foreach (CheckBox cb in ItemGroup) { cb.IsSelected = state; } diff --git a/src/Tizen.NUI.Components/Controls/Control.cs b/src/Tizen.NUI.Components/Controls/Control.cs index 4e62577..9d777b1 100755 --- a/src/Tizen.NUI.Components/Controls/Control.cs +++ b/src/Tizen.NUI.Components/Controls/Control.cs @@ -44,7 +44,7 @@ namespace Tizen.NUI.Components /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - protected string style; + protected string StyleName { get; set; } private TapGestureDetector tapGestureDetector = new TapGestureDetector(); @@ -109,9 +109,9 @@ namespace Tizen.NUI.Components } ApplyStyle(viewStyle); - this.style = styleSheet; + this.StyleName = styleSheet; - Initialize(style); + Initialize(StyleName); } /// Internal used. diff --git a/src/Tizen.NUI.Components/Controls/DropDown.cs b/src/Tizen.NUI.Components/Controls/DropDown.cs index 6fc1eba..2e12a57 100755 --- a/src/Tizen.NUI.Components/Controls/DropDown.cs +++ b/src/Tizen.NUI.Components/Controls/DropDown.cs @@ -829,12 +829,12 @@ namespace Tizen.NUI.Components /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public int Index; + public int Index { get; set; } /// Clicked item text string of DropDown's list /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public string Text; + public string Text { get; set; } } #endregion diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs index 2a9a3c5..c8fdac0 100755 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs @@ -814,7 +814,7 @@ namespace Tizen.NUI.Components /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder ClickedView; + public ViewHolder ClickedView { get; set; } } /// @@ -831,7 +831,7 @@ namespace Tizen.NUI.Components /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder TouchedView; + public ViewHolder TouchedView { get; set; } } /// diff --git a/src/Tizen.NUI.Components/Controls/ImageScrollBar.cs b/src/Tizen.NUI.Components/Controls/ImageScrollBar.cs index 43ce43c..4d465b0 100755 --- a/src/Tizen.NUI.Components/Controls/ImageScrollBar.cs +++ b/src/Tizen.NUI.Components/Controls/ImageScrollBar.cs @@ -473,7 +473,7 @@ namespace Tizen.NUI.Components /// 8 protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { - ScrollBarStyle tempStyle = StyleManager.Instance.GetViewStyle(style) as ScrollBarStyle; + ScrollBarStyle tempStyle = StyleManager.Instance.GetViewStyle(StyleName) as ScrollBarStyle; if (tempStyle != null) { Style.CopyFrom(tempStyle); diff --git a/src/Tizen.NUI.Components/Controls/Popup.cs b/src/Tizen.NUI.Components/Controls/Popup.cs index 9057961..5863687 100755 --- a/src/Tizen.NUI.Components/Controls/Popup.cs +++ b/src/Tizen.NUI.Components/Controls/Popup.cs @@ -737,7 +737,7 @@ namespace Tizen.NUI.Components /// 8 protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { - PopupStyle popupStyle = StyleManager.Instance.GetViewStyle(style) as PopupStyle; + PopupStyle popupStyle = StyleManager.Instance.GetViewStyle(StyleName) as PopupStyle; if (popupStyle != null) { string strSaveTitleText = TitleText; diff --git a/src/Tizen.NUI.Components/Controls/Progress.cs b/src/Tizen.NUI.Components/Controls/Progress.cs index 4dbf591..52c3c8d 100755 --- a/src/Tizen.NUI.Components/Controls/Progress.cs +++ b/src/Tizen.NUI.Components/Controls/Progress.cs @@ -120,9 +120,8 @@ namespace Tizen.NUI.Components return instance.state; }); - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected ProgressStatusType state = ProgressStatusType.Determinate; + /// This needs to be considered more if public-open is necessary. + private ProgressStatusType state = ProgressStatusType.Determinate; private const float round = 0.5f; private ImageView trackImage = null; @@ -423,7 +422,7 @@ namespace Tizen.NUI.Components /// 8 protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { - ProgressStyle tempStyle = StyleManager.Instance.GetViewStyle(style) as ProgressStyle; + ProgressStyle tempStyle = StyleManager.Instance.GetViewStyle(StyleName) as ProgressStyle; if (null != tempStyle) { Style.CopyFrom(tempStyle); @@ -435,9 +434,9 @@ namespace Tizen.NUI.Components /// Change Image status. It can be override. /// /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + /// This needs to be considered more if public-open is necessary. [EditorBrowsable(EditorBrowsableState.Never)] - protected virtual void UpdateStates() + private void UpdateStates() { ChangeImageState(state); } @@ -446,9 +445,9 @@ namespace Tizen.NUI.Components /// Update progress value /// /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + /// This needs to be considered more if public-open is necessary. [EditorBrowsable(EditorBrowsableState.Never)] - protected virtual void UpdateValue() + private void UpdateValue() { if (null == trackImage || null == progressImage) { diff --git a/src/Tizen.NUI.Components/Controls/RadioButton.cs b/src/Tizen.NUI.Components/Controls/RadioButton.cs index f11d647..ee69f22 100755 --- a/src/Tizen.NUI.Components/Controls/RadioButton.cs +++ b/src/Tizen.NUI.Components/Controls/RadioButton.cs @@ -69,11 +69,11 @@ namespace Tizen.NUI.Components { get { - return itemGroup as RadioButtonGroup; + return base.ItemGroup as RadioButtonGroup; } internal set { - itemGroup = value; + base.ItemGroup = value; } } diff --git a/src/Tizen.NUI.Components/Controls/RadioButtonGroup.cs b/src/Tizen.NUI.Components/Controls/RadioButtonGroup.cs index fcf87ad..18a031d 100755 --- a/src/Tizen.NUI.Components/Controls/RadioButtonGroup.cs +++ b/src/Tizen.NUI.Components/Controls/RadioButtonGroup.cs @@ -54,7 +54,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public RadioButton GetItem(int index) { - return itemGroup[index] as RadioButton; + return ItemGroup[index] as RadioButton; } /// @@ -96,12 +96,12 @@ namespace Tizen.NUI.Components protected override void SelectionHandler(SelectButton selection) { RadioButton radio = selection as RadioButton; - if (!itemGroup.Contains(radio)) + if (!ItemGroup.Contains(radio)) { return; } - foreach (RadioButton btn in itemGroup) + foreach (RadioButton btn in ItemGroup) { if (btn != null && btn != radio && btn.IsEnabled == true) { diff --git a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs index 2583528..8aced58 100755 --- a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs +++ b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs @@ -359,7 +359,9 @@ namespace Tizen.NUI.Components // If false then can only flick pages when the current animation/scroll as ended. private bool flickWhenAnimating = false; private PropertyNotification propertyNotification; - protected float finalTargetPosition; + + // Let's consider more whether this needs to be set as protected. + private float finalTargetPosition; /// /// [Draft] Constructor @@ -507,7 +509,9 @@ namespace Tizen.NUI.Components private bool readyToNotice = false; - protected float noticeAnimationEndBeforePosition = 0.0f; + private float noticeAnimationEndBeforePosition = 0.0f; + // Let's consider more whether this needs to be set as protected. + public float NoticeAnimationEndBeforePosition { get => noticeAnimationEndBeforePosition; set => noticeAnimationEndBeforePosition = value; } private void OnScroll() { @@ -521,8 +525,8 @@ namespace Tizen.NUI.Components { // Check whether we reached pre-reached target position if (readyToNotice && - mScrollingChild.CurrentPosition.Y <= finalTargetPosition + noticeAnimationEndBeforePosition && - mScrollingChild.CurrentPosition.Y >= finalTargetPosition - noticeAnimationEndBeforePosition) + mScrollingChild.CurrentPosition.Y <= finalTargetPosition + NoticeAnimationEndBeforePosition && + mScrollingChild.CurrentPosition.Y >= finalTargetPosition - NoticeAnimationEndBeforePosition) { //Notice first readyToNotice = false; diff --git a/src/Tizen.NUI.Components/Controls/SelectButton.cs b/src/Tizen.NUI.Components/Controls/SelectButton.cs index 9f3a147..4c4bde6 100755 --- a/src/Tizen.NUI.Components/Controls/SelectButton.cs +++ b/src/Tizen.NUI.Components/Controls/SelectButton.cs @@ -30,13 +30,16 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public class SelectButton : Button { + private SelectGroup itemGroup = null; + /// /// Item group which is used to manager all SelectButton in it. /// /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - protected SelectGroup itemGroup = null; + protected SelectGroup ItemGroup { get => itemGroup; set => itemGroup = value; } + static SelectButton() { } /// @@ -92,9 +95,9 @@ namespace Tizen.NUI.Components { get { - if (itemGroup != null) + if (ItemGroup != null) { - return itemGroup.GetIndex(this); + return ItemGroup.GetIndex(this); } return -1; @@ -217,7 +220,7 @@ namespace Tizen.NUI.Components /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsSelected; + public bool IsSelected { get; set; } } } } diff --git a/src/Tizen.NUI.Components/Controls/SelectGroup.cs b/src/Tizen.NUI.Components/Controls/SelectGroup.cs index f5abaa7..09ea95d 100755 --- a/src/Tizen.NUI.Components/Controls/SelectGroup.cs +++ b/src/Tizen.NUI.Components/Controls/SelectGroup.cs @@ -32,11 +32,13 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public abstract class SelectGroup { + private List itemGroup; + /// Selection group composed of items /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - protected List itemGroup; + protected List ItemGroup { get => itemGroup; set => itemGroup = value; } private int selectedIndex; @@ -46,7 +48,7 @@ namespace Tizen.NUI.Components /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public int Count => itemGroup.Count; + public int Count => ItemGroup.Count; /// /// Get the index of currently or latest selected item. @@ -64,7 +66,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected SelectGroup() { - itemGroup = new List(); + ItemGroup = new List(); } /// @@ -77,7 +79,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public bool Contains(SelectButton selection) { - return itemGroup.Contains(selection); + return ItemGroup.Contains(selection); } /// @@ -90,7 +92,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public int GetIndex(SelectButton selection) { - return itemGroup.IndexOf(selection); + return ItemGroup.IndexOf(selection); } /// @@ -103,11 +105,11 @@ namespace Tizen.NUI.Components protected void AddSelection(SelectButton selection) { if (null == selection) return; - if (itemGroup.Contains(selection)) + if (ItemGroup.Contains(selection)) { return; } - itemGroup.Add(selection); + ItemGroup.Add(selection); selection.SelectedEvent += OnSelectedEvent; } @@ -120,12 +122,12 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected void RemoveSelection(SelectButton selection) { - if (!itemGroup.Contains(selection)) + if (!ItemGroup.Contains(selection)) { return; } selection.SelectedEvent -= OnSelectedEvent; - itemGroup.Remove(selection); + ItemGroup.Remove(selection); } /// @@ -164,7 +166,7 @@ namespace Tizen.NUI.Components /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public int SelectedIndex; + public int SelectedIndex { get; set; } } } } diff --git a/src/Tizen.NUI.Components/Controls/Slider.cs b/src/Tizen.NUI.Components/Controls/Slider.cs index 74d605b..f69a8e0 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.cs @@ -838,7 +838,7 @@ namespace Tizen.NUI.Components /// 8 protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { - SliderStyle sliderStyle = StyleManager.Instance.GetViewStyle(style) as SliderStyle; + SliderStyle sliderStyle = StyleManager.Instance.GetViewStyle(StyleName) as SliderStyle; if (sliderStyle != null) { Style?.CopyFrom(sliderStyle); diff --git a/src/Tizen.NUI.Components/Controls/Switch.cs b/src/Tizen.NUI.Components/Controls/Switch.cs index da159ae..3591d17 100755 --- a/src/Tizen.NUI.Components/Controls/Switch.cs +++ b/src/Tizen.NUI.Components/Controls/Switch.cs @@ -359,7 +359,7 @@ namespace Tizen.NUI.Components /// 8 protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { - SwitchStyle switchStyle = StyleManager.Instance.GetViewStyle(style) as SwitchStyle; + SwitchStyle switchStyle = StyleManager.Instance.GetViewStyle(StyleName) as SwitchStyle; if (null != switchStyle) { Style.CopyFrom(switchStyle); diff --git a/src/Tizen.NUI.Components/Controls/Tab.cs b/src/Tizen.NUI.Components/Controls/Tab.cs index d306d30..8834b37 100755 --- a/src/Tizen.NUI.Components/Controls/Tab.cs +++ b/src/Tizen.NUI.Components/Controls/Tab.cs @@ -468,7 +468,7 @@ namespace Tizen.NUI.Components /// 8 protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { - TabStyle tabStyle = StyleManager.Instance.GetViewStyle(style) as TabStyle; + TabStyle tabStyle = StyleManager.Instance.GetViewStyle(StyleName) as TabStyle; if (tabStyle != null) { Style.CopyFrom(tabStyle); diff --git a/src/Tizen.NUI.Components/Controls/Toast.cs b/src/Tizen.NUI.Components/Controls/Toast.cs index d357239..9b6fb2a 100755 --- a/src/Tizen.NUI.Components/Controls/Toast.cs +++ b/src/Tizen.NUI.Components/Controls/Toast.cs @@ -74,9 +74,7 @@ namespace Tizen.NUI.Components } private Window window = null; - /// text labels - protected TextLabel[] textLabels = null; - private TextLabel textLabel = null; + private TextLabel textLabel = null; private string strText = null; private Timer timer = null; private readonly uint duration = 3000; @@ -337,7 +335,7 @@ namespace Tizen.NUI.Components /// /// The default toast style. /// 8 - protected override ViewStyle CreateViewStyle() + protected override ViewStyle GetViewStyle() { return new ToastStyle(); } diff --git a/src/Tizen.NUI.Components/Utils/StyleManager.cs b/src/Tizen.NUI.Components/Utils/StyleManager.cs index b176283..ab59778 100755 --- a/src/Tizen.NUI.Components/Utils/StyleManager.cs +++ b/src/Tizen.NUI.Components/Utils/StyleManager.cs @@ -230,7 +230,7 @@ namespace Tizen.NUI.Components /// CurrentTheme /// /// 8 - public string CurrentTheme; + public string CurrentTheme { get; set; } } internal static string GetFrameworkResourcePath(string resourceFileName) diff --git a/src/Tizen.NUI.Wearable/src/public/WearableList.cs b/src/Tizen.NUI.Wearable/src/public/WearableList.cs index e7784a8..fdc6acc 100644 --- a/src/Tizen.NUI.Wearable/src/public/WearableList.cs +++ b/src/Tizen.NUI.Wearable/src/public/WearableList.cs @@ -47,7 +47,7 @@ namespace Tizen.NUI.Wearable mContainer.PositionUsesPivotPoint = true; mContainer.ParentOrigin = Tizen.NUI.ParentOrigin.Center; mContainer.PivotPoint = Tizen.NUI.PivotPoint.TopCenter; - noticeAnimationEndBeforePosition = 50; + NoticeAnimationEndBeforePosition = 50; ScrollAvailableArea = new Vector2( 0, mContainer.SizeHeight); -- 2.7.4