kopia lustrzana https://github.com/ryukoposting/Signal-Android
Show bottom sheet when you tap an avatar in the story viewer.
rodzic
9851bc300e
commit
512ba2b0a8
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.recipients.ui.bottomsheet;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -83,6 +84,7 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
private View buttonStrip;
|
private View buttonStrip;
|
||||||
private View interactionsContainer;
|
private View interactionsContainer;
|
||||||
private BadgeImageView badgeImageView;
|
private BadgeImageView badgeImageView;
|
||||||
|
private Callback callback;
|
||||||
|
|
||||||
public static BottomSheetDialogFragment create(@NonNull RecipientId recipientId,
|
public static BottomSheetDialogFragment create(@NonNull RecipientId recipientId,
|
||||||
@Nullable GroupId groupId)
|
@Nullable GroupId groupId)
|
||||||
|
@ -341,6 +343,8 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
removeAdminButton.setEnabled(!busy);
|
removeAdminButton.setEnabled(!busy);
|
||||||
removeFromGroupButton.setEnabled(!busy);
|
removeFromGroupButton.setEnabled(!busy);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
callback = getParentFragment() != null && getParentFragment() instanceof Callback ? (Callback) getParentFragment() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSystemContactSheet(@NonNull Intent intent) {
|
private void openSystemContactSheet(@NonNull Intent intent) {
|
||||||
|
@ -363,4 +367,16 @@ public final class RecipientBottomSheetDialogFragment extends BottomSheetDialogF
|
||||||
public void show(@NonNull FragmentManager manager, @Nullable String tag) {
|
public void show(@NonNull FragmentManager manager, @Nullable String tag) {
|
||||||
BottomSheetUtil.show(manager, tag, this);
|
BottomSheetUtil.show(manager, tag, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||||
|
super.onDismiss(dialog);
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onRecipientBottomSheetDismissed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Callback {
|
||||||
|
void onRecipientBottomSheetDismissed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ import org.thoughtcrime.securesms.mediapreview.VideoControlsDelegate
|
||||||
import org.thoughtcrime.securesms.mms.GlideApp
|
import org.thoughtcrime.securesms.mms.GlideApp
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||||
|
import org.thoughtcrime.securesms.recipients.ui.bottomsheet.RecipientBottomSheetDialogFragment
|
||||||
import org.thoughtcrime.securesms.safety.SafetyNumberBottomSheet
|
import org.thoughtcrime.securesms.safety.SafetyNumberBottomSheet
|
||||||
import org.thoughtcrime.securesms.stories.StorySlateView
|
import org.thoughtcrime.securesms.stories.StorySlateView
|
||||||
import org.thoughtcrime.securesms.stories.StoryVolumeOverlayView
|
import org.thoughtcrime.securesms.stories.StoryVolumeOverlayView
|
||||||
|
@ -93,7 +94,8 @@ class StoryViewerPageFragment :
|
||||||
MultiselectForwardBottomSheet.Callback,
|
MultiselectForwardBottomSheet.Callback,
|
||||||
StorySlateView.Callback,
|
StorySlateView.Callback,
|
||||||
StoryInfoBottomSheetDialogFragment.OnInfoSheetDismissedListener,
|
StoryInfoBottomSheetDialogFragment.OnInfoSheetDismissedListener,
|
||||||
SafetyNumberBottomSheet.Callbacks {
|
SafetyNumberBottomSheet.Callbacks,
|
||||||
|
RecipientBottomSheetDialogFragment.Callback {
|
||||||
|
|
||||||
private val storyVolumeViewModel: StoryVolumeViewModel by viewModels(ownerProducer = { requireActivity() })
|
private val storyVolumeViewModel: StoryVolumeViewModel by viewModels(ownerProducer = { requireActivity() })
|
||||||
|
|
||||||
|
@ -859,6 +861,8 @@ class StoryViewerPageFragment :
|
||||||
} else {
|
} else {
|
||||||
from.text = name
|
from.text = name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
from.setOnClickListener { onSenderClicked(storyPost.sender.id) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun presentDate(date: TextView, storyPost: StoryPost) {
|
private fun presentDate(date: TextView, storyPost: StoryPost) {
|
||||||
|
@ -867,17 +871,27 @@ class StoryViewerPageFragment :
|
||||||
|
|
||||||
private fun presentSenderAvatar(senderAvatar: AvatarImageView, post: StoryPost) {
|
private fun presentSenderAvatar(senderAvatar: AvatarImageView, post: StoryPost) {
|
||||||
AvatarUtil.loadIconIntoImageView(post.sender, senderAvatar, DimensionUnit.DP.toPixels(32f).toInt())
|
AvatarUtil.loadIconIntoImageView(post.sender, senderAvatar, DimensionUnit.DP.toPixels(32f).toInt())
|
||||||
|
senderAvatar.setOnClickListener { onSenderClicked(post.sender.id) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun presentGroupAvatar(groupAvatar: AvatarImageView, post: StoryPost) {
|
private fun presentGroupAvatar(groupAvatar: AvatarImageView, post: StoryPost) {
|
||||||
if (post.group != null) {
|
if (post.group != null) {
|
||||||
groupAvatar.setRecipient(post.group)
|
groupAvatar.setRecipient(post.group)
|
||||||
groupAvatar.visible = true
|
groupAvatar.visible = true
|
||||||
|
groupAvatar.setOnClickListener { onSenderClicked(post.sender.id) }
|
||||||
} else {
|
} else {
|
||||||
groupAvatar.visible = false
|
groupAvatar.visible = false
|
||||||
|
groupAvatar.setOnClickListener(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onSenderClicked(senderId: RecipientId) {
|
||||||
|
viewModel.setIsDisplayingRecipientBottomSheet(true)
|
||||||
|
RecipientBottomSheetDialogFragment
|
||||||
|
.create(senderId, null)
|
||||||
|
.show(childFragmentManager, "BOTTOM")
|
||||||
|
}
|
||||||
|
|
||||||
private fun presentBottomBar(post: StoryPost, replyState: StoryViewerPageState.ReplyState, isReceiptsEnabled: Boolean) {
|
private fun presentBottomBar(post: StoryPost, replyState: StoryViewerPageState.ReplyState, isReceiptsEnabled: Boolean) {
|
||||||
if (replyState == StoryViewerPageState.ReplyState.NONE) {
|
if (replyState == StoryViewerPageState.ReplyState.NONE) {
|
||||||
viewsAndReplies.visible = false
|
viewsAndReplies.visible = false
|
||||||
|
@ -1282,6 +1296,10 @@ class StoryViewerPageFragment :
|
||||||
viewModel.setIsDisplayingPartialSendDialog(false)
|
viewModel.setIsDisplayingPartialSendDialog(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onRecipientBottomSheetDismissed() {
|
||||||
|
viewModel.setIsDisplayingRecipientBottomSheet(false)
|
||||||
|
}
|
||||||
|
|
||||||
interface Callback {
|
interface Callback {
|
||||||
fun onGoToPreviousStory(recipientId: RecipientId)
|
fun onGoToPreviousStory(recipientId: RecipientId)
|
||||||
fun onFinishedPosts(recipientId: RecipientId)
|
fun onFinishedPosts(recipientId: RecipientId)
|
||||||
|
|
|
@ -242,6 +242,10 @@ class StoryViewerPageViewModel(
|
||||||
storyViewerPlaybackStore.update { it.copy(isDisplayingCaptionOverlay = isDisplayingCaptionOverlay) }
|
storyViewerPlaybackStore.update { it.copy(isDisplayingCaptionOverlay = isDisplayingCaptionOverlay) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setIsDisplayingRecipientBottomSheet(isDisplayingRecipientBottomSheet: Boolean) {
|
||||||
|
storyViewerPlaybackStore.update { it.copy(isDisplayingRecipientBottomSheet = isDisplayingRecipientBottomSheet) }
|
||||||
|
}
|
||||||
|
|
||||||
fun setIsUserTouching(isUserTouching: Boolean) {
|
fun setIsUserTouching(isUserTouching: Boolean) {
|
||||||
storyViewerPlaybackStore.update { it.copy(isUserTouching = isUserTouching) }
|
storyViewerPlaybackStore.update { it.copy(isUserTouching = isUserTouching) }
|
||||||
storyLongPressSubject.onNext(isUserTouching)
|
storyLongPressSubject.onNext(isUserTouching)
|
||||||
|
|
|
@ -22,7 +22,8 @@ data class StoryViewerPlaybackState(
|
||||||
val isUserLongTouching: Boolean = false,
|
val isUserLongTouching: Boolean = false,
|
||||||
val isUserScrollingChild: Boolean = false,
|
val isUserScrollingChild: Boolean = false,
|
||||||
val isUserScaling: Boolean = false,
|
val isUserScaling: Boolean = false,
|
||||||
val isDisplayingPartialSendDialog: Boolean = false
|
val isDisplayingPartialSendDialog: Boolean = false,
|
||||||
|
val isDisplayingRecipientBottomSheet: Boolean = false
|
||||||
) {
|
) {
|
||||||
val hideChromeImmediate: Boolean = isRunningSharedElementAnimation || isDisplayingFirstTimeNavigation
|
val hideChromeImmediate: Boolean = isRunningSharedElementAnimation || isDisplayingFirstTimeNavigation
|
||||||
|
|
||||||
|
@ -51,5 +52,6 @@ data class StoryViewerPlaybackState(
|
||||||
isDisplayingInfoDialog ||
|
isDisplayingInfoDialog ||
|
||||||
isUserScaling ||
|
isUserScaling ||
|
||||||
isDisplayingHideDialog ||
|
isDisplayingHideDialog ||
|
||||||
isDisplayingPartialSendDialog
|
isDisplayingPartialSendDialog ||
|
||||||
|
isDisplayingRecipientBottomSheet
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue