Added forward confirmation dialog
This commit is contained in:
parent
1a905516a6
commit
eef14a847b
3 changed files with 58 additions and 12 deletions
|
@ -19,12 +19,15 @@
|
||||||
*/
|
*/
|
||||||
package org.linphone.chat;
|
package org.linphone.chat;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentManager;
|
import android.app.FragmentManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
|
@ -37,6 +40,7 @@ import org.linphone.core.ChatRoom;
|
||||||
import org.linphone.core.Factory;
|
import org.linphone.core.Factory;
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
import org.linphone.utils.FileUtils;
|
import org.linphone.utils.FileUtils;
|
||||||
|
import org.linphone.utils.LinphoneUtils;
|
||||||
|
|
||||||
public class ChatActivity extends MainActivity {
|
public class ChatActivity extends MainActivity {
|
||||||
public static final String NAME = "Chat";
|
public static final String NAME = "Chat";
|
||||||
|
@ -216,21 +220,11 @@ public class ChatActivity extends MainActivity {
|
||||||
mSharedFiles = null;
|
mSharedFiles = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mForwardMessage != null) {
|
|
||||||
Log.i("[Chat] Found message to forward");
|
|
||||||
ChatRoom room = LinphoneManager.getCore().getChatRoom(peerAddress, localAddress);
|
|
||||||
if (room != null) {
|
|
||||||
Log.i("[Chat] Found chat room in which to forward message");
|
|
||||||
ChatMessage message = room.createForwardMessage(mForwardMessage);
|
|
||||||
message.send();
|
|
||||||
mForwardMessage = null;
|
|
||||||
Log.i("[Chat] Message forwarded");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatMessagesFragment fragment = new ChatMessagesFragment();
|
ChatMessagesFragment fragment = new ChatMessagesFragment();
|
||||||
fragment.setArguments(extras);
|
fragment.setArguments(extras);
|
||||||
changeFragment(fragment, "Chat room", isChild);
|
changeFragment(fragment, "Chat room", isChild);
|
||||||
|
|
||||||
|
showForwardDialog(localAddress, peerAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showChatRoom(Address localAddress, Address peerAddress) {
|
public void showChatRoom(Address localAddress, Address peerAddress) {
|
||||||
|
@ -335,4 +329,55 @@ public class ChatActivity extends MainActivity {
|
||||||
mForwardMessage = message;
|
mForwardMessage = message;
|
||||||
Toast.makeText(this, R.string.toast_choose_chat_room_for_sharing, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.toast_choose_chat_room_for_sharing, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showForwardDialog(final Address localAddress, final Address peerAddress) {
|
||||||
|
if (mForwardMessage == null) return;
|
||||||
|
|
||||||
|
final Dialog dialog =
|
||||||
|
LinphoneUtils.getDialog(
|
||||||
|
this, getString(R.string.chat_message_forward_confirmation_dialog));
|
||||||
|
dialog.findViewById(R.id.dialog_delete_button).setVisibility(View.GONE);
|
||||||
|
|
||||||
|
ImageView icon = dialog.findViewById(R.id.dialog_icon);
|
||||||
|
icon.setVisibility(View.VISIBLE);
|
||||||
|
icon.setImageResource(R.drawable.forward_message_dialog_default);
|
||||||
|
|
||||||
|
Button cancel = dialog.findViewById(R.id.dialog_cancel_button);
|
||||||
|
cancel.setOnClickListener(
|
||||||
|
new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
mForwardMessage = null;
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button ok = dialog.findViewById(R.id.dialog_ok_button);
|
||||||
|
ok.setVisibility(View.VISIBLE);
|
||||||
|
ok.setText(getString(R.string.chat_message_context_menu_forward));
|
||||||
|
ok.setOnClickListener(
|
||||||
|
new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
doMessageForwarding(localAddress, peerAddress);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doMessageForwarding(Address localAddress, Address peerAddress) {
|
||||||
|
if (mForwardMessage != null) {
|
||||||
|
Log.i("[Chat] Found message to forward");
|
||||||
|
ChatRoom room = LinphoneManager.getCore().getChatRoom(peerAddress, localAddress);
|
||||||
|
if (room != null) {
|
||||||
|
Log.i("[Chat] Found chat room in which to forward message");
|
||||||
|
ChatMessage message = room.createForwardMessage(mForwardMessage);
|
||||||
|
message.send();
|
||||||
|
mForwardMessage = null;
|
||||||
|
Log.i("[Chat] Message forwarded");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
|
@ -277,6 +277,7 @@
|
||||||
<string name="chat_event_ephemeral_disabled">You disabled ephemeral messages</string>
|
<string name="chat_event_ephemeral_disabled">You disabled ephemeral messages</string>
|
||||||
<string name="chat_event_ephemeral_enabled">You enabled ephemeral messages: %s</string>
|
<string name="chat_event_ephemeral_enabled">You enabled ephemeral messages: %s</string>
|
||||||
<string name="chat_event_ephemeral_lifetime_changed">Ephemeral messages expiry date: %s</string>
|
<string name="chat_event_ephemeral_lifetime_changed">Ephemeral messages expiry date: %s</string>
|
||||||
|
<string name="chat_message_forward_confirmation_dialog">Do you want to forward the message in this room?</string>
|
||||||
|
|
||||||
<!-- Status Bar -->
|
<!-- Status Bar -->
|
||||||
<string name="status_connected">Connected</string>
|
<string name="status_connected">Connected</string>
|
||||||
|
|
Loading…
Reference in a new issue