Search in sources :

Example 1 with Message

use of com.waz.api.Message in project wire-android by wireapp.

the class StreamMediaPlayerController method onStateChanged.

@Override
public void onStateChanged(MediaPlayerState state) {
    Message selectedMessage = getMessage();
    lastMediaStateHashMap.put(selectedMessage.getId(), mediaPlayer.getState());
}
Also used : Message(com.waz.api.Message)

Example 2 with Message

use of com.waz.api.Message in project wire-android by wireapp.

the class LikesListFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup viewContainer, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_likes_list, viewContainer, false);
    toolbar = ViewUtils.getView(rootView, R.id.t__likes_list__toolbar);
    likersListView = ViewUtils.getView(rootView, R.id.rv__likes_list);
    likesAdapter = new LikesAdapter();
    likersListView.setLayoutManager(new LinearLayoutManager(getActivity()));
    likersListView.setAdapter(likesAdapter);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getContainer().closeLikesList();
        }
    });
    Message likedMessage = getArguments().getParcelable(ARGUMENT_LIKED_MESSAGE);
    messageModelObserver.setAndUpdate(likedMessage);
    return rootView;
}
Also used : Message(com.waz.api.Message) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 3 with Message

use of com.waz.api.Message in project wire-android by wireapp.

the class ConversationFragment method onErrorCanNotSentMessageToUnverifiedConversation.

private void onErrorCanNotSentMessageToUnverifiedConversation(final ErrorsList.ErrorDescription errorDescription) {
    if (getControllerFactory().getNavigationController().getCurrentPage() != Page.MESSAGE_STREAM) {
        return;
    }
    KeyboardUtils.hideKeyboard(getActivity());
    final IConversation currentConversation = errorDescription.getConversation();
    final Iterable<? extends User> users = currentConversation.getUsers();
    final Map<User, String> userNameMap = new HashMap<>();
    int tmpUnverifiedDevices = 0;
    int userCount = 0;
    final boolean onlySelfChanged;
    for (User user : users) {
        if (user.getVerified() == Verification.VERIFIED) {
            continue;
        }
        userCount++;
        userNameMap.put(user, user.getDisplayName());
        for (OtrClient client : user.getOtrClients()) {
            if (client.getVerified() == Verification.VERIFIED) {
                continue;
            }
            tmpUnverifiedDevices++;
        }
    }
    if (self != null && self.getUser().getVerified() != Verification.VERIFIED) {
        onlySelfChanged = userCount == 0;
        userCount++;
        userNameMap.put(self.getUser(), getString(R.string.conversation_degraded_confirmation__header__you));
        for (OtrClient client : self.getUser().getOtrClients()) {
            if (client.getVerified() == Verification.VERIFIED) {
                continue;
            }
            tmpUnverifiedDevices++;
        }
    } else {
        onlySelfChanged = false;
    }
    final List<String> userNameList = new ArrayList<>(userNameMap.values());
    final int userNameCount = userNameList.size();
    final String header;
    if (userNameCount == 0) {
        header = getResources().getString(R.string.conversation__degraded_confirmation__header__someone);
    } else if (userNameCount == 1) {
        final int unverifiedDevices = Math.max(1, tmpUnverifiedDevices);
        header = getResources().getQuantityString(R.plurals.conversation__degraded_confirmation__header__single_user, unverifiedDevices, userNameList.get(0));
    } else {
        header = getString(R.string.conversation__degraded_confirmation__header__multiple_user, TextUtils.join(", ", userNameList.subList(0, userNameCount - 1)), userNameList.get(userNameCount - 1));
    }
    int tmpMessageCount = 0;
    for (Message m : errorDescription.getMessages()) {
        tmpMessageCount++;
    }
    final int messageCount = Math.max(1, tmpMessageCount);
    final String message = getResources().getQuantityString(R.plurals.conversation__degraded_confirmation__message, messageCount);
    final ConfirmationCallback callback = new ConfirmationCallback() {

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
            final Iterable<? extends Message> messages = errorDescription.getMessages();
            for (Message message : messages) {
                errorDescription.dismiss();
                message.retry();
            }
        }

        @Override
        public void negativeButtonClicked() {
        }

        @Override
        public void canceled() {
        }

        @Override
        public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
            if (confirmed || canceled) {
                return;
            }
            if (onlySelfChanged) {
                getContext().startActivity(ZetaPreferencesActivity.getOtrDevicesPreferencesIntent(getContext()));
            } else {
                final View anchorView = ViewUtils.getView(getActivity(), R.id.cursor_menu_item_participant);
                getControllerFactory().getConversationScreenController().showParticipants(anchorView, true);
            }
        }
    };
    final String positiveButton = getString(R.string.conversation__degraded_confirmation__positive_action);
    final String negativeButton = onlySelfChanged ? getString(R.string.conversation__degraded_confirmation__negative_action_self) : getResources().getQuantityString(R.plurals.conversation__degraded_confirmation__negative_action, userCount);
    final ConfirmationRequest request = new ConfirmationRequest.Builder().withHeader(header).withMessage(message).withPositiveButton(positiveButton).withNegativeButton(negativeButton).withConfirmationCallback(callback).withCancelButton().withHeaderIcon(R.drawable.shield_half).withWireTheme(getControllerFactory().getThemeController().getThemeDependentOptionsTheme()).build();
    getControllerFactory().getConfirmationController().requestConfirmation(request, IConfirmationController.CONVERSATION);
}
Also used : User(com.waz.api.User) ConfirmationCallback(com.waz.zclient.controllers.confirmation.ConfirmationCallback) Message(com.waz.api.Message) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IConversation(com.waz.api.IConversation) ShieldView(com.waz.zclient.ui.views.e2ee.ShieldView) AudioMessageRecordingView(com.waz.zclient.ui.audiomessage.AudioMessageRecordingView) LoadingIndicatorView(com.waz.zclient.views.LoadingIndicatorView) MessagesListView(com.waz.zclient.messages.MessagesListView) View(android.view.View) TextView(android.widget.TextView) TypingIndicatorView(com.waz.zclient.pages.main.conversation.views.TypingIndicatorView) AbsListView(android.widget.AbsListView) ActionMenuView(android.support.v7.widget.ActionMenuView) SuppressLint(android.annotation.SuppressLint) OtrClient(com.waz.api.OtrClient) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Example 4 with Message

use of com.waz.api.Message in project wire-android by wireapp.

the class StreamMediaPlayerBarFragment method updateMediaPlayerIndicator.

private void updateMediaPlayerIndicator() {
    if (streamMediaController == null) {
        return;
    }
    Message trackMetaData = streamMediaController.getMessage();
    MediaPlayerState mediaPlayerState = streamMediaController.getMediaPlayerState(trackMetaData);
    if (mediaPlayerState == MediaPlayerState.PlaybackCompleted) {
        return;
    }
    if (mediaPlayerState.isPauseControl()) {
        toolbar.setNavigationIcon(ThemeUtils.isDarkTheme(getContext()) ? R.drawable.ic_action_pause_light : R.drawable.ic_action_pause_dark);
    } else if (mediaPlayerState.isPlayControl()) {
        toolbar.setNavigationIcon(ThemeUtils.isDarkTheme(getContext()) ? R.drawable.ic_action_play_light : R.drawable.ic_action_play_dark);
    }
}
Also used : Message(com.waz.api.Message) MediaPlayerState(com.waz.zclient.controllers.mediaplayer.MediaPlayerState)

Example 5 with Message

use of com.waz.api.Message in project wire-android by wireapp.

the class StreamMediaPlayerController method registerBroadcastReceiver.

private void registerBroadcastReceiver() {
    interruptionBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            Message trackMetaData = getMessage();
            if (!getMediaPlayerState(trackMetaData).isPauseControl()) {
                return;
            }
            if (intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
                String phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
                if (!phoneState.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                    return;
                }
            }
            pause(trackMetaData.getConversationId());
        }
    };
    IntentFilter interruptionIntentFilter = new IntentFilter();
    interruptionIntentFilter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    interruptionIntentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    interruptionIntentFilter.addAction(Intent.ACTION_NEW_OUTGOING_CALL);
    context.registerReceiver(interruptionBroadcastReceiver, interruptionIntentFilter);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Message(com.waz.api.Message) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Aggregations

Message (com.waz.api.Message)5 View (android.view.View)2 SuppressLint (android.annotation.SuppressLint)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Nullable (android.support.annotation.Nullable)1 ActionMenuView (android.support.v7.widget.ActionMenuView)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 AbsListView (android.widget.AbsListView)1 TextView (android.widget.TextView)1 IConversation (com.waz.api.IConversation)1 OtrClient (com.waz.api.OtrClient)1 User (com.waz.api.User)1 ConfirmationCallback (com.waz.zclient.controllers.confirmation.ConfirmationCallback)1 ConfirmationRequest (com.waz.zclient.controllers.confirmation.ConfirmationRequest)1 MediaPlayerState (com.waz.zclient.controllers.mediaplayer.MediaPlayerState)1 MessagesListView (com.waz.zclient.messages.MessagesListView)1