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);
}
}
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;
}
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);
}
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;
}
}
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);
}
}
Aggregations