Fix nested overlays in more buttons

This commit is contained in:
Kelvin 2023-12-20 12:35:40 +01:00
commit 5af4787c45
2 changed files with 10 additions and 4 deletions

View file

@ -739,7 +739,7 @@ class UISlideOverlays {
} }
fun showMoreButtonOverlay(container: ViewGroup, buttonGroup: RoundButtonGroup, ignoreTags: List<Any> = listOf(), onPinnedbuttons: ((List<RoundButton>)->Unit)? = null): SlideUpMenuOverlay { fun showMoreButtonOverlay(container: ViewGroup, buttonGroup: RoundButtonGroup, ignoreTags: List<Any> = listOf(), invokeParents: Boolean = true, onPinnedbuttons: ((List<RoundButton>)->Unit)? = null): SlideUpMenuOverlay {
val visible = buttonGroup.getVisibleButtons().filter { !ignoreTags.contains(it.tagRef) }; val visible = buttonGroup.getVisibleButtons().filter { !ignoreTags.contains(it.tagRef) };
val hidden = buttonGroup.getInvisibleButtons().filter { !ignoreTags.contains(it.tagRef) }; val hidden = buttonGroup.getInvisibleButtons().filter { !ignoreTags.contains(it.tagRef) };
@ -747,7 +747,7 @@ class UISlideOverlays {
hidden hidden
.map { btn -> SlideUpMenuItem(container.context, btn.iconResource, btn.text.text.toString(), "", "", { .map { btn -> SlideUpMenuItem(container.context, btn.iconResource, btn.text.text.toString(), "", "", {
btn.handler?.invoke(btn); btn.handler?.invoke(btn);
}, true) as View }.toTypedArray(), }, invokeParents) as View }.toTypedArray(),
arrayOf(SlideUpMenuItem(container.context, R.drawable.ic_pin, container.context.getString(R.string.change_pins), container.context.getString(R.string.decide_which_buttons_should_be_pinned), "", { arrayOf(SlideUpMenuItem(container.context, R.drawable.ic_pin, container.context.getString(R.string.change_pins), container.context.getString(R.string.decide_which_buttons_should_be_pinned), "", {
showOrderOverlay(container, container.context.getString(R.string.select_your_pins_in_order), (visible + hidden).map { Pair(it.text.text.toString(), it.tagRef!!) }) { showOrderOverlay(container, container.context.getString(R.string.select_your_pins_in_order), (visible + hidden).map { Pair(it.text.text.toString(), it.tagRef!!) }) {
val selected = it val selected = it

View file

@ -437,11 +437,11 @@ class VideoDetailView : ConstraintLayout {
var buttonMore: RoundButton? = null; var buttonMore: RoundButton? = null;
buttonMore = RoundButton(context, R.drawable.ic_menu, context.getString(R.string.more), TAG_MORE) { buttonMore = RoundButton(context, R.drawable.ic_menu, context.getString(R.string.more), TAG_MORE) {
_slideUpOverlay = UISlideOverlays.showMoreButtonOverlay(_overlayContainer, _buttonPins, listOf(TAG_MORE)) {selected -> _slideUpOverlay = UISlideOverlays.showMoreButtonOverlay(_overlayContainer, _buttonPins, listOf(TAG_MORE), false) {selected ->
_buttonPins.setButtons(*(selected + listOf(buttonMore!!)).toTypedArray()); _buttonPins.setButtons(*(selected + listOf(buttonMore!!)).toTypedArray());
_buttonPinStore.set(*selected.filter { it.tagRef is String }.map{ it.tagRef as String }.toTypedArray()) _buttonPinStore.set(*selected.filter { it.tagRef is String }.map{ it.tagRef as String }.toTypedArray())
_buttonPinStore.save(); _buttonPinStore.save();
} };
}; };
_buttonMore = buttonMore; _buttonMore = buttonMore;
updateMoreButtons(); updateMoreButtons();
@ -769,6 +769,7 @@ class VideoDetailView : ConstraintLayout {
Logger.e(TAG, "Failed to reopen live chat", ex); Logger.e(TAG, "Failed to reopen live chat", ex);
} }
} }
_slideUpOverlay?.hide();
} else null, } else null,
RoundButton(context, R.drawable.ic_screen_share, context.getString(R.string.background), TAG_BACKGROUND) { RoundButton(context, R.drawable.ic_screen_share, context.getString(R.string.background), TAG_BACKGROUND) {
if(!allowBackground) { if(!allowBackground) {
@ -781,6 +782,7 @@ class VideoDetailView : ConstraintLayout {
allowBackground = false; allowBackground = false;
it.text.text = resources.getString(R.string.background); it.text.text = resources.getString(R.string.background);
} }
_slideUpOverlay?.hide();
}, },
RoundButton(context, R.drawable.ic_download, context.getString(R.string.download), TAG_DOWNLOAD) { RoundButton(context, R.drawable.ic_download, context.getString(R.string.download), TAG_DOWNLOAD) {
video?.let { video?.let {
@ -793,11 +795,13 @@ class VideoDetailView : ConstraintLayout {
preventPictureInPicture = true; preventPictureInPicture = true;
shareVideo(); shareVideo();
}; };
_slideUpOverlay?.hide();
}, },
RoundButton(context, R.drawable.ic_screen_share, context.getString(R.string.overlay), TAG_OVERLAY) { RoundButton(context, R.drawable.ic_screen_share, context.getString(R.string.overlay), TAG_OVERLAY) {
this.startPictureInPicture(); this.startPictureInPicture();
fragment.forcePictureInPicture(); fragment.forcePictureInPicture();
//PiPActivity.startPiP(context); //PiPActivity.startPiP(context);
_slideUpOverlay?.hide();
}, },
RoundButton(context, R.drawable.ic_export, context.getString(R.string.page), TAG_OPEN) { RoundButton(context, R.drawable.ic_export, context.getString(R.string.page), TAG_OPEN) {
video?.let { video?.let {
@ -805,9 +809,11 @@ class VideoDetailView : ConstraintLayout {
fragment.navigate<BrowserFragment>(url); fragment.navigate<BrowserFragment>(url);
fragment.minimizeVideoDetail(); fragment.minimizeVideoDetail();
}; };
_slideUpOverlay?.hide();
}, },
RoundButton(context, R.drawable.ic_refresh, context.getString(R.string.reload), "Reload") { RoundButton(context, R.drawable.ic_refresh, context.getString(R.string.reload), "Reload") {
reloadVideo(); reloadVideo();
_slideUpOverlay?.hide();
}).filterNotNull(); }).filterNotNull();
if(!_buttonPinStore.getAllValues().any()) if(!_buttonPinStore.getAllValues().any())
_buttonPins.setButtons(*(buttons + listOf(_buttonMore)).toTypedArray()); _buttonPins.setButtons(*(buttons + listOf(_buttonMore)).toTypedArray());