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,6 +241,12 @@
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:padding="12dp"/>
|
android:padding="12dp"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:background="@drawable/footer_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/chat"
|
android:id="@+id/chat"
|
||||||
android:src="@drawable/footer_chat"
|
android:src="@drawable/footer_chat"
|
||||||
|
@ -248,8 +254,19 @@
|
||||||
android:contentDescription="@string/content_description_chat_button"
|
android:contentDescription="@string/content_description_chat_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:padding="15dp"
|
||||||
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>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -241,15 +241,32 @@
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:contentDescription="@string/content_description_hang_up"/>
|
android:contentDescription="@string/content_description_hang_up"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:background="@drawable/footer_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/chat"
|
android:id="@+id/chat"
|
||||||
android:src="@drawable/footer_chat"
|
android:src="@drawable/footer_chat"
|
||||||
android:background="@color/colorC"
|
android:background="@color/colorC"
|
||||||
|
android:contentDescription="@string/content_description_chat_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="15dp"
|
android:padding="15dp"
|
||||||
android:contentDescription="@string/content_description_chat_button"/>
|
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>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -295,6 +295,12 @@
|
||||||
android:layout_weight="0.4"
|
android:layout_weight="0.4"
|
||||||
android:padding="12dp"/>
|
android:padding="12dp"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:background="@drawable/footer_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.8">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/chat"
|
android:id="@+id/chat"
|
||||||
android:src="@drawable/footer_chat"
|
android:src="@drawable/footer_chat"
|
||||||
|
@ -302,8 +308,19 @@
|
||||||
android:contentDescription="@string/content_description_chat_button"
|
android:contentDescription="@string/content_description_chat_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0.8"
|
android:padding="15dp"
|
||||||
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>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -24,6 +24,8 @@ 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.LinphoneCallParams;
|
import org.linphone.core.LinphoneCallParams;
|
||||||
|
import org.linphone.core.LinphoneChatMessage;
|
||||||
|
import org.linphone.core.LinphoneChatRoom;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreListenerBase;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
|
@ -91,6 +93,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
||||||
private Handler mControlsHandler = new Handler();
|
private Handler mControlsHandler = new Handler();
|
||||||
private Runnable mControls;
|
private Runnable mControls;
|
||||||
private ImageView switchCamera;
|
private ImageView switchCamera;
|
||||||
|
private TextView missedChats;
|
||||||
private RelativeLayout mActiveCallHeader, sideMenuContent, avatar_layout;
|
private RelativeLayout mActiveCallHeader, sideMenuContent, avatar_layout;
|
||||||
private ImageView pause, hangUp, dialer, video, micro, speaker, options, addCall, transfer, conference, conferenceStatus, contactPicture;
|
private ImageView pause, hangUp, dialer, video, micro, speaker, options, addCall, transfer, conference, conferenceStatus, contactPicture;
|
||||||
private ImageView audioRoute, routeSpeaker, routeEarpiece, routeBluetooth, menu, chat;
|
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);
|
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
||||||
mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||||
|
|
||||||
mListener = new LinphoneCoreListenerBase(){
|
mListener = new LinphoneCoreListenerBase() {
|
||||||
|
@Override
|
||||||
|
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
||||||
|
displayMissedChats();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
|
public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
||||||
|
@ -362,6 +370,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
||||||
|
|
||||||
chat = (ImageView) findViewById(R.id.chat);
|
chat = (ImageView) findViewById(R.id.chat);
|
||||||
chat.setOnClickListener(this);
|
chat.setOnClickListener(this);
|
||||||
|
missedChats = (TextView) findViewById(R.id.missed_chats);
|
||||||
|
|
||||||
//Others
|
//Others
|
||||||
|
|
||||||
|
@ -500,6 +509,7 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
||||||
refreshInCallActions();
|
refreshInCallActions();
|
||||||
refreshCallList(getResources());
|
refreshCallList(getResources());
|
||||||
enableAndRefreshInCallActions();
|
enableAndRefreshInCallActions();
|
||||||
|
displayMissedChats();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshInCallActions() {
|
private void refreshInCallActions() {
|
||||||
|
@ -1806,4 +1816,26 @@ public class CallActivity extends Activity implements OnClickListener, SensorEve
|
||||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
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();
|
LinphoneManager.getInstance().changeStatusToOnline();
|
||||||
|
|
||||||
if (getIntent().getIntExtra("PreviousActivity", 0) != CALL_ACTIVITY){
|
if (getIntent().getIntExtra("PreviousActivity", 0) != CALL_ACTIVITY) {
|
||||||
if (LinphoneManager.getLc().getCalls().length > 0) {
|
if (LinphoneManager.getLc().getCalls().length > 0) {
|
||||||
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
||||||
LinphoneCall.State callState = call.getState();
|
LinphoneCall.State callState = call.getState();
|
||||||
|
|
Loading…
Reference in a new issue