Search in sources :

Example 61 with RequiresApi

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();
}
Also used : KeyGenParameterSpec(android.security.keystore.KeyGenParameterSpec) Calendar(java.util.Calendar) RequiresApi(androidx.annotation.RequiresApi)

Example 62 with RequiresApi

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());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationManager(android.app.NotificationManager) Recipient(org.thoughtcrime.securesms.recipients.Recipient) NotificationPrivacyPreference(org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference) WorkerThread(androidx.annotation.WorkerThread) RequiresApi(androidx.annotation.RequiresApi)

Example 63 with RequiresApi

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();
}
Also used : Animator(android.animation.Animator) RequiresApi(androidx.annotation.RequiresApi)

Example 64 with RequiresApi

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);
    }
}
Also used : StorageVolume(android.os.storage.StorageVolume) StorageManager(android.os.storage.StorageManager) NonNull(androidx.annotation.NonNull) RequiresApi(androidx.annotation.RequiresApi)

Example 65 with RequiresApi

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();
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager) NonNull(androidx.annotation.NonNull) RequiresApi(androidx.annotation.RequiresApi)

Aggregations

RequiresApi (androidx.annotation.RequiresApi)117 NotificationChannel (android.app.NotificationChannel)16 Intent (android.content.Intent)13 SuppressLint (android.annotation.SuppressLint)10 NotificationManager (android.app.NotificationManager)9 Uri (android.net.Uri)9 StatusBarNotification (android.service.notification.StatusBarNotification)9 NonNull (androidx.annotation.NonNull)9 IOException (java.io.IOException)8 Notification (android.app.Notification)6 PendingIntent (android.app.PendingIntent)6 Context (android.content.Context)6 ObjectAnimator (android.animation.ObjectAnimator)5 Bundle (android.os.Bundle)5 ByteBuffer (java.nio.ByteBuffer)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 SecretKey (javax.crypto.SecretKey)5 GestureDescription (android.accessibilityservice.GestureDescription)4 TaskStackBuilder (android.app.TaskStackBuilder)4 Bitmap (android.graphics.Bitmap)4