From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码
---
ZigbeeApp/Shared/Phone/UserCenter/Abount/AbountForm.cs | 313 ++++++++++++++++++++++------------------------------
1 files changed, 132 insertions(+), 181 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Abount/AbountForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Abount/AbountForm.cs
old mode 100755
new mode 100644
index e1f7466..e10d95a
--- a/ZigbeeApp/Shared/Phone/UserCenter/Abount/AbountForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Abount/AbountForm.cs
@@ -1,10 +1,9 @@
锘縰sing System;
using System.Collections.Generic;
using System.Net;
-using System.Runtime.Remoting.Contexts;
using System.Text;
using Shared.Common;
-using Shared.Phone.Device.CommonForm;
+
namespace Shared.Phone.UserCenter.Abount
{
/// <summary>
@@ -20,11 +19,11 @@
/// <summary>
/// The web client.
/// </summary>
- public WebClient webClient=new WebClient { };
+ public WebClient webClient = new WebClient { };
/// <summary>
/// 鏇存柊涓�
/// </summary>
- public Button updatingBtn;
+ public NormalViewControl btnUpdating;
/// <summary>
/// distributedMark
/// </summary>
@@ -32,7 +31,7 @@
/// <summary>
/// updateRow
/// </summary>
- public DeviceInfoRow updateRow;
+ public FrameRowControl rowUpdate;
/// <summary>
/// 涓嬭浇瀹夊崜apk鐨刡yte闀垮害
/// </summary>
@@ -41,21 +40,15 @@
#endregion
/// <summary>
- /// Initializes a new instance of the <see cref="T:Shared.Phone.UserCenter.Abount.AbountForm"/> class.
- /// </summary>
- public AbountForm()
- {
-
- }
- /// <summary>
/// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
/// </summary>
- public void ShowForm()
+ /// <param name="autoUpdate">鎵撳紑鐣岄潰涔嬪悗,濡傛灉鏈夋柊鐗堟湰,鏄惁鐩存帴鍗囩骇</param>
+ public void ShowForm(bool autoUpdate)
{
//璁剧疆鏍囬淇℃伅
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAboutMe));
//鍒濆鍖栦腑閮ㄦ帶浠�
- this.InitMiddleFrame();
+ this.InitMiddleFrame(autoUpdate);
}
/// <summary>
/// Closes the form.
@@ -63,28 +56,9 @@
public override void CloseFormBefore()
{
#if Android
- //if (isUpdating == true)
- //{
- //var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.CancelUpdating), Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim));
- //alert.Show();
- //alert.ResultEventHandler += (send, e) =>
- //{
- // if (e)
- // {
- SetDownLoadBtnNoVisible();
- CancelDownLoadApkAsync();
- base.CloseFormBefore();
- //}
- // else
- // {
- // return;
- // }
- // };
- //}
- //else
- //{
- // base.CloseFormBefore();
- //}
+ SetDownLoadBtnNoVisible();
+ CancelDownLoadApkAsync();
+ base.CloseFormBefore();
#elif iOS
base.CloseFormBefore();
#endif
@@ -92,141 +66,121 @@
/// <summary>
/// 鍒濆鍖栦腑閮ㄦ帶浠�
/// </summary>
- private void InitMiddleFrame()
+ /// <param name="autoUpdate">鎵撳紑鐣岄潰涔嬪悗,濡傛灉鏈夋柊鐗堟湰,鏄惁鐩存帴鍗囩骇</param>
+ private void InitMiddleFrame(bool autoUpdate)
{
- bodyFrameLayout.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
- var logoFrameLayout = new FrameLayout
+ //澶撮儴鐧借壊鑳屾櫙
+ var frameLogo = new FrameLayoutBase();
+ frameLogo.Height = Application.GetRealHeight(484);
+ frameLogo.BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
+ bodyFrameLayout.AddChidren(frameLogo);
+ //鍥炬爣
+ var btnLogo = new ImageView();
+ btnLogo.Y = Application.GetRealHeight(104);
+ btnLogo.Width = this.GetPictrueRealSize(167);
+ btnLogo.Height = this.GetPictrueRealSize(167);
+ btnLogo.Radius = (uint)Application.GetRealHeight(37);
+ btnLogo.ImagePath = "Account/Logo_Evoyo.png";
+ btnLogo.Gravity = Gravity.CenterHorizontal;
+ frameLogo.AddChidren(btnLogo);
+ //Evoyo Home
+ var btnName = new NormalViewControl(700, 60, true);
+ btnName.Y = Application.GetRealHeight(294);
+ btnName.Gravity = Gravity.CenterHorizontal;
+ btnName.Text = "Evoyo Home";
+ btnName.TextSize = 15;
+ btnName.TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor;
+ btnName.TextAlignment = TextAlignment.Center;
+ frameLogo.AddChidren(btnName);
+ //鐗堟湰鍙�
+ var btnVersion = new NormalViewControl(700, 50, true);
+ btnVersion.Y = Application.GetRealHeight(366);
+ btnVersion.Gravity = Gravity.CenterHorizontal;
+ btnVersion.Text = $"{Language.StringByID(R.MyInternationalizationString.VersionCode)} {CommonPage.CodeIDString}";
+ btnVersion.TextSize = 12;
+ btnVersion.TextColor = ZigbeeColor.Current.GXCTextGrayColor;
+ btnVersion.TextAlignment = TextAlignment.Center;
+ frameLogo.AddChidren(btnVersion);
+ //鍒楄〃鎺т欢
+ var listView = new FrameListControl(12);
+ listView.Y = frameLogo.Bottom + Application.GetRealHeight(23);
+ listView.BackgroundColor = UserCenterColor.Current.White;
+ listView.Height = Application.GetRealHeight(500);
+ bodyFrameLayout.AddChidren(listView);
+ //鏈嶅姟鍗忚
+ var rowService = new FrameRowControl(listView.rowSpace / 2);
+ listView.AddChidren(rowService);
+ rowService.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.SLA), 400);
+ rowService.AddRightArrow();
+ rowService.AddBottomLine();
+ rowService.ButtonClickEvent += (sender, e) =>
{
- Height = Application.GetRealHeight(484),
- BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
- };
- bodyFrameLayout.AddChidren(logoFrameLayout);
-
- var logoBackground = new FrameLayout
- {
- Y = Application.GetRealHeight(104),
- Width = Application.GetMinRealAverage(167),
- Height = Application.GetMinRealAverage(167),
- Gravity = Gravity.CenterHorizontal,
- BackgroundColor = ZigbeeColor.Current.GXCButtonBlackSelectedColor,
- Radius = (uint)Application.GetRealHeight(37),
- };
- logoFrameLayout.AddChidren(logoBackground);
-
- var logoBtn = new Button()
- {
- Width = Application.GetMinRealAverage(144),
- Height = Application.GetMinRealAverage(144),
- UnSelectedImagePath = "Account/Logo_White.png",
- Gravity = Gravity.Center
- };
- logoBackground.AddChidren(logoBtn);
-
- var nameBtn = new Button()
- {
- Y = Application.GetRealHeight(294),
- Width = Application.GetRealWidth(700),
- Height = Application.GetRealHeight(60),
- Gravity = Gravity.CenterHorizontal,
- Text = "HDL Home",
- TextSize = 15,
- TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor
- };
- logoFrameLayout.AddChidren(nameBtn);
-
- var versionBtn = new Button()
- {
- Y = Application.GetRealHeight(366),
- Width = Application.GetRealWidth(700),
- Height = Application.GetRealHeight(50),
- Gravity = Gravity.CenterHorizontal,
- Text = $"{Language.StringByID(R.MyInternationalizationString.VersionCode)} {CommonPage.CodeIDString}",
- TextSize = 12,
- TextColor = ZigbeeColor.Current.GXCTextGrayColor
- };
- logoFrameLayout.AddChidren(versionBtn);
-
-
- var versionFL = new FrameLayout
- {
- Y = Application.GetRealHeight(510),
- Height = Application.GetRealHeight(300),
- BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
- };
- bodyFrameLayout.AddChidren(versionFL);
-
- var SLARow = new DeviceInfoRow(12);
- SLARow.Init();
- SLARow.SetTipTitle(R.MyInternationalizationString.SLA);
- SLARow.NameText.TextAlignment = TextAlignment.CenterRight;
- versionFL.AddChidren(SLARow);
- SLARow.ClickBtn.MouseUpEventHandler += (sender, e) =>
- {
- var slaForm = new SLAForm();
- slaForm.AddForm();
+ var form = new SLAForm();
+ form.AddForm();
};
- updateRow = new DeviceInfoRow(12 + 127 + 12);
- updateRow.Init();
- updateRow.SetTipTitle(R.MyInternationalizationString.UpdateVersion);
- updateRow.NameText.TextAlignment = TextAlignment.CenterRight;
- updateRow.HideLine(true);
- updateRow.SetTitle(R.MyInternationalizationString.TheAppVersionIsNewest);
- updateRow.CanClick(false);
- updateRow.SetTitleColor(ZigbeeColor.Current.GXCTextGrayColor);
- versionFL.AddChidren(updateRow);
- updateRow.ClickBtn.MouseUpEventHandler += (sender, e) =>
+ //鐗堟湰鏇存柊
+ this.rowUpdate = new FrameRowControl(listView.rowSpace / 2);
+ listView.AddChidren(rowUpdate);
+ rowUpdate.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.UpdateVersion), 400);
+ rowUpdate.AddRightArrow();
+ var btnRightView = rowUpdate.AddMostRightView("", 400);
+ rowUpdate.CanClick = false;
+ rowUpdate.ButtonClickEvent += (sender, e) =>
{
UpdateVersion();
};
+ //璋冩暣妗屽竷楂樺害
+ listView.AdjustRealHeight(Application.GetRealHeight(23));
-
- updatingBtn = new Button()
- {
- Y = Application.GetRealHeight(994),
- Width = Application.GetRealWidth(556),
- Height = Application.GetRealHeight(106),
- Radius=(uint)Application.GetRealHeight(53),
- BackgroundColor=ZigbeeColor.Current.GXCDailogBackGroundColor,
- TextID = R.MyInternationalizationString.Updating,
- TextSize=15,
- TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
- Gravity=Gravity.CenterHorizontal
- };
- bodyFrameLayout.AddChidren(updatingBtn);
-
- SetDownLoadBtnNoVisible();
- CheckVersion();
- }
+ //鏇存柊涓�
+ this.btnUpdating = new NormalViewControl(556, 106, true);
+ btnUpdating.Y = Application.GetRealHeight(994);
+ btnUpdating.Radius = (uint)Application.GetRealHeight(53);
+ btnUpdating.BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor;
+ btnUpdating.TextID = R.MyInternationalizationString.Updating;
+ btnUpdating.TextSize = 15;
+ btnUpdating.TextColor = ZigbeeColor.Current.GXCTextWhiteColor;
+ btnUpdating.Gravity = Gravity.CenterHorizontal;
+ btnUpdating.TextAlignment = TextAlignment.Center;
+ bodyFrameLayout.AddChidren(btnUpdating);
- /// <summary>
- /// CheckVersion
- /// </summary>
- private void CheckVersion()
- {
- new System.Threading.Thread(async () =>
+ //璁剧疆杩涘害鎺т欢涓嶅彲瑙�
+ this.SetDownLoadBtnNoVisible();
+
+ //妫�娴嬫柊鐗堟湰
+ HdlThreadLogic.Current.RunThread(async () =>
{
- var re = await CanUpdateAsync();
- if (re)
+ var result = await CanUpdateAsync();
+ HdlThreadLogic.Current.RunMain(() =>
{
- Application.RunOnMainThread(() =>
+ if (result)
{
- updateRow.CanClick(true);
- updateRow.SetTitleColor(ZigbeeColor.Current.GXCButtonSelectedColor);
- updateRow.SetTitle(R.MyInternationalizationString.Update);
- });
- }
- })
- { IsBackground = true }.Start();
+ //鏇存柊鏈�鏂扮増
+ btnRightView.TextID = R.MyInternationalizationString.Update;
+ rowUpdate.CanClick = true;
+ if (autoUpdate == true)
+ {
+ //鐩存帴鍗囩骇
+ rowUpdate.ButtonClickEvent?.Invoke(null, null);
+ }
+ }
+ else
+ {
+ btnRightView.TextID = R.MyInternationalizationString.TheAppVersionIsNewest;
+ }
+ });
+ });
}
+
/// <summary>
/// 璁剧疆杩涘害鎺т欢涓嶅彲瑙�
/// </summary>
private void SetDownLoadBtnNoVisible()
{
isUpdating = false;
- updatingBtn.Visible = false;
+ btnUpdating.Visible = false;
}
/// <summary>
/// 璁剧疆杩涘害鎺т欢鍙
@@ -234,8 +188,8 @@
private void SetDownLoadBtnVisible()
{
isUpdating = true;
- updatingBtn.Visible = true;
- updateRow.CanClick(false);
+ btnUpdating.Visible = true;
+ rowUpdate.CanClick = false;
}
/// <summary>
@@ -247,7 +201,6 @@
#if iOS
try
{
- CommonPage.Loading.Start();
var versionResult = await RequestHttpsiOSAppVersionAsync();
if (versionResult == null || versionResult.Results == null)
{
@@ -257,30 +210,30 @@
if (results[0] == null)
{
return false;
- }
- var newVersion = results[0]["version"]?.ToString();
- var updateContent = results[0]["releaseNotes"]?.ToString();
- if (newVersion != CommonPage.CodeIDString)
+ }
+ var newVersion = results[0]["version"]?.ToString();
+
+ var updateContent = results[0]["releaseNotes"]?.ToString();
+ if (newVersion.CompareTo(CommonPage.CodeIDString) > 0)
{
return true;
}
- retuun false;
+ return false;
}
catch
{
- return false;
-
+ return false;
}
-
+
#elif Android
try
{
- var versionResult = await RequestHttpsAndroidAppVersionAsync();
+ var versionResult = RequestHttpsAndroidAppVersionAsync();
if (versionResult == null)
{
return false;
}
- if (int.Parse(versionResult.FirmwareVersion.Replace(".", "")) > int.Parse(CommonPage.CodeIDString.Replace(".", "")))
+ if (versionResult.FirmwareVersion.CompareTo(CommonPage.CodeIDString) > 0)
{
distributedMark = versionResult.DistributedMark;
return true;
@@ -300,7 +253,7 @@
private async void UpdateVersion()
{
#if iOS
- CommonPage.Instance.OpenUrl();
+ OpenUrl();
#elif Android
try
{
@@ -311,7 +264,7 @@
};
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj);
- var bytesTotalLengthResult = await CommonPage.Instance.RequestHttpsZigbeeAsync("FirmwareMana/DownloadPlatformUploadFirmwarePreLength", Encoding.UTF8.GetBytes(requestJson));
+ var bytesTotalLengthResult = CommonPage.Instance.RequestHttpsZigbeeAsync("FirmwareMana/DownloadPlatformUploadFirmwarePreLength", Encoding.UTF8.GetBytes(requestJson));
if (bytesTotalLengthResult == null || bytesTotalLengthResult.ResponseData == null)
{
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.UpdateAppFail);
@@ -351,17 +304,17 @@
/// 鑾峰彇iOS-APP鐗堟湰淇℃伅
/// </summary>
/// <returns>The https app version async.</returns>
- public async System.Threading.Tasks.Task<ResponseEntity.ResultPack> RequestHttpsiOSAppVersionAsync()
+ public async System.Threading.Tasks.Task<Common.ResponseEntity.ResultPack> RequestHttpsiOSAppVersionAsync()
{
try
{
var webClient = new WebClient { };
- var result = await webClient.DownloadDataTaskAsync("https://itunes.apple.com/lookup?id=1461693569");
+ var result = await webClient.DownloadDataTaskAsync("https://itunes.apple.com/lookup?id=1528702586");
if (result == null)
{
return null;
}
- return Newtonsoft.Json.JsonConvert.DeserializeObject<ResponseEntity.ResultPack>(Encoding.UTF8.GetString(result));
+ return Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResultPack>(Encoding.UTF8.GetString(result));
}
catch
{
@@ -373,7 +326,7 @@
/// </summary>
public void OpenUrl()
{
- Uri url = new Uri("https://itunes.apple.com/cn/app/hdl-home/id1461693569?mt=8");
+ Uri url = new Uri("https://itunes.apple.com/cn/app/hdl-home/id1528702586?mt=8");
UIKit.UIApplication.SharedApplication.OpenUrl(url);
}
#elif Android
@@ -394,7 +347,7 @@
if (Android.OS.BuildVersionCodes.M < Android.OS.Build.VERSION.SdkInt)
{
//鍙傛暟1 涓婁笅鏂�, 鍙傛暟2 Provider涓绘満鍦板潃 鍜岄厤缃枃浠朵腑淇濇寔涓�鑷� 鍙傛暟3 鍏变韩鐨勬枃浠�
- var apkUri = Android.Support.V4.Content.FileProvider.GetUriForFile(context, "com.hdl.home.fileProvider", file);
+ var apkUri = Android.Support.V4.Content.FileProvider.GetUriForFile(context, "com.evoyo.home.fileProvider", file);
//娣诲姞杩欎竴鍙ヨ〃绀哄鐩爣搴旂敤涓存椂鎺堟潈璇ri鎵�浠h〃鐨勬枃浠�
intent.AddFlags(Android.Content.ActivityFlags.GrantReadUriPermission);
intent.SetDataAndType(apkUri, "application/vnd.android.package-archive");
@@ -410,7 +363,7 @@
/// 鑾峰彇 Android-APP 鐗堟湰淇℃伅
/// </summary>
/// <returns>The https app version async.</returns>
- private async System.Threading.Tasks.Task<Common.ResponseEntity.ApkInfoOBJ> RequestHttpsAndroidAppVersionAsync()
+ private Common.ResponseEntity.ApkInfoOBJ RequestHttpsAndroidAppVersionAsync()
{
try
{
@@ -420,7 +373,7 @@
RequestVersion = CommonPage.CodeIDString
};
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestOBJ);
- var result = await CommonPage.Instance.RequestHttpsZigbeeAsync("FirmwareMana/DetectionPlatformUploadFirmware", System.Text.Encoding.UTF8.GetBytes(requestJson));
+ var result = CommonPage.Instance.RequestHttpsZigbeeAsync("FirmwareMana/DetectionPlatformUploadFirmware", System.Text.Encoding.UTF8.GetBytes(requestJson));
if (result == null)
{
return null;
@@ -437,19 +390,17 @@
{
return null;
}
- int MaxIndex = 0;
- int NewVersion = 0;
+
+ Common.ResponseEntity.ApkInfoOBJ apkInfoOBJ = null;
for (int i = 0; i < responeData.pageData.Count; i++)
{
var apkInfo = responeData.pageData[i];
- var version = int.Parse(apkInfo.FirmwareVersion.Replace(".", ""));
- if (version > NewVersion)
+ if (apkInfoOBJ == null || apkInfo.FirmwareVersion.CompareTo(apkInfoOBJ.FirmwareVersion) > 0)
{
- NewVersion = version;
- MaxIndex = i;
+ apkInfoOBJ = apkInfo;
}
}
- return responeData.pageData[MaxIndex];
+ return apkInfoOBJ;
}
return null;
}
@@ -501,7 +452,7 @@
Application.RunOnMainThread(() =>
{
SetDownLoadBtnVisible();
- updatingBtn.Text = $"{ Language.StringByID(R.MyInternationalizationString.Updating)} {(int)(e.BytesReceived / (float)ApkBytesTotalLength * 100)}%";
+ btnUpdating.Text = $"{ Language.StringByID(R.MyInternationalizationString.Updating)} {(int)(e.BytesReceived / (float)ApkBytesTotalLength * 100)}%";
});
}
}
--
Gitblit v1.8.0