Display unread chat count in call view
This commit is contained in:
parent
e892b12530
commit
f5e77447ad
5 changed files with 107 additions and 24 deletions
|
@ -241,15 +241,32 @@
|
|||
android:layout_weight="0.5"
|
||||
android:padding="12dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:src="@drawable/footer_chat"
|
||||
android:background="@color/colorC"
|
||||
android:contentDescription="@string/content_description_chat_button"
|
||||
<RelativeLayout
|
||||
android:background="@drawable/footer_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="15dp"/>
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:src="@drawable/footer_chat"
|
||||
android:background="@color/colorC"
|
||||
android:contentDescription="@string/content_description_chat_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="15dp"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/missed_chats"
|
||||
android:background="@drawable/history_chat_indicator"
|
||||
style="@style/font18"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="15dp"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
|
|
@ -241,15 +241,32 @@
|
|||
android:padding="12dp"
|
||||
android:contentDescription="@string/content_description_hang_up"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:src="@drawable/footer_chat"
|
||||
android:background="@color/colorC"
|
||||
<RelativeLayout
|
||||
android:background="@drawable/footer_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="15dp"
|
||||
android:contentDescription="@string/content_description_chat_button"/>
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:src="@drawable/footer_chat"
|
||||
android:background="@color/colorC"
|
||||
android:contentDescription="@string/content_description_chat_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="15dp"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/missed_chats"
|
||||
android:background="@drawable/history_chat_indicator"
|
||||
style="@style/font18"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="15dp"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
|
|
@ -294,16 +294,33 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.4"
|
||||
android:padding="12dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:src="@drawable/footer_chat"
|
||||
android:background="@color/colorC"
|
||||
android:contentDescription="@string/content_description_chat_button"
|
||||
|
||||
<RelativeLayout
|
||||
android:background="@drawable/footer_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.8"
|
||||
android:padding="15dp"/>
|
||||
android:layout_weight="0.8">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:src="@drawable/footer_chat"
|
||||
android:background="@color/colorC"
|
||||
android:contentDescription="@string/content_description_chat_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="15dp"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/missed_chats"
|
||||
android:background="@drawable/history_chat_indicator"
|
||||
style="@style/font18"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="15dp"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -24,6 +24,8 @@ import org.linphone.core.LinphoneAddress;
|
|||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneCallParams;
|
||||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
|
@ -91,6 +93,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
private Handler mControlsHandler = new Handler();
|
||||
private Runnable mControls;
|
||||
private ImageView switchCamera;
|
||||
private TextView missedChats;
|
||||
private RelativeLayout mActiveCallHeader, sideMenuContent, avatar_layout;
|
||||
private ImageView pause, hangUp, dialer, video, micro, speaker, options, addCall, transfer, conference, conferenceStatus, contactPicture;
|
||||
private ImageView audioRoute, routeSpeaker, routeEarpiece, routeBluetooth, menu, chat;
|
||||
|
@ -161,7 +164,12 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
||||
mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
|
||||
mListener = new LinphoneCoreListenerBase(){
|
||||
mListener = new LinphoneCoreListenerBase() {
|
||||
@Override
|
||||
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
||||
displayMissedChats();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
|
||||
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
||||
|
@ -362,6 +370,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
|
||||
chat = (ImageView) findViewById(R.id.chat);
|
||||
chat.setOnClickListener(this);
|
||||
missedChats = (TextView) findViewById(R.id.missed_chats);
|
||||
|
||||
//Others
|
||||
|
||||
|
@ -500,6 +509,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
refreshInCallActions();
|
||||
refreshCallList(getResources());
|
||||
enableAndRefreshInCallActions();
|
||||
displayMissedChats();
|
||||
}
|
||||
|
||||
private void refreshInCallActions() {
|
||||
|
@ -1806,4 +1816,26 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
|||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
|
||||
}
|
||||
|
||||
private void displayMissedChats() {
|
||||
int count = 0;
|
||||
LinphoneChatRoom[] chats = LinphoneManager.getLc().getChatRooms();
|
||||
for (LinphoneChatRoom chatroom : chats) {
|
||||
count += chatroom.getUnreadMessagesCount();
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
missedChats.setText(count + "");
|
||||
missedChats.setVisibility(View.VISIBLE);
|
||||
if (!isAnimationDisabled) {
|
||||
missedChats.startAnimation(AnimationUtils.loadAnimation(this, R.anim.bounce));
|
||||
}
|
||||
if(count > 99){
|
||||
//TODO
|
||||
}
|
||||
} else {
|
||||
missedChats.clearAnimation();
|
||||
missedChats.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1248,7 +1248,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
|
||||
LinphoneManager.getInstance().changeStatusToOnline();
|
||||
|
||||
if (getIntent().getIntExtra("PreviousActivity", 0) != CALL_ACTIVITY){
|
||||
if (getIntent().getIntExtra("PreviousActivity", 0) != CALL_ACTIVITY) {
|
||||
if (LinphoneManager.getLc().getCalls().length > 0) {
|
||||
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
||||
LinphoneCall.State callState = call.getState();
|
||||
|
|
Loading…
Reference in a new issue