remove popup label when the popup key is removed

This commit is contained in:
Helium314 2025-01-05 22:21:26 +01:00
parent 2ad45af856
commit d25df2c4de
2 changed files with 10 additions and 1 deletions

View file

@ -327,7 +327,7 @@ public class Key implements Comparable<Key> {
// Final attributes. // Final attributes.
mCode = key.mCode; mCode = key.mCode;
mLabel = key.mLabel; mLabel = key.mLabel;
mHintLabel = key.mHintLabel; mHintLabel = PopopUtilKt.findPopupHintLabel(popupKeys, key.mHintLabel);
mLabelFlags = key.mLabelFlags; mLabelFlags = key.mLabelFlags;
mIconName = key.mIconName; mIconName = key.mIconName;
mWidth = key.mWidth; mWidth = key.mWidth;

View file

@ -0,0 +1,9 @@
package helium314.keyboard.keyboard
import helium314.keyboard.keyboard.internal.PopupKeySpec
fun findPopupHintLabel(popupKeys: Array<PopupKeySpec>?, oldHintLabel: String?): String? {
if (popupKeys == null || oldHintLabel == null) return null
if (popupKeys.any { it.mLabel == oldHintLabel }) return oldHintLabel
return popupKeys.firstOrNull { it.mLabel != null }?.mLabel
}