using System;
using Android.Content;
using Android.Content.PM;
using Android.Graphics;
using Com.Hdl.Widget;
namespace Shared
{
public class HDLUtils
{
///
/// 接口类的返回信息
///
private static HDLUtils m_Current = null;
///
/// 接口类的返回信息
///
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;
///
/// 全局打印
///
public static void WriteLine(object mes)
{
#if DEBUG
//Console.WriteLine (mes);
#endif
}
///
/// 重启APP
///
public static void RestartApp()
{
HDLUtlisXM.RelaunchApp(Application.Activity, true);
}
///
/// 设置原生控件库 authorities的值
///
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);
}
/////
///// 生成二维码
/////
//public static Bitmap createQRCode(string url, int size = 500)
//{
// return HDLUtlisXM.CreateQRCode(url, size);
//}
///
/// 跳转浏览器打开地址
///
///
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);
}
///
/// 打开其他app
///
///
///
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;
}
}
}
}