Do not use sliders if phone is unlocked

This commit is contained in:
Sylvain Berfini 2018-11-12 15:12:30 +01:00
parent 2a85dc43d5
commit d9df197d3d
3 changed files with 82 additions and 77 deletions

View file

@ -163,7 +163,6 @@
android:layout_height="wrap_content"
android:alpha="0.2"/>
<ImageView
android:src="@drawable/arrow_hangup"
android:layout_width="wrap_content"

View file

@ -71,6 +71,7 @@
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool><!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->
<bool name="hide_camera_settings">false</bool>
<bool name="hide_in_call_stats">false</bool>
<bool name="do_not_use_sliders_to_answer_hangup_call_if_phone_unlocked">true</bool>
<!-- Settings -->
<bool name="disable_every_log">false</bool>

View file

@ -20,6 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import android.Manifest;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
@ -65,6 +67,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
private boolean alreadyAcceptedOrDeniedCall, begin;
private float answerX, oldMove;
private float declineX;
private KeyguardManager mKeyguardManager;
public static CallIncomingActivity instance() {
return instance;
@ -100,23 +103,33 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
accept = findViewById(R.id.accept);
lookupCurrentCall();
if (LinphonePreferences.instance() != null && mCall != null && mCall.getRemoteParams() != null &&
LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests() &&
mCall.getRemoteParams().videoEnabled()) {
accept.setImageResource(R.drawable.call_video_start);
}
decline = findViewById(R.id.decline);
arrow = findViewById(R.id.arrow_hangup);
mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
boolean doNotUseSliders = getResources().getBoolean(R.bool.do_not_use_sliders_to_answer_hangup_call_if_phone_unlocked);
if (doNotUseSliders && !mKeyguardManager.inKeyguardRestrictedInputMode()) {
accept.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
decline.setVisibility(View.GONE);
acceptUnlock.setVisibility(View.VISIBLE);
answer();
}
});
decline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
decline();
}
});
} else {
accept.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
@ -179,15 +192,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
return true;
}
});
decline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
accept.setVisibility(View.GONE);
acceptUnlock.setVisibility(View.VISIBLE);
}
});
mListener = new CoreListenerStub() {
@Override