Search in sources :

Example 11 with MainThread

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

the class PaymentsAddMoneyRepository method getWalletAddress.

@MainThread
void getWalletAddress(@NonNull AsynchronousCallback.MainThread<AddressAndUri, Error> callback) {
    if (!SignalStore.paymentsValues().mobileCoinPaymentsEnabled()) {
        callback.onError(Error.PAYMENTS_NOT_ENABLED);
    }
    MobileCoinPublicAddress publicAddress = ApplicationDependencies.getPayments().getWallet().getMobileCoinPublicAddress();
    String paymentAddressBase58 = publicAddress.getPaymentAddressBase58();
    Uri paymentAddressUri = publicAddress.getPaymentAddressUri();
    callback.onComplete(new AddressAndUri(paymentAddressBase58, paymentAddressUri));
}
Also used : MobileCoinPublicAddress(org.thoughtcrime.securesms.payments.MobileCoinPublicAddress) Uri(android.net.Uri) MainThread(androidx.annotation.MainThread)

Example 12 with MainThread

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

the class AppForegroundObserver method begin.

@MainThread
public void begin() {
    ThreadUtil.assertMainThread();
    ProcessLifecycleOwner.get().getLifecycle().addObserver(new DefaultLifecycleObserver() {

        @Override
        public void onStart(@NonNull LifecycleOwner owner) {
            onForeground();
        }

        @Override
        public void onStop(@NonNull LifecycleOwner owner) {
            onBackground();
        }
    });
}
Also used : DefaultLifecycleObserver(androidx.lifecycle.DefaultLifecycleObserver) LifecycleOwner(androidx.lifecycle.LifecycleOwner) ProcessLifecycleOwner(androidx.lifecycle.ProcessLifecycleOwner) MainThread(androidx.annotation.MainThread)

Example 13 with MainThread

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

the class WebRtcCallViewModel method updateFromWebRtcViewModel.

@MainThread
public void updateFromWebRtcViewModel(@NonNull WebRtcViewModel webRtcViewModel, boolean enableVideo) {
    canEnterPipMode = !webRtcViewModel.getState().isPreJoinOrNetworkUnavailable();
    if (callStarting && webRtcViewModel.getState().isPassedPreJoin()) {
        callStarting = false;
    }
    CallParticipant localParticipant = webRtcViewModel.getLocalParticipant();
    microphoneEnabled.setValue(localParticipant.isMicrophoneEnabled());
    CallParticipantsState state = participantsState.getValue();
    boolean wasScreenSharing = state.getFocusedParticipant().isScreenSharing();
    CallParticipantsState newState = CallParticipantsState.update(state, webRtcViewModel, enableVideo);
    participantsState.setValue(newState);
    if (switchOnFirstScreenShare && !wasScreenSharing && newState.getFocusedParticipant().isScreenSharing()) {
        switchOnFirstScreenShare = false;
        events.setValue(new Event.SwitchToSpeaker());
    }
    if (webRtcViewModel.getGroupState().isConnected()) {
        if (!containsPlaceholders(previousParticipantsList)) {
            CallParticipantListUpdate update = CallParticipantListUpdate.computeDeltaUpdate(previousParticipantsList, webRtcViewModel.getRemoteParticipants());
            callParticipantListUpdate.setValue(update);
        }
        previousParticipantsList = webRtcViewModel.getRemoteParticipants();
        identityChangedRecipients.setValue(webRtcViewModel.getIdentityChangedParticipants());
    }
    updateWebRtcControls(webRtcViewModel.getState(), webRtcViewModel.getGroupState(), localParticipant.getCameraState().isEnabled(), webRtcViewModel.isRemoteVideoEnabled(), webRtcViewModel.isRemoteVideoOffer(), localParticipant.isMoreThanOneCameraAvailable(), Util.hasItems(webRtcViewModel.getRemoteParticipants()), webRtcViewModel.getActiveDevice(), webRtcViewModel.getAvailableDevices(), webRtcViewModel.getRemoteDevicesCount().orElse(0), webRtcViewModel.getParticipantLimit());
    if (newState.isInOutgoingRingingMode()) {
        cancelTimer();
        if (!wasInOutgoingRingingMode) {
            elapsedTimeHandler.postDelayed(stopOutgoingRingingMode, CallParticipantsState.MAX_OUTGOING_GROUP_RING_DURATION);
        }
        wasInOutgoingRingingMode = true;
    } else {
        if (webRtcViewModel.getState() == WebRtcViewModel.State.CALL_CONNECTED && callConnectedTime == -1) {
            callConnectedTime = wasInOutgoingRingingMode ? System.currentTimeMillis() : webRtcViewModel.getCallConnectedTime();
            startTimer();
        } else if (webRtcViewModel.getState() != WebRtcViewModel.State.CALL_CONNECTED || webRtcViewModel.getGroupState().isNotIdleOrConnected()) {
            cancelTimer();
            callConnectedTime = -1;
        }
    }
    if (localParticipant.getCameraState().isEnabled()) {
        canDisplayTooltipIfNeeded = false;
        hasEnabledLocalVideo = true;
        events.setValue(new Event.DismissVideoTooltip());
    }
    // If remote video is enabled and we a) haven't shown our video and b) have not dismissed the popup
    if (canDisplayTooltipIfNeeded && webRtcViewModel.isRemoteVideoEnabled() && !hasEnabledLocalVideo) {
        canDisplayTooltipIfNeeded = false;
        events.setValue(new Event.ShowVideoTooltip());
    }
}
Also used : CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) SingleLiveEvent(org.thoughtcrime.securesms.util.SingleLiveEvent) MainThread(androidx.annotation.MainThread)

Example 14 with MainThread

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

the class SearchToolbar method hide.

@MainThread
private void hide() {
    if (getVisibility() == View.VISIBLE) {
        if (listener != null)
            listener.onSearchClosed();
        if (Build.VERSION.SDK_INT >= 21) {
            Animator animator = ViewAnimationUtils.createCircularReveal(this, (int) x, (int) y, getWidth(), 0);
            animator.setDuration(400);
            animator.addListener(new AnimationCompleteListener() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    setVisibility(View.INVISIBLE);
                }
            });
            animator.start();
        } else {
            setVisibility(View.INVISIBLE);
        }
    }
}
Also used : Animator(android.animation.Animator) AnimationCompleteListener(org.thoughtcrime.securesms.animation.AnimationCompleteListener) MainThread(androidx.annotation.MainThread)

Example 15 with MainThread

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

the class VerificationCodeView method append.

@MainThread
public void append(int value) {
    if (index >= codes.size())
        return;
    setInactive(containers);
    setActive(containers.get(index));
    TextView codeView = codes.get(index++);
    Animation translateIn = new TranslateAnimation(0, 0, codeView.getHeight(), 0);
    translateIn.setInterpolator(new OvershootInterpolator());
    translateIn.setDuration(500);
    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setDuration(200);
    AnimationSet animationSet = new AnimationSet(false);
    animationSet.addAnimation(fadeIn);
    animationSet.addAnimation(translateIn);
    animationSet.reset();
    animationSet.setStartTime(0);
    codeView.setText(String.valueOf(value));
    codeView.clearAnimation();
    codeView.startAnimation(animationSet);
    if (index == codes.size() && listener != null) {
        listener.onCodeComplete(Stream.of(codes).map(TextView::getText).collect(Collectors.joining()));
    }
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) TextView(android.widget.TextView) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) MainThread(androidx.annotation.MainThread)

Aggregations

MainThread (androidx.annotation.MainThread)27 Animator (android.animation.Animator)4 NonNull (androidx.annotation.NonNull)3 IMedia (org.videolan.libvlc.interfaces.IMedia)3 Uri (android.net.Uri)2 ArrayMap (android.util.ArrayMap)2 AlphaAnimation (android.view.animation.AlphaAnimation)2 Animation (android.view.animation.Animation)2 AnimationSet (android.view.animation.AnimationSet)2 OvershootInterpolator (android.view.animation.OvershootInterpolator)2 TranslateAnimation (android.view.animation.TranslateAnimation)2 TextView (android.widget.TextView)2 RequiresApi (androidx.annotation.RequiresApi)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 DefaultLifecycleObserver (androidx.lifecycle.DefaultLifecycleObserver)2 LifecycleOwner (androidx.lifecycle.LifecycleOwner)2 ProcessLifecycleOwner (androidx.lifecycle.ProcessLifecycleOwner)2 MediaItem (com.google.android.exoplayer2.MediaItem)2 AnimationCompleteListener (org.thoughtcrime.securesms.animation.AnimationCompleteListener)2 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)2