wxr
2020-06-15 b8e94316e41eba72d927d5ca7d931b26139ee8ff
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
118
119
120
using System;
using Android.Content;
using Android.Content.PM;
using Android.Graphics;
using Com.Hdl.Widget;
 
namespace Shared
{
    public class HDLUtils
    {
 
        /// <summary>
        /// 接口类的返回信息
        /// </summary>
        private static HDLUtils m_Current = null;
        /// <summary>
        /// 接口类的返回信息
        /// </summary>
        public static HDLUtils Current
        {
            get
            {
                if (m_Current == null)
                {
                    m_Current = new HDLUtils();
                }
                return m_Current;
            }
        }
 
 
 
        public static int RectCornerTopLeft = 1;
        public static int RectCornerTopRight = 2;
        public static int RectCornerBottomLeft = 4;
        public static int RectCornerBottomRight = 8;
 
        /// <summary>
        /// 全局打印
        /// </summary>
        public static void WriteLine(object mes)
        {
#if DEBUG
            //Console.WriteLine (mes);
#endif
        }
 
        /// <summary>
        /// 重启APP
        /// </summary>
        public static void RestartApp()
        {
 
            HDLUtlisXM.RelaunchApp(Application.Activity, true);
 
        }
 
        /// <summary>
        /// 设置原生控件库 authorities的值
        /// </summary>
        public static void SetAuthoritiesName(string name)
        {
            HDLUtlisXM.MAuthorityNAME = name;
        }
 
        public static Android.Graphics.Color GetUIColorWithUint(uint uintColor)
        {
 
            byte r, g, b, a;
            r = (byte)(uintColor / 256 / 256 % 256);
            g = (byte)(uintColor / 256 % 256);
            b = (byte)(uintColor % 256);
            a = (byte)(uintColor / 256 / 256 / 256 % 256);
            return Android.Graphics.Color.Argb(a, r, g, b);
        }
 
        ///// <summary>
        ///// 生成二维码
        ///// </summary>
        //public static Bitmap createQRCode(string url, int size = 500)
        //{
        //    return HDLUtlisXM.CreateQRCode(url, size);
        //}
 
        /// <summary>
        /// 跳转浏览器打开地址
        /// </summary>
        /// <param name="mUrl"></param>
        public static void OpenUrl(string mUrl)
        {
            Android.Net.Uri uri = Android.Net.Uri.Parse(mUrl);
            Intent intent = new Intent(Intent.ActionView);
            intent.SetData(uri);
            Application.Activity.StartActivity(intent);
        }
 
        /// <summary>
        /// 打开其他app
        /// </summary>
        /// <param name="packageName"></param>
        /// <returns></returns>
        public static bool OpenAppWithPackageName(string packageName)
        {
            Intent intent = Application.Activity.PackageManager.GetLaunchIntentForPackage(packageName);
            if (intent == null)
            {//未安装app
             //提示安装
                return false;
            }
            else
            {//安装了App
                intent.AddCategory(Intent.CategoryLauncher);
                intent.SetAction(Intent.ActionMain);
                Application.Activity.StartActivity(intent);
                return true;
            }
        }
 
    }
}