Search in sources :

Example 16 with RequiresApi

use of androidx.annotation.RequiresApi in project OneSignal-Android-SDK by OneSignal.

the class OneSignalNotificationManager method getActiveGrouplessNotifications.

/**
 * Getter for obtaining any groupless notifications
 * A groupless notification is:
 * 1. Not a summary
 * 2. A null group key or group key using assigned GROUPLESS_SUMMARY_KEY
 */
@RequiresApi(api = Build.VERSION_CODES.M)
static ArrayList<StatusBarNotification> getActiveGrouplessNotifications(Context context) {
    ArrayList<StatusBarNotification> grouplessStatusBarNotifications = new ArrayList<>();
    /* Iterate over all active notifications and add the groupless non-summary
         * notifications to a ArrayList to be returned */
    StatusBarNotification[] statusBarNotifications = getActiveNotifications(context);
    for (StatusBarNotification statusBarNotification : statusBarNotifications) {
        Notification notification = statusBarNotification.getNotification();
        boolean isGroupSummary = NotificationLimitManager.isGroupSummary(statusBarNotification);
        boolean isGroupless = notification.getGroup() == null || notification.getGroup().equals(OneSignalNotificationManager.getGrouplessSummaryKey());
        if (!isGroupSummary && isGroupless)
            grouplessStatusBarNotifications.add(statusBarNotification);
    }
    return grouplessStatusBarNotifications;
}
Also used : StatusBarNotification(android.service.notification.StatusBarNotification) ArrayList(java.util.ArrayList) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) RequiresApi(androidx.annotation.RequiresApi)

Example 17 with RequiresApi

use of androidx.annotation.RequiresApi in project robolectric by robolectric.

the class ShadowActivityManager method addApplicationExitInfo.

/**
 * Adds an {@link ApplicationExitInfo} with the given information
 *
 * @deprecated Prefer using overload with {@link ApplicationExitInfoBuilder}
 */
@Deprecated
@RequiresApi(api = R)
public void addApplicationExitInfo(String processName, int pid, int reason, int status) {
    ApplicationExitInfo info = ApplicationExitInfoBuilder.newBuilder().setProcessName(processName).setPid(pid).setReason(reason).setStatus(status).build();
    addApplicationExitInfo(info);
}
Also used : ApplicationExitInfo(android.app.ApplicationExitInfo) RequiresApi(androidx.annotation.RequiresApi)

Example 18 with RequiresApi

use of androidx.annotation.RequiresApi in project Douya by DreaminginCodeZH.

the class ResourcesFlusher method flushLollipop.

@MainThread
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
private static void flushLollipop(@NonNull Resources resources) {
    if (!sDrawableCacheFieldInitialized) {
        try {
            // noinspection JavaReflectionMemberAccess
            sDrawableCacheField = Resources.class.getDeclaredField("mDrawableCache");
            sDrawableCacheField.setAccessible(true);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
        sDrawableCacheFieldInitialized = true;
    }
    if (sDrawableCacheField == null) {
        return;
    }
    Map drawableCache = null;
    try {
        drawableCache = (Map) sDrawableCacheField.get(resources);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    if (drawableCache == null) {
        return;
    }
    drawableCache.clear();
}
Also used : Resources(android.content.res.Resources) Map(java.util.Map) ArrayMap(android.util.ArrayMap) MainThread(androidx.annotation.MainThread) RequiresApi(androidx.annotation.RequiresApi)

Example 19 with RequiresApi

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

the class FileBackend method cropCenterSquarePdf.

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private Bitmap cropCenterSquarePdf(final Uri uri, final int size) {
    try {
        ParcelFileDescriptor fileDescriptor = mXmppConnectionService.getContentResolver().openFileDescriptor(uri, "r");
        final Bitmap bitmap = renderPdfDocument(fileDescriptor, size, false);
        return cropCenterSquare(bitmap, size);
    } catch (Exception 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) FileWriterException(eu.siacs.conversations.utils.FileWriterException) FileNotFoundException(java.io.FileNotFoundException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) RequiresApi(androidx.annotation.RequiresApi)

Example 20 with RequiresApi

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

the class FileBackend method renderPdfDocument.

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private Bitmap renderPdfDocument(ParcelFileDescriptor fileDescriptor, int targetSize, boolean fit) throws IOException {
    final PdfRenderer pdfRenderer = new PdfRenderer(fileDescriptor);
    final PdfRenderer.Page page = pdfRenderer.openPage(0);
    final Dimensions dimensions = scalePdfDimensions(new Dimensions(page.getHeight(), page.getWidth()), targetSize, fit);
    final Bitmap rendered = Bitmap.createBitmap(dimensions.width, dimensions.height, Bitmap.Config.ARGB_8888);
    rendered.eraseColor(0xffffffff);
    page.render(rendered, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
    page.close();
    pdfRenderer.close();
    fileDescriptor.close();
    return rendered;
}
Also used : PdfRenderer(android.graphics.pdf.PdfRenderer) Bitmap(android.graphics.Bitmap) RequiresApi(androidx.annotation.RequiresApi)

Aggregations

RequiresApi (androidx.annotation.RequiresApi)161 NotificationChannel (android.app.NotificationChannel)20 Intent (android.content.Intent)16 NonNull (androidx.annotation.NonNull)16 SuppressLint (android.annotation.SuppressLint)14 Uri (android.net.Uri)14 NotificationManager (android.app.NotificationManager)13 IOException (java.io.IOException)13 StatusBarNotification (android.service.notification.StatusBarNotification)10 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)10 Context (android.content.Context)9 Rect (android.graphics.Rect)8 Notification (android.app.Notification)7 ByteBuffer (java.nio.ByteBuffer)7 ArrayList (java.util.ArrayList)7 SecretKey (javax.crypto.SecretKey)7 PendingIntent (android.app.PendingIntent)6 Bitmap (android.graphics.Bitmap)5 Point (android.graphics.Point)5 Build (android.os.Build)5