{
internal class InfoInputPage : DialogPage
{
- internal InfoInputPage()
+ private AP mAp;
+ ApInfoSource mApInfoSource;
+
+ private TextField mValueField;
+ private string mTitle;
+ private bool mIsStaticIpConfig;
+
+ internal InfoInputPage(AP ap, ApInfoSource apInfoSource, bool isStaticIpConfig)
{
Debug("InfoInputPage");
+ mAp = ap;
+ mApInfoSource = apInfoSource;
+ mIsStaticIpConfig = isStaticIpConfig;
}
internal void CreateComponents(string title, string value)
{
+ mTitle = title;
var infoView = new RecyclerViewItem()
{
Layout = new LinearLayout()
HeightSpecification = LayoutParamPolicies.WrapContent,
};
- var valueField = new TextField()
+ var mValueField = new TextField()
{
WidthSpecification = 600,
PlaceholderText = value,
};
- infoView.Add(valueField);
+ infoView.Add(mValueField);
var cancelButton = new Button()
{
private void OnOkClicked(object sender, ClickedEventArgs e)
{
- Debug("OnOkClicked");
+ Debug("OnOkClicked " + mValueField.Text + " : " + mTitle);
+ UpdateInfo(mTitle, mValueField.Text);
+ mApInfoSource.Clear();
+ mApInfoSource.ShowInfo(mIsStaticIpConfig, true);
Navigator.Pop();
}
Debug("OnCancelClicked");
Navigator.Pop();
}
+
+ private void UpdateInfo(string fieldName, string value)
+ {
+ Debug("UpdateInfo");
+
+ if (fieldName == Resources.IDS_WIFI_BODY_IP_ADDRESS)
+ {
+ mAp.IPv4 = value;
+ }
+ else if (fieldName == Resources.IDS_WIFI_BODY_SUBNET_MASK)
+ {
+ mAp.SubnetMask = value;
+ }
+ else if (fieldName == Resources.IDS_WIFI_BODY_GATEWAY_ADDRESS)
+ {
+ mAp.GatewayAddress = value;
+ }
+ else if (fieldName == Resources.IDS_WIFI_BODY_DNS_1)
+ {
+ mAp.Dns1 = value;
+ }
+ else if (fieldName == Resources.IDS_WIFI_BODY_DNS_2)
+ {
+ mAp.Dns2 = value;
+ }
+ else if (fieldName == Resources.IDS_ST_SBODY_PROXY_ADDRESS)
+ {
+ mAp.ProxyAddress = value;
+ }
+ else if (fieldName == Resources.IDS_ST_SBODY_PROXY_PORT)
+ {
+ try
+ {
+ mAp.ProxyPort = int.Parse(value);
+ }
+ catch (Exception e)
+ {
+ Error("Exception occured while parsing port number " + e.Message);
+ }
+ }
+ else
+ {
+ Debug("Invalid field name");
+ }
+ }
}
-}
\ No newline at end of file
+}
else
{
Debug("Ok info");
- Navigator.Push(CreateInfoInputPage(info.InfoTitle, info.InfoValue));
+ if(IsFieldEditable(info.InfoTitle))
+ {
+ Navigator.Push(CreateInfoInputPage(info.InfoTitle, info.InfoValue));
+ }
+ }
+ }
+
+ private bool IsFieldEditable(string fieldName)
+ {
+ // Checks if particular field on info page is editable or not.
+ if (fieldName == Resources.IDS_WIFI_BODY_MAC_ADDRESS)
+ {
+ return false;
+ }
+ else
+ {
+ 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();
+ var page = new InfoInputPage(mAp, mApInfoSource, mOnOffSwitch.IsSelected);
page.CreateComponents(title, value);
return page;
}