Java Code Examples for org.telegram.messenger.AndroidUtilities#getTrimmedString()

The following examples show how to use org.telegram.messenger.AndroidUtilities#getTrimmedString() . 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: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public boolean processSendingText(CharSequence text)
{
    text = AndroidUtilities.getTrimmedString(text);
    int maxLength = MessagesController.getInstance(currentAccount).maxMessageLength;
    if (text.length() != 0)
    {
        int count = (int) Math.ceil(text.length() / (float) maxLength);
        for (int a = 0; a < count; a++)
        {
            CharSequence[] message = new CharSequence[]{text.subSequence(a * maxLength, Math.min((a + 1) * maxLength, text.length()))};
            ArrayList<TLRPC.MessageEntity> entities = DataQuery.getInstance(currentAccount).getEntities(message);
            SendMessagesHelper.getInstance(currentAccount).sendMessage(message[0].toString(), dialog_id, replyingMessageObject, messageWebPage, messageWebPageSearch, entities, null, null);
        }
        return true;
    }
    return false;
}
 
Example 2
Source File: ChatActivityEnterView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public boolean processSendingText(CharSequence text)
{
    text = AndroidUtilities.getTrimmedString(text);
    int maxLength = MessagesController.getInstance(currentAccount).maxMessageLength;
    if (text.length() != 0)
    {
        int count = (int) Math.ceil(text.length() / (float) maxLength);
        for (int a = 0; a < count; a++)
        {
            CharSequence[] message = new CharSequence[]{text.subSequence(a * maxLength, Math.min((a + 1) * maxLength, text.length()))};
            ArrayList<TLRPC.MessageEntity> entities = DataQuery.getInstance(currentAccount).getEntities(message);
            SendMessagesHelper.getInstance(currentAccount).sendMessage(message[0].toString(), dialog_id, replyingMessageObject, messageWebPage, messageWebPageSearch, entities, null, null);
        }
        return true;
    }
    return false;
}
 
Example 3
Source File: ChatAttachAlertPollLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static CharSequence getFixedString(CharSequence text) {
    if (TextUtils.isEmpty(text)) {
        return text;
    }
    text = AndroidUtilities.getTrimmedString(text);
    while (TextUtils.indexOf(text, "\n\n\n") >= 0) {
        text = TextUtils.replace(text, new String[]{"\n\n\n"}, new CharSequence[]{"\n\n"});
    }
    while (TextUtils.indexOf(text, "\n\n\n") == 0) {
        text = TextUtils.replace(text, new String[]{"\n\n\n"}, new CharSequence[]{"\n\n"});
    }
    return text;
}
 
Example 4
Source File: ChatAttachAlertPollLayout.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public static CharSequence getFixedString(CharSequence text) {
    if (TextUtils.isEmpty(text)) {
        return text;
    }
    text = AndroidUtilities.getTrimmedString(text);
    while (TextUtils.indexOf(text, "\n\n\n") >= 0) {
        text = TextUtils.replace(text, new String[]{"\n\n\n"}, new CharSequence[]{"\n\n"});
    }
    while (TextUtils.indexOf(text, "\n\n\n") == 0) {
        text = TextUtils.replace(text, new String[]{"\n\n\n"}, new CharSequence[]{"\n\n"});
    }
    return text;
}
 
Example 5
Source File: PhotoViewerCaptionEnterView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public CharSequence getFieldCharSequence() {
    return AndroidUtilities.getTrimmedString(messageEditText.getText());
}
 
Example 6
Source File: PhotoViewerCaptionEnterView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public CharSequence getFieldCharSequence() {
    return AndroidUtilities.getTrimmedString(messageEditText.getText());
}