[NUI] replace field declaration with property (#1701)
authorwoohyun <woo_hyun0705@naver.com>
Fri, 12 Jun 2020 05:25:28 +0000 (14:25 +0900)
committerGitHub <noreply@github.com>
Fri, 12 Jun 2020 05:25:28 +0000 (14:25 +0900)
This would fix CA1051 warnings which indicates that
"Do not declare visible instance fields".

20 files changed:
src/Tizen.NUI.Components/Controls/Button.cs
src/Tizen.NUI.Components/Controls/CheckBox.cs
src/Tizen.NUI.Components/Controls/CheckBoxGroup.cs
src/Tizen.NUI.Components/Controls/Control.cs
src/Tizen.NUI.Components/Controls/DropDown.cs
src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs
src/Tizen.NUI.Components/Controls/ImageScrollBar.cs
src/Tizen.NUI.Components/Controls/Popup.cs
src/Tizen.NUI.Components/Controls/Progress.cs
src/Tizen.NUI.Components/Controls/RadioButton.cs
src/Tizen.NUI.Components/Controls/RadioButtonGroup.cs
src/Tizen.NUI.Components/Controls/ScrollableBase.cs
src/Tizen.NUI.Components/Controls/SelectButton.cs
src/Tizen.NUI.Components/Controls/SelectGroup.cs
src/Tizen.NUI.Components/Controls/Slider.cs
src/Tizen.NUI.Components/Controls/Switch.cs
src/Tizen.NUI.Components/Controls/Tab.cs
src/Tizen.NUI.Components/Controls/Toast.cs
src/Tizen.NUI.Components/Utils/StyleManager.cs
src/Tizen.NUI.Wearable/src/public/WearableList.cs

index 13526bb..1d478d7 100755 (executable)
@@ -1175,7 +1175,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         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);
index a5a6bac..acb5f1e 100755 (executable)
@@ -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;
             }
         }
     }
index 20f8678..bf3a9bc 100755 (executable)
@@ -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;
         }
 
         /// <summary>
@@ -97,9 +97,9 @@ namespace Tizen.NUI.Components
         public int[] GetCheckedIndices()
         {
             List<int> selectedItemsList = new List<int>();
-            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<CheckBox> selectedList = new List<CheckBox>();
 
-            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;
             }
index 4e62577..9d777b1 100755 (executable)
@@ -44,7 +44,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         /// 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.
index 6fc1eba..2e12a57 100755 (executable)
@@ -829,12 +829,12 @@ namespace Tizen.NUI.Components
             /// <since_tizen> 6 </since_tizen>
             /// 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; }
             /// <summary> Clicked item text string of DropDown's list </summary>
             /// <since_tizen> 6 </since_tizen>
             /// 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
 
index 2a9a3c5..c8fdac0 100755 (executable)
@@ -814,7 +814,7 @@ namespace Tizen.NUI.Components
             /// <since_tizen> 6 </since_tizen>
             /// 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; }
         }
 
         /// <summary>
@@ -831,7 +831,7 @@ namespace Tizen.NUI.Components
             /// <since_tizen> 6 </since_tizen>
             /// 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; }
         }
 
         /// <summary>
index 43ce43c..4d465b0 100755 (executable)
@@ -473,7 +473,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         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);
index 9057961..5863687 100755 (executable)
@@ -737,7 +737,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         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;
index 4dbf591..52c3c8d 100755 (executable)
@@ -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
         /// <since_tizen> 8 </since_tizen>
         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.
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
-        /// 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
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
-        /// 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)
             {
index f11d647..ee69f22 100755 (executable)
@@ -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;
             }
         }
 
index fcf87ad..18a031d 100755 (executable)
@@ -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;
         }
 
         /// <summary>
@@ -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)
                 {
index 2583528..8aced58 100755 (executable)
@@ -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;
 
         /// <summary>
         /// [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;
index 9f3a147..4c4bde6 100755 (executable)
@@ -30,13 +30,16 @@ namespace Tizen.NUI.Components
     [EditorBrowsable(EditorBrowsableState.Never)]
     public class SelectButton : Button
     {
+        private SelectGroup itemGroup = null;
+
         /// <summary>
         /// Item group which is used to manager all SelectButton in it.
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
         /// 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() { }
 
         /// <summary>
@@ -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
             /// <since_tizen> 6 </since_tizen>
             /// 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; }
         }
     }
 }
index f5abaa7..09ea95d 100755 (executable)
@@ -32,11 +32,13 @@ namespace Tizen.NUI.Components
     [EditorBrowsable(EditorBrowsableState.Never)]
     public abstract class SelectGroup
     {
+        private List<SelectButton> itemGroup;
+
         /// <summary> Selection group composed of items </summary>
         /// <since_tizen> 6 </since_tizen>
         /// 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<SelectButton> itemGroup;
+        protected List<SelectButton> ItemGroup { get => itemGroup; set => itemGroup = value; }
 
         private int selectedIndex;
 
@@ -46,7 +48,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         /// 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;
 
         /// <summary>
         /// 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<SelectButton>();
+            ItemGroup = new List<SelectButton>();
         }
 
         /// <summary>
@@ -77,7 +79,7 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool Contains(SelectButton selection)
         {
-            return itemGroup.Contains(selection);
+            return ItemGroup.Contains(selection);
         }
 
         /// <summary>
@@ -90,7 +92,7 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public int GetIndex(SelectButton selection)
         {
-            return itemGroup.IndexOf(selection);
+            return ItemGroup.IndexOf(selection);
         }
 
         /// <summary>
@@ -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);
         }
 
         /// <summary>
@@ -164,7 +166,7 @@ namespace Tizen.NUI.Components
             /// <since_tizen> 6 </since_tizen>
             /// 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; }
         }
     }
 }
index 74d605b..f69a8e0 100755 (executable)
@@ -838,7 +838,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         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);
index da159ae..3591d17 100755 (executable)
@@ -359,7 +359,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         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);
index d306d30..8834b37 100755 (executable)
@@ -468,7 +468,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         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);
index d357239..9b6fb2a 100755 (executable)
@@ -74,9 +74,7 @@ namespace Tizen.NUI.Components
         }
 
         private Window window = null;
-        /// <summary> text labels </summary>
-        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
         /// </summary>
         /// <returns>The default toast style.</returns>
         /// <since_tizen> 8 </since_tizen>
-        protected override ViewStyle CreateViewStyle()
+        protected override ViewStyle GetViewStyle()
         {
             return new ToastStyle();
         }
index b176283..ab59778 100755 (executable)
@@ -230,7 +230,7 @@ namespace Tizen.NUI.Components
             /// CurrentTheme
             /// </summary>
             /// <since_tizen> 8 </since_tizen>
-            public string CurrentTheme;
+            public string CurrentTheme { get; set; }
         }
 
         internal static string GetFrameworkResourcePath(string resourceFileName)
index e7784a8..fdc6acc 100644 (file)
@@ -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);