old mode 100644
new mode 100755
| | |
| | | using Microsoft.AppCenter.Analytics; |
| | | using Microsoft.AppCenter.Crashes; |
| | | using Com.Tencent.MM.Sdk.Openapi; |
| | | |
| | | using ZXing.Mobile;
|
| | | using System.IO;
|
| | |
|
| | | namespace com.hdl.home |
| | | { |
| | | |
| | |
| | | var req = new SendAuth.Req { Scope = "snsapi_userinfo", State = "ZigbeeApp" }; |
| | | api.SendReq(req); |
| | | } |
| | | /// <summary>
/// 所有初始化全部在这个方法实现
/// </summary>
void initAll()
{
BaseActivity.IsEnnableGPS = false; |
| | | /// <summary>
/// 所有初始化全部在这个方法实现
/// </summary>
void initAll()
{ |
| | | string checkFile = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Shared.Phone.UserCenter.DirNameResourse.OpenGbsFile);
|
| | | Shared.Application.IsGpsEnable = System.IO.File.Exists(checkFile); |
| | | |
| | | //设置极光调试模式,为false时只打印警告信息 |
| | | // System.Console.WriteLine($"AAA : {System.DateTime.Now.ToString()}"); |
| | | #if Release
JPushInterface.SetDebugMode(false); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | namespace Shared |
| | | { |
| | | public static class QRCode |
| | | { |
| | | static ZXing.Mobile.MobileBarcodeScanner scanner;
|
| | | public static void ScanQRcode(Action<string> action, string cancel = "取消", string flashText = "闪光灯", string titleText = "二维码扫描")
|
| | | {
|
| | | ((BaseActivity)Shared.Application.Activity).SetCamera(async (obj) =>
|
| | | {
|
| | | if (obj)
|
| | | {
|
| | | if (scanner == null)
|
| | | {
|
| | | MobileBarcodeScanner.Initialize(Shared.Application.Activity.Application);
|
| | | var mZXingCustomScanView = new GateWay.Droid.ZXingCustomScanView(Shared.Application.Activity.Application);
|
| | | mZXingCustomScanView.cancelTextView.Text = cancel;
|
| | | mZXingCustomScanView.flashTextView.Text = flashText;
|
| | | mZXingCustomScanView.titleTextView.Text = titleText;
|
| | | var bOn = false;
|
| | | scanner = new ZXing.Mobile.MobileBarcodeScanner()
|
| | | {
|
| | | UseCustomOverlay = true,
|
| | | CustomOverlay = mZXingCustomScanView
|
| | | };
|
| | |
|
| | | mZXingCustomScanView.OnCancel += () => {
|
| | |
|
| | | scanner?.Cancel();
|
| | | };
|
| | |
|
| | | mZXingCustomScanView.OnTorch += () =>
|
| | | {
|
| | | bOn = !bOn;
|
| | | scanner?.Torch(bOn);
|
| | | };
|
| | | }
|
| | |
|
| | | var result = await scanner.Scan();
|
| | |
|
| | | if (result != null)
|
| | | action?.Invoke(result.Text);
|
| | | else
|
| | | action?.Invoke(null);
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | action?.Invoke(null);
|
| | | }
|
| | | });
|
| | | } |
| | | |
| | | public static byte[] BytesFromText(string text, int width = 300, int height = 300) |
| | | { |
| | | var barcodeWriter = new ZXing.Mobile.BarcodeWriter |
| | | { |
| | | Format = ZXing.BarcodeFormat.QR_CODE, |
| | | Options = new ZXing.Common.EncodingOptions |
| | | { |
| | | Width = width, |
| | | Height = height, |
| | | Margin = 0 |
| | | } |
| | | }; |
| | | |
| | | barcodeWriter.Renderer = new ZXing.Mobile.BitmapRenderer();
|
| | | var bitmap = barcodeWriter.Write(text);
|
| | | using (var stream = new MemoryStream()) |
| | | { |
| | | bitmap.Compress(Android.Graphics.Bitmap.CompressFormat.Png, 100, stream); // this is the diff between iOS and Android |
| | | stream.Position = 0; |
| | | return stream.ToArray(); |
| | | } |
| | | } |
| | | } |
| | | } |