Skip to content

Commit 0834dc2

Browse files
committed
fix(mods): use fixed-height content area in switch-version dialog instead of unreliable window resize
1 parent c303b61 commit 0834dc2

2 files changed

Lines changed: 52 additions & 59 deletions

File tree

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/modloaders/InstalledModAdapter.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -460,19 +460,6 @@ private void showSwitchVersionDialog(Context context, ModEntry entry, int positi
460460
retryButton.setOnClickListener(v -> loadVersions.run());
461461
loadVersions.run();
462462
dialog.show();
463-
464-
// AlertDialog windows default to wrap_content. The dialog's root view
465-
// uses match_parent with the version list measured as a 0dp
466-
// match-constraint height between the title and the toggle row —
467-
// inside a wrap_content window that 0dp child has nothing definite to
468-
// fill, so it collapses to ~0 height and only the header appears to
469-
// render. Force the window to fill virtually the whole screen so the
470-
// list area actually gets the remaining space to lay out into.
471-
if (dialog.getWindow() != null) {
472-
dialog.getWindow().setLayout(
473-
ViewGroup.LayoutParams.MATCH_PARENT,
474-
ViewGroup.LayoutParams.MATCH_PARENT);
475-
}
476463
}
477464

478465
/** Parses one entry of Modrinth's GET /project/{id}/version response. */

app_pojavlauncher/src/main/res/layout/dialog_switch_mod_version.xml

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:app="http://schemas.android.com/apk/res-auto"
55
xmlns:tools="http://schemas.android.com/tools"
66
android:layout_width="match_parent"
7-
android:layout_height="match_parent"
7+
android:layout_height="wrap_content"
88
android:paddingHorizontal="@dimen/padding_heavy"
99
android:paddingTop="@dimen/padding_heavy"
1010
android:paddingBottom="@dimen/padding_large">
@@ -36,57 +36,62 @@
3636
app:layout_constraintEnd_toEndOf="parent"
3737
app:layout_constraintTop_toTopOf="parent" />
3838

39-
<!-- Loading state -->
40-
<ProgressBar
41-
android:id="@+id/switch_version_progress"
42-
android:layout_width="wrap_content"
43-
android:layout_height="wrap_content"
44-
android:layout_marginTop="@dimen/padding_large"
45-
app:layout_constraintTop_toBottomOf="@id/switch_version_title"
46-
app:layout_constraintStart_toStartOf="parent"
47-
app:layout_constraintEnd_toEndOf="parent" />
48-
49-
<!-- Error / empty state -->
50-
<LinearLayout
51-
android:id="@+id/switch_version_error_layout"
52-
android:layout_width="0dp"
53-
android:layout_height="wrap_content"
54-
android:orientation="vertical"
55-
android:gravity="center"
56-
android:visibility="gone"
39+
<!-- Content area: progress / error / list are mutually exclusive siblings
40+
inside a single FIXED-height container. A fixed dp height (matching
41+
this codebase's existing dialog_expendable_list_view.xml pattern) is
42+
used deliberately instead of match_parent/0dp match-constraint —
43+
AlertDialog windows size themselves to wrap_content, which gives a
44+
match_parent/0dp list nothing definite to measure against and it
45+
collapses to zero height. A concrete height here sidesteps that
46+
entirely and matches how VersionSelectorDialog already solves the
47+
exact same problem elsewhere in this app. -->
48+
<FrameLayout
49+
android:id="@+id/switch_version_content"
50+
android:layout_width="match_parent"
51+
android:layout_height="@dimen/_280sdp"
5752
android:layout_marginTop="@dimen/padding_large"
58-
app:layout_constraintTop_toBottomOf="@id/switch_version_title"
59-
app:layout_constraintStart_toStartOf="parent"
60-
app:layout_constraintEnd_toEndOf="parent">
53+
app:layout_constraintTop_toBottomOf="@id/switch_version_title">
6154

62-
<TextView
63-
android:id="@+id/switch_version_error_textview"
55+
<ProgressBar
56+
android:id="@+id/switch_version_progress"
6457
android:layout_width="wrap_content"
6558
android:layout_height="wrap_content"
66-
android:textColor="@color/secondary_text"
67-
android:textAlignment="center"
68-
android:text="@string/switch_mod_version_no_versions" />
59+
android:layout_gravity="center" />
6960

70-
<Button
71-
android:id="@+id/switch_version_retry_button"
72-
android:layout_width="wrap_content"
61+
<LinearLayout
62+
android:id="@+id/switch_version_error_layout"
63+
android:layout_width="match_parent"
7364
android:layout_height="wrap_content"
74-
android:layout_marginTop="@dimen/padding_moderate"
75-
android:text="@string/switch_mod_version_retry" />
65+
android:layout_gravity="center"
66+
android:orientation="vertical"
67+
android:gravity="center"
68+
android:visibility="gone">
7669

77-
</LinearLayout>
70+
<TextView
71+
android:id="@+id/switch_version_error_textview"
72+
android:layout_width="wrap_content"
73+
android:layout_height="wrap_content"
74+
android:textColor="@color/secondary_text"
75+
android:textAlignment="center"
76+
android:text="@string/switch_mod_version_no_versions" />
7877

79-
<!-- Version list -->
80-
<androidx.recyclerview.widget.RecyclerView
81-
android:id="@+id/switch_version_list"
82-
android:layout_width="0dp"
83-
android:layout_height="0dp"
84-
android:layout_marginTop="@dimen/padding_large"
85-
android:clipToPadding="false"
86-
app:layout_constraintTop_toBottomOf="@id/switch_version_title"
87-
app:layout_constraintBottom_toTopOf="@id/switch_version_toggle_incompatible"
88-
app:layout_constraintStart_toStartOf="parent"
89-
app:layout_constraintEnd_toEndOf="parent" />
78+
<Button
79+
android:id="@+id/switch_version_retry_button"
80+
android:layout_width="wrap_content"
81+
android:layout_height="wrap_content"
82+
android:layout_marginTop="@dimen/padding_moderate"
83+
android:text="@string/switch_mod_version_retry" />
84+
85+
</LinearLayout>
86+
87+
<androidx.recyclerview.widget.RecyclerView
88+
android:id="@+id/switch_version_list"
89+
android:layout_width="match_parent"
90+
android:layout_height="match_parent"
91+
android:clipToPadding="false"
92+
android:visibility="gone" />
93+
94+
</FrameLayout>
9095

9196
<!-- Show/hide incompatible toggle -->
9297
<TextView
@@ -100,7 +105,7 @@
100105
android:textSize="@dimen/_12ssp"
101106
android:text="@string/switch_mod_version_show_incompatible"
102107
app:layout_constraintStart_toStartOf="parent"
103-
app:layout_constraintBottom_toTopOf="@id/switch_version_warning" />
108+
app:layout_constraintTop_toBottomOf="@id/switch_version_content" />
104109

105110
<!-- Warning footer -->
106111
<TextView
@@ -111,7 +116,7 @@
111116
android:text="@string/switch_mod_version_warning"
112117
android:textColor="@color/mod_version_incompatible"
113118
android:textSize="@dimen/_10ssp"
114-
app:layout_constraintBottom_toTopOf="@id/switch_version_cancel" />
119+
app:layout_constraintTop_toBottomOf="@id/switch_version_toggle_incompatible" />
115120

116121
<!-- Cancel button -->
117122
<Button
@@ -120,6 +125,7 @@
120125
android:layout_height="wrap_content"
121126
android:layout_marginTop="@dimen/padding_moderate"
122127
android:text="@android:string/cancel"
128+
app:layout_constraintTop_toBottomOf="@id/switch_version_warning"
123129
app:layout_constraintBottom_toBottomOf="parent"
124130
app:layout_constraintStart_toStartOf="parent"
125131
app:layout_constraintEnd_toEndOf="parent" />

0 commit comments

Comments
 (0)