mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-08 10:08:51 -06:00
Multiple fixes to edge-to-edge display (API 35)
This commit is contained in:
@@ -25,12 +25,14 @@ import android.widget.FrameLayout
|
|||||||
import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitPresenter
|
import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitPresenter
|
||||||
import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitState
|
import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitState
|
||||||
import org.isoron.uhabits.databinding.ShowHabitBinding
|
import org.isoron.uhabits.databinding.ShowHabitBinding
|
||||||
|
import org.isoron.uhabits.utils.applyToolbarInsets
|
||||||
import org.isoron.uhabits.utils.setupToolbar
|
import org.isoron.uhabits.utils.setupToolbar
|
||||||
|
|
||||||
class ShowHabitView(context: Context) : FrameLayout(context) {
|
class ShowHabitView(context: Context) : FrameLayout(context) {
|
||||||
private val binding = ShowHabitBinding.inflate(LayoutInflater.from(context))
|
private val binding = ShowHabitBinding.inflate(LayoutInflater.from(context))
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
binding.toolbar.applyToolbarInsets()
|
||||||
addView(binding.root)
|
addView(binding.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -251,7 +251,11 @@ fun View.getCenter(): PointF {
|
|||||||
fun View.applyRootViewInsets() {
|
fun View.applyRootViewInsets() {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
||||||
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
view.setPadding(systemBarsInsets.left, 0, systemBarsInsets.right, systemBarsInsets.bottom)
|
val displayCutoutInsets = insets.getInsets(WindowInsetsCompat.Type.displayCutout())
|
||||||
|
val left = maxOf(systemBarsInsets.left, displayCutoutInsets.left)
|
||||||
|
val right = maxOf(systemBarsInsets.right, displayCutoutInsets.right)
|
||||||
|
view.setPadding(left, 0, right, 0)
|
||||||
|
view.background = ColorDrawable(Color.BLACK)
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +263,9 @@ fun View.applyRootViewInsets() {
|
|||||||
fun View.applyToolbarInsets() {
|
fun View.applyToolbarInsets() {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
||||||
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
view.setPadding(0, systemBarsInsets.top, 0, 0)
|
val displayCutoutInsets = insets.getInsets(WindowInsetsCompat.Type.displayCutout())
|
||||||
|
val top = maxOf(systemBarsInsets.top, displayCutoutInsets.top)
|
||||||
|
view.setPadding(0, top, 0, 0)
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -61,8 +62,10 @@
|
|||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
android:layout_weight="1"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
android:background="?attr/contrast0">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -265,4 +268,4 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -58,7 +58,10 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/formPanel"
|
android:id="@+id/formPanel"
|
||||||
style="@style/dialogFormPanel">
|
style="@style/dialogFormPanel"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?attr/contrast0">
|
||||||
|
|
||||||
<FrameLayout style="@style/FormOuterBox">
|
<FrameLayout style="@style/FormOuterBox">
|
||||||
<LinearLayout style="@style/FormInnerBox">
|
<LinearLayout style="@style/FormInnerBox">
|
||||||
|
|||||||
Reference in New Issue
Block a user