Added ability to seek voice messages from player alert.

This commit is contained in:
23rd
2021-02-07 05:13:57 +03:00
committed by immat0x1
parent 3a57330f78
commit a371376d92
2 changed files with 12 additions and 6 deletions

View File

@@ -216,7 +216,7 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
}
rewindingProgress = currentProgress;
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject != null && messageObject.isMusic()) {
if (messageObject != null && (messageObject.isMusic() || messageObject.isVoice())) {
if (!MediaController.getInstance().isMessagePaused()) {
MediaController.getInstance().getPlayingMessageObject().audioProgress = rewindingProgress;
}
@@ -634,7 +634,7 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
MediaController.getInstance().seekToProgress(MediaController.getInstance().getPlayingMessageObject(), progress);
}
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject != null && messageObject.isMusic()) {
if (messageObject != null && (messageObject.isMusic() || messageObject.isVoice())) {
updateProgress(messageObject);
}
}
@@ -737,7 +737,9 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
if (Build.VERSION.SDK_INT >= 21) {
repeatButton.setBackgroundDrawable(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector), 1, AndroidUtilities.dp(18)));
}
if (!messageObject.isVoice()) {
bottomView.addView(repeatButton, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP));
}
repeatButton.setOnClickListener(v -> {
updateSubMenu();
repeatButton.toggleSubMenu();
@@ -835,7 +837,7 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
}
rewindingProgress = currentProgress;
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject != null && messageObject.isMusic()) {
if (messageObject != null && (messageObject.isMusic() || messageObject.isVoice())) {
updateProgress(messageObject);
}
if (rewindingState == -1 && pressedCount > 0) {
@@ -923,7 +925,9 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
if (Build.VERSION.SDK_INT >= 21) {
prevButton.setBackgroundDrawable(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector), 1, AndroidUtilities.dp(22)));
}
if (!messageObject.isVoice()) {
bottomView.addView(prevButton, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP));
}
prevButton.setContentDescription(LocaleController.getString("AccDescrPrevious", R.string.AccDescrPrevious));
buttons[2] = playButton = new ImageView(context);
@@ -1047,7 +1051,9 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
if (Build.VERSION.SDK_INT >= 21) {
nextButton.setBackgroundDrawable(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector), 1, AndroidUtilities.dp(22)));
}
if (!messageObject.isVoice()) {
bottomView.addView(nextButton, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP));
}
nextButton.setContentDescription(LocaleController.getString("Next", R.string.Next));
buttons[4] = likeButton = new ImageView(context);
@@ -1662,7 +1668,7 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
}
} else if (id == NotificationCenter.messagePlayingProgressDidChanged) {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject != null && messageObject.isMusic()) {
if (messageObject != null && (messageObject.isMusic() || messageObject.isVoice())) {
updateProgress(messageObject);
}
} else if (id == NotificationCenter.musicDidLoad) {
@@ -1941,7 +1947,7 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
private void updateTitle(boolean shutdown) {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) {
if (messageObject == null && shutdown || messageObject != null && !(messageObject.isMusic() || messageObject.isVoice())) {
dismiss();
} else {
if (messageObject == null) {

View File

@@ -648,7 +648,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
if (currentStyle == STYLE_AUDIO_PLAYER) {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (fragment != null && messageObject != null) {
if (messageObject.isMusic()) {
if (messageObject.isMusic() || messageObject.isVoice()) {
if (getContext() instanceof LaunchActivity) {
fragment.showDialog(new AudioPlayerAlert(getContext(), resourcesProvider));
}