Ask for camera permission when trying to pick a picture when editing a contact image or sending a file via chat
This commit is contained in:
parent
290a22a934
commit
2cda8ad43e
4 changed files with 28 additions and 6 deletions
|
@ -54,7 +54,7 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
||||||
private LinphoneCoreListenerBase mListener;
|
private LinphoneCoreListenerBase mListener;
|
||||||
private LinearLayout acceptUnlock;
|
private LinearLayout acceptUnlock;
|
||||||
private LinearLayout declineUnlock;
|
private LinearLayout declineUnlock;
|
||||||
private boolean isActive;
|
private boolean isScreenActive, alreadyAcceptedOrDeniedCall;
|
||||||
private float answerX;
|
private float answerX;
|
||||||
private float declineX;
|
private float declineX;
|
||||||
|
|
||||||
|
@ -87,9 +87,9 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
||||||
|
|
||||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
|
||||||
isActive = pm.isInteractive();
|
isScreenActive = pm.isInteractive();
|
||||||
} else {
|
} else {
|
||||||
isActive = pm.isScreenOn();
|
isScreenActive = pm.isScreenOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
final int screenWidth = getResources().getDisplayMetrics().widthPixels;
|
final int screenWidth = getResources().getDisplayMetrics().widthPixels;
|
||||||
|
@ -102,7 +102,7 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
||||||
accept.setOnClickListener(new View.OnClickListener() {
|
accept.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if(isActive) {
|
if(isScreenActive) {
|
||||||
answer();
|
answer();
|
||||||
} else {
|
} else {
|
||||||
decline.setVisibility(View.GONE);
|
decline.setVisibility(View.GONE);
|
||||||
|
@ -111,7 +111,7 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!isActive) {
|
if(!isScreenActive) {
|
||||||
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) {
|
||||||
|
@ -177,7 +177,7 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
||||||
decline.setOnClickListener(new View.OnClickListener() {
|
decline.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if(isActive) {
|
if(isScreenActive) {
|
||||||
decline();
|
decline();
|
||||||
} else {
|
} else {
|
||||||
accept.setVisibility(View.GONE);
|
accept.setVisibility(View.GONE);
|
||||||
|
@ -215,6 +215,9 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.addListener(mListener);
|
lc.addListener(mListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alreadyAcceptedOrDeniedCall = false;
|
||||||
|
mCall = null;
|
||||||
|
|
||||||
// Only one call ringing at a time is allowed
|
// Only one call ringing at a time is allowed
|
||||||
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
|
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
|
||||||
|
@ -267,11 +270,21 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decline() {
|
private void decline() {
|
||||||
|
if (alreadyAcceptedOrDeniedCall) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
alreadyAcceptedOrDeniedCall = true;
|
||||||
|
|
||||||
LinphoneManager.getLc().terminateCall(mCall);
|
LinphoneManager.getLc().terminateCall(mCall);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void answer() {
|
private void answer() {
|
||||||
|
if (alreadyAcceptedOrDeniedCall) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
alreadyAcceptedOrDeniedCall = true;
|
||||||
|
|
||||||
LinphoneCallParams params = LinphoneManager.getLc().createCallParams(mCall);
|
LinphoneCallParams params = LinphoneManager.getLc().createCallParams(mCall);
|
||||||
|
|
||||||
boolean isLowBandwidthConnection = !LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance().getApplicationContext());
|
boolean isLowBandwidthConnection = !LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance().getApplicationContext());
|
||||||
|
|
|
@ -192,6 +192,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
pickImage();
|
pickImage();
|
||||||
|
LinphoneActivity.instance().checkAndRequestCameraPermission();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//registerForContextMenu(sendImage);
|
//registerForContextMenu(sendImage);
|
||||||
|
|
|
@ -250,6 +250,7 @@ public class ContactEditorFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
pickImage();
|
pickImage();
|
||||||
|
LinphoneActivity.instance().checkAndRequestCameraPermission();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201;
|
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201;
|
||||||
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO_INCOMING_CALL = 203;
|
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO_INCOMING_CALL = 203;
|
||||||
private static final int PERMISSIONS_REQUEST_EXTERNAL_FILE_STORAGE = 204;
|
private static final int PERMISSIONS_REQUEST_EXTERNAL_FILE_STORAGE = 204;
|
||||||
|
private static final int PERMISSIONS_REQUEST_CAMERA = 205;
|
||||||
|
|
||||||
private static LinphoneActivity instance;
|
private static LinphoneActivity instance;
|
||||||
|
|
||||||
|
@ -1149,6 +1150,12 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
checkAndRequestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, PERMISSIONS_REQUEST_EXTERNAL_FILE_STORAGE);
|
checkAndRequestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, PERMISSIONS_REQUEST_EXTERNAL_FILE_STORAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkAndRequestCameraPermission() {
|
||||||
|
if (getPackageManager().checkPermission(Manifest.permission.CAMERA, getPackageName()) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
checkAndRequestPermission(Manifest.permission.CAMERA, PERMISSIONS_REQUEST_CAMERA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void checkAndRequestPermission(String permission, int result) {
|
public void checkAndRequestPermission(String permission, int result) {
|
||||||
if (getPackageManager().checkPermission(permission, getPackageName()) != PackageManager.PERMISSION_GRANTED) {
|
if (getPackageManager().checkPermission(permission, getPackageName()) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
Loading…
Reference in a new issue