Making sure the path activity renders well o n small screens (#1061)

* Making sure the path activity renders well o n small screens

* Tweaked the function

* Removed commented code
pull/1713/head
ThomasSession 1 month ago committed by GitHub
parent 8d8def5321
commit 6a7e0f7885
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -10,12 +10,14 @@ import android.util.AttributeSet
import android.util.TypedValue
import android.view.Gravity
import android.view.View
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import androidx.core.view.doOnLayout
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
@ -49,6 +51,7 @@ import org.thoughtcrime.securesms.util.fadeIn
import org.thoughtcrime.securesms.util.fadeOut
import org.thoughtcrime.securesms.util.getAccentColor
class PathActivity : ScreenLockActionBarActivity() {
private lateinit var binding: ActivityPathBinding
private val broadcastReceivers = mutableListOf<BroadcastReceiver>()
@ -82,6 +85,20 @@ class PathActivity : ScreenLockActionBarActivity() {
}
}
}
binding.pathScroll.doOnLayout {
val child: View = binding.pathScroll.getChildAt(0)
val isScrollable: Boolean = child.height > binding.pathScroll.height
val params = binding.pathRowsContainer.layoutParams as FrameLayout.LayoutParams
if(isScrollable){
params.gravity = Gravity.CENTER_HORIZONTAL
} else {
params.gravity = Gravity.CENTER
}
binding.pathRowsContainer.layoutParams = params
}
}
private fun registerObservers() {

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerY="0.75"
android:centerColor="#00000000"
android:endColor="?colorPrimary"
android:angle="270" />
</shape>

@ -27,12 +27,27 @@
android:layout_margin="@dimen/large_spacing"
android:clipChildren="false">
<LinearLayout
android:id="@+id/pathRowsContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true" />
<ScrollView
android:id="@+id/pathScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:paddingBottom="@dimen/large_spacing">
<LinearLayout
android:id="@+id/pathRowsContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical" />
</ScrollView>
<View
android:id="@+id/gradientView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/fade_gradient" />
<ProgressBar
android:id="@+id/spinner"

Loading…
Cancel
Save