NekoX/TMessagesProj/src/main/java/org/telegram/messenger/AutoMessageReplyReceiver.java

40 lines
1.5 KiB
Java
Raw Normal View History

2015-05-21 23:27:27 +02:00
/*
2019-01-23 18:03:33 +01:00
* This is the source code of Telegram for Android v. 5.x.x.
2015-05-21 23:27:27 +02:00
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
2019-01-23 18:03:33 +01:00
* Copyright Nikolai Kudashov, 2013-2018.
2015-05-21 23:27:27 +02:00
*/
2015-09-24 22:52:02 +02:00
package org.telegram.messenger;
2015-05-21 23:27:27 +02:00
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
2019-05-14 14:08:05 +02:00
import androidx.core.app.RemoteInput;
2015-05-21 23:27:27 +02:00
public class AutoMessageReplyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
2016-04-22 15:49:00 +02:00
ApplicationLoader.postInitApplication();
2015-05-21 23:27:27 +02:00
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
if (remoteInput == null) {
return;
}
CharSequence text = remoteInput.getCharSequence(NotificationsController.EXTRA_VOICE_REPLY);
if (text == null || text.length() == 0) {
return;
}
long dialog_id = intent.getLongExtra("dialog_id", 0);
int max_id = intent.getIntExtra("max_id", 0);
2018-07-30 04:07:02 +02:00
int currentAccount = intent.getIntExtra("currentAccount", 0);
2015-05-21 23:27:27 +02:00
if (dialog_id == 0 || max_id == 0) {
return;
}
2020-09-30 15:48:47 +02:00
SendMessagesHelper.getInstance(currentAccount).sendMessage(text.toString(), dialog_id, null, null, null, true, null, null, null, true, 0);
MessagesController.getInstance(currentAccount).markDialogAsRead(dialog_id, max_id, max_id, 0, false, 0, 0, true, 0);
2015-05-21 23:27:27 +02:00
}
}