use of androidx.annotation.RequiresApi in project mobile-center-sdk-android by Microsoft.
the class CryptoAesAndEtmHandler method generateKey.
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void generateKey(CryptoUtils.ICryptoFactory cryptoFactory, String alias, Context context) throws Exception {
Calendar writeExpiry = Calendar.getInstance();
writeExpiry.add(Calendar.YEAR, ENCRYPT_KEY_LIFETIME_IN_YEARS);
CryptoUtils.IKeyGenerator keyGenerator = cryptoFactory.getKeyGenerator(KeyProperties.KEY_ALGORITHM_HMAC_SHA256, ANDROID_KEY_STORE);
keyGenerator.init(new KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_SIGN).setKeyValidityForOriginationEnd(writeExpiry.getTime()).build());
keyGenerator.generateKey();
}
use of androidx.annotation.RequiresApi in project Signal-Android by WhisperSystems.
the class BubbleUtil method canBubble.
/**
* Checks whether we are allowed to create a bubble for the given recipient.
*
* In order to Bubble, a recipient must have a thread, be unblocked, and the user must not have
* notification privacy settings enabled. Furthermore, we check the Notifications system to verify
* that bubbles are allowed in the first place.
*/
@RequiresApi(CONVERSATION_SUPPORT_VERSION)
@WorkerThread
public static boolean canBubble(@NonNull Context context, @NonNull RecipientId recipientId, @Nullable Long threadId) {
if (threadId == null) {
Log.i(TAG, "Cannot bubble recipient without thread");
return false;
}
NotificationPrivacyPreference privacyPreference = SignalStore.settings().getMessageNotificationsPrivacy();
if (!privacyPreference.isDisplayContact()) {
Log.i(TAG, "Bubbles are not available when notification privacy settings are enabled.");
return false;
}
Recipient recipient = Recipient.resolved(recipientId);
if (recipient.isBlocked()) {
Log.i(TAG, "Cannot bubble blocked recipient");
return false;
}
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
NotificationChannel conversationChannel = notificationManager.getNotificationChannel(ConversationUtil.getChannelId(context, recipient), ConversationUtil.getShortcutId(recipientId));
return notificationManager.areBubblesAllowed() || (conversationChannel != null && conversationChannel.canBubble());
}
use of androidx.annotation.RequiresApi in project Signal-Android by WhisperSystems.
the class EditProfileFragment method handleFinishedLollipop.
@RequiresApi(api = 21)
private void handleFinishedLollipop() {
int[] finishButtonLocation = new int[2];
int[] revealLocation = new int[2];
finishButton.getLocationInWindow(finishButtonLocation);
reveal.getLocationInWindow(revealLocation);
int finishX = finishButtonLocation[0] - revealLocation[0];
int finishY = finishButtonLocation[1] - revealLocation[1];
finishX += finishButton.getWidth() / 2;
finishY += finishButton.getHeight() / 2;
Animator animation = ViewAnimationUtils.createCircularReveal(reveal, finishX, finishY, 0f, (float) Math.max(reveal.getWidth(), reveal.getHeight()));
animation.setDuration(500);
animation.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
finishButton.setProgress(0);
if (nextIntent != null && getActivity() != null) {
startActivity(nextIntent);
}
controller.onProfileNameUploadCompleted();
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
reveal.setVisibility(View.VISIBLE);
animation.start();
}
use of androidx.annotation.RequiresApi in project Signal-Android by WhisperSystems.
the class StorageUtil method getDisplayPath.
@RequiresApi(24)
@NonNull
public static String getDisplayPath(@NonNull Context context, @NonNull Uri uri) {
String lastPathSegment = Objects.requireNonNull(uri.getLastPathSegment());
String backupVolume = lastPathSegment.replaceFirst(":.*", "");
String backupName = lastPathSegment.replaceFirst(".*:", "");
StorageManager storageManager = ServiceUtil.getStorageManager(context);
List<StorageVolume> storageVolumes = storageManager.getStorageVolumes();
StorageVolume storageVolume = null;
for (StorageVolume volume : storageVolumes) {
if (Objects.equals(volume.getUuid(), backupVolume)) {
storageVolume = volume;
break;
}
}
if (storageVolume == null) {
return backupName;
} else {
return context.getString(R.string.StorageUtil__s_s, storageVolume.getDescription(context), backupName);
}
}
use of androidx.annotation.RequiresApi in project Signal-Android by WhisperSystems.
the class SubscriptionManagerCompat method getActiveSubscriptionInfoList.
@RequiresApi(api = 22)
@NonNull
private List<SubscriptionInfo> getActiveSubscriptionInfoList() {
SubscriptionManager subscriptionManager = ServiceUtil.getSubscriptionManager(context);
if (subscriptionManager == null) {
Log.w(TAG, "Missing SubscriptionManager.");
return Collections.emptyList();
}
List<SubscriptionInfo> list = subscriptionManager.getActiveSubscriptionInfoList();
return list != null ? list : Collections.emptyList();
}
Aggregations