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;
|
}
|
}
|
|
}
|
}
|