Java Code Examples for org.telegram.messenger.ChatObject#canSendStickers()

The following examples show how to use org.telegram.messenger.ChatObject#canSendStickers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MentionsAdapter.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo)
{
    currentAccount = UserConfig.selectedAccount;
    info = chatInfo;
    if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null)
    {
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null)
        {
            inlineMediaEnabled = ChatObject.canSendStickers(chat);
            if (inlineMediaEnabled)
            {
                searchResultUsernames = null;
                notifyDataSetChanged();
                delegate.needChangePanelVisibility(false);
                processFoundUser(foundContextBot);
            }
        }
    }
    if (lastText != null)
    {
        searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
    }
}
 
Example 2
Source File: MentionsAdapter.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo)
{
    currentAccount = UserConfig.selectedAccount;
    info = chatInfo;
    if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null)
    {
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null)
        {
            inlineMediaEnabled = ChatObject.canSendStickers(chat);
            if (inlineMediaEnabled)
            {
                searchResultUsernames = null;
                notifyDataSetChanged();
                delegate.needChangePanelVisibility(false);
                processFoundUser(foundContextBot);
            }
        }
    }
    if (lastText != null)
    {
        searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
    }
}
 
Example 3
Source File: MentionsAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo) {
    currentAccount = UserConfig.selectedAccount;
    info = chatInfo;
    if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null) {
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null) {
            inlineMediaEnabled = ChatObject.canSendStickers(chat);
            if (inlineMediaEnabled) {
                searchResultUsernames = null;
                notifyDataSetChanged();
                delegate.needChangePanelVisibility(false);
                processFoundUser(foundContextBot);
            }
        }
    }
    if (lastText != null) {
        searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
    }
}
 
Example 4
Source File: MentionsAdapter.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setChatInfo(TLRPC.ChatFull chatInfo) {
    currentAccount = UserConfig.selectedAccount;
    info = chatInfo;
    if (!inlineMediaEnabled && foundContextBot != null && parentFragment != null) {
        TLRPC.Chat chat = parentFragment.getCurrentChat();
        if (chat != null) {
            inlineMediaEnabled = ChatObject.canSendStickers(chat);
            if (inlineMediaEnabled) {
                searchResultUsernames = null;
                notifyDataSetChanged();
                delegate.needChangePanelVisibility(false);
                processFoundUser(foundContextBot);
            }
        }
    }
    if (lastText != null) {
        searchUsernameOrHashtag(lastText, lastPosition, messages, lastUsernameOnly);
    }
}
 
Example 5
Source File: MentionsAdapter.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void processFoundUser(TLRPC.User user)
{
    contextUsernameReqid = 0;
    locationProvider.stop();
    if (user != null && user.bot && user.bot_inline_placeholder != null)
    {
        foundContextBot = user;
        if (parentFragment != null)
        {
            TLRPC.Chat chat = parentFragment.getCurrentChat();
            if (chat != null)
            {
                inlineMediaEnabled = ChatObject.canSendStickers(chat);
                if (!inlineMediaEnabled)
                {
                    notifyDataSetChanged();
                    delegate.needChangePanelVisibility(true);
                    return;
                }
            }
        }
        if (foundContextBot.bot_inline_geo)
        {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            boolean allowGeo = preferences.getBoolean("inlinegeo_" + foundContextBot.id, false);
            if (!allowGeo && parentFragment != null && parentFragment.getParentActivity() != null)
            {
                final TLRPC.User foundContextBotFinal = foundContextBot;
                AlertDialog.Builder builder = new AlertDialog.Builder(parentFragment.getParentActivity());
                builder.setTitle(LocaleController.getString("ShareYouLocationTitle", R.string.ShareYouLocationTitle));
                builder.setMessage(LocaleController.getString("ShareYouLocationInline", R.string.ShareYouLocationInline));
                final boolean buttonClicked[] = new boolean[1];
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) ->
                {
                    buttonClicked[0] = true;
                    if (foundContextBotFinal != null)
                    {
                        SharedPreferences preferences1 = MessagesController.getNotificationsSettings(currentAccount);
                        preferences1.edit().putBoolean("inlinegeo_" + foundContextBotFinal.id, true).commit();
                        checkLocationPermissionsOrStart();
                    }
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (dialog, which) ->
                {
                    buttonClicked[0] = true;
                    onLocationUnavailable();
                });
                parentFragment.showDialog(builder.create(), dialog ->
                {
                    if (!buttonClicked[0])
                    {
                        onLocationUnavailable();
                    }
                });
            }
            else
            {
                checkLocationPermissionsOrStart();
            }
        }
    }
    else
    {
        foundContextBot = null;
        inlineMediaEnabled = true;
    }
    if (foundContextBot == null)
    {
        noUserName = true;
    }
    else
    {
        if (delegate != null)
        {
            delegate.onContextSearch(true);
        }
        searchForContextBotResults(true, foundContextBot, searchingContextQuery, "");
    }
}
 
Example 6
Source File: MentionsAdapter.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void processFoundUser(TLRPC.User user)
{
    contextUsernameReqid = 0;
    locationProvider.stop();
    if (user != null && user.bot && user.bot_inline_placeholder != null)
    {
        foundContextBot = user;
        if (parentFragment != null)
        {
            TLRPC.Chat chat = parentFragment.getCurrentChat();
            if (chat != null)
            {
                inlineMediaEnabled = ChatObject.canSendStickers(chat);
                if (!inlineMediaEnabled)
                {
                    notifyDataSetChanged();
                    delegate.needChangePanelVisibility(true);
                    return;
                }
            }
        }
        if (foundContextBot.bot_inline_geo)
        {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            boolean allowGeo = preferences.getBoolean("inlinegeo_" + foundContextBot.id, false);
            if (!allowGeo && parentFragment != null && parentFragment.getParentActivity() != null)
            {
                final TLRPC.User foundContextBotFinal = foundContextBot;
                AlertDialog.Builder builder = new AlertDialog.Builder(parentFragment.getParentActivity());
                builder.setTitle(LocaleController.getString("ShareYouLocationTitle", R.string.ShareYouLocationTitle));
                builder.setMessage(LocaleController.getString("ShareYouLocationInline", R.string.ShareYouLocationInline));
                final boolean buttonClicked[] = new boolean[1];
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) ->
                {
                    buttonClicked[0] = true;
                    if (foundContextBotFinal != null)
                    {
                        SharedPreferences preferences1 = MessagesController.getNotificationsSettings(currentAccount);
                        preferences1.edit().putBoolean("inlinegeo_" + foundContextBotFinal.id, true).commit();
                        checkLocationPermissionsOrStart();
                    }
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (dialog, which) ->
                {
                    buttonClicked[0] = true;
                    onLocationUnavailable();
                });
                parentFragment.showDialog(builder.create(), dialog ->
                {
                    if (!buttonClicked[0])
                    {
                        onLocationUnavailable();
                    }
                });
            }
            else
            {
                checkLocationPermissionsOrStart();
            }
        }
    }
    else
    {
        foundContextBot = null;
        inlineMediaEnabled = true;
    }
    if (foundContextBot == null)
    {
        noUserName = true;
    }
    else
    {
        if (delegate != null)
        {
            delegate.onContextSearch(true);
        }
        searchForContextBotResults(true, foundContextBot, searchingContextQuery, "");
    }
}
 
Example 7
Source File: MentionsAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void processFoundUser(TLRPC.User user) {
    contextUsernameReqid = 0;
    locationProvider.stop();
    if (user != null && user.bot && user.bot_inline_placeholder != null) {
        foundContextBot = user;
        if (parentFragment != null) {
            TLRPC.Chat chat = parentFragment.getCurrentChat();
            if (chat != null) {
                inlineMediaEnabled = ChatObject.canSendStickers(chat);
                if (!inlineMediaEnabled) {
                    notifyDataSetChanged();
                    delegate.needChangePanelVisibility(true);
                    return;
                }
            }
        }
        if (foundContextBot.bot_inline_geo) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            boolean allowGeo = preferences.getBoolean("inlinegeo_" + foundContextBot.id, false);
            if (!allowGeo && parentFragment != null && parentFragment.getParentActivity() != null) {
                final TLRPC.User foundContextBotFinal = foundContextBot;
                AlertDialog.Builder builder = new AlertDialog.Builder(parentFragment.getParentActivity());
                builder.setTitle(LocaleController.getString("ShareYouLocationTitle", R.string.ShareYouLocationTitle));
                builder.setMessage(LocaleController.getString("ShareYouLocationInline", R.string.ShareYouLocationInline));
                final boolean[] buttonClicked = new boolean[1];
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> {
                    buttonClicked[0] = true;
                    if (foundContextBotFinal != null) {
                        SharedPreferences preferences1 = MessagesController.getNotificationsSettings(currentAccount);
                        preferences1.edit().putBoolean("inlinegeo_" + foundContextBotFinal.id, true).commit();
                        checkLocationPermissionsOrStart();
                    }
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (dialog, which) -> {
                    buttonClicked[0] = true;
                    onLocationUnavailable();
                });
                parentFragment.showDialog(builder.create(), dialog -> {
                    if (!buttonClicked[0]) {
                        onLocationUnavailable();
                    }
                });
            } else {
                checkLocationPermissionsOrStart();
            }
        }
    } else {
        foundContextBot = null;
        inlineMediaEnabled = true;
    }
    if (foundContextBot == null) {
        noUserName = true;
    } else {
        if (delegate != null) {
            delegate.onContextSearch(true);
        }
        searchForContextBotResults(true, foundContextBot, searchingContextQuery, "");
    }
}
 
Example 8
Source File: MentionsAdapter.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void processFoundUser(TLRPC.User user) {
    contextUsernameReqid = 0;
    locationProvider.stop();
    if (user != null && user.bot && user.bot_inline_placeholder != null) {
        foundContextBot = user;
        if (parentFragment != null) {
            TLRPC.Chat chat = parentFragment.getCurrentChat();
            if (chat != null) {
                inlineMediaEnabled = ChatObject.canSendStickers(chat);
                if (!inlineMediaEnabled) {
                    notifyDataSetChanged();
                    delegate.needChangePanelVisibility(true);
                    return;
                }
            }
        }
        if (foundContextBot.bot_inline_geo) {
            SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
            boolean allowGeo = preferences.getBoolean("inlinegeo_" + foundContextBot.id, false);
            if (!allowGeo && parentFragment != null && parentFragment.getParentActivity() != null) {
                final TLRPC.User foundContextBotFinal = foundContextBot;
                AlertDialog.Builder builder = new AlertDialog.Builder(parentFragment.getParentActivity());
                builder.setTitle(LocaleController.getString("ShareYouLocationTitle", R.string.ShareYouLocationTitle));
                builder.setMessage(LocaleController.getString("ShareYouLocationInline", R.string.ShareYouLocationInline));
                final boolean[] buttonClicked = new boolean[1];
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> {
                    buttonClicked[0] = true;
                    if (foundContextBotFinal != null) {
                        SharedPreferences preferences1 = MessagesController.getNotificationsSettings(currentAccount);
                        preferences1.edit().putBoolean("inlinegeo_" + foundContextBotFinal.id, true).commit();
                        checkLocationPermissionsOrStart();
                    }
                });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (dialog, which) -> {
                    buttonClicked[0] = true;
                    onLocationUnavailable();
                });
                parentFragment.showDialog(builder.create(), dialog -> {
                    if (!buttonClicked[0]) {
                        onLocationUnavailable();
                    }
                });
            } else {
                checkLocationPermissionsOrStart();
            }
        }
    } else {
        foundContextBot = null;
        inlineMediaEnabled = true;
    }
    if (foundContextBot == null) {
        noUserName = true;
    } else {
        if (delegate != null) {
            delegate.onContextSearch(true);
        }
        searchForContextBotResults(true, foundContextBot, searchingContextQuery, "");
    }
}