Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: fix WindowType of Tooltip #30

Merged
merged 4 commits into from
Jan 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion curtains/src/main/java/curtains/Windows.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package curtains

import android.content.res.Resources
import android.os.Build
import android.view.FrameMetrics
import android.view.View
Expand Down Expand Up @@ -46,13 +47,24 @@ val View.windowType: WindowType
val title = windowLayoutParams.title
when {
title == "Toast" -> TOAST
title == "Tooltip" -> TOOLTIP
title == tooltipString -> TOOLTIP
title.startsWith("PopupWindow:") -> POPUP_WINDOW
else -> UNKNOWN
}
}
}

// see [com.android.internal.view.TooltipPopup]
private val tooltipString by lazy(LazyThreadSafetyMode.NONE) {
// use id rather than 'Tooltip' because of i18n
val tooltipStringId = Resources.getSystem().getIdentifier("tooltip_popup_title", "string", "android")
try {
Resources.getSystem().getString(tooltipStringId)
} catch (e: Resources.NotFoundException) {
"Tooltip"
}
}

/**
* The list of touch event interceptors, inserted in [Window.Callback.dispatchTouchEvent].
*
Expand Down