Fixed dimensions and padding throughout the homescreen

This commit is contained in:
Viktor De Pasquale 2019-10-05 12:53:40 +02:00
parent 823b121cc7
commit 1d64ddb7f5
5 changed files with 49 additions and 14 deletions

View File

@ -1,6 +1,7 @@
package com.topjohnwu.magisk.utils package com.topjohnwu.magisk.utils
import android.view.View import android.view.View
import android.view.ViewGroup
import android.widget.TextSwitcher import android.widget.TextSwitcher
import android.widget.TextView import android.widget.TextView
import android.widget.ViewSwitcher import android.widget.ViewSwitcher
@ -9,6 +10,7 @@ import androidx.annotation.DrawableRes
import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.view.postDelayed import androidx.core.view.postDelayed
import androidx.core.view.updateLayoutParams
import androidx.databinding.BindingAdapter import androidx.databinding.BindingAdapter
import androidx.databinding.InverseBindingAdapter import androidx.databinding.InverseBindingAdapter
import androidx.databinding.InverseBindingListener import androidx.databinding.InverseBindingListener
@ -265,4 +267,28 @@ fun TextSwitcher.setTextBinding(text: CharSequence) {
if (currentText != text) { if (currentText != text) {
setText(text) setText(text)
} }
}
@BindingAdapter(
"android:layout_marginLeft",
"android:layout_marginTop",
"android:layout_marginRight",
"android:layout_marginBottom",
requireAll = false
)
fun View.setMargins(
marginLeft: Int?,
marginTop: Int?,
marginRight: Int?,
marginBottom: Int?
) = updateLayoutParams<ViewGroup.MarginLayoutParams> {
marginLeft?.let { leftMargin = it }
marginTop?.let { topMargin = it }
marginRight?.let { rightMargin = it }
marginBottom?.let { bottomMargin = it }
}
@BindingAdapter("nestedScrollingEnabled")
fun RecyclerView.setNestedScrolling(enabled: Boolean) {
isNestedScrollingEnabled = enabled
} }

View File

@ -81,6 +81,7 @@
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@{viewModel.insets.bottom + (int) @dimen/l1}"
app:fabSize="normal" app:fabSize="normal"
app:layout_anchor="@+id/main_bottom_bar" app:layout_anchor="@+id/main_bottom_bar"
app:srcCompat="@drawable/ic_superuser_md2" /> app:srcCompat="@drawable/ic_superuser_md2" />

View File

@ -17,7 +17,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"
android:padding="@dimen/l1" android:paddingStart="@dimen/l1"
android:paddingTop="@dimen/l1"
android:paddingEnd="@dimen/l1"
android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/margin_fab}"
tools:layout_marginTop="24dp"> tools:layout_marginTop="24dp">
<LinearLayout <LinearLayout
@ -255,11 +258,12 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
itemBinding="@{viewModel.itemBinding}" itemBinding="@{viewModel.itemBinding}"
items="@{viewModel.itemsMainline}"
nestedScrollingEnabled="@{false}"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clipToPadding="false" android:clipToPadding="false"
android:fadingEdgeLength="@dimen/l1" android:fadingEdgeLength="@dimen/l1"
items="@{viewModel.itemsMainline}"
android:layout_width="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="@dimen/l1" android:paddingTop="@dimen/l1"
android:requiresFadingEdge="horizontal" android:requiresFadingEdge="horizontal"
@ -291,11 +295,11 @@
style="?styleCardNormal" style="?styleCardNormal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="1"
android:layout_marginEnd="@dimen/l1" android:layout_marginEnd="@dimen/l1"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/support_icon_dia" app:layout_constraintEnd_toStartOf="@+id/support_icon_dia"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
@ -309,17 +313,18 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end" android:layout_gravity="end"
android:text="\@diareuse"
android:textAppearance="?appearanceTextCaptionNormal" android:textAppearance="?appearanceTextCaptionNormal"
android:textStyle="bold" android:textStyle="bold"
android:text="\@diareuse"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
itemBinding="@{viewModel.itemBinding}" itemBinding="@{viewModel.itemBinding}"
items="@{viewModel.itemsApp}"
nestedScrollingEnabled="@{false}"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clipToPadding="false" android:clipToPadding="false"
items="@{viewModel.itemsApp}"
android:layout_width="wrap_content"
android:fadingEdgeLength="@dimen/l1" android:fadingEdgeLength="@dimen/l1"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="@dimen/l1" android:paddingTop="@dimen/l1"
@ -361,9 +366,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1" android:layout_marginStart="@dimen/l1"
app:layout_constrainedWidth="true" app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/support_icon_common" app:layout_constraintStart_toEndOf="@+id/support_icon_common"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
@ -377,17 +382,18 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="sans-serif-black" android:fontFamily="sans-serif-black"
android:text="@string/home_links_project"
android:textAppearance="?appearanceTextCaptionNormal" android:textAppearance="?appearanceTextCaptionNormal"
android:textStyle="bold" android:textStyle="bold" />
android:text="@string/home_links_project" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
itemBinding="@{viewModel.itemBinding}" itemBinding="@{viewModel.itemBinding}"
items="@{viewModel.itemsProject}"
nestedScrollingEnabled="@{false}"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clipToPadding="false" android:clipToPadding="false"
android:fadingEdgeLength="@dimen/l1" android:fadingEdgeLength="@dimen/l1"
items="@{viewModel.itemsProject}"
android:layout_width="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="@dimen/l1" android:paddingTop="@dimen/l1"
android:requiresFadingEdge="horizontal" android:requiresFadingEdge="horizontal"

View File

@ -46,7 +46,6 @@
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
style="?styleImageSmall" style="?styleImageSmall"
android:layout_marginStart="@dimen/l_50"
android:layout_height="14sp" android:layout_height="14sp"
app:layout_constraintBottom_toBottomOf="@+id/developer_link_name" app:layout_constraintBottom_toBottomOf="@+id/developer_link_name"
app:layout_constraintStart_toEndOf="@+id/developer_link_name" app:layout_constraintStart_toEndOf="@+id/developer_link_name"

View File

@ -16,4 +16,7 @@
<dimen name="l2">32dp</dimen> <dimen name="l2">32dp</dimen>
<dimen name="r1">8dp</dimen> <dimen name="r1">8dp</dimen>
<!--l1 + fab size-->
<dimen name="margin_fab">80dp</dimen>
</resources> </resources>