Beispiel #1
0
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            base.ProcessMvxIntentResult(result);

            if (result.RequestCode != googleSignInResult)
            {
                return;
            }

            lock (lockable)
            {
                var signInData = Auth.GoogleSignInApi.GetSignInResultFromIntent(result.Data);
                if (signInData.IsSuccess)
                {
                    subject.OnNext(signInData.SignInAccount.IdToken);
                    subject.OnCompleted();
                }
                else
                {
                    subject.OnError(new GoogleLoginException(signInData.Status.IsCanceled));
                }

                isLoggingIn = false;
            }
        }
Beispiel #2
0
 private void OnMvxIntentResultReceived(object sender, MvxIntentResultEventArgs e)
 {
     MvxLog.Instance.Trace("OnMvxIntentResultReceived in MvxAndroidTask");
     // TODO - is this correct - should we always remove the result registration even if this isn't necessarily our result?
     Mvx.Resolve <IMvxIntentResultSource>().Result -= OnMvxIntentResultReceived;
     ProcessMvxIntentResult(e);
 }
Beispiel #3
0
        private bool ProcessPictureUri(MvxIntentResultEventArgs result, Uri uri)
        {
            if (_currentRequestParameters == null)
            {
                return(false); // we have not handled this - so we return null
            }
            var responseSent = false;

            try
            {
                // Note for furture bug-fixing/maintenance - it might be better to use var outputFileUri = data.GetParcelableArrayExtra("outputFileuri") here?
                if (result.ResultCode != Result.Ok)
                {
                    return(true);
                }
                if (uri == null ||
                    string.IsNullOrEmpty(uri.Path))
                {
                    return(true);
                }
                var memoryStream = LoadInMemoryBitmap(uri);
                responseSent = true;
                _currentRequestParameters.PictureAvailable(memoryStream);
                return(true);
            }
            finally
            {
                if (!responseSent)
                {
                    _currentRequestParameters.AssumeCancelled();
                }

                _currentRequestParameters = null;
            }
        }
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            try
            {
                MvxPluginLog.Instance.Trace("ProcessMvxIntentResult started...");

                Uri uri;

                switch ((MvxIntentRequestCode)result.RequestCode)
                {
                    case MvxIntentRequestCode.PickFromFile:
                        uri = result.Data?.Data;
                        break;
                    case MvxIntentRequestCode.PickFromCamera:
                        uri = _cachedUriLocation;
                        break;
                    default:
                        // ignore this result - it's not for us
                        MvxPluginLog.Instance.Trace("Unexpected request received from MvxIntentResult - request was {0}",
                                       result.RequestCode);
                        return;
                }

                ProcessPictureUri(result, uri);
            }
            catch (Exception e)
            {
                // TODO: We currently have no way of bubbling this up. Throwing here
                // can crash the app :(

                MvxPluginLog.Instance.ErrorException("Failed to process Intent from PictureChooser", e);
            }
        }
Beispiel #5
0
 private void OnMvxIntentResultReceived(object sender, MvxIntentResultEventArgs e)
 {
     MvxLogHost.GetLog <MvxAndroidTask>()?.Log(LogLevel.Trace, "OnMvxIntentResultReceived in MvxAndroidTask");
     // TODO - is this correct - should we always remove the result registration even if this isn't necessarily our result?
     Mvx.IoCProvider.Resolve <IMvxIntentResultSource>().Result -= OnMvxIntentResultReceived;
     ProcessMvxIntentResult(e);
 }
Beispiel #6
0
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            MvxTrace.Trace("ProcessMvxIntentResult started...");

            Uri uri;

            switch ((MvxIntentRequestCode)result.RequestCode)
            {
            case MvxIntentRequestCode.PickFromFile:
                uri = result.Data?.Data;
                break;

            case MvxIntentRequestCode.PickFromCamera:
                uri = _cachedUriLocation;
                break;

            default:
                // ignore this result - it's not for us
                MvxTrace.Trace("Unexpected request received from MvxIntentResult - request was {0}",
                               result.RequestCode);
                return;
            }

            ProcessPictureUri(result, uri);
        }
        public void OnResult(MvxIntentResultEventArgs result)
        {
            var handler = Result;

            if (handler != null)
            {
                handler(this, result);
            }
        }
Beispiel #8
0
        protected override void EventSourceOnActivityResultCalled(object sender,
                                                                  MvxValueEventArgs <MvxActivityResultParameters> args)
        {
            var sink             = Mvx.IoCProvider.Resolve <IMvxIntentResultSink>();
            var resultParameters = args.Value;
            var intentResult     = new MvxIntentResultEventArgs(resultParameters.RequestCode, resultParameters.ResultCode,
                                                                resultParameters.Data);

            sink.OnResult(intentResult);
        }
        private void ProcessPictureUri(MvxIntentResultEventArgs result, Uri uri)
        {
            if (_currentRequestParameters == null)
            {
                MvxTrace.Error("Internal error - response received but _currentRequestParameters is null");
                return; // we have not handled this - so we return null
            }

            var responseSent = false;

            try
            {
                // Note for furture bug-fixing/maintenance - it might be better to use var outputFileUri = data.GetParcelableArrayExtra("outputFileuri") here?
                if (result.ResultCode != Result.Ok)
                {
                    MvxTrace.Trace("Non-OK result received from MvxIntentResult - {0} - request was {1}",
                                   result.ResultCode, result.RequestCode);
                    return;
                }

                if (uri == null ||
                    string.IsNullOrEmpty(uri.Path))
                {
                    MvxTrace.Trace("Empty uri or file path received for MvxIntentResult");
                    return;
                }

                MvxTrace.Trace("Loading InMemoryBitmap started...");
                var memoryStream = LoadInMemoryBitmap(uri);
                if (memoryStream == null)
                {
                    MvxTrace.Trace("Loading InMemoryBitmap failed...");
                    return;
                }
                MvxTrace.Trace("Loading InMemoryBitmap complete...");
                responseSent = true;
                MvxTrace.Trace("Sending pictureAvailable...");
                _currentRequestParameters.PictureAvailable(memoryStream);
                MvxTrace.Trace("pictureAvailable completed...");
                return;
            }
            finally
            {
                if (!responseSent)
                {
                    _currentRequestParameters.AssumeCancelled();
                }

                _currentRequestParameters = null;
            }
        }
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            base.ProcessMvxIntentResult(result);

            // on return, delete all attachments from external cache
            foreach (File file in filesToDelete)
            {
                if (file.Exists())
                {
                    file.Delete();
                }
            }
            filesToDelete.Clear();
        }
Beispiel #11
0
        private void OnMvxIntentResultReceived(object sender, MvxIntentResultEventArgs e)
        {
            var androidView = sender as IMvxAndroidView;

            if (androidView == null)
            {
                MvxTrace.Trace("Error - sender activity is null or does not support IMvxAndroidView");
                return;
            }

            if (ProcessMvxIntentResult(e))
            {
                androidView.MvxIntentResultReceived -= OnMvxIntentResultReceived;
            }
        }
Beispiel #12
0
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            Uri uri = null;

            switch ((MvxIntentRequestCode)result.RequestCode)
            {
            case MvxIntentRequestCode.PickFromFile:
                uri = (result.Data == null) ? null : result.Data.Data;
                break;

            case MvxIntentRequestCode.PickFromCamera:
                uri = _cachedUriLocation;
                break;
            }
            ProcessPictureUri(result, uri);
        }
Beispiel #13
0
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            base.ProcessMvxIntentResult(result);

            if (result.RequestCode != googleSignInResult)
            {
                return;
            }

            lock (lockable)
            {
                var signInData = Auth.GoogleSignInApi.GetSignInResultFromIntent(result.Data);
                if (signInData.IsSuccess)
                {
                    var activity = Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity as FragmentActivity;

                    Task.Run(() =>
                    {
                        try
                        {
                            var token = GoogleAuthUtil.GetToken(activity, signInData.SignInAccount.Account, scope);
                            subject.OnNext(token);
                            subject.OnCompleted();
                        }
                        catch (Exception e)
                        {
                            subject.OnError(e);
                        }
                        finally
                        {
                            isLoggingIn = false;
                        }
                    });
                }
                else
                {
                    subject.OnError(new GoogleLoginException(signInData.Status.IsCanceled));
                    isLoggingIn = false;
                }
            }
        }
Beispiel #14
0
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            var creditCard = CreditCard.Empty;
            var card       = result?
                             .Data?
                             .GetParcelableExtra(CardIOActivity.ExtraScanResult)?
                             .JavaCast <Card.IO.CreditCard>();

            if (card != null)
            {
                creditCard = new CreditCard
                {
                    Cvv             = card.Cvv,
                    CardNumber      = card.CardNumber,
                    ExpirationYear  = card.ExpiryYear,
                    ExpirationMonth = card.ExpiryMonth
                };
            }

            _callback?.Invoke(creditCard);
        }
Beispiel #15
0
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            switch (result.RequestCode)
            {
            case LoginIdentityRequestCode:
                if (_response != null)
                {
                    _onLoggedIn(_response);
                    return;
                }

                _assumeCancelled();
                return;

            default:
                // ignore this result - it's not for us
                Mvx.Trace("Unexpected request received from MvxIntentResult - request was {0}",
                          result.RequestCode);
                _assumeCancelled();
                break;
            }
        }
Beispiel #16
0
        protected override bool ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            Uri uri;

            switch ((MvxIntentRequestCode)result.RequestCode)
            {
            case MvxIntentRequestCode.PickFromFile:
                uri = (result.Data == null) ? null : result.Data.Data;
                break;

            case MvxIntentRequestCode.PickFromCamera:
                uri = _cachedUriLocation;
                break;

            default:
                // ignore this result - it's not for us
                MvxTrace.Trace("Unexpected request received from MvxIntentResult - request was {0}", result.RequestCode);
                return(base.ProcessMvxIntentResult(result));
            }

            return(ProcessPictureUri(result, uri));
        }
        protected override void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
        {
            base.ProcessMvxIntentResult(result);

            if (result.RequestCode != googleSignInResult)
            {
                return;
            }

            lock (lockable)
            {
                var signInData = Auth.GoogleSignInApi.GetSignInResultFromIntent(result.Data);
                if (signInData.IsSuccess)
                {
                    Task.Run(() =>
                    {
                        try
                        {
                            var token = GoogleAuthUtil.GetToken(Application.Context, signInData.SignInAccount.Account, scope);
                            loginSubject.OnNext(token);
                            loginSubject.OnCompleted();
                        }
                        catch (Exception e)
                        {
                            loginSubject.OnError(e);
                        }
                        finally
                        {
                            isLoggingIn = false;
                        }
                    });
                }
                else
                {
                    loginSubject.OnError(new GoogleLoginException(signInData.Status.IsCanceled));
                    isLoggingIn = false;
                }
            }
        }
Beispiel #18
0
 protected virtual bool ProcessMvxIntentResult(MvxIntentResultEventArgs result)
 {
     // default processing does nothing
     return(false);
 }
Beispiel #19
0
 protected virtual void ProcessMvxIntentResult(MvxIntentResultEventArgs result)
 {
     // default processing does nothing
 }
Beispiel #20
0
        public void OnResult(MvxIntentResultEventArgs result)
        {
            var handler = this.Result;

            handler?.Invoke(this, result);
        }
Beispiel #21
0
 public void OnResult(MvxIntentResultEventArgs result)
 {
     Result?.Invoke(this, result);
 }