Search in sources :

Example 81 with RequiresApi

use of androidx.annotation.RequiresApi in project Conversations by siacs.

the class RtpSessionActivity method startPictureInPicture.

@RequiresApi(api = Build.VERSION_CODES.O)
private void startPictureInPicture() {
    try {
        final Rational rational = this.binding.remoteVideo.getAspectRatio();
        final Rational clippedRational = Rationals.clip(rational);
        Log.d(Config.LOGTAG, "suggested rational " + rational + ". clipped to " + clippedRational);
        enterPictureInPictureMode(new PictureInPictureParams.Builder().setAspectRatio(clippedRational).build());
    } catch (final IllegalStateException e) {
        // this sometimes happens on Samsung phones (possibly when Knox is enabled)
        Log.w(Config.LOGTAG, "unable to enter picture in picture mode", e);
    }
}
Also used : Rational(android.util.Rational) PictureInPictureParams(android.app.PictureInPictureParams) RequiresApi(androidx.annotation.RequiresApi)

Example 82 with RequiresApi

use of androidx.annotation.RequiresApi in project BlurView by Dimezis.

the class RenderScriptBlur method blur.

/**
 * @param bitmap     bitmap to blur
 * @param blurRadius blur radius (1..25)
 * @return blurred bitmap
 */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public final Bitmap blur(Bitmap bitmap, float blurRadius) {
    // Allocation will use the same backing array of pixels as bitmap if created with USAGE_SHARED flag
    Allocation inAllocation = Allocation.createFromBitmap(renderScript, bitmap);
    if (!canReuseAllocation(bitmap)) {
        if (outAllocation != null) {
            outAllocation.destroy();
        }
        outAllocation = Allocation.createTyped(renderScript, inAllocation.getType());
        lastBitmapWidth = bitmap.getWidth();
        lastBitmapHeight = bitmap.getHeight();
    }
    blurScript.setRadius(blurRadius);
    blurScript.setInput(inAllocation);
    // do not use inAllocation in forEach. it will cause visual artifacts on blurred Bitmap
    blurScript.forEach(outAllocation);
    outAllocation.copyTo(bitmap);
    inAllocation.destroy();
    return bitmap;
}
Also used : Allocation(android.renderscript.Allocation) RequiresApi(androidx.annotation.RequiresApi)

Example 83 with RequiresApi

use of androidx.annotation.RequiresApi in project Conversations by siacs.

the class SSLSocketHelper method setHostnameNougat.

@RequiresApi(api = Build.VERSION_CODES.N)
private static void setHostnameNougat(final SSLSocket socket, final String hostname) {
    final SSLParameters parameters = new SSLParameters();
    parameters.setServerNames(Collections.singletonList(new SNIHostName(hostname)));
    socket.setSSLParameters(parameters);
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) SNIHostName(javax.net.ssl.SNIHostName) RequiresApi(androidx.annotation.RequiresApi)

Example 84 with RequiresApi

use of androidx.annotation.RequiresApi in project Conversations by siacs.

the class FileBackend method getPdfDocumentPreview.

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private Bitmap getPdfDocumentPreview(final File file, final int size) {
    try {
        final ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
        final Bitmap rendered = renderPdfDocument(fileDescriptor, size, true);
        drawOverlay(rendered, paintOverlayBlackPdf(rendered) ? R.drawable.open_pdf_black : R.drawable.open_pdf_white, 0.75f);
        return rendered;
    } catch (final IOException | SecurityException e) {
        Log.d(Config.LOGTAG, "unable to render PDF document preview", e);
        final Bitmap placeholder = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
        placeholder.eraseColor(0xff000000);
        return placeholder;
    }
}
Also used : Bitmap(android.graphics.Bitmap) ParcelFileDescriptor(android.os.ParcelFileDescriptor) IOException(java.io.IOException) RequiresApi(androidx.annotation.RequiresApi)

Example 85 with RequiresApi

use of androidx.annotation.RequiresApi in project Conversations by siacs.

the class FileBackend method getPdfDocumentDimensions.

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private Dimensions getPdfDocumentDimensions(final File file) {
    final ParcelFileDescriptor fileDescriptor;
    try {
        fileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
        if (fileDescriptor == null) {
            return new Dimensions(0, 0);
        }
    } catch (FileNotFoundException e) {
        return new Dimensions(0, 0);
    }
    try {
        final PdfRenderer pdfRenderer = new PdfRenderer(fileDescriptor);
        final PdfRenderer.Page page = pdfRenderer.openPage(0);
        final int height = page.getHeight();
        final int width = page.getWidth();
        page.close();
        pdfRenderer.close();
        return scalePdfDimensions(new Dimensions(height, width));
    } catch (IOException | SecurityException e) {
        Log.d(Config.LOGTAG, "unable to get dimensions for pdf document", e);
        return new Dimensions(0, 0);
    }
}
Also used : PdfRenderer(android.graphics.pdf.PdfRenderer) ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Paint(android.graphics.Paint) RequiresApi(androidx.annotation.RequiresApi)

Aggregations

RequiresApi (androidx.annotation.RequiresApi)117 NotificationChannel (android.app.NotificationChannel)16 Intent (android.content.Intent)13 SuppressLint (android.annotation.SuppressLint)10 NotificationManager (android.app.NotificationManager)9 Uri (android.net.Uri)9 StatusBarNotification (android.service.notification.StatusBarNotification)9 NonNull (androidx.annotation.NonNull)9 IOException (java.io.IOException)8 Notification (android.app.Notification)6 PendingIntent (android.app.PendingIntent)6 Context (android.content.Context)6 ObjectAnimator (android.animation.ObjectAnimator)5 Bundle (android.os.Bundle)5 ByteBuffer (java.nio.ByteBuffer)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 SecretKey (javax.crypto.SecretKey)5 GestureDescription (android.accessibilityservice.GestureDescription)4 TaskStackBuilder (android.app.TaskStackBuilder)4 Bitmap (android.graphics.Bitmap)4