public ShareRoutesServicesViewModel(string routeId) { if (!string.IsNullOrEmpty(routeId)) { _routeId = routeId; _vroute = new ViewRoute(routeId); } else { throw new Exception("routeId is empty!"); } _appInstalledService = DependencyService.Get <IApplicationInstalledService>(); TapAddUserCommand = new Command(tapAddUserCommandAsync); TapPublishAlbumCommand = new Command(tapPublishAlbumCommandAsync); TapMakeReferenceCommand = new Command(tapMakeReferenceCommand); TapOtherCommand = new Command(tapOtherCommand); TapTelegramCommand = new Command(tapTelegramCommand); TapInstagramCommand = new Command(tapInstagramCommand); TapFacebookCommand = new Command(tapFacebookCommand); TapViberCommand = new Command(tapViberCommand); TapWhatsappCommand = new Command(tapWhatsappCommand); TapGMailCommand = new Command(tapGMailCommand); BackNavigationCommand = new Command(backNavigationCommand); _routeId = routeId; }
internal async Task <IEnumerable <ViewRoutePoint> > GetPointsForOverviewRouteAsync() { var resultPoints = new List <ViewRoutePoint>(); IEnumerable <ViewRoute> routes; if (string.IsNullOrEmpty(_routeId)) { TokenStoreService tokenService = new TokenStoreService(); string userId = await tokenService.GetUserIdAsync(); routes = _routeManager.GetRoutes(userId); } else { ViewRoute route = _routeManager.GetViewRouteById(_routeId); var routesList = new List <ViewRoute>(); routesList.Add(route); routes = routesList; } foreach (var route in routes) { var points = _routePointManager.GetPointsByRouteId(route.RouteId); foreach (var point in points) { resultPoints.Add(point); } } return(resultPoints); }
private async void startShowAlbumCommand(object obj) { if (!string.IsNullOrEmpty(_currentViewPoi?.ByRouteId)) { var routesApi = new RoutesApiRequest(DefaultUrls.ApiUrl, await _tokenService.GetAuthTokenAsync()); var routeRoot = await routesApi.GetRouteRoot(_currentViewPoi?.ByRouteId); if ((routesApi.GetLastHttpStatusCode() == HttpStatusCode.OK) && (!string.IsNullOrEmpty(routeRoot.Route.Id))) { var vRoute = new ViewRoute(_currentViewPoi.ByRouteId); if (!string.IsNullOrEmpty(routeRoot.Route.Id)) { //Может быть неопубликованный маршрут, все-таки покажем его vRoute.FillFromWSModel(routeRoot, string.Empty); } if (!string.IsNullOrEmpty(routeRoot.Route.ImgFilename)) { bool resultDownloadCover = await routesApi.DownloadCoverImage(_currentViewPoi?.ByRouteId, routeRoot.Route.ImgFilename); } else { vRoute.ImgFilename = _currentPoiImage; } await Navigation.PushModalAsync(new RouteCoverPage(vRoute, true)); } } }
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 void ShareRouteOnlyPointsDescription(ViewRoute vroute, string packageName) { Intent share = new Intent(Intent.ActionSend); share.SetType("html/*"); if ((vroute != null) && (!string.IsNullOrEmpty(vroute.Id))) { StringBuilder sbRoute = GetRouteText(vroute); share.PutExtra(Intent.ExtraText, $"{sbRoute.ToString()}"); 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 NewRouteViewModel(bool isFirstRoute) { _vroute = new ViewRoute(string.Empty); _isFirstRoute = isFirstRoute; ShowNewRouteDialogCommand = new Command(showNewRouteData); OpenRoutePointDialogCommand = new Command(openRoutePointDialogAsync); }
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 RouteCoverPage(ViewRoute vRoute, bool isNeedShowAlbum) { InitializeComponent(); _vm = new RouteCoverViewModel(vRoute, isNeedShowAlbum) { Navigation = this.Navigation }; BindingContext = _vm; }
public RouteCarouselRootViewModel(string routeId) { BackNavigationCommand = new Command(backNavigationCommand); CardsItemAppearedCommand = new Command(cardsItemAppearedCommand); ShowOtherPhotoCommand = new Command(showOtherPhotoCommand); SwipeDescriptionRightCommand = new Command(swipeDescriptionRightCommand); SwipeDescriptionLeftCommand = new Command(swipeDescriptionLeftCommand); ViewPhotoCommand = new Command(viewPhotoCommand); ChangeImageAspectCommand = new Command(changeImageAspectCommand); _trackFileManager = new TrackFileManager(); _vRoute = new ViewRoute(routeId); }
public PointCarouselItemViewModel(string routeId, string routePointId, string routePointMediaId) { _routeObject = new ViewRoute(routeId); _pointObject = new ViewRoutePoint(routeId, routePointId); _mediaObject = new ViewRoutePointMediaObject(); _mediaObject.Load(routePointMediaId); ChangeImageAspectCommand = new Command(changeImageAspectCommand); EditRoutePointCommand = new Command(editRoutePointCommand); PhotoImageAspect = Aspect.AspectFill; }
/// <summary> /// Вызывается при открытии обложки из страницы альбомов, когда маршрут уже существует в локальной БД /// </summary> /// <param name="viewRoute"></param> public RouteCoverViewModel(ViewRoute viewRoute, bool isNeedShowAlbum) { init(); _isNeedShowAlbum = isNeedShowAlbum; if (!string.IsNullOrEmpty(viewRoute.Id)) { _routeId = viewRoute.Id; _vroute = viewRoute; } else { throw new Exception("viewRoute.Id is empty!"); } }
private async void updatePoiCommand(object obj) { string resultValidateText = getValidatePoiText(); if (string.IsNullOrEmpty(resultValidateText)) { PoiApiRequest poiApi = new PoiApiRequest(_authToken); _vpoi.UpdateDate = DateTimeOffset.Now; bool resultUpload = await poiApi.UploadPoiAsync(_vpoi.GetJsonStructure()); if (resultUpload) { applyChanges(); string msgText = CommonResource.PoiMsg_Warning; if (!string.IsNullOrEmpty(_vpoi.ByRouteId)) { var route = new ViewRoute(_vpoi.ByRouteId); if ((!route.IsPublished) && (_vpoi.IsPublished)) { msgText = CommonResource.PoiMsg_RouteAvailableOnlyForMe; } } MessagingCenter.Send <PoiUpdatedMessage>(new PoiUpdatedMessage() { PoiId = _vpoi.Id }, string.Empty); MainThread.BeginInvokeOnMainThread(() => { UserDialogs.Instance.Alert(msgText, CommonResource.PoiMsg_Saved, CommonResource.CommonMsg_Ok); }); await Navigation.PopModalAsync(); } } else { MainThread.BeginInvokeOnMainThread(() => { UserDialogs.Instance.Alert(resultValidateText, CommonResource.CommonMsg_Warning, CommonResource.CommonMsg_Ok); }); } }
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 bool Make(AutoGeneratedRouted autoRoute, string creatorId) { if (autoRoute.Points.Count > 0) { var vroute = new ViewRoute(string.Empty); vroute.CreatorId = creatorId; vroute.CreateDate = DateTime.Now; vroute.Name = autoRoute.Name; if (vroute.Save()) { foreach (var autoPoint in autoRoute.Points.Where(p => !p.IsDeleted)) { var vroutePoint = new ViewRoutePoint(vroute.RouteId, string.Empty); vroutePoint.Name = autoPoint.Name; vroutePoint.Longitude = autoPoint.Longitude; vroutePoint.Latitude = autoPoint.Latitude; vroutePoint.Version++; if (vroutePoint.Save()) { foreach (var autoMedia in autoPoint.Images.Where(i => !i.IsDeleted)) { string localImageId = autoMedia.Id; /*if (mediaObjectIsExists(mediaId)) * { * //в случае если мы используем одно и то же фото в нескольких альбомах, придется его дублировать * //связано с тем, что id media соответствует имени файла и если меняем свойства объекта в каком-то маршруте, меняется для всех * //media object в этом случае один, и это проблема * mediaId = makeNewMediaObject(mediaId); * }*/ string mediaId = makeNewMediaObject(localImageId); vroutePoint.AddMediaItem(mediaId, MediaObjectTypeEnum.Image); } vroutePoint.Save(); } } return(true); } } return(false); }
internal MakeRouteLinkPageViewModel(string routeId) { if (!string.IsNullOrEmpty(routeId)) { _routeId = routeId; _vroute = new ViewRoute(routeId); } else { throw new Exception("routeId is empty!"); } UrlTappedCommand = new Command(urlTappedCommandAsync); MakeSharedLinkCommand = new Command(makeSharedLinkCommandAsync); ShareRouteCommand = new Command(shareRouteCommand); BackNavigationCommand = new Command(backNavigationCommand); CopyUrlCommand = new Command(copyUrlCommand); CaptionText = _accessByLink; }
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); } } }
/// <summary> /// Вызывается при открытии обложки из ленты, в этом случае не все элементы маршрута еще могут быть загружены /// </summary> /// <param name="viewFeedItem"></param> public RouteCoverViewModel(ViewFeedItem viewFeedItem) { init(); _isNeedShowAlbum = true; if (!string.IsNullOrEmpty(viewFeedItem.Id)) { _routeId = viewFeedItem.Id; _vroute = new ViewRoute(viewFeedItem.Id); _vroute.CreateDate = viewFeedItem.CreateDate; _vroute.Description = viewFeedItem.Description; _vroute.Name = viewFeedItem.Name; _vroute.ImgFilename = viewFeedItem.CoverImage; _vroute.CreatorId = viewFeedItem.CreatorId; _creatorName = viewFeedItem.CreatorName; } else { throw new Exception("viewFeedItem.Id is empty!"); } }
internal void DeleteObjectFromLocalStorage(ViewRoute vRoute) { if (vRoute != null) { try { Route route = !string.IsNullOrEmpty(vRoute.Id) ? RealmInstance.Find <Route>(vRoute.Id) : null; if (route != null) { RealmInstance.Write(() => { RealmInstance.Remove(route); }); } } catch (Exception e) { HandleError.Process("RouteManager", "DeleteObjectFromLocalStorage", 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); }
public RouteViewModel(string routeId, bool isFirstRoute, bool isNeedSyncRoute) { _vroute = new ViewRoute(routeId); _isFirstRoute = isFirstRoute; _vroute.ServerSynced = !isNeedSyncRoute; _isNeedSyncRouteInitial = isNeedSyncRoute; _isNeedSyncRoute = _isNeedSyncRouteInitial; //ShareCommand = new Command(shareCommandAsync); ShareRouteCommand = new Command(shareRouteCommandAsync); SyncRouteCommand = new Command(syncRouteCommandAsync); ChooseImageForCoverCommand = new Command(chooseImageForCoverCommand); ShowNewRouteDialogCommand = new Command(showNewRouteData); AddNewRoutePointCommand = new Command(addNewRoutePointAsync); StartDialogCommand = new Command(startDialogAsync); EditRouteCommand = new Command(editRouteCommandAsync); EditRouteCompleteCommand = new Command(editRouteCompleteCommand); CancelEditRouteCommand = new Command(cancelEditRouteCommand); FullScreenMapCommand = new Command(fullScreenMapCommandAsync); PhotoAlbumCommand = new Command(photoAlbumCommandAsync); BackNavigationCommand = new Command(backNavigationCommand); DeleteRouteCommand = new Command(deleteRouteCommand); SelectTrackCommand = new Command(selectTrackCommand); }
protected List <string> GetRouteJsonStructure(ViewRoute viewRoute, string coverImgBase64) { List <string> jsonStructures = new List <string>(); if (viewRoute != null) { JObject jsonObject = JObject.FromObject(new { RouteId = viewRoute.RouteId, Name = viewRoute.Name, CreateDate = viewRoute.CreateDate.DateTime, Version = viewRoute.Version, IsPublished = viewRoute.IsPublished, CreatorId = viewRoute.CreatorId, Description = viewRoute.Description, ImgFilename = viewRoute.ImgFilename, CoverImgBase64 = string.IsNullOrEmpty(coverImgBase64) ? null : coverImgBase64, UserId = 0 }); jsonStructures.Add(jsonObject.ToString()); } return(jsonStructures); }
public void ShareRouteOnlyPhotos(ViewRoute vroute, string packageName) { }