Improved incoming call's answer and delete buttons UI

This commit is contained in:
Sylvain Berfini 2018-11-16 16:24:15 +01:00
parent 1491cb9710
commit cd1449c157
3 changed files with 100 additions and 90 deletions

View file

@ -527,7 +527,7 @@ public final class LinphoneService extends Service {
} }
int notificationTextId; int notificationTextId;
int inconId; int iconId;
switch (call.getState()) { switch (call.getState()) {
case Released: case Released:
case End: case End:
@ -537,15 +537,15 @@ public final class LinphoneService extends Service {
case Paused: case Paused:
case PausedByRemote: case PausedByRemote:
case Pausing: case Pausing:
inconId = R.drawable.topbar_call_notification; iconId = R.drawable.topbar_call_notification;
notificationTextId = R.string.incall_notif_paused; notificationTextId = R.string.incall_notif_paused;
break; break;
default: default:
if (call.getCurrentParams().videoEnabled()) { if (call.getCurrentParams().videoEnabled()) {
inconId = R.drawable.topbar_videocall_notification; iconId = R.drawable.topbar_videocall_notification;
notificationTextId = R.string.incall_notif_video; notificationTextId = R.string.incall_notif_video;
} else { } else {
inconId = R.drawable.topbar_call_notification; iconId = R.drawable.topbar_call_notification;
notificationTextId = R.string.incall_notif_active; notificationTextId = R.string.incall_notif_active;
} }
break; break;
@ -565,7 +565,7 @@ public final class LinphoneService extends Service {
Intent notifIntent = new Intent(this, incomingReceivedActivity); Intent notifIntent = new Intent(this, incomingReceivedActivity);
notifIntent.putExtra("Notification", true); notifIntent.putExtra("Notification", true);
mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT); mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = Compatibility.createInCallNotification(getApplicationContext(), notif.notificationId, showAnswerAction, mNotificationTitle, getString(notificationTextId), inconId, bm, name, mNotifContentIntent); Notification notification = Compatibility.createInCallNotification(getApplicationContext(), notif.notificationId, showAnswerAction, mNotificationTitle, getString(notificationTextId), iconId, bm, name, mNotifContentIntent);
notifyWrapper(notif.notificationId, notification); notifyWrapper(notif.notificationId, notification);
} }

View file

@ -60,7 +60,8 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
private static CallIncomingActivity instance; private static CallIncomingActivity instance;
private TextView name, number; private TextView name, number;
private ImageView contactPicture, accept, decline, arrow; private ImageView contactPicture, acceptIcon;
private LinearLayout accept, decline;
private Call mCall; private Call mCall;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private LinearLayout acceptUnlock; private LinearLayout acceptUnlock;
@ -102,17 +103,17 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
acceptUnlock = findViewById(R.id.acceptUnlock); acceptUnlock = findViewById(R.id.acceptUnlock);
declineUnlock = findViewById(R.id.declineUnlock); declineUnlock = findViewById(R.id.declineUnlock);
acceptIcon = findViewById(R.id.acceptIcon);
accept = findViewById(R.id.accept); accept = findViewById(R.id.accept);
lookupCurrentCall(); lookupCurrentCall();
if (LinphonePreferences.instance() != null && mCall != null && mCall.getRemoteParams() != null && if (LinphonePreferences.instance() != null && mCall != null && mCall.getRemoteParams() != null &&
LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests() && LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests() &&
mCall.getRemoteParams().videoEnabled()) { mCall.getRemoteParams().videoEnabled()) {
accept.setImageResource(R.drawable.call_video_start); acceptIcon.setImageResource(R.drawable.call_video_start);
} }
decline = findViewById(R.id.decline); decline = findViewById(R.id.decline);
arrow = findViewById(R.id.arrow_hangup);
mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
boolean doNotUseSliders = getResources().getBoolean(R.bool.do_not_use_sliders_to_answer_hangup_call_if_phone_unlocked); boolean doNotUseSliders = getResources().getBoolean(R.bool.do_not_use_sliders_to_answer_hangup_call_if_phone_unlocked);
@ -131,47 +132,46 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
} }
}); });
} else { } else {
acceptUnlock.setVisibility(View.VISIBLE);
accept.setOnTouchListener(new View.OnTouchListener() { accept.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View view, MotionEvent motionEvent) { public boolean onTouch(View view, MotionEvent motionEvent) {
float curX; float curX;
switch (motionEvent.getAction()) { switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
acceptUnlock.setVisibility(View.VISIBLE);
decline.setVisibility(View.GONE); decline.setVisibility(View.GONE);
answerX = motionEvent.getX() + accept.getWidth() / 2; answerX = motionEvent.getX() - accept.getWidth();
begin = true; begin = true;
oldMove = 0; oldMove = 0;
break; break;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
curX = motionEvent.getX(); curX = motionEvent.getX() - accept.getWidth();
view.scrollBy((int) (answerX - curX), view.getScrollY()); view.scrollBy((int) (answerX - curX), view.getScrollY());
oldMove -= answerX - curX; oldMove -= answerX - curX;
answerX = curX; answerX = curX;
if (oldMove < -25) if (oldMove < -25)
begin = false; begin = false;
if (curX < arrow.getWidth() && !begin) { if (curX < (screenWidth / 4) - accept.getWidth() && !begin) {
answer(); answer();
return true; return true;
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
view.scrollTo(0, view.getScrollY());
decline.setVisibility(View.VISIBLE); decline.setVisibility(View.VISIBLE);
acceptUnlock.setVisibility(View.GONE); view.scrollTo(0, view.getScrollY());
break; break;
} }
return true; return true;
} }
}); });
declineUnlock.setVisibility(View.VISIBLE);
decline.setOnTouchListener(new View.OnTouchListener() { decline.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View view, MotionEvent motionEvent) { public boolean onTouch(View view, MotionEvent motionEvent) {
float curX; float curX;
switch (motionEvent.getAction()) { switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
declineUnlock.setVisibility(View.VISIBLE);
accept.setVisibility(View.GONE); accept.setVisibility(View.GONE);
declineX = motionEvent.getX(); declineX = motionEvent.getX();
break; break;
@ -179,15 +179,14 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
curX = motionEvent.getX(); curX = motionEvent.getX();
view.scrollBy((int) (declineX - curX), view.getScrollY()); view.scrollBy((int) (declineX - curX), view.getScrollY());
declineX = curX; declineX = curX;
if (curX > (screenWidth - arrow.getWidth() * 4)) { if (curX > (3 * screenWidth / 4)) {
decline(); decline();
return true; return true;
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
view.scrollTo(0, view.getScrollY());
accept.setVisibility(View.VISIBLE); accept.setVisibility(View.VISIBLE);
declineUnlock.setVisibility(View.GONE); view.scrollTo(0, view.getScrollY());
break; break;
} }
return true; return true;

View file

@ -93,88 +93,99 @@
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:orientation="horizontal" > android:orientation="horizontal" >
<ImageView <LinearLayout
android:id="@+id/decline" android:id="@+id/decline"
android:src="@drawable/call_hangup" android:layout_width="0dp"
android:background="@drawable/hangup" android:layout_height="wrap_content"
android:contentDescription="@string/content_description_decline" android:layout_weight="1"
android:layout_width="0dp" android:orientation="horizontal"
android:layout_height="wrap_content" android:background="@color/colorI"
android:layout_weight="1" android:gravity="center"
android:padding="12dp"/> android:padding="12dp">
<LinearLayout <ImageView
android:id="@+id/acceptUnlock" android:src="@drawable/call_hangup"
android:layout_width="wrap_content" android:contentDescription="@string/content_description_decline"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:visibility="gone" android:layout_height="wrap_content"/>
android:orientation="horizontal"
android:background="@color/colorA"
android:paddingLeft="15dp"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:layout_gravity="bottom">
<ImageView <LinearLayout
android:src="@drawable/arrow_accept" android:id="@+id/declineUnlock"
android:layout_width="wrap_content" android:visibility="gone"
android:layout_height="wrap_content"/> android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<ImageView <ImageView
android:src="@drawable/arrow_accept" android:id="@+id/arrow_hangup"
android:layout_width="wrap_content" android:src="@drawable/arrow_hangup"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:alpha="0.6"/> android:layout_height="wrap_content"/>
<ImageView <ImageView
android:id="@+id/acceptArrow" android:src="@drawable/arrow_hangup"
android:src="@drawable/arrow_accept" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:alpha="0.6"/>
android:alpha="0.2"/>
</LinearLayout>
<ImageView <ImageView
android:id="@+id/accept" android:src="@drawable/arrow_hangup"
android:src="@drawable/call_audio_start" android:layout_width="wrap_content"
android:background="@drawable/call" android:layout_height="wrap_content"
android:contentDescription="@string/content_description_accept" android:alpha="0.2"/>
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="12dp"/>
<LinearLayout </LinearLayout>
android:id="@+id/declineUnlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="horizontal"
android:background="@color/colorD"
android:paddingLeft="15dp"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:layout_gravity="bottom">
<ImageView </LinearLayout>
android:id="@+id/arrow_hangup"
android:src="@drawable/arrow_hangup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.2"/>
<ImageView <LinearLayout
android:src="@drawable/arrow_hangup" android:id="@+id/accept"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:alpha="0.6"/> android:layout_weight="1"
android:orientation="horizontal"
android:background="@color/colorL"
android:gravity="center"
android:padding="12dp">
<ImageView <LinearLayout
android:src="@drawable/arrow_hangup" android:id="@+id/acceptUnlock"
android:layout_width="wrap_content" android:visibility="gone"
android:layout_height="wrap_content"/> android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout> <ImageView
android:src="@drawable/arrow_accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.2"/>
<ImageView
android:src="@drawable/arrow_accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.6"/>
<ImageView
android:src="@drawable/arrow_accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<ImageView
android:id="@+id/acceptIcon"
android:src="@drawable/call_audio_start"
android:contentDescription="@string/content_description_accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout> </LinearLayout>