use of android.app.RemoteAction in project K6nele by Kaljurand.
the class AbstractRecognizerIntentActivity method getPictureInPictureArgs.
@TargetApi(26)
private PictureInPictureArgs getPictureInPictureArgs() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
Intent thisIntent = getIntent();
ArrayList<RemoteAction> actions = new ArrayList<>();
// Action to start recognition
actions.add(new RemoteAction(Icon.createWithResource(this, R.drawable.ic_voice_search_api_material), "Recognize", "Tap & Speak", PendingIntent.getActivity(this, 10, thisIntent, 0)));
// Action to go to the settings
actions.add(new RemoteAction(Icon.createWithResource(this, R.drawable.ic_settings_24dp), "Settings", "Settings", PendingIntent.getActivity(this, 11, new Intent(getApplicationContext(), Preferences.class), 0)));
PictureInPictureArgs mPictureInPictureArgs = new PictureInPictureArgs();
mPictureInPictureArgs.setActions(actions);
return mPictureInPictureArgs;
}
return null;
}
use of android.app.RemoteAction in project ring-client-android by savoirfairelinux.
the class CallFragment method enterPipMode.
@Override
public void enterPipMode(SipCall sipCall) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PictureInPictureParams.Builder paramBuilder = new PictureInPictureParams.Builder();
if (mVideoSurface.getVisibility() == View.VISIBLE) {
int[] l = new int[2];
mVideoSurface.getLocationInWindow(l);
int x = l[0];
int y = l[1];
int w = mVideoSurface.getWidth();
int h = mVideoSurface.getHeight();
Rect videoBounds = new Rect(x, y, x + w, y + h);
paramBuilder.setAspectRatio(new Rational(w, h));
paramBuilder.setSourceRectHint(videoBounds);
}
ArrayList<RemoteAction> actions = new ArrayList<>(1);
actions.add(new RemoteAction(Icon.createWithResource(getContext(), R.drawable.ic_call_end_white), getString(R.string.action_call_hangup), getString(R.string.action_call_hangup), PendingIntent.getService(getContext(), new Random().nextInt(), new Intent(DRingService.ACTION_CALL_END).setClass(getContext(), DRingService.class).putExtra(NotificationService.KEY_CALL_ID, sipCall.getCallId()), PendingIntent.FLAG_ONE_SHOT)));
paramBuilder.setActions(actions);
getActivity().enterPictureInPictureMode(paramBuilder.build());
} else if (DeviceUtils.isTv(getContext())) {
getActivity().enterPictureInPictureMode();
}
}
Aggregations