mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Compare commits
4 Commits
e608c6ea62
...
a9acbd6cab
| Author | SHA1 | Date | |
|---|---|---|---|
| a9acbd6cab | |||
| e121f46b61 | |||
| d57de9d10c | |||
| e4348a2144 |
@@ -26,6 +26,7 @@ import org.isoron.uhabits.BuildConfig
|
|||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.core.models.PaletteColor
|
import org.isoron.uhabits.core.models.PaletteColor
|
||||||
import org.isoron.uhabits.databinding.AboutBinding
|
import org.isoron.uhabits.databinding.AboutBinding
|
||||||
|
import org.isoron.uhabits.utils.applyBottomInset
|
||||||
import org.isoron.uhabits.utils.applyRootViewInsets
|
import org.isoron.uhabits.utils.applyRootViewInsets
|
||||||
import org.isoron.uhabits.utils.currentTheme
|
import org.isoron.uhabits.utils.currentTheme
|
||||||
import org.isoron.uhabits.utils.setupToolbar
|
import org.isoron.uhabits.utils.setupToolbar
|
||||||
@@ -55,6 +56,7 @@ class AboutView(
|
|||||||
binding.tvTranslate.setOnClickListener { screen.showTranslationWebsite() }
|
binding.tvTranslate.setOnClickListener { screen.showTranslationWebsite() }
|
||||||
binding.tvVersion.setOnClickListener { screen.onPressDeveloperCountdown() }
|
binding.tvVersion.setOnClickListener { screen.onPressDeveloperCountdown() }
|
||||||
binding.tvVersion.text = String.format(version, BuildConfig.VERSION_NAME)
|
binding.tvVersion.text = String.format(version, BuildConfig.VERSION_NAME)
|
||||||
|
binding.outerLinearLayout.applyBottomInset()
|
||||||
applyRootViewInsets()
|
applyRootViewInsets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,14 @@
|
|||||||
package org.isoron.uhabits.activities.habits.list.views
|
package org.isoron.uhabits.activities.habits.list.views
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.Rect
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper.DOWN
|
import androidx.recyclerview.widget.ItemTouchHelper.DOWN
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper.END
|
import androidx.recyclerview.widget.ItemTouchHelper.END
|
||||||
@@ -57,6 +60,7 @@ class HabitCardListView(
|
|||||||
) : RecyclerView(context, null, R.attr.scrollableRecyclerViewStyle) {
|
) : RecyclerView(context, null, R.attr.scrollableRecyclerViewStyle) {
|
||||||
|
|
||||||
var checkmarkCount: Int = 0
|
var checkmarkCount: Int = 0
|
||||||
|
private var insetDecorationsAdded: Boolean = false
|
||||||
|
|
||||||
var dataOffset: Int = 0
|
var dataOffset: Int = 0
|
||||||
set(value) {
|
set(value) {
|
||||||
@@ -75,9 +79,32 @@ class HabitCardListView(
|
|||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
isLongClickable = true
|
isLongClickable = true
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
|
applyBottomInset()
|
||||||
super.setAdapter(adapter)
|
super.setAdapter(adapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun applyBottomInset() {
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(this) { _, insets ->
|
||||||
|
if (insetDecorationsAdded) return@setOnApplyWindowInsetsListener insets
|
||||||
|
insetDecorationsAdded = true
|
||||||
|
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
addItemDecoration(object : ItemDecoration() {
|
||||||
|
override fun getItemOffsets(
|
||||||
|
outRect: Rect,
|
||||||
|
view: View,
|
||||||
|
parent: RecyclerView,
|
||||||
|
state: State
|
||||||
|
) {
|
||||||
|
val itemCount = parent.adapter?.itemCount
|
||||||
|
if (parent.getChildAdapterPosition(view) == itemCount?.minus(1)) {
|
||||||
|
outRect.bottom = systemBarsInsets.bottom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun createHabitCardView(): HabitCardView {
|
fun createHabitCardView(): HabitCardView {
|
||||||
return cardViewFactory.create()
|
return cardViewFactory.create()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,17 +238,18 @@ class HabitCardView(
|
|||||||
|
|
||||||
private fun getAbsoluteButtonLocation(timestamp: Timestamp): PointF {
|
private fun getAbsoluteButtonLocation(timestamp: Timestamp): PointF {
|
||||||
val containerLocation = IntArray(2)
|
val containerLocation = IntArray(2)
|
||||||
this.getLocationOnScreen(containerLocation)
|
this.getLocationInWindow(containerLocation)
|
||||||
val relButtonLocation = getRelativeButtonLocation(timestamp)
|
val relButtonLocation = getRelativeButtonLocation(timestamp)
|
||||||
val windowInsets = rootWindowInsets
|
val windowInsets = rootWindowInsets
|
||||||
val statusBarHeight = if (SDK_INT <= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
val xInset = windowInsets?.displayCutout?.safeInsetLeft ?: 0
|
||||||
|
val yInset = if (SDK_INT <= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||||
windowInsets?.systemWindowInsetTop ?: 0
|
windowInsets?.systemWindowInsetTop ?: 0
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
return PointF(
|
return PointF(
|
||||||
containerLocation[0].toFloat() + relButtonLocation.x,
|
containerLocation[0].toFloat() + relButtonLocation.x - xInset,
|
||||||
containerLocation[1].toFloat() + relButtonLocation.y - statusBarHeight
|
containerLocation[1].toFloat() + relButtonLocation.y - yInset
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ 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.applyBottomInset
|
||||||
import org.isoron.uhabits.utils.applyToolbarInsets
|
import org.isoron.uhabits.utils.applyToolbarInsets
|
||||||
import org.isoron.uhabits.utils.setupToolbar
|
import org.isoron.uhabits.utils.setupToolbar
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ class ShowHabitView(context: Context) : FrameLayout(context) {
|
|||||||
} else {
|
} else {
|
||||||
binding.targetCard.visibility = GONE
|
binding.targetCard.visibility = GONE
|
||||||
}
|
}
|
||||||
|
binding.linearLayout.applyBottomInset()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setListener(presenter: ShowHabitPresenter) {
|
fun setListener(presenter: ShowHabitPresenter) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.isoron.uhabits.R
|
|||||||
import org.isoron.uhabits.activities.AndroidThemeSwitcher
|
import org.isoron.uhabits.activities.AndroidThemeSwitcher
|
||||||
import org.isoron.uhabits.core.models.PaletteColor
|
import org.isoron.uhabits.core.models.PaletteColor
|
||||||
import org.isoron.uhabits.databinding.SettingsActivityBinding
|
import org.isoron.uhabits.databinding.SettingsActivityBinding
|
||||||
|
import org.isoron.uhabits.utils.applyBottomInset
|
||||||
import org.isoron.uhabits.utils.applyRootViewInsets
|
import org.isoron.uhabits.utils.applyRootViewInsets
|
||||||
import org.isoron.uhabits.utils.setupToolbar
|
import org.isoron.uhabits.utils.setupToolbar
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ class SettingsActivity : AppCompatActivity() {
|
|||||||
theme = themeSwitcher.currentTheme
|
theme = themeSwitcher.currentTheme
|
||||||
)
|
)
|
||||||
binding.root.applyRootViewInsets()
|
binding.root.applyRootViewInsets()
|
||||||
|
binding.root.applyBottomInset()
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,6 +260,14 @@ fun View.applyRootViewInsets() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun View.applyBottomInset() {
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
|
||||||
|
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
view.setPadding(0, 0, 0, systemBarsInsets.bottom)
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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())
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
~ Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||||
~
|
~
|
||||||
~ This file is part of Loop Habit Tracker.
|
~ This file is part of Loop Habit Tracker.
|
||||||
@@ -37,6 +36,7 @@
|
|||||||
android:layout_below="@id/toolbar">
|
android:layout_below="@id/toolbar">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/outerLinearLayout"
|
||||||
style="@style/CardList">
|
style="@style/CardList">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -120,21 +120,66 @@
|
|||||||
linked at the bottom of the list. If you qualify, please feel free to
|
linked at the bottom of the list. If you qualify, please feel free to
|
||||||
submit a pull request adding yourself here.
|
submit a pull request adding yourself here.
|
||||||
-->
|
-->
|
||||||
<TextView style="@style/About.Item" android:text="Álinson S. Xavier (@iSoron)"/>
|
<TextView
|
||||||
<TextView style="@style/About.Item" android:text="Quentin Hibon (@hiqua)"/>
|
style="@style/About.Item"
|
||||||
<TextView style="@style/About.Item" android:text="Oleg Ivashchenko (@olegivo)"/>
|
android:text="Álinson S. Xavier (@iSoron)" />
|
||||||
<TextView style="@style/About.Item" android:text="Kristian Tashkov (@KristianTashkov)"/>
|
|
||||||
<TextView style="@style/About.Item" android:text="Jakub Kalinowski (@kalina559)"/>
|
<TextView
|
||||||
<TextView style="@style/About.Item" android:text="Rechee Jozil (@recheej)"/>
|
style="@style/About.Item"
|
||||||
<TextView style="@style/About.Item" android:text="Sebastian Gallese (@sgallese)"/>
|
android:text="Quentin Hibon (@hiqua)" />
|
||||||
<TextView style="@style/About.Item" android:text="Luboš Luňák (@llunak)"/>
|
|
||||||
<TextView style="@style/About.Item" android:text="Bindu (@vbh)"/>
|
<TextView
|
||||||
<TextView style="@style/About.Item" android:text="Victor Yu (@vyu1)"/>
|
style="@style/About.Item"
|
||||||
<TextView style="@style/About.Item" android:text="Christoph Hennemann (@chennemann)"/>
|
android:text="Oleg Ivashchenko (@olegivo)" />
|
||||||
<TextView style="@style/About.Item" android:text="Денис (@sciamano)"/>
|
|
||||||
<TextView style="@style/About.Item" android:text="Joseph Tran (@JotraN)"/>
|
<TextView
|
||||||
<TextView style="@style/About.Item" android:text="Nikhil (@regularcoder)"/>
|
style="@style/About.Item"
|
||||||
<TextView style="@style/About.Item" android:text="JanetQC"/>
|
android:text="Kristian Tashkov (@KristianTashkov)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Jakub Kalinowski (@kalina559)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Rechee Jozil (@recheej)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Sebastian Gallese (@sgallese)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Luboš Luňák (@llunak)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Bindu (@vbh)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Victor Yu (@vyu1)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Christoph Hennemann (@chennemann)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Денис (@sciamano)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Joseph Tran (@JotraN)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="Nikhil (@regularcoder)" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/About.Item"
|
||||||
|
android:text="JanetQC" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvContributors"
|
android:id="@+id/tvContributors"
|
||||||
style="@style/About.Item.Clickable"
|
style="@style/About.Item.Clickable"
|
||||||
|
|||||||
@@ -17,8 +17,7 @@
|
|||||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout android:id="@+id/container"
|
||||||
android:id="@+id/container"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -41,6 +40,7 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
style="@style/CardList"
|
style="@style/CardList"
|
||||||
|
android:id="@+id/linearLayout"
|
||||||
android:clipToPadding="false">
|
android:clipToPadding="false">
|
||||||
|
|
||||||
<org.isoron.uhabits.activities.habits.show.views.SubtitleCardView
|
<org.isoron.uhabits.activities.habits.show.views.SubtitleCardView
|
||||||
|
|||||||
Reference in New Issue
Block a user