Search in sources :

Example 21 with MainThread

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

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 22 with MainThread

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

the class SearchToolbar method display.

@MainThread
public void display(float x, float y) {
    if (getVisibility() != View.VISIBLE) {
        this.x = x;
        this.y = y;
        searchItem.expandActionView();
        if (Build.VERSION.SDK_INT >= 21) {
            Animator animator = ViewAnimationUtils.createCircularReveal(this, (int) x, (int) y, 0, getWidth());
            animator.setDuration(400);
            setVisibility(View.VISIBLE);
            animator.start();
        } else {
            setVisibility(View.VISIBLE);
        }
    }
}
Also used : Animator(android.animation.Animator) MainThread(androidx.annotation.MainThread)

Example 23 with MainThread

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

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 24 with MainThread

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

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 25 with MainThread

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

the class SimpleProgressDialog method show.

@MainThread
@NonNull
public static AlertDialog show(@NonNull Context context) {
    AlertDialog dialog = new AlertDialog.Builder(context).setView(R.layout.progress_dialog).setCancelable(false).create();
    dialog.show();
    dialog.getWindow().setLayout(context.getResources().getDimensionPixelSize(R.dimen.progress_dialog_size), context.getResources().getDimensionPixelSize(R.dimen.progress_dialog_size));
    return dialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) MainThread(androidx.annotation.MainThread) NonNull(androidx.annotation.NonNull)

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