fix: the store sign-in page keeps its place when the display density changes (#886)

* fix: the store sign-in page keeps its place when the display density changes

StoreLoginActivity sized its toolbar and error panel in code with dp(), so it
was left out of the density change and a fold between two displays of
different density still recreated it and reloaded the sign-in page. Handle
density in the manifest and apply the dp sizes again in onConfigurationChanged.

Checked on the foldable emulator with the GOG sign-in open: wm density
420 -> 560 -> 320 does not relaunch the activity, the page stays, and the top
bar follows the new density.

* fix: re-apply the sign-in text sizes together with the other dp sizes

The title (16sp) and error text (15sp) were set in sp at creation, so after a density change they kept the old scale. Set them again in onConfigurationChanged.

---------

Co-authored-by: ovurrsl <ovurrsl@users.noreply.github.com>
This commit is contained in:
Resul Övürandovurrsl authored and GitHub committed 2026-10-16 09:50:28 -04:00
1 parent e3fe63aee6
commit dce7e7ece6
2 files changed
+26 -1

No files matched your search

+1 -1
View File
@@ -123,7 +123,7 @@
android:name=".stores.StoreLoginActivity"
android:exported="false"
android:screenOrientation="sensorLandscape"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|density"
android:theme="@style/AppTheme" />
<activity
@@ -1,6 +1,7 @@
package com.droiddeck.launcher.stores
import android.annotation.SuppressLint
import android.content.res.Configuration
import android.graphics.Color
import android.net.Uri
import android.net.http.SslError
@@ -64,6 +65,10 @@ class StoreLoginActivity : ComponentActivity() {
private lateinit var errorPanel: LinearLayout
private lateinit var errorText: TextView
private lateinit var titleText: TextView
private lateinit var topBar: LinearLayout
private lateinit var reloadButton: ImageButton
private lateinit var closeButton: ImageButton
private lateinit var retryButton: Button
private var oauthState: String? = null
private val captured = AtomicBoolean(false)
private var flooded = false
@@ -130,6 +135,7 @@ class StoreLoginActivity : ComponentActivity() {
contentDescription = getString(R.string.stores_login_close); layoutParams = LinearLayout.LayoutParams(dp(48), dp(48))
setOnClickListener { finish() }
}
topBar = bar; reloadButton = reload; closeButton = close
bar.addView(titleText); bar.addView(reload); bar.addView(close)
progressBar = ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal).apply {
max = 100; isIndeterminate = false
@@ -144,6 +150,7 @@ class StoreLoginActivity : ComponentActivity() {
}
errorText = TextView(this).apply { setTextColor(0xFFF2F4F7.toInt()); textSize = 15f; gravity = Gravity.CENTER }
val retry = Button(this).apply { text = getString(R.string.stores_login_retry); setOnClickListener { reloadLogin() } }
retryButton = retry
errorPanel.addView(errorText)
errorPanel.addView(retry, LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { topMargin = dp(16) })
contentHost.addView(errorPanel, FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
@@ -151,6 +158,24 @@ class StoreLoginActivity : ComponentActivity() {
return root
}
/**
* The activity handles density changes itself so that folding between two displays of different
* density keeps the page and the sign-in in progress; the dp-based chrome sizes are applied again.
*/
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
if (!::topBar.isInitialized) return
topBar.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(48))
titleText.setPadding(dp(16), 0, dp(8), 0)
titleText.textSize = 16f
errorText.textSize = 15f
reloadButton.layoutParams = LinearLayout.LayoutParams(dp(48), dp(48))
closeButton.layoutParams = LinearLayout.LayoutParams(dp(48), dp(48))
progressBar.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(3))
errorPanel.setPadding(dp(24), dp(24), dp(24), dp(24))
retryButton.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply { topMargin = dp(16) }
}
private fun showError(message: String) {
runOnUiThread { errorText.text = message; errorPanel.visibility = View.VISIBLE; errorPanel.bringToFront(); progressBar.visibility = View.GONE }
}