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