Limit the width of the login screen in landscape mode to be easier on the eye.
This commit is contained in:
parent
72ba8733b3
commit
100514cde6
|
@ -1,10 +1,13 @@
|
|||
package com.github.apognu.otter.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.doOnLayout
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.github.apognu.otter.R
|
||||
import com.github.apognu.otter.fragments.LoginDialog
|
||||
|
@ -27,6 +30,8 @@ class LoginActivity : AppCompatActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.activity_login)
|
||||
|
||||
limitContainerWidth()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -79,6 +84,12 @@ class LoginActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
|
||||
limitContainerWidth()
|
||||
}
|
||||
|
||||
private fun authedLogin(hostname: String, username: String, password: String) {
|
||||
val body = mapOf(
|
||||
"username" to username,
|
||||
|
@ -180,4 +191,16 @@ class LoginActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun limitContainerWidth() {
|
||||
container.doOnLayout {
|
||||
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && container.width >= 1440) {
|
||||
container.layoutParams.width = 1440
|
||||
} else {
|
||||
container.layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
|
||||
container.requestLayout()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,10 @@
|
|||
android:background="@color/colorPrimary">
|
||||
|
||||
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="32dp">
|
||||
|
|
Loading…
Reference in New Issue