Exemple #1
0
        public string GetPicture(ITLDialogWith with, string group)
        {
            TLFileLocation location = null;

            if (with is TLUser user && user.Photo is TLUserProfilePhoto userPhoto)
            {
                location = userPhoto.PhotoSmall as TLFileLocation;
            }
Exemple #2
0
 public GalleryItem(ITLTransferable source, string caption, ITLDialogWith from, int date, bool stickers)
 {
     Source      = source;
     Caption     = caption;
     From        = from;
     Date        = date;
     HasStickers = stickers;
 }
Exemple #3
0
        private Visibility ConvertBannedRights(ITLDialogWith with, bool invert)
        {
            if (with is TLChannel channel && channel.HasBannedRights && channel.BannedRights.IsSendInline)
            {
                return(invert ? Visibility.Collapsed : Visibility.Visible);
            }

            return(invert ? Visibility.Visible : Visibility.Collapsed);
        }
Exemple #4
0
        private string ConvertBannedRights(ITLDialogWith with)
        {
            if (with is TLChannel channel && channel.HasBannedRights && channel.BannedRights != null && channel.BannedRights.IsSendInline)
            {
                if (channel.BannedRights.IsForever())
                {
                    return(Strings.Android.AttachInlineRestrictedForever);
                }
                else
                {
                    return(string.Format(Strings.Android.AttachInlineRestricted, BindConvert.Current.BannedUntil(channel.BannedRights.UntilDate)));
                }
            }

            return(null);
        }
        public static async void NavigateToDialog(this INavigationService service, ITLDialogWith with, int?message = null, string accessToken = null)
        {
            if (with is TLUser user && user.IsRestricted)
            {
                var reason = user.ExtractRestrictionReason();
                if (reason != null)
                {
                    await TLMessageDialog.ShowAsync(reason, "Sorry", "OK");

                    return;
                }
            }

            if (with is TLChannel channel && channel.IsRestricted)
            {
                var reason = channel.ExtractRestrictionReason();
                if (reason != null)
                {
                    await TLMessageDialog.ShowAsync(reason, "Sorry", "OK");

                    return;
                }
            }

            var peer = with.ToPeer();

            if (service.CurrentPageType == typeof(DialogPage) && peer.Equals(service.CurrentPageParam))
            {
                if (service.Frame.Content is DialogPage page && page.ViewModel != null)
                {
                    if (message.HasValue)
                    {
                        await page.ViewModel.LoadMessageSliceAsync(null, message.Value);
                    }

                    if (accessToken != null)
                    {
                        page.ViewModel.AccessToken = accessToken;
                    }
                }
                else
                {
                    service.Refresh(TLSerializationService.Current.Serialize(peer));
                }
            }
Exemple #6
0
        public string GetLaunch(ITLDialogWith with)
        {
            var launch = string.Empty;

            if (with is TLChat chat)
            {
                launch += string.Format(CultureInfo.InvariantCulture, "chat_id={0}", chat.Id);
            }
            else if (with is TLChannel channel)
            {
                launch += string.Format(CultureInfo.InvariantCulture, "channel_id={0}&access_hash={1}", channel.Id, channel.AccessHash ?? 0);
            }
            else if (with is TLUser user)
            {
                launch += string.Format(CultureInfo.InvariantCulture, "from_id={0}&access_hash={1}", user.Id, user.AccessHash ?? 0);
            }

            return(launch);
        }
Exemple #7
0
        public string GetGroup(ITLDialogWith with)
        {
            if (with == null)
            {
                return(null);
            }

            if (with is TLChat chat)
            {
                return(string.Format(CultureInfo.InvariantCulture, "c{0}", chat.Id));
            }
            else if (with is TLChannel channel)
            {
                return(string.Format(CultureInfo.InvariantCulture, "c{0}", channel.Id));
            }
            else if (with is TLUser user)
            {
                return(string.Format(CultureInfo.InvariantCulture, "u{0}", user.Id));
            }

            return(null);
        }
Exemple #8
0
        public static async void NavigateToDialog(this INavigationService service, ITLDialogWith with, int?message = null, string accessToken = null)
        {
            if (with == null)
            {
                return;
            }

            if (with is TLUser user && user.IsRestricted)
            {
                var reason = user.ExtractRestrictionReason();
                if (reason != null)
                {
                    await TLMessageDialog.ShowAsync(reason, "Sorry", "OK");

                    return;
                }
            }

            if (with is TLChannel channel)
            {
                if (channel.IsRestricted)
                {
                    var reason = channel.ExtractRestrictionReason();
                    if (reason != null)
                    {
                        await TLMessageDialog.ShowAsync(reason, "Sorry", "OK");

                        return;
                    }
                }
                else if ((channel.IsLeft) && !channel.HasUsername)
                {
                    return;
                }
            }

            var peer = with.ToPeer();

            if (service.CurrentPageType == typeof(DialogPage) && peer.Equals(service.CurrentPageParam))
            {
                if (service.Frame.Content is DialogPage page && page.ViewModel != null)
                {
                    if (message.HasValue)
                    {
                        await page.ViewModel.LoadMessageSliceAsync(null, message.Value);
                    }

                    if (accessToken != null)
                    {
                        page.ViewModel.AccessToken = accessToken;
                    }

                    if (App.InMemoryState.ForwardMessages != null)
                    {
                        page.ViewModel.Reply = new TLMessagesContainter {
                            FwdMessages = new TLVector <TLMessage>(App.InMemoryState.ForwardMessages)
                        };
                    }

                    if (App.InMemoryState.SwitchInline != null)
                    {
                        var switchInlineButton = App.InMemoryState.SwitchInline;
                        var bot = App.InMemoryState.SwitchInlineBot;

                        page.ViewModel.SetText(string.Format("@{0} {1}", bot.Username, switchInlineButton.Query), focus: true);
                        page.ViewModel.ResolveInlineBot(bot.Username, switchInlineButton.Query);

                        App.InMemoryState.SwitchInline    = null;
                        App.InMemoryState.SwitchInlineBot = null;
                    }
                    else if (App.InMemoryState.SendMessage != null)
                    {
                        var text   = App.InMemoryState.SendMessage;
                        var hasUrl = App.InMemoryState.SendMessageUrl;

                        page.ViewModel.SetText(text);

                        if (hasUrl)
                        {
                            page.ViewModel.SetSelection(text.IndexOf('\n') + 1);
                        }

                        App.InMemoryState.SendMessage    = null;
                        App.InMemoryState.SendMessageUrl = false;
                    }
                }
                else
                {
                    service.Refresh(TLSerializationService.Current.Serialize(peer));
                }
            }
Exemple #9
0
 public GalleryDocumentItem(TLDocument document, ITLDialogWith from)
 {
     _document = document;
     _from     = from;
 }
Exemple #10
0
 public GalleryPhotoItem(TLPhoto photo, ITLDialogWith from)
 {
     _photo = photo;
     _from  = from;
 }
Exemple #11
0
 private string ConvertFrom(ITLDialogWith with)
 {
     return(with is TLUser user && user.IsSelf ? user.FullName : with?.DisplayName);
 }