Android 29 SDK + edge to edge

This commit is contained in:
Jay 2019-10-25 01:44:47 -07:00
parent c9fbe98bc4
commit b9e3e3de55
17 changed files with 147 additions and 19 deletions

View File

@ -29,14 +29,14 @@ ext {
} }
android { android {
compileSdkVersion 28 compileSdkVersion 29
buildToolsVersion '29.0.2' buildToolsVersion '29.0.2'
publishNonDefault true publishNonDefault true
defaultConfig { defaultConfig {
applicationId "eu.kanade.tachiyomi" applicationId "eu.kanade.tachiyomi"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 28 targetSdkVersion 29
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 41 versionCode 41
versionName "0.8.4" versionName "0.8.4"

View File

@ -10,6 +10,8 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application <application
android:name=".App" android:name=".App"

View File

@ -22,6 +22,8 @@ import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.SecondaryDrawerController import eu.kanade.tachiyomi.ui.base.controller.SecondaryDrawerController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.manga.info.MangaWebViewController import eu.kanade.tachiyomi.ui.manga.info.MangaWebViewController
import eu.kanade.tachiyomi.util.* import eu.kanade.tachiyomi.util.*
@ -152,6 +154,13 @@ open class BrowseCatalogueController(bundle: Bundle) :
presenter.sourceFilters = newFilters presenter.sourceFilters = newFilters
navView.setFilters(presenter.filterItems) navView.setFilters(presenter.filterItems)
} }
navView.doOnApplyWindowInsets { v, insets, padding ->
v.updatePaddingRelative(
bottom = padding.bottom + insets.systemWindowInsetBottom,
top = padding.top + insets.systemWindowInsetTop
)
}
return navView return navView
} }

View File

@ -13,6 +13,8 @@ import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.data.library.LibraryUpdateService
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
import eu.kanade.tachiyomi.util.inflate import eu.kanade.tachiyomi.util.inflate
import eu.kanade.tachiyomi.util.plusAssign import eu.kanade.tachiyomi.util.plusAssign
import eu.kanade.tachiyomi.util.toast import eu.kanade.tachiyomi.util.toast
@ -87,6 +89,9 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
swipe_refresh.isEnabled = firstPos <= 0 swipe_refresh.isEnabled = firstPos <= 0
} }
}) })
recycler.doOnApplyWindowInsets { v, insets, padding ->
v.updatePaddingRelative(bottom = padding.bottom + insets.systemWindowInsetBottom)
}
// Double the distance required to trigger sync // Double the distance required to trigger sync
swipe_refresh.setDistanceToTriggerSync((2 * 64 * resources.displayMetrics.density).toInt()) swipe_refresh.setDistanceToTriggerSync((2 * 64 * resources.displayMetrics.density).toInt())

View File

@ -31,10 +31,14 @@ import eu.kanade.tachiyomi.ui.base.controller.TabbedController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.category.CategoryController import eu.kanade.tachiyomi.ui.category.CategoryController
import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
import eu.kanade.tachiyomi.ui.main.updateLayoutParams
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.migration.MigrationController import eu.kanade.tachiyomi.ui.migration.MigrationController
import eu.kanade.tachiyomi.util.inflate import eu.kanade.tachiyomi.util.inflate
import eu.kanade.tachiyomi.util.toast import eu.kanade.tachiyomi.util.toast
import kotlinx.android.synthetic.main.chapters_controller.*
import kotlinx.android.synthetic.main.library_controller.* import kotlinx.android.synthetic.main.library_controller.*
import kotlinx.android.synthetic.main.main_activity.* import kotlinx.android.synthetic.main.main_activity.*
import rx.Subscription import rx.Subscription
@ -187,7 +191,12 @@ class LibraryController(
is LibraryNavigationView.BadgeGroup -> onDownloadBadgeChanged() is LibraryNavigationView.BadgeGroup -> onDownloadBadgeChanged()
} }
} }
view.doOnApplyWindowInsets { v, insets, padding ->
v.updatePaddingRelative(
bottom = padding.bottom + insets.systemWindowInsetBottom,
top = padding.top + insets.systemWindowInsetTop
)
}
return view return view
} }

View File

@ -6,7 +6,11 @@ import android.content.Intent
import android.content.res.Configuration import android.content.res.Configuration
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.support.annotation.Px
import android.support.annotation.RequiresApi
import android.support.v4.view.GravityCompat import android.support.v4.view.GravityCompat
import android.support.v4.view.ViewCompat
import android.support.v4.view.WindowInsetsCompat
import android.support.v4.widget.DrawerLayout import android.support.v4.widget.DrawerLayout
import android.support.v7.app.AppCompatDelegate import android.support.v7.app.AppCompatDelegate
import android.support.v7.app.AppCompatDelegate.* import android.support.v7.app.AppCompatDelegate.*
@ -307,7 +311,8 @@ class MainActivity : BaseActivity() {
object NoopWindowInsetsListener : View.OnApplyWindowInsetsListener { object NoopWindowInsetsListener : View.OnApplyWindowInsetsListener {
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets { override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
v.setPadding(0,insets.systemWindowInsetTop,0,0) v.setPadding(insets.systemWindowInsetLeft,insets.systemWindowInsetTop,insets.systemWindowInsetRight,0)
//insets.consumeSystemWindowInsets()
return insets return insets
} }
} }
@ -315,6 +320,71 @@ object NoopWindowInsetsListener : View.OnApplyWindowInsetsListener {
object NoopWindowInsetsListener2 : View.OnApplyWindowInsetsListener { object NoopWindowInsetsListener2 : View.OnApplyWindowInsetsListener {
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets { override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
v.setPadding(0,0,0,insets.systemWindowInsetBottom) v.setPadding(0,0,0,insets.systemWindowInsetBottom)
insets.consumeSystemWindowInsets()
return insets return insets
} }
}
fun View.doOnApplyWindowInsets(f: (View, WindowInsetsCompat, ViewPaddingState) -> Unit) {
// Create a snapshot of the view's padding state
val paddingState = createStateForView(this)
ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets ->
f(v, insets, paddingState)
insets
}
requestApplyInsetsWhenAttached()
}
fun View.requestApplyInsetsWhenAttached() {
if (isAttachedToWindow) {
requestApplyInsets()
} else {
addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
override fun onViewAttachedToWindow(v: View) {
v.requestApplyInsets()
}
override fun onViewDetachedFromWindow(v: View) = Unit
})
}
}
inline fun <reified T : ViewGroup.LayoutParams> View.updateLayoutParams(block: T.() -> Unit) {
val params = layoutParams as T
block(params)
layoutParams = params
}
inline val View.marginBottom: Int
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.bottomMargin ?: 0
inline fun View.updatePadding(
@Px left: Int = paddingLeft,
@Px top: Int = paddingTop,
@Px right: Int = paddingRight,
@Px bottom: Int = paddingBottom
) {
setPadding(left, top, right, bottom)
}
private fun createStateForView(view: View) = ViewPaddingState(view.paddingLeft,
view.paddingTop, view.paddingRight, view.paddingBottom, view.paddingStart, view.paddingEnd)
data class ViewPaddingState(
val left: Int,
val top: Int,
val right: Int,
val bottom: Int,
val start: Int,
val end: Int
)
@RequiresApi(17)
inline fun View.updatePaddingRelative(
@Px start: Int = paddingStart,
@Px top: Int = paddingTop,
@Px end: Int = paddingEnd,
@Px bottom: Int = paddingBottom
) {
setPaddingRelative(start, top, end, bottom)
} }

View File

@ -21,6 +21,12 @@ import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
import eu.kanade.tachiyomi.ui.main.NoopWindowInsetsListener2
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
import eu.kanade.tachiyomi.ui.main.marginBottom
import eu.kanade.tachiyomi.ui.main.updateLayoutParams
import eu.kanade.tachiyomi.ui.main.updatePadding
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.util.getCoordinates import eu.kanade.tachiyomi.util.getCoordinates
@ -82,6 +88,17 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
recycler.setHasFixedSize(true) recycler.setHasFixedSize(true)
adapter?.fastScroller = fast_scroller adapter?.fastScroller = fast_scroller
val fabBaseMarginBottom = fab?.marginBottom ?: 0
recycler.doOnApplyWindowInsets { v, insets, padding ->
v.updatePaddingRelative(bottom = padding.bottom + insets.systemWindowInsetBottom)
fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
}
fast_scroller?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = insets.systemWindowInsetBottom
}
}
//fast_scroller.setOnApplyWindowInsetsListener(NoopWindowInsetsListener2)
swipe_refresh.refreshes().subscribeUntilDestroy { fetchChaptersFromSource() } swipe_refresh.refreshes().subscribeUntilDestroy { fetchChaptersFromSource() }
fab.clicks().subscribeUntilDestroy { fab.clicks().subscribeUntilDestroy {

View File

@ -40,6 +40,8 @@ import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.main.doOnApplyWindowInsets
import eu.kanade.tachiyomi.ui.main.updatePaddingRelative
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.util.getResourceColor import eu.kanade.tachiyomi.util.getResourceColor
import eu.kanade.tachiyomi.util.openInBrowser import eu.kanade.tachiyomi.util.openInBrowser
@ -128,6 +130,11 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
copyToClipboard(view.context.getString(R.string.title), presenter.manga.title) copyToClipboard(view.context.getString(R.string.title), presenter.manga.title)
} }
view.doOnApplyWindowInsets { v, insets, padding ->
v.updatePaddingRelative(
bottom = padding.bottom + insets.systemWindowInsetBottom
)
}
} }
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {

View File

@ -24,12 +24,14 @@ class PageIndicatorTextView(
private val strokeColor = Color.rgb(45, 45, 45) private val strokeColor = Color.rgb(45, 45, 45)
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
textColorField.set(this, strokeColor) setTextColor(strokeColor)
//textColorField.set(this, strokeColor)
paint.strokeWidth = 4f paint.strokeWidth = 4f
paint.style = Paint.Style.STROKE paint.style = Paint.Style.STROKE
super.onDraw(canvas) super.onDraw(canvas)
textColorField.set(this, fillColor) setTextColor(fillColor)
//textColorField.set(this, fillColor)
paint.strokeWidth = 0f paint.strokeWidth = 0f
paint.style = Paint.Style.FILL paint.style = Paint.Style.FILL
super.onDraw(canvas) super.onDraw(canvas)
@ -54,8 +56,8 @@ class PageIndicatorTextView(
private companion object { private companion object {
// We need to use reflection to set the text color instead of using [setTextColor], // We need to use reflection to set the text color instead of using [setTextColor],
// otherwise the view is invalidated inside [onDraw] and there's an infinite loop // otherwise the view is invalidated inside [onDraw] and there's an infinite loop
val textColorField = TextView::class.java.getDeclaredField("mCurTextColor").apply { /* val textColorField = TextView::class.java.getDeclaredField("mCurTextColor").apply {
isAccessible = true isAccessible = true
}!! }!!*/
} }
} }

View File

@ -61,7 +61,18 @@ class SettingsGeneralController : SettingsController() {
defaultValue = "5" defaultValue = "5"
summary = "%s" summary = "%s"
onChange { onChange {newValue ->
val activity = activity ?: return@onChange false
val app = activity.application
AppCompatDelegate.setDefaultNightMode(when (newValue) {
"1" -> AppCompatDelegate.MODE_NIGHT_NO
"2", "3", "4" -> AppCompatDelegate.MODE_NIGHT_YES
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
})
//LocaleHelper.changeLocale(newValue.toString())
//LocaleHelper.updateConfiguration(app, app.resources.configuration)
//activity?.recreate()
activity?.recreate() activity?.recreate()
true true
} }

View File

@ -5,5 +5,5 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="end" android:layout_gravity="end"
android:fitsSystemWindows="false"/> android:fitsSystemWindows="true"/>

View File

@ -28,6 +28,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:clipToPadding="false"
android:descendantFocusability="blocksDescendants" android:descendantFocusability="blocksDescendants"
tools:listitem="@layout/chapters_item"> tools:listitem="@layout/chapters_item">

View File

@ -5,4 +5,4 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="end" android:layout_gravity="end"
android:fitsSystemWindows="false" /> android:fitsSystemWindows="true" />

View File

@ -47,7 +47,7 @@
<!--==============--> <!--==============-->
<!-- Amoled Theme --> <!-- Amoled Theme -->
<!--==============--> <!--==============-->
<style name="Theme.Base.Amoled" parent="Theme.Base"> <style name="Theme.Tachiyomi.Amoled" parent="Theme.Base">
<item name="colorPrimary">@color/colorAmoledPrimary</item> <item name="colorPrimary">@color/colorAmoledPrimary</item>
<item name="colorPrimaryDark">@color/colorAmoledPrimary</item> <item name="colorPrimaryDark">@color/colorAmoledPrimary</item>
<item name="android:colorBackground">@color/md_black_1000</item> <item name="android:colorBackground">@color/md_black_1000</item>

View File

@ -25,7 +25,6 @@
<!--==============--> <!--==============-->
<style name="Theme.Tachiyomi.Amoled" parent="Theme.Base"> <style name="Theme.Tachiyomi.Amoled" parent="Theme.Base">
<!-- Attributes specific for SDK 21 and up --> <!-- Attributes specific for SDK 21 and up -->
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item> <item name="android:navigationBarColor">@android:color/transparent</item>
</style> </style>

View File

@ -8,9 +8,6 @@
</style> </style>
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base"> <style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<!-- Attributes specific for SDK 21 and up --> <!-- Attributes specific for SDK 21 and up -->
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item> <item name="android:navigationBarColor">@android:color/transparent</item>
@ -21,7 +18,6 @@
<!--==============--> <!--==============-->
<style name="Theme.Tachiyomi.Amoled" parent="Theme.Base"> <style name="Theme.Tachiyomi.Amoled" parent="Theme.Base">
<!-- Attributes specific for SDK 21 and up --> <!-- Attributes specific for SDK 21 and up -->
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item> <item name="android:navigationBarColor">@android:color/transparent</item>
</style> </style>

View File

@ -2,10 +2,10 @@
<resources> <resources>
<!-- Application Colors --> <!-- Application Colors -->
<color name="colorPrimary">#54759E</color> <color name="colorPrimary">#54759E</color>
<color name="colorPrimaryDark">#435E7E</color> <color name="colorPrimaryDark">#54759E</color>
<!-- Dark Application Colors --> <!-- Dark Application Colors -->
<color name="colorDarkPrimary">#212121</color> <color name="colorDarkPrimary">#212121</color>
<color name="colorDarkPrimaryDark">#1C1C1D</color> <color name="colorDarkPrimaryDark">#212121</color>
<color name="colorAmoledPrimary">@color/md_black_1000</color> <color name="colorAmoledPrimary">@color/md_black_1000</color>
<!-- Light Theme --> <!-- Light Theme -->