From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001 From: hxb <hxb@hdlchina.com.cn> Date: 星期二, 30 八月 2022 09:37:38 +0800 Subject: [PATCH] 合并了IOS的代码 --- ZigbeeApp/GateWay.Droid/Application.cs | 225 ++++++++------------------------------------------------ 1 files changed, 32 insertions(+), 193 deletions(-) diff --git a/ZigbeeApp/GateWay.Droid/Application.cs b/ZigbeeApp/GateWay.Droid/Application.cs old mode 100755 new mode 100644 index 7858c42..11b2585 --- a/ZigbeeApp/GateWay.Droid/Application.cs +++ b/ZigbeeApp/GateWay.Droid/Application.cs @@ -17,10 +17,10 @@ using Com.Tencent.MM.Sdk.Openapi; using ZXing.Mobile; using System.IO; - +using GateWay.Droid.JPush; + namespace com.hdl.home { - [Activity(Name = "com.hdl.home.wxapi.WXEntryActivity", Exported = true, Theme = "@android:style/Theme.Translucent", LaunchMode = Android.Content.PM.LaunchMode.SingleTask)] class WXEntryActivity : Android.App.Activity, IWXAPIEventHandler { @@ -83,6 +83,12 @@ public class Application : Android.App.Application { public Application(IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base(handle, ownerShip) { } + + /// <summary> + /// 妫�娴嬪唴瀛樻硠闇茬殑涓滆タ + /// </summary> + //private Square.LeakCanary.RefWatcher _refWatcher; + public override void OnCreate() { //濡傛灉涓嶆槸App鐨勪富杩涚▼,鍒欎笉闇�瑕佸鐞� @@ -101,9 +107,16 @@ //璋冭瘯:璁板綍绯荤粺寮傚父 Shared.Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.SystemLogFile, ex.Message + "\r\n" + ex.StackTrace, true, false); } - base.OnCreate(); - // 閫氳繃WXAPIFactory宸ュ巶锛岃幏鍙朓WXAPI鐨勫疄渚� - //api = WXAPIFactory.CreateWXAPI(this, "wx2ec8f53f6fa36e82", true); + base.OnCreate(); + // 閫氳繃WXAPIFactory宸ュ巶锛岃幏鍙朓WXAPI鐨勫疄渚� + //api = WXAPIFactory.CreateWXAPI(this, "wx2ec8f53f6fa36e82", true); + + //妫�娴嬪唴瀛樻硠闇茬殑涓滆タ + //if (Square.LeakCanary.LeakCanaryXamarin.IsInAnalyzerProcess(this) == false) + //{ + // _refWatcher = Square.LeakCanary.LeakCanaryXamarin.Install(this); + // _refWatcher.Watch(this); + //} // 灏嗗簲鐢ㄧ殑appId娉ㄥ唽鍒板井淇� api?.RegisterApp("wx2ec8f53f6fa36e82"); @@ -136,26 +149,23 @@ var req = new SendAuth.Req { Scope = "snsapi_userinfo", State = "ZigbeeApp" }; api?.SendReq(req); } + /// <summary> /// 鎵�鏈夊垵濮嬪寲鍏ㄩ儴鍦ㄨ繖涓柟娉曞疄鐜� /// </summary> void initAll() { - Shared.Application.IsGpsEnable = System.IO.File.Exists(Shared.Phone.UserCenter.DirNameResourse.OpenGbsFile); + //鍙栨秷灞忓箷甯镐寒 + BaseActivity.KeepScreenON = false; //闅愯棌搴曢儴杞寜閿� - BaseActivity.IsHideVirualButtons = true; - - //璁剧疆鏋佸厜璋冭瘯妯″紡锛屼负false鏃跺彧鎵撳嵃璀﹀憡淇℃伅 - // System.Console.WriteLine($"AAA : {System.DateTime.Now.ToString()}"); -#if Release - JPushInterface.SetDebugMode(false); - //淇濆瓨鎵嬫満鍚嶇О鍒版湰鍦版枃浠� - //System.Console.WriteLine($"BBB : {System .DateTime .Now .ToString ()}"); + BaseActivity.IsHideVirualButtons = true; - JPushInterface.Init(this); - //System.Console.WriteLine($"CCC : {System.DateTime.Now.ToString()}"); -#endif + //璁剧疆鏋佸厜璋冭瘯妯″紡锛屼负false鏃跺彧鎵撳嵃璀﹀憡淇℃伅 + // System.Console.WriteLine($"AAA : {System.DateTime.Now.ToString()}"); + JPushInterface.SetDebugMode(true); + JPushInterface.Init(this); + string registration_id = JPushInterface.GetRegistrationID(this); BaseActivity.BackKeyAction = () => { @@ -321,183 +331,8 @@ } } return false; - } - - + } } - - [BroadcastReceiver(Name = "com.evoyo.home.JpushNotificationReceiver", Exported = false, Enabled = true)] - [IntentFilter(new string[] { "cn.jpush.android.intent.REGISTRATION", - "cn.jpush.android.intent.MESSAGE_RECEIVED", - "cn.jpush.android.intent.NOTIFICATION_RECEIVED", - "cn.jpush.android.intent.NOTIFICATION_OPENED", - "cn.jpush.android.intent.CONNECTION" }, Categories = new string[] { "com.evoyo.home" })] - public class JpushNotificationReceiver : BroadcastReceiver - { - private static string TAG = "JpushNotificationReceiver"; - private NotificationManager nm; - static string ACTION = "android.intent.action.BOOT_COMPLETED"; - public override void OnReceive(Context context, Intent intent) - { - if (nm == null) - { - nm = (NotificationManager)context.GetSystemService(Context.NotificationService); - } - //base.OnReceive (context, intent); - try - { - Bundle bundle = intent.Extras; - if (intent.Action == ACTION) - { - //寮�鏈鸿嚜鍔ㄦ湇鍔¤嚜鍔ㄥ惎鍔�,PushService鏄鍚姩鐨勬湇鍔� - Intent service = new Intent(context, typeof(PushService)); - context.StartService(service); - } - - //鎺ユ敹Registration Id - if (JPushInterface.ActionRegistrationId == intent.Action) - { - string regId = bundle.GetString(JPushInterface.ExtraRegistrationId); - if (!string.IsNullOrEmpty(regId)) - { - Shared.Common.Config.Instance.RegistrationID = regId; - Shared.Common.Config.Instance.Save(); - } -#if Release - //璋冭瘯:璁板綍鏋佸厜ID - Shared.Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.JiguangFile, "receive2:" + regId, false, true); -#endif - } - //鐢ㄦ埛鐐瑰嚮鎵撳紑浜嗛�氱煡 - else if (JPushInterface.ActionNotificationOpened == intent.Action) - { - OpenNotification(context, bundle); - } - //鎺ュ彈鍒版帹閫佷笅鏉ョ殑閫氱煡 - else if (JPushInterface.ActionNotificationReceived == intent.Action) - { - //int notifactionId = bundle.GetInt(JPushInterface.ExtraNotificationId); - ReceivingNotification(context, bundle); - //Shared.Common.CommonPage.Instance.SingOut(); - } - //鎺ユ敹鍒版帹閫佷笅鏉ョ殑鑷畾涔夋秷鎭� - else if (JPushInterface.ActionMessageReceived == intent.Action) - { - bundle.GetString(JPushInterface.ExtraMessage); - } - else - { - } - } - catch (System.Exception e) - { - - System.Console.WriteLine("鏋佸厜鎺ㄩ�佸嚭閿�:" + e.Message); - } - } - /// <summary> - /// 鎺ユ敹娑堟伅閫氱煡 - /// </summary> - /// <param name="context">Context.</param> - /// <param name="bundle">Bundle.</param> - private void ReceivingNotification(Context context, Bundle bundle) - { - String title = bundle.GetString(JPushInterface.ExtraNotificationTitle); - System.Console.WriteLine(TAG, " title : " + title); - String message = bundle.GetString(JPushInterface.ExtraAlert); - System.Console.WriteLine(TAG, "message : " + message); - String extras = bundle.GetString(JPushInterface.ExtraExtra); - System.Console.WriteLine(TAG, "extras : " + extras); - - //澶勭悊鏋佸厜娑堟伅鎺ㄩ�佺殑閫昏緫鍑芥暟 - Shared.Phone.UserCenter.HdlJiguangMsgPushLogic.Current.AdjustJiguangMsgPush(title, message, extras); - } - /// <summary> - /// 鎵撳紑娑堟伅鏄剧ず鐣岄潰 - /// </summary> - /// <param name="context">Context.</param> - /// <param name="bundle">Bundle.</param> - private void OpenNotification(Context context, Bundle bundle) - { - - Intent i = new Intent(context, typeof(BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class); - i.PutExtras(bundle); - i.SetFlags(ActivityFlags.NewTask); - context.StartActivity(i); - - String extras = bundle.GetString(JPushInterface.ExtraExtra); - //String myValue = ""; - try - { - VideoMethod(extras); - //JSONObject extrasJson = new JSONObject(extras); - //myValue = extrasJson.OptString("myKey"); - - } - catch (Exception e) - { - System.Console.WriteLine(TAG, "Unexpected: extras is not a valid json", e); - return; - } - - //if (TYPE_THIS.equals(myValue)) - //{ - //Intent mIntent = new Intent(context, ThisActivity.class); - //mIntent.putExtras(bundle); - //mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - //context.startActivity(mIntent); - //} - //else if (TYPE_ANOTHER.equals(myValue)) - //{ - //Intent mIntent = new Intent(context, AnotherActivity.class); - //mIntent.putExtras(bundle); - //mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - //context.startActivity(mIntent); - //} - } - - /// <summary> - /// android閫氱煡鏍忕偣鍑绘墦寮�鍙瀵硅鐨勬柟娉� - /// </summary> - /// <param name="hiddenJson">浜戠鎺ㄨ繃鏉ョ殑鏁版嵁</param> - private void VideoMethod(string hiddenJson) - { - var hiddanJson = Newtonsoft.Json.Linq.JObject.Parse(hiddenJson); - if (hiddanJson == null) - { - return; - } - var json = Newtonsoft.Json.Linq.JObject.Parse(hiddanJson["HiddanJson"].ToString()); - if (json == null) - { - return; - } - Shared.Phone.VideoPhone.ESVideoInfo eSVideoInfo = new Shared.Phone.VideoPhone.ESVideoInfo(); - if (json["uuid"].ToString().Contains(",")) - { - var uuid = json["uuid"].ToString().Split(','); - eSVideoInfo.ESVideoUUID = uuid[0]; - - } - else - { - eSVideoInfo.ESVideoUUID = json["uuid"].ToString(); - } - - eSVideoInfo.DeviceName = Language.StringByID(Shared.R.MyInternationalizationString.theOutdoorUnit); - eSVideoInfo.ESRoomID = int.Parse(json["roomno"].ToString()); - if (!string.IsNullOrEmpty(json["unitno"].ToString())) - { - string str = json["unitno"].ToString(); - string str1 = str.Substring(0, 2).TrimStart('0'); - string str2 = str.Substring(2, 2).TrimStart('0'); - eSVideoInfo.RoomName = str1 + Language.StringByID(Shared.R.MyInternationalizationString.dong) + str2 + Language.StringByID(Shared.R.MyInternationalizationString.unit); - } - - Shared.Phone.VideoPhone.ESVideo.ShowESvideoVideoIntercom(eSVideoInfo); - - } - } } namespace Shared @@ -575,5 +410,9 @@ return stream.ToArray(); } } + + } + + } -- Gitblit v1.8.0