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());
}
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;
}
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);
}
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);
}
}
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);
}
Aggregations