codec2_talkie/codec2talkie/src/main/java/com/radio/codec2talkie/storage/message/group/MessageGroupDialogSendTo.java

59 wiersze
2.0 KiB
Java
Czysty Zwykły widok Historia

2022-07-18 09:24:30 +00:00
package com.radio.codec2talkie.storage.message.group;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
2022-07-18 10:26:38 +00:00
import android.widget.Button;
2022-07-18 17:17:40 +00:00
import android.widget.EditText;
2022-07-18 09:24:30 +00:00
import androidx.annotation.NonNull;
2022-07-18 10:26:38 +00:00
import androidx.appcompat.app.AlertDialog;
2022-07-18 09:24:30 +00:00
import com.radio.codec2talkie.R;
2022-07-18 17:17:40 +00:00
import com.radio.codec2talkie.app.AppService;
import com.radio.codec2talkie.protocol.message.TextMessage;
2022-07-18 09:24:30 +00:00
2023-07-15 13:25:48 +00:00
import java.util.Locale;
2022-07-18 10:26:38 +00:00
public class MessageGroupDialogSendTo extends AlertDialog implements View.OnClickListener {
2022-07-18 09:24:30 +00:00
2022-07-18 17:17:40 +00:00
private final AppService _appService;
public MessageGroupDialogSendTo(@NonNull Context context, AppService appService) {
2022-07-18 09:24:30 +00:00
super(context);
2022-07-18 17:17:40 +00:00
_appService = appService;
2022-07-18 09:24:30 +00:00
}
@Override
protected void onCreate(Bundle savedInstanceState) {
2022-07-18 17:17:40 +00:00
setTitle(getContext().getString(R.string.activity_send_message_to_title));
2022-07-18 09:24:30 +00:00
setContentView(R.layout.activity_send_message_to);
2022-07-18 10:26:38 +00:00
Button sendButton = findViewById(R.id.send_message_to_btn_ok);
assert sendButton != null;
sendButton.setOnClickListener(this);
Button cancelButton = findViewById(R.id.send_message_to_btn_cancel);
assert cancelButton != null;
cancelButton.setOnClickListener(this);
2022-07-18 09:24:30 +00:00
}
@Override
public void onClick(View v) {
2022-07-18 10:26:38 +00:00
int id = v.getId();
if (id == R.id.send_message_to_btn_ok) {
2022-07-18 17:17:40 +00:00
EditText targetEdit = findViewById(R.id.send_message_to_target_edit);
EditText messageEdit = findViewById(R.id.send_message_to_message_edit);
assert targetEdit != null;
assert messageEdit != null;
TextMessage textMessage = new TextMessage();
2023-07-15 13:25:48 +00:00
textMessage.dst = targetEdit.getText().toString().toUpperCase(Locale.ROOT);
2022-07-18 17:17:40 +00:00
textMessage.text = messageEdit.getText().toString();
2023-07-15 13:25:48 +00:00
textMessage.ackId = 0;
2022-07-18 17:17:40 +00:00
_appService.sendTextMessage(textMessage);
dismiss();
2022-07-18 10:26:38 +00:00
} else if (id == R.id.send_message_to_btn_cancel) {
dismiss();
}
2022-07-18 09:24:30 +00:00
}
}