Search in sources :

Example 26 with RequiresApi

use of androidx.annotation.RequiresApi in project Gadgetbridge by Freeyourgadget.

the class BondingUtil method companionDeviceManagerBond.

/**
 * Uses the CompanionDeviceManager bonding method
 */
@RequiresApi(Build.VERSION_CODES.O)
private static void companionDeviceManagerBond(BondingInterface bondingInterface, final GBDeviceCandidate deviceCandidate) {
    BluetoothDeviceFilter deviceFilter = new BluetoothDeviceFilter.Builder().setAddress(deviceCandidate.getMacAddress()).build();
    AssociationRequest pairingRequest = new AssociationRequest.Builder().addDeviceFilter(deviceFilter).setSingleDevice(true).build();
    CompanionDeviceManager manager = (CompanionDeviceManager) bondingInterface.getContext().getSystemService(Context.COMPANION_DEVICE_SERVICE);
    LOG.debug(String.format("Searching for %s associations", deviceCandidate.getMacAddress()));
    for (String association : manager.getAssociations()) {
        LOG.debug(String.format("Already associated with: %s", association));
        if (association.equals(deviceCandidate.getMacAddress())) {
            LOG.info("The device has already been bonded through CompanionDeviceManager, using regular");
            // If it's already "associated", we should immediately pair
            // because the callback is never called (AFAIK?)
            BondingUtil.bluetoothBond(bondingInterface, deviceCandidate);
            return;
        }
    }
    LOG.debug("Starting association request");
    manager.associate(pairingRequest, getCompanionDeviceManagerCallback(bondingInterface), null);
}
Also used : CompanionDeviceManager(android.companion.CompanionDeviceManager) AssociationRequest(android.companion.AssociationRequest) BluetoothDeviceFilter(android.companion.BluetoothDeviceFilter) RequiresApi(androidx.annotation.RequiresApi)

Example 27 with RequiresApi

use of androidx.annotation.RequiresApi in project ExoPlayer by google.

the class MediaCodecVideoRenderer method setHdr10PlusInfoV29.

@RequiresApi(29)
private static void setHdr10PlusInfoV29(MediaCodecAdapter codec, byte[] hdr10PlusInfo) {
    Bundle codecParameters = new Bundle();
    codecParameters.putByteArray(MediaCodec.PARAMETER_KEY_HDR10_PLUS_INFO, hdr10PlusInfo);
    codec.setParameters(codecParameters);
}
Also used : Bundle(android.os.Bundle) RequiresApi(androidx.annotation.RequiresApi)

Example 28 with RequiresApi

use of androidx.annotation.RequiresApi in project ExoPlayer by google.

the class DefaultTimeBar method setSystemGestureExclusionRectsV29.

@RequiresApi(29)
private void setSystemGestureExclusionRectsV29(int width, int height) {
    if (lastExclusionRectangle != null && lastExclusionRectangle.width() == width && lastExclusionRectangle.height() == height) {
        // Allocating inside onLayout is considered a DrawAllocation lint error, so avoid if possible.
        return;
    }
    lastExclusionRectangle = new Rect(/* left= */
    0, /* top= */
    0, width, height);
    setSystemGestureExclusionRects(Collections.singletonList(lastExclusionRectangle));
}
Also used : Rect(android.graphics.Rect) RequiresApi(androidx.annotation.RequiresApi)

Example 29 with RequiresApi

use of androidx.annotation.RequiresApi in project Signal-Android by WhisperSystems.

the class DataExportUtil method createTsv.

@RequiresApi(api = 26)
@NonNull
private static String createTsv(@NonNull List<Payment> payments) {
    Context context = ApplicationDependencies.getApplication();
    StringBuilder sb = new StringBuilder();
    sb.append(String.format(Locale.US, "%s\t%s\t%s\t%s\t%s%n", "Date Time", "From", "To", "Amount", "Fee"));
    for (Payment payment : payments) {
        if (payment.getState() != State.SUCCESSFUL) {
            continue;
        }
        String self = Recipient.self().getDisplayName(context);
        String otherParty = describePayee(context, payment.getPayee());
        String from;
        String to;
        switch(payment.getDirection()) {
            case SENT:
                from = self;
                to = otherParty;
                break;
            case RECEIVED:
                from = otherParty;
                to = self;
                break;
            default:
                throw new AssertionError();
        }
        sb.append(String.format(Locale.US, "%s\t%s\t%s\t%s\t%s%n", DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochMilli(payment.getDisplayTimestamp())), from, to, payment.getAmountWithDirection().requireMobileCoin().toBigDecimal(), payment.getFee().requireMobileCoin().toBigDecimal()));
    }
    return sb.toString();
}
Also used : Context(android.content.Context) NonNull(androidx.annotation.NonNull) RequiresApi(androidx.annotation.RequiresApi)

Example 30 with RequiresApi

use of androidx.annotation.RequiresApi in project Signal-Android by WhisperSystems.

the class ChooseBackupFragment method onChooseBackupSelected.

@RequiresApi(21)
private void onChooseBackupSelected(@NonNull View view) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("application/octet-stream");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
    if (Build.VERSION.SDK_INT >= 26) {
        intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, SignalStore.settings().getLatestSignalBackupDirectory());
    }
    try {
        startActivityForResult(intent, OPEN_FILE_REQUEST_CODE);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(requireContext(), R.string.ChooseBackupFragment__no_file_browser_available, Toast.LENGTH_LONG).show();
        Log.w(TAG, "No matching activity!", e);
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) 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