Display when a remote contact is writing a message using rfc3994 and send local composing notifications
This commit is contained in:
parent
0a8040157b
commit
623ec93c7f
10 changed files with 80 additions and 5 deletions
|
@ -49,6 +49,14 @@
|
||||||
|
|
||||||
</org.linphone.ui.LinphoneScrollView>
|
</org.linphone.ui.LinphoneScrollView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/remoteComposing"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textColor="@color/text_contrast"
|
||||||
|
android:text="@string/remote_composing" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/messageLayout"
|
android:id="@+id/messageLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -49,6 +49,14 @@
|
||||||
|
|
||||||
</org.linphone.ui.LinphoneScrollView>
|
</org.linphone.ui.LinphoneScrollView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/remoteComposing"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textColor="@color/text_contrast"
|
||||||
|
android:text="@string/remote_composing" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/messageLayout"
|
android:id="@+id/messageLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -49,6 +49,14 @@
|
||||||
|
|
||||||
</org.linphone.ui.LinphoneScrollView>
|
</org.linphone.ui.LinphoneScrollView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/remoteComposing"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textColor="@color/text_contrast"
|
||||||
|
android:text="@string/remote_composing" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/messageLayout"
|
android:id="@+id/messageLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -49,6 +49,14 @@
|
||||||
|
|
||||||
</org.linphone.ui.LinphoneScrollView>
|
</org.linphone.ui.LinphoneScrollView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/remoteComposing"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textColor="@color/text_contrast"
|
||||||
|
android:text="@string/remote_composing" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/messageLayout"
|
android:id="@+id/messageLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -389,4 +389,6 @@
|
||||||
<string name="zrtp_accept">Accepter</string>
|
<string name="zrtp_accept">Accepter</string>
|
||||||
<string name="zrtp_deny">Refuser</string>
|
<string name="zrtp_deny">Refuser</string>
|
||||||
<string name="zrtp_help">Vous ne devriez accepter que si vous avez le même code (ci-dessus) que votre contact</string>
|
<string name="zrtp_help">Vous ne devriez accepter que si vous avez le même code (ci-dessus) que votre contact</string>
|
||||||
|
|
||||||
|
<string name="remote_composing">Votre correspondant est en train de taper...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -444,4 +444,6 @@
|
||||||
<string name="zrtp_accept">Accept</string>
|
<string name="zrtp_accept">Accept</string>
|
||||||
<string name="zrtp_deny">Deny</string>
|
<string name="zrtp_deny">Deny</string>
|
||||||
<string name="zrtp_help">You should only accept if you have the same code (see above) as your correspondent</string>
|
<string name="zrtp_help">You should only accept if you have the same code (see above) as your correspondent</string>
|
||||||
|
|
||||||
|
<string name="remote_composing">Remote is writing...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -444,4 +444,6 @@
|
||||||
<string name="zrtp_accept">Accept</string>
|
<string name="zrtp_accept">Accept</string>
|
||||||
<string name="zrtp_deny">Deny</string>
|
<string name="zrtp_deny">Deny</string>
|
||||||
<string name="zrtp_help">You should only accept if you have the same code (see above) as your correspondent</string>
|
<string name="zrtp_help">You should only accept if you have the same code (see above) as your correspondent</string>
|
||||||
|
|
||||||
|
<string name="remote_composing">Remote is writing...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.http.util.ByteArrayBuffer;
|
import org.apache.http.util.ByteArrayBuffer;
|
||||||
|
import org.linphone.LinphoneSimpleListener.LinphoneOnComposingReceivedListener;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneChatMessage;
|
import org.linphone.core.LinphoneChatMessage;
|
||||||
|
@ -85,7 +86,7 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.StateListener {
|
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.StateListener, LinphoneOnComposingReceivedListener {
|
||||||
private static final int ADD_PHOTO = 1337;
|
private static final int ADD_PHOTO = 1337;
|
||||||
private static final int MENU_DELETE_MESSAGE = 0;
|
private static final int MENU_DELETE_MESSAGE = 0;
|
||||||
private static final int MENU_SAVE_PICTURE = 1;
|
private static final int MENU_SAVE_PICTURE = 1;
|
||||||
|
@ -105,7 +106,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
private String sipUri;
|
private String sipUri;
|
||||||
private EditText message;
|
private EditText message;
|
||||||
private ImageView cancelUpload;
|
private ImageView cancelUpload;
|
||||||
private TextView sendImage, sendMessage, contactName;
|
private TextView sendImage, sendMessage, contactName, remoteComposing;
|
||||||
private AvatarWithShadow contactPicture;
|
private AvatarWithShadow contactPicture;
|
||||||
private RelativeLayout messagesLayout, uploadLayout, textLayout;
|
private RelativeLayout messagesLayout, uploadLayout, textLayout;
|
||||||
private LinphoneScrollView messagesScrollView;
|
private LinphoneScrollView messagesScrollView;
|
||||||
|
@ -143,6 +144,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
sendMessage = (TextView) view.findViewById(R.id.sendMessage);
|
sendMessage = (TextView) view.findViewById(R.id.sendMessage);
|
||||||
sendMessage.setOnClickListener(this);
|
sendMessage.setOnClickListener(this);
|
||||||
|
|
||||||
|
remoteComposing = (TextView) view.findViewById(R.id.remoteComposing);
|
||||||
|
remoteComposing.setVisibility(View.GONE);
|
||||||
|
|
||||||
message = (EditText) view.findViewById(R.id.message);
|
message = (EditText) view.findViewById(R.id.message);
|
||||||
if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) {
|
if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) {
|
||||||
message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
|
message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
|
||||||
|
@ -208,6 +212,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if (message.getText().toString().equals("")) {
|
if (message.getText().toString().equals("")) {
|
||||||
sendMessage.setEnabled(false);
|
sendMessage.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
|
if (chatRoom != null)
|
||||||
|
chatRoom.compose();
|
||||||
sendMessage.setEnabled(true);
|
sendMessage.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -555,6 +561,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
LinphoneService.instance().removeMessageNotification();
|
LinphoneService.instance().removeMessageNotification();
|
||||||
|
|
||||||
|
if (LinphoneManager.isInstanciated())
|
||||||
|
LinphoneManager.getInstance().setOnComposingReceivedListener(null);
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (!message.getText().toString().equals("") && LinphoneActivity.isInstanciated()) {
|
if (!message.getText().toString().equals("") && LinphoneActivity.isInstanciated()) {
|
||||||
|
@ -576,6 +585,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
message.addTextChangedListener(textWatcher);
|
message.addTextChangedListener(textWatcher);
|
||||||
addVirtualKeyboardVisiblityListener();
|
addVirtualKeyboardVisiblityListener();
|
||||||
|
|
||||||
|
if (LinphoneManager.isInstanciated())
|
||||||
|
LinphoneManager.getInstance().setOnComposingReceivedListener(this);
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
|
@ -587,6 +599,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
String draft = LinphoneActivity.instance().getChatStorage().getDraft(sipUri);
|
String draft = LinphoneActivity.instance().getChatStorage().getDraft(sipUri);
|
||||||
message.setText(draft);
|
message.setText(draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1082,4 +1096,16 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
LARGE,
|
LARGE,
|
||||||
REAL;
|
REAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComposingReceived(LinphoneChatRoom room) {
|
||||||
|
if (chatRoom != null && room != null && chatRoom.getPeerAddress().asStringUriOnly().equals(room.getPeerAddress().asStringUriOnly())) {
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.util.TimerTask;
|
||||||
import org.linphone.LinphoneSimpleListener.ConnectivityChangedListener;
|
import org.linphone.LinphoneSimpleListener.ConnectivityChangedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener.AudioState;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener.AudioState;
|
||||||
|
import org.linphone.LinphoneSimpleListener.LinphoneOnComposingReceivedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnDTMFReceivedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnDTMFReceivedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
|
||||||
|
@ -1421,9 +1422,15 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinphoneOnComposingReceivedListener composingReceivedListener;
|
||||||
|
public void setOnComposingReceivedListener(LinphoneOnComposingReceivedListener listener) {
|
||||||
|
composingReceivedListener = listener;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom cr) {
|
public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom cr) {
|
||||||
// TODO Auto-generated method stub
|
Log.d("Composing received for chatroom " + cr.getPeerAddress().asStringUriOnly());
|
||||||
|
if (composingReceivedListener != null)
|
||||||
|
composingReceivedListener.onComposingReceived(cr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.LinphoneChatMessage;
|
import org.linphone.core.LinphoneChatMessage;
|
||||||
|
import org.linphone.core.LinphoneChatRoom;
|
||||||
import org.linphone.core.LinphoneCore.GlobalState;
|
import org.linphone.core.LinphoneCore.GlobalState;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
|
|
||||||
|
@ -76,4 +77,7 @@ public interface LinphoneSimpleListener {
|
||||||
public static interface LinphoneOnDTMFReceivedListener extends LinphoneSimpleListener {
|
public static interface LinphoneOnDTMFReceivedListener extends LinphoneSimpleListener {
|
||||||
void onDTMFReceived(LinphoneCall call, int dtmf);
|
void onDTMFReceived(LinphoneCall call, int dtmf);
|
||||||
}
|
}
|
||||||
|
public static interface LinphoneOnComposingReceivedListener extends LinphoneSimpleListener {
|
||||||
|
void onComposingReceived(LinphoneChatRoom room);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue