--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using SettingCore;
+using SettingCore.Views;
+
+namespace SettingWiFi
+{
+ public class InfoItem : BaseComponent
+ {
+ private TextField textField;
+ private TextLabel primary = null;
+ private TextLabel secondaryLabel = null;
+
+ private readonly Color underlineColor = new Color("#FF6200");
+ private readonly Color disabledItemColor = new Color("#CACACA");
+ public string Value
+ {
+ get
+ {
+ return textField.Text;
+ }
+ set
+ {
+ textField.Text = value;
+ }
+ }
+
+ private TextLabel GetLabel(string titleText, bool isEnabled)
+ {
+ var label = new TextLabel
+ {
+ AccessibilityHidden = true,
+ ThemeChangeSensitive = true,
+ Text = titleText,
+ Margin = new Extents(16, 0, 0, 0).SpToPx(),
+ PixelSize = 24.SpToPx(),
+ };
+ if (!isEnabled)
+ {
+ label.TextColor = disabledItemColor;
+ }
+
+ return label;
+ }
+ public InfoItem(string primaryText, bool isEnabled , string curvalue, bool fillValue, bool drawUnderline = true)
+ : base()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ };
+ Padding = new Extents(0, 0, 8, 8).SpToPx();
+
+ primary = GetLabel(primaryText, isEnabled);
+ Add(primary);
+
+ if (!isEnabled)
+ {
+ secondaryLabel = GetLabel(curvalue, false);
+ Add(secondaryLabel);
+ }
+ else
+ {
+ var textFieldView = new View
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Margin = new Extents(16, 16, 0, 0).SpToPx(),
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ },
+ };
+ textField = new TextField()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 48,
+ BackgroundColor = Color.White,
+ PlaceholderText = curvalue,
+ Padding = new Extents(16, 16, 0, 0).SpToPx(),
+ };
+
+ textFieldView.Add(textField);
+ if (fillValue)
+ {
+ textField.Text = curvalue;
+ }
+ if (drawUnderline)
+ {
+ textFieldView.Add(CreateUnderline());
+ }
+
+ Add(textFieldView);
+ }
+ }
+
+ private View CreateUnderline()
+ {
+ return new View()
+ {
+ BorderlineColor = underlineColor,
+ BorderlineWidth = 1,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 1,
+ };
+ }
+ }
+}
using SettingCore;
+using SettingCore.Views;
using System;
using System.Collections.Generic;
using Tizen;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
using Tizen.NUI.Components;
-//using SettingWiFi.res.locale;
using static SettingWiFi.Logger;
namespace SettingWiFi
{
internal class InfoPage : ContentPage
{
- Switch mOnOffSwitch;
- CollectionView mApInfoListView;
-
private AP mAp;
private WiFi mWifi;
- ApInfoSource mApInfoSource;
-
- bool mIsOriginOnOffSwitchSelected;
+ private View mInfoView;
+ private ScrollableBase mScrollableInfo;
+ private Switch mOnOffSwitch;
+ private InfoItem[] staticItems = new InfoItem[9];
+ private InfoItem[] dynamicItems = new InfoItem[4];
+ private bool mIsOriginOnOffSwitchSelected;
internal InfoPage(WiFi wifi)
{
internal void CreateComponents(AP ap)
{
mAp = ap;
-
- var appBar = new AppBar()
- {
- Title = Resources.IDS_WIFI_HEADER_WI_FI_NETWORK_INFO_ABB,
- };
-
- AppBarStyle appBarStyle = (AppBarStyle)ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
- Button backButton = new Button(((AppBarStyle)appBarStyle).BackButton);
-
- backButton.Clicked += OnBackClicked;
- appBar.NavigationContent = backButton;
-
- View infoView = new View()
+ mInfoView = new View()
{
Layout = new LinearLayout()
{
HeightSpecification = LayoutParamPolicies.MatchParent,
};
- mApInfoSource = new ApInfoSource(mWifi, mAp);
-
- mApInfoListView = new CollectionView()
+ mScrollableInfo = new ScrollableBase()
{
- ItemsSource = mApInfoSource,
- ItemsLayouter = new LinearLayouter(),
- ItemTemplate = CreateItemTemplate(),
- IsGrouped = false,
- ScrollingDirection = ScrollableBase.Direction.Vertical,
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = LayoutParamPolicies.MatchParent,
- };
+ ScrollingDirection = ScrollableBase.Direction.Vertical,
+ HideScrollbar = false,
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ },
- var header = GetHeader();
+ };
+ mIsOriginOnOffSwitchSelected = ap.StaticIPConfig;
+ AddHeader();
+ AddInfo();
var forgetButton = new Button()
{
};
forgetButton.Clicked += OnForgetClicked;
+ mInfoView.Add(forgetButton);
- infoView.Add(header);
- infoView.Add(mApInfoListView);
- infoView.Add(forgetButton);
-
- AppBar = appBar;
- Content = infoView;
-
- mApInfoSource.ShowInfo(mOnOffSwitch.IsSelected, false);
- }
-
- private void OnInfoItemClicked(object sender, ClickedEventArgs e)
- {
- Debug("OnInfoItemClicked");
- DefaultLinearItem infoItem = (DefaultLinearItem)sender;
- var info = infoItem.BindingContext as ApInfoText;
- if (info == null)
- {
- Error("Info null");
- }
- else
- {
- Debug("Ok info");
- if(IsFieldEditable(info.InfoTitle))
- {
- RoundedDialogPage.ShowDialog(CreateInfoInputPage(info.InfoTitle, info.InfoValue));
- //NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(CreateInfoInputPage(info.InfoTitle, info.InfoValue));
- }
- }
+ AppBar = CreateAppBar();
+ Content = mInfoView;
}
- private bool IsFieldEditable(string fieldName)
+ private AppBar CreateAppBar()
{
- // Checks if particular field on info page is editable or not.
- if (fieldName == Resources.IDS_WIFI_BODY_MAC_ADDRESS)
- {
- return false;
- }
- else
+ var appBar = new AppBar()
{
- if (mOnOffSwitch.IsSelected)
- {
- return true;
- }
- else
- {
- if(fieldName == Resources.IDS_ST_SBODY_PROXY_ADDRESS || fieldName == Resources.IDS_ST_SBODY_PROXY_PORT)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
-
- private Page CreateInfoInputPage(string title, string value)
- {
- var page = new InfoInputPage(mAp, mApInfoSource, mOnOffSwitch.IsSelected);
- page.CreateComponents(title, value);
- return page;
- }
+ Title = Resources.IDS_WIFI_HEADER_WI_FI_NETWORK_INFO_ABB,
+ };
+ AppBarStyle appBarStyle = (AppBarStyle)ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
+ Button backButton = new Button(((AppBarStyle)appBarStyle).BackButton);
- private DataTemplate CreateItemTemplate()
- {
- return new DataTemplate(() =>
- {
- DefaultLinearItem item = new DefaultLinearItem()
- {
- WidthSpecification = LayoutParamPolicies.MatchParent,
- };
- item.Label.SetBinding(TextLabel.TextProperty, "InfoTitle");
- item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
- item.SubLabel.SetBinding(TextLabel.TextProperty, "InfoValue");
- item.SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;
- item.IsSelectable = false;
- item.Clicked += OnInfoItemClicked;
- return item;
- });
+ backButton.Clicked += OnBackClicked;
+ appBar.NavigationContent = backButton;
+ return appBar;
}
- private RecyclerViewItem GetHeader()
+ private void AddHeader()
{
- var header = new RecyclerViewItem()
+ Debug("");
+ View headerView = new View()
{
Layout = new LinearLayout()
{
mOnOffSwitch.SelectedChanged += OnSwitchClicked;
toggle.Extra = mOnOffSwitch;
- header.Add(toggle);
- return header;
+ headerView.Add(CreateAPTitleView());
+ headerView.Add(toggle);
+
+ mInfoView.Add(headerView);
+ }
+
+ private View CreateAPTitleView()
+ {
+ var textFieldView = new View
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Margin = new Extents(16, 16, 16, 16).SpToPx(),
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ VerticalAlignment = VerticalAlignment.Center,
+ },
+ };
+
+ string iconpath = Resources.GetPath() + "/images/rectangle_for_info_page.png";
+ var icon = new ImageView(iconpath)
+ {
+ Size2D = new Size2D(32, 32).SpToPx(),
+ Margin = new Extents(0, 5, 0, 0).SpToPx(),
+ };
+
+ TextLabel title = new TextLabel()
+ {
+ Text = mAp.Essid,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ Margin = new Extents(16, 0, 0, 0),
+ };
+
+ textFieldView.Add(icon);
+ textFieldView.Add(title);
+ return textFieldView;
+ }
+
+ private void AddInfo()
+ {
+ mScrollableInfo.RemoveAllChildren();
+ mWifi.SyncAPObjectState(mAp);
+
+ if (mOnOffSwitch.IsSelected)
+ {
+ // Static Info to show
+ ShowStaticInfo();
+ }
+ else
+ {
+ ShowDynamicInfo();
+ }
+ }
+ private void ShowStaticInfo()
+ {
+ GetStaticInfo();
+ mInfoView.Add(mScrollableInfo);
+ }
+
+ private void ShowDynamicInfo()
+ {
+ Debug("+");
+ GetDynamicInfo();
+ mInfoView.Add(mScrollableInfo);
+ }
+
+ private void GetStaticInfo()
+ {
+ Debug("+");
+ staticItems[0] = new InfoItem(Resources.IDS_WIFI_BODY_IP_ADDRESS, true, mAp.IPv4, true);
+ staticItems[1] = new InfoItem(Resources.IDS_WIFI_BODY_SUBNET_MASK, true, mAp.SubnetMask, true);
+ staticItems[2] = new InfoItem(Resources.IDS_WIFI_BODY_GATEWAY, true, mAp.GatewayAddress, true);
+ staticItems[3] = new InfoItem(Resources.IDS_ST_BODY_NETWORK_PREFIX_LENGTH, true, mAp.NetworkPrefixLength, true);
+ staticItems[4] = new InfoItem(Resources.IDS_WIFI_BODY_DNS_1, true, mAp.Dns1, true);
+ staticItems[5] = new InfoItem(Resources.IDS_WIFI_BODY_DNS_2, true, mAp.Dns2, true);
+ staticItems[6] = new InfoItem(Resources.IDS_WIFI_BODY_MAC_ADDRESS, false, mAp.Bssid, true);
+ if(mAp.ProxyAddress?.Length > 0)
+ {
+ staticItems[7] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_ADDRESS, true, mAp.ProxyAddress, true, false);
+ }
+ else
+ {
+ staticItems[7] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_ADDRESS, true, "proxy.example.com", false, false);
+ }
+ if(mAp.ProxyPort > 0)
+ {
+ string port = "" + mAp.ProxyPort;
+ staticItems[8] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_PORT, true, port, true, false);
+ }
+ else
+ {
+ staticItems[8] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_PORT, true, "8080", false, false);
+ }
+
+
+ foreach (var item in staticItems)
+ {
+ mScrollableInfo.Add(item);
+ }
+ }
+
+ private void GetDynamicInfo()
+ {
+ Debug("+");
+ dynamicItems[0] = new InfoItem(Resources.IDS_WIFI_BODY_IP_ADDRESS, false, mAp.IPv4, true);
+ dynamicItems[1] = new InfoItem(Resources.IDS_WIFI_BODY_MAC_ADDRESS, false, mAp.Bssid, true);
+
+ if (mAp.ProxyAddress?.Length > 0)
+ {
+ dynamicItems[2] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_ADDRESS, true, mAp.ProxyAddress, true, false);
+ }
+ else
+ {
+ dynamicItems[2] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_ADDRESS, true, "proxy.example.com", false, false);
+ }
+ if (mAp.ProxyPort > 0)
+ {
+ string port = "" + mAp.ProxyPort;
+ new InfoItem(Resources.IDS_ST_SBODY_PROXY_PORT, true, port,true, false);
+ }
+ else
+ {
+ dynamicItems[3] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_PORT, true, "8080", false, false);
+ }
+ foreach (var item in dynamicItems)
+ {
+ mScrollableInfo.Add(item);
+ }
}
private void OnSwitchClicked(object sender, SelectedChangedEventArgs e)
{
- mAp.StaticIPConfig = mOnOffSwitch.IsSelected;
- mApInfoSource.Clear();
- mApInfoSource.ShowInfo(e.IsSelected, true);
+ Debug("");
+ if (mAp.IsConnected())
+ {
+ mAp.StaticIPConfig = mOnOffSwitch.IsSelected;
+ mWifi.UpdateIpConfigMethod(mAp, mOnOffSwitch.IsSelected);
+ mWifi.UpdateApInfo(mAp);
+ }
+
+ AddInfo();
}
private ContentPage CreateForgetPage()
private void OnBackClicked(object source, ClickedEventArgs args)
{
- if (mIsOriginOnOffSwitchSelected != mOnOffSwitch.IsSelected)
- {
- UpdateApInfo(mOnOffSwitch.IsSelected);
- }
- mAp.StaticIPConfig = mOnOffSwitch.IsSelected;
- NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
- }
-
- private void UpdateApInfo(bool isStaticIpConfig)
- {
- Debug("");
+ Debug("+");
if (mAp.IsConnected())
{
- mWifi.UpdateIpConfigMethod(mAp, isStaticIpConfig);
- if (isStaticIpConfig)
+ if (mOnOffSwitch.IsSelected)
{
- GetStaticIpInfo();
+ UpdateStaticIpInfo();
}
+ else
+ {
+ UpdateDynamicIpInfo();
+ }
+
mWifi.UpdateApInfo(mAp);
}
+
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+ }
+
+ private void UpdateStaticIpInfo()
+ {
+ Debug("+");
+
+ mWifi.UpdateIPAddress(mAp, staticItems[0].Value);
+ mWifi.UpdateSubnetMask(mAp, staticItems[1].Value);
+ mWifi.UpdateGatewayAddress(mAp, staticItems[2].Value);
+ mWifi.UpdateDns1(mAp, staticItems[4].Value);
+ mWifi.UpdateDns2(mAp, staticItems[5].Value);
+ UpdateProxy(staticItems[7].Value, staticItems[8].Value);
}
- private void GetStaticIpInfo()
+ private void UpdateDynamicIpInfo()
{
- Debug("GetStaticIpInfo from mApInfoSource");
- var list = mApInfoSource.GetItemList();
- foreach (var info in list)
+ Debug("+");
+ UpdateProxy(dynamicItems[2].Value, dynamicItems[3].Value);
+ }
+
+ public void UpdateProxy(string proxy, string port)
+ {
+ if(proxy?.Length > 0)
{
- if (info.mUpdater != null)
- info.mUpdater(info.InfoValue);
+ int portNum;
+ if (Int32.TryParse(port, out portNum) == false)
+ {
+ Error("port parsing error");
+ return;
+ }
+ else
+ {
+ proxy = proxy + ":" + portNum;
+ }
+ Debug("Proxy: " + proxy);
+ mWifi.UpdateProxy(mAp, proxy);
}
}
-
private void OnForgetClicked(object source, ClickedEventArgs args)
{
Debug("Forget " + mAp.Essid);