public RoutePointV2ViewModel(string routeId, string routePointId)
        {
            BackNavigationCommand   = new Command(backNavigationCommand);
            TakePhotoCommand        = new Command(takePhotoAsync);
            ViewPhotoCommand        = new Command(viewPhotoAsync);
            PressPhotoCommand       = new Command(pressPhotoCommand);
            PlayMediaCommand        = new Command(playMediaAsync);
            DeletePhotoCommand      = new Command(deletePhotoAsync);
            DeletePointCommand      = new Command(deletePoint);
            AddPhotoCommand         = new Command(addPhotoAsync);
            AddAudioCommand         = new Command(addAudioAsync);
            ShareCommand            = new Command(shareCommand);
            EditNameCommand         = new Command(editNameCommand);
            CancelNameCommand       = new Command(cancelNameCommand);
            EditNameCompleteCommand = new Command(editNameCompleteCommand);
            ClearNameCommand        = new Command(clearNameCommand);
            EditDescriptionCommand  = new Command(editDescriptionCommand);
            CopyCoordinatesCommand  = new Command(copyCoordinatesCommand);
            UpdateAddressCommand    = new Command(updateAddressCommand);
            CopyAddressCommand      = new Command(copyAddressCommand);
            RecognizeAudioCommand   = new Command(recognizeAudioCommandAsync);

            RecordAudioStopAndSaveCommand = new Command(recordAudioStopAndSaveCommand);
            RecordAudioCancel             = new Command(recordAudioCancel);

            ShareToMapCommand    = new Command(shareToMapCommand);
            EditPoiDialogCommand = new Command(editPoiDialogCommand);

            _vpoint            = new ViewRoutePoint(routeId, routePointId);
            _routePointManager = new RoutePointManager();
            _newPoint          = string.IsNullOrEmpty(routePointId);

            Analytics.TrackEvent("Dialog point opened");
        }
        public void Share(ViewRoute vroute, string packageName)
        {
            if ((vroute != null) && (!string.IsNullOrEmpty(vroute.Id)))
            {
                RoutePointManager pointManager = new RoutePointManager();
                var    routePoints             = pointManager.GetPointsByRouteId(vroute.RouteId);
                Intent share = new Intent(Intent.ActionSendMultiple);
                share.SetType("image/*");
                List <Uri> uris = new List <Uri>();
                if (routePoints.Any())
                {
                    Java.IO.File file    = new Java.IO.File(vroute.CoverImage);
                    var          fileUri = FileProvider.GetUriForFile(Android.App.Application.Context, Android.App.Application.Context.PackageName + ".fileprovider", file);
                    share.PutExtra(Intent.ExtraStream, fileUri);
                    uris.Add(fileUri);
                    share.PutParcelableArrayListExtra(Intent.ExtraStream, uris.ToArray());
                }
                share.SetFlags(ActivityFlags.NewTask);

                if (!string.IsNullOrEmpty(packageName))
                {
                    AddComponentNameToIntent(packageName, share);
                }

                try
                {
                    Android.App.Application.Context.StartActivity(share);
                }
                catch (Exception e)
                {
                    HandleError.Process("Facebook", "Share route", e, false);
                }
            }
        }
 public MapRouteOverviewViewModel(string routeId)
 {
     BackNavigationCommand = new Command(backNavigationCommand);
     _routePointManager    = new RoutePointManager();
     _routeManager         = new RouteManager();
     _routeId = routeId;
 }
        public new void Share(ViewRoute vroute, string packageName)
        {
            if ((vroute != null) && (!string.IsNullOrEmpty(vroute.Id)))
            {
                RoutePointManager pointManager = new RoutePointManager();
                var    routePoints             = pointManager.GetPointsByRouteId(vroute.RouteId);
                Intent share = new Intent(Intent.ActionSend);
                share.SetType("image/*");
                if (routePoints.Any())
                {
                    Java.IO.File file    = new Java.IO.File(vroute.CoverImage);
                    var          fileUri = FileProvider.GetUriForFile(Android.App.Application.Context, Android.App.Application.Context.PackageName + ".fileprovider", file);
                    share.PutExtra(Intent.ExtraStream, fileUri);
                    share.AddFlags(ActivityFlags.GrantReadUriPermission);
                }

                var componentName = new ComponentName("com.instagram.android", "com.instagram.share.handleractivity.ShareHandlerActivity");
                share.SetComponent(componentName);

                try
                {
                    var intentNew = Intent.CreateChooser(share, "Share to");
                    intentNew.SetFlags(ActivityFlags.NewTask);
                    Android.App.Application.Context.StartActivity(intentNew);
                }
                catch (Exception e)
                {
                    HandleError.Process("Instagram", "Share route", e, false);
                }
            }
        }
 public MapOverviewViewModel()
 {
     UpdatePOIsCommand              = new Command(updatePOIsCommand);
     HidePoiDialogCommand           = new Command(hidePoiDialogCommand);
     StartShowAlbumCommand          = new Command(startShowAlbumCommand);
     RequestToLocationAccessCommand = new Command(requestToLocationAccessCommand);
     _routePointManager             = new RoutePointManager();
     _routeManager  = new RouteManager();
     PoiImageWidth  = Convert.ToInt32(DeviceSize.FullScreenWidth * 0.9);
     PoiImageHeight = Convert.ToInt32(DeviceSize.FullScreenHeight * 0.5);
 }
Пример #6
0
 public MapRouteOverviewV2ViewModel(string routeId)
 {
     HidePoiDialogCommand        = new Command(hidePoiDialogCommand);
     OpenRoutePointDialogCommand = new Command(openRoutePointDialogCommand);
     SetNewLocationCommand       = new Command(setNewLocationCommand);
     BackNavigationCommand       = new Command(backNavigationCommandAsync);
     CancelSetLocationCommand    = new Command(cancelSetLocationCommand);
     _routeId              = routeId;
     _trackFileManager     = new TrackFileManager();
     _routePointManager    = new RoutePointManager();
     RoutePointFrameWidth  = Convert.ToInt32(DeviceSize.FullScreenWidth * 0.9);
     RoutePointFrameHeight = Convert.ToInt32(DeviceSize.FullScreenHeight * 0.7);
 }
        public new void Share(ViewRoute vroute, string packageName)
        {
            //https://stackoverflow.com/questions/30196530/share-image-plain-text-and-html-text-via-intent
            //https://guides.codepath.com/android/Sharing-Content-with-Intents
            if ((vroute != null) && (!string.IsNullOrEmpty(vroute.Id)))
            {
                RoutePointManager pointManager = new RoutePointManager();
                var    routePoints             = pointManager.GetPointsByRouteId(vroute.RouteId);
                Intent share = new Intent(Intent.ActionSendMultiple);
                share.SetType("image/*");
                List <Uri> uris = new List <Uri>();
                if (routePoints.Any())
                {
                    foreach (var point in routePoints)
                    {
                        foreach (var path in point.MediaObjectPaths)
                        {
                            Java.IO.File file    = new Java.IO.File(path);
                            var          fileUri = FileProvider.GetUriForFile(Android.App.Application.Context, Android.App.Application.Context.PackageName + ".fileprovider", file);
                            uris.Add(fileUri);
                        }
                    }

                    share.PutParcelableArrayListExtra(Intent.ExtraStream, uris.ToArray());
                }
                share.PutExtra(Intent.ExtraAllowMultiple, true);
                share.SetFlags(ActivityFlags.NewTask);

                if (!string.IsNullOrEmpty(packageName))
                {
                    AddComponentNameToIntent(packageName, share);
                }

                try
                {
                    Android.App.Application.Context.StartActivity(share);
                }
                catch (Exception e)
                {
                    HandleError.Process("Whatsapp", "Share route", e, false);
                }
            }
        }
        public EditRoutePointDescriptionViewModel(string routePointId)
        {
            BackNavigationCommand  = new Command(backNavigationCommand);
            CancelCommand          = new Command(cancelCommand);
            EditDescriptionCommand = new Command(editDescriptionCommand);
            if (!string.IsNullOrEmpty(routePointId))
            {
                RoutePointManager manager = new RoutePointManager();
                var point = manager.GetPointById(routePointId);
                _vpoint = new ViewRoutePoint(point.RouteId, routePointId);
                _previousDescription = _vpoint.Description;
            }
            else
            {
                HandleError.Process("EditRoutePointDescription", "EditDescripton", new Exception("Ошибка, точка еще не создана."), true);
            }

            IsEditMode = false;
        }
        public void Share(ViewRoute vroute, string packageName)
        {
            if ((vroute != null) && (!string.IsNullOrEmpty(vroute.Id)))
            {
                RoutePointManager pointManager = new RoutePointManager();
                var    routePoints             = pointManager.GetPointsByRouteId(vroute.RouteId);
                Intent share = new Intent(Intent.ActionSendMultiple);
                share.SetType("image/*");
                List <Uri> uris = new List <Uri>();
                if (routePoints.Any())
                {
                    foreach (var point in routePoints)
                    {
                        foreach (var path in point.MediaObjectPaths)
                        {
                            Java.IO.File file    = new Java.IO.File(path);
                            var          fileUri = FileProvider.GetUriForFile(Android.App.Application.Context, Android.App.Application.Context.PackageName + ".fileprovider", file);
                            uris.Add(fileUri);
                        }
                    }
                    share.PutParcelableArrayListExtra(Intent.ExtraStream, uris.ToArray());
                }
                StringBuilder sbRoute = GetRouteText(vroute);
                share.PutExtra(Intent.ExtraText, $"{sbRoute.ToString()}");
                share.PutExtra(Intent.ExtraAllowMultiple, true);
                share.SetFlags(ActivityFlags.NewTask);

                if (!string.IsNullOrEmpty(packageName))
                {
                    AddComponentNameToIntent(packageName, share);
                }

                try
                {
                    Android.App.Application.Context.StartActivity(share);
                }
                catch (Exception e)
                {
                    HandleError.Process("CommonShareService", "Share route", e, false);
                }
            }
        }
        public StringBuilder GetRouteText(ViewRoute vroute)
        {
            RoutePointManager pointManager = new RoutePointManager();
            var           routePoints      = pointManager.GetPointsByRouteId(vroute.RouteId);
            StringBuilder sbRoute          = new StringBuilder();

            sbRoute.AppendLine($"{vroute.CreateDate.ToString("yyyy MMMM")}");
            sbRoute.AppendLine($"{vroute.Name}");
            if (routePoints.Any())
            {
                foreach (var point in routePoints)
                {
                    sbRoute.AppendLine("");
                    sbRoute.AppendLine($"{point.CreateDate.ToString("dd.MM.yyyy")}");
                    if (!string.IsNullOrEmpty(point.Name.Trim()))
                    {
                        sbRoute.AppendLine(point.Name);
                    }

                    if ((!point.Latitude.Equals(0d)) && (!point.Longitude.Equals(0d)))
                    {
                        sbRoute.AppendLine(
                            $"{point.Latitude.ToString("G", CultureInfo.InvariantCulture)}, {point.Longitude.ToString("G", CultureInfo.InvariantCulture)}");
                    }

                    if (!string.IsNullOrEmpty(point.Address.Trim()))
                    {
                        sbRoute.AppendLine($"Адрес: {point.Address}");
                    }

                    if (!string.IsNullOrEmpty(point.Description.Trim()))
                    {
                        sbRoute.AppendLine($"Описание: {point.Description}");
                    }
                }
            }

            return(sbRoute);
        }