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

4083 limit dialog sizes #4084

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Lakoja
Copy link
Collaborator

@Lakoja Lakoja commented Oct 29, 2023

Fixes #4083

Limits the size of full screen dialogs on larger devices.

grafik

@@ -78,3 +81,15 @@ fun TextView.fixTextSelection() {
setTextIsSelectable(false)
post { setTextIsSelectable(true) }
}

fun Float.dpToPx(resource: Resources): Float {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't have those, yet?

maxHeightSpec = maxAvailablePixels.height
}

this.setLayout(maxWidthSpec, maxHeightSpec)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Draft..

However this leads to this size being fixed. I. e. SOFT_INPUT_ADJUST_RESIZE not working anymore: Once the keyboard is visible half the (caption) dialog is covered and not scrollable...

if (maxWidthDp == ViewGroup.LayoutParams.MATCH_PARENT && maxHeightDp == ViewGroup.LayoutParams.MATCH_PARENT) {
this.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
} else {
val maxAvailablePixels = getAvailableScreenPixels(this)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway: I have the feeling this could be a one-line configuration somewhere. E. g. defining the right variable in a style and use that for dialogs?

}

private fun getAvailableScreenPixels(window: Window): Size {
val windowInsets = window.windowManager.maximumWindowMetrics.windowInsets
Copy link
Collaborator Author

@Lakoja Lakoja Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Draft

Unfortunately all methods and fields in this method are api level 30 (and not 24).

The task should be simple: Get size available to / used by app window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit dialog sizes on tablets
1 participant