Ejemplo n.º 1
0
        private void PickImage(NativeAction actionPick)
        {
#if UNITY_ANDROID
            NativeGallery.RequestPermission((result, action) =>
            {
                if (result == (int)NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetImageFromGalleryForAndroid((path) =>
                    {
                        if (path.IsNotNullAndEmpty())
                        {
                            mPhotoPath = path;
                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + path, ImgPhoto);
                            BtnDel.gameObject.SetActive(true);
                        }
                        Debug.Log("Image path: " + path);
                    }, "选择图片", "image/*", false, action);
                }
            }, (int)actionPick);
#elif UNITY_IOS
            // NativeGallery.Permission rest;
            if (actionPick == NativeAction.Album)
            {
                NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(1);
                if (rest == NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetImageFromGallery((backPath) =>
                    {
                        if (backPath.IsNotNullAndEmpty())
                        {
                            mPhotoPath = backPath;
                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + backPath, ImgPhoto, false);
                            BtnDel.gameObject.SetActive(true);
                        }
                    }, "选择图片", "image/*");
                }
            }
            else if (actionPick == NativeAction.Camera)
            {
                NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(4);
                if (rest == NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetIPhoneCameraImageFromGallery((backPath) =>
                    {
                        if (backPath.IsNotNullAndEmpty())
                        {
                            mPhotoPath = backPath;
                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + backPath, ImgPhoto, false);
                            BtnDel.gameObject.SetActive(true);
                        }
                    }, "选择图片", "image/*");
                }
            }
#else
#endif
        }
Ejemplo n.º 2
0
 /**
  * 打开原生相机录制视频
  */
 private void IPhonePlayerMakeVideoOpenCamera()
 {
     NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(1);
     if (rest == NativeGallery.Permission.Granted)
     {
         NativeGallery.IPhoneCameraMakeVideoFromGallery(backPath =>
         {
             if (backPath.IsNotNullAndEmpty())
             {
                 mPath          = backPath;
                 mThumbnailPath = Application.temporaryCachePath + "/videoThumbnail.png";
                 AudioContent.gameObject.SetActive(false);
                 ImageDownloadUtils.Instance.SetAsyncImage("file://" + Application.temporaryCachePath + "/videoThumbnail.png", ImagePic);
                 BtnVideo.gameObject.SetActive(true);
                 BtnDel.gameObject.SetActive(true);
             }
         }, "选择视频", "video/*");
     }
 }
Ejemplo n.º 3
0
 /**
  * 打开原生相册 选择照片
  */
 private void IPhonePlayerSelectPictureOpenAlbum()
 {
     NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(1);
     if (rest == NativeGallery.Permission.Granted)
     {
         NativeGallery.GetImageFromGallery((backPath) =>
         {
             if (backPath.IsNotNullAndEmpty())
             {
                 mPath          = backPath;
                 mThumbnailPath = backPath;
                 AudioContent.gameObject.SetActive(false);
                 if (mPath.IsNotNullAndEmpty())
                 {
                     ImageDownloadUtils.Instance.SetAsyncImage("file://" + mThumbnailPath, ImagePic);
                     BtnVideo.gameObject.SetActive(false);
                     BtnDel.gameObject.SetActive(true);
                 }
             }
         }, "选择图片", "image/*");
     }
 }
Ejemplo n.º 4
0
 /**
  * 打开原生相机拍照
  */
 private void IPhonePlayerSelectPictureOpenCamera()
 {
     NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(4);
     if (rest == NativeGallery.Permission.Granted)
     {
         NativeGallery.GetIPhoneCameraImageFromGallery((backPath) =>
         {
             if (backPath.IsNotNullAndEmpty())
             {
                 // 打开原生图片选择
                 UIMgr.OpenPanel <AttendanceAddPanel>(new AttendanceAddPanelData()
                 {
                     BoxId         = mData.BoxId,
                     BoxDay        = mData.BoxDay,
                     Path          = backPath,
                     ThumbnailPath = backPath,
                     Action        = AttendanceAdd.Pic
                 }, UITransitionType.CIRCLE);
                 Close();
             }
         }, "选择图片", "image/*");
     }
 }
Ejemplo n.º 5
0
 /**
  * 打开原生相机录制视频
  */
 private void IPhonePlayerMakeVideoOpenCamera()
 {
     NativeGallery.Permission rest1 = NativeGallery.RequestIPhonePermission(4);
     NativeGallery.Permission rest2 = NativeGallery.RequestIPhonePermission(3);
     if (rest1 == NativeGallery.Permission.Granted)
     {
         NativeGallery.IPhoneCameraMakeVideoFromGallery(backPath =>
         {
             if (backPath.IsNotNullAndEmpty())
             {
                 // 打开原生视频选择
                 UIMgr.OpenPanel <AttendanceAddPanel>(new AttendanceAddPanelData()
                 {
                     BoxId         = mData.BoxId,
                     BoxDay        = mData.BoxDay,
                     Path          = backPath,
                     ThumbnailPath = Application.temporaryCachePath + "/videoThumbnail.png",
                     Action        = AttendanceAdd.Video,
                 }, UITransitionType.CIRCLE);
                 Close();
             }
         }, "选择视频", "video/*");
     }
 }
Ejemplo n.º 6
0
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as BindWIFIMessagePanelData ?? new BindWIFIMessagePanelData();

            if (Application.platform == RuntimePlatform.Android)
            {
                NativeGallery.RequestPermission((result, action) =>
                {
                    isSendMessage = true;
                    Log.I("RequestPermission: " + result);
                    if (result == (int)NativeGallery.Permission.Granted)
                    {
                        // InvokeRepeating("GetWifiInfo",1,1); 可以实时更新wifi,但无法修改wifi密码,暂时舍弃
                        NativeGallery.GetSomethingFromNative((json, action1) =>
                        {
                            if (json.IsNotNullAndEmpty())
                            {
                                isSSIDContains5G(json);
                                InputFieldSSID.text = json;
                                string pwd          = PlayerPrefsUtil.GetWiFiPWD(json);
                                if (pwd.IsNotNullAndEmpty())
                                {
                                    InputFieldPWD.text = pwd;
                                }
                                else
                                {
                                    InputFieldPWD.text = string.Empty;
                                }
                            }
                            Log.I("GetSomethingFromNative: " + json);
                        }, (int)NativeAction.Location);
                    }
                }, (int)NativeAction.Location);
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                if (NativeGallery.RequestIPhonePermission(2) == NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetSomethingFromIPhone(result =>
                    {
                        if (result.IsNotNullAndEmpty())
                        {
                            InputFieldSSID.text = result;
                            isSSIDContains5G(result);
                            string pwd = PlayerPrefsUtil.GetWiFiPWD(result);
                            if (pwd.IsNotNullAndEmpty())
                            {
                                InputFieldPWD.text = pwd;
                            }
                            else
                            {
                                InputFieldPWD.text = String.Empty;
                            }
                        }
                    }, 1);
                }
            }

            var submit = Observable.Merge(
                InputFieldSSID.OnEndEditAsObservable().Where(_ => Input.GetKeyDown(KeyCode.Return)),
                BtnCommit.OnClickAsObservable().Select(_ => InputFieldSSID.text)
                );

            submit.Where(s => s != "")
            .Subscribe(s =>
            {
                AudioManager.PlaySound("Button_Audio");
                isSendMessage = false;
                if (saveWiFipwd)
                {
                    // 保存 WiFi ssid 和 pwd 到本地
                    PlayerPrefsUtil.SetWiFiSSIDPWD(InputFieldSSID.text, InputFieldPWD.text);
                }
                else
                {
                    PlayerPrefsUtil.SetWiFiSSIDPWD(InputFieldSSID.text, String.Empty);
                }

                Debug.Log("submit-确定 " + "ssid=" + s + "  pwd=" + InputFieldPWD.text);
                UIMgr.OpenPanel <BindDevicePanel>(new BindDevicePanelData()
                {
                    pwdStr  = InputFieldPWD.text,
                    ssidStr = InputFieldSSID.text
                }, UITransitionType.CIRCLE, this);
            }).AddTo(this);
            BtnClearPWD.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                InputFieldPWD.text = String.Empty;
            }).AddTo(this);
            BtnSSIDList.onClick.AddListener(() =>
            {
                AudioManager.PlaySound("Button_Audio");
#if UNITY_ANDROID
                NativeGallery.RequestPermission((result, action) =>
                {
                    Log.I("RequestPermission: " + result);
                    if (result == (int)NativeGallery.Permission.Granted)
                    {
                        NativeGallery.OpenWifiSettings();
                    }
                }, (int)NativeAction.Location);
#elif UNITY_IOS
                NativeGallery.OpenSettings();
#else
#endif
            });
            InputFieldSSID.OnValueChangedAsObservable().Subscribe((s =>
            {
                var texture2D = mResLoader.LoadSync <Texture2D>("ic_bindDetermine");
                if (s.Length > 0)
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("ic_bindDetermine");
                }
                else
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("btn_code_sel");
                }
                ImgDetermine.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
            })).AddTo(this);

            BtnShow.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                var texture2D = mResLoader.LoadSync <Texture2D>("ic_savepwd");
                showWiFipwd   = !showWiFipwd;
                if (showWiFipwd)
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("btn_show_pwd");
                    InputFieldPWD.contentType = InputField.ContentType.EmailAddress;
                }
                else
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("btn_hide_pwd");
                    InputFieldPWD.contentType = InputField.ContentType.Password;
                }

                var image    = BtnShow.transform.Find("Image").GetComponent <Image>();
                image.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
                InputFieldPWD.MyUpdateLabel();
            }).AddTo(this);

            BtnConnectTips.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                UIMgr.OpenPanel <BindCheckWIFIPanel>(new BindCheckWIFIPanelData(), UITransitionType.NULL);
            }).AddTo(this);

            BtnBack.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                Debug.Log("WiFi 返回");
                Back();
            }).AddTo(this);

            BtnSavepwd.OnClickAsObservable().Subscribe(_ =>
            {
                AudioManager.PlaySound("Button_Audio");
                Debug.Log("记住密码");
                saveWiFipwd   = !saveWiFipwd;
                var texture2D = mResLoader.LoadSync <Texture2D>("ic_savepwd");
                if (saveWiFipwd)
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("ic_savepwd");
                }
                else
                {
                    texture2D = mResLoader.LoadSync <Texture2D>("ic_unsavepwd");
                }
                ImageSavePWD.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.one * 0.5f);
            }).AddTo(this);


            SimpleEventSystem.GetEvent <TipConfirmClick>()
            .Subscribe(_ =>
            {
                if (_.GetAction == TipAction.Contains5GAlter)
                {
                    if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        NativeGallery.RequestPermission((result, action) =>
                        {
                            Log.I("RequestPermission: " + result);
                            if (result == (int)NativeGallery.Permission.Granted)
                            {
                                NativeGallery.OpenWifiSettings();
                            }
                        }, (int)NativeAction.Location);
                    }
                    else if (Application.platform == RuntimePlatform.IPhonePlayer)
                    {
                        NativeGallery.OpenSettings();
                    }
                }
            }).AddTo(this);

            // please add init code here
        }