Search in sources :

Example 1 with RemoteAction

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;
}
Also used : ArrayList(java.util.ArrayList) RemoteAction(android.app.RemoteAction) PictureInPictureArgs(android.app.PictureInPictureArgs) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) SharedPreferences(android.content.SharedPreferences) TargetApi(android.annotation.TargetApi)

Example 2 with RemoteAction

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();
    }
}
Also used : Rect(android.graphics.Rect) Rational(android.util.Rational) Random(java.util.Random) PictureInPictureParams(android.app.PictureInPictureParams) RemoteAction(android.app.RemoteAction) ArrayList(java.util.ArrayList) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Aggregations

PendingIntent (android.app.PendingIntent)2 RemoteAction (android.app.RemoteAction)2 Intent (android.content.Intent)2 ArrayList (java.util.ArrayList)2 TargetApi (android.annotation.TargetApi)1 PictureInPictureArgs (android.app.PictureInPictureArgs)1 PictureInPictureParams (android.app.PictureInPictureParams)1 SharedPreferences (android.content.SharedPreferences)1 Rect (android.graphics.Rect)1 RecognizerIntent (android.speech.RecognizerIntent)1 Rational (android.util.Rational)1 Random (java.util.Random)1