JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
namespace Shared.SimpleControl.Phone
{
    public class UpdateAppPage : FrameLayout
    {
        VerticalScrolViewLayout middleVerticalScrolViewLayout;
 
        public UpdateAppPage ()
        {
            BackgroundColor = SkinStyle.Current.MainColor;
        }
 
        public void ShowUpdateAppPage ()
        {
            #region 标题
            var topView = new FrameLayout () {
                Height = Application.GetRealHeight (136),
            };
            AddChidren (topView);
 
            var title = new Button () {
                Y = Application.GetRealHeight (10),
                TextAlignment = TextAlignment.Center,
                Text = Language.StringByID (R.MyInternationalizationString.UpdateApp),
                TextSize = 19,
                TextColor = SkinStyle.Current.TextColor1
            };
            topView.AddChidren (title);
 
            var back = new Button () {
                Height = Application.GetRealHeight (90),
                Width = Application.GetRealWidth (85),
                UnSelectedImagePath = "Item/Back.png",
                SelectedImagePath = "Item/BackSelected.png",
                Y = Application.GetRealHeight (30),
            };
            topView.AddChidren (back);
            back.MouseUpEventHandler += (sender, e) => {
                (Parent as PageLayout).PageIndex -= 1;
            };
            #endregion
 
            var BodyView = new FrameLayout () {
                Y = topView.Bottom,
                Height = Application.GetRealHeight (Application.DesignHeight - 126),
                BackgroundColor = SkinStyle.Current.ViewColor,
            };
            AddChidren (BodyView);
 
            var btnCurVersion = new Button () {
                X = Application.GetRealWidth (60),
                Y = Application.GetRealHeight (60),
                TextAlignment = TextAlignment.CenterLeft,
                Text = Language.StringByID (R.MyInternationalizationString.CurrentVersion) + MainPage.CodeIDString,
                TextColor = SkinStyle.Current.TextColor1,
                Width = Application.GetRealHeight (500),
                Height = Application.GetRealHeight (80),
            };
            BodyView.AddChidren (btnCurVersion);
 
            var btnLatestVersion = new Button () {
                X = Application.GetRealWidth (60),
                Y = btnCurVersion.Bottom + Application.GetRealHeight (30),
                TextAlignment = TextAlignment.CenterLeft,
                Text = Language.StringByID (R.MyInternationalizationString.LatestVersion) + "",
                TextColor = SkinStyle.Current.TextColor1,
                Width = Application.GetRealHeight (500),
                Height = Application.GetRealHeight (80),
            };
            BodyView.AddChidren (btnLatestVersion);
 
            var btnCheckVersion = new Button () {
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = SkinStyle.Current.ButtonColor,
                TextID = R.MyInternationalizationString.CheckVersion,
                TextAlignment = TextAlignment.Center,
                Y = btnLatestVersion.Bottom + Application.GetRealHeight (50),
                Width = Application.GetRealHeight (300),
                Height = Application.GetRealHeight (80),
                TextColor = SkinStyle.Current.TextColor1,
            };
            BodyView.AddChidren (btnCheckVersion);
 
            btnCheckVersion.MouseUpEventHandler += (ss, dd) => {
                Action<string> action = (pre) => {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Start (pre + " %");
                        if (Convert.ToInt32 (pre) >= 100) {
                            MainPage.Loading.Hide ();
                        }
                    });
                };
#if Android
                (Shared.Application.Activity as BaseActivity).SetImagePermission ((obj) => {
                    if (obj) {
                        System.Threading.Tasks.Task.Run (() => {
                            SharedMethod.SharedMethod.DownloadFile (action);
                        });
                    }
                });
#endif
            };
        }
    }
    public class UpdateAppInfo
    {
        public string CodeIDString = "";
 
        public UpdateVersionType UpdateVersionType_IOS = 0;
        public UpdateVersionType UpdateVersionType_Android = 0;
    }
 
    public enum UpdateVersionType
    {
        None = 0,//不需要更新
        Option,//提醒更新
        Force,//强制更新
        Skip,//
    }
}