Small refactor

pull/26/head
Koitharu 6 years ago
parent 23412e5c17
commit f9ccd0851d

@ -58,8 +58,8 @@ androidExtensions {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
implementation 'androidx.core:core-ktx:1.3.0-rc01' implementation 'androidx.core:core-ktx:1.3.0-rc01'
implementation 'androidx.fragment:fragment-ktx:1.2.4' implementation 'androidx.fragment:fragment-ktx:1.2.4'

@ -42,7 +42,8 @@ import org.koitharu.kotatsu.utils.ext.*
class ReaderActivity : BaseFullscreenActivity(), ReaderView, ChaptersDialog.OnChapterChangeListener, class ReaderActivity : BaseFullscreenActivity(), ReaderView, ChaptersDialog.OnChapterChangeListener,
GridTouchHelper.OnGridTouchListener, OnPageSelectListener, ReaderConfigDialog.Callback, GridTouchHelper.OnGridTouchListener, OnPageSelectListener, ReaderConfigDialog.Callback,
ReaderListener, SharedPreferences.OnSharedPreferenceChangeListener { ReaderListener, SharedPreferences.OnSharedPreferenceChangeListener,
View.OnApplyWindowInsetsListener {
private val presenter by moxyPresenter(factory = ::ReaderPresenter) private val presenter by moxyPresenter(factory = ::ReaderPresenter)
private val settings by inject<AppSettings>() private val settings by inject<AppSettings>()
@ -66,7 +67,7 @@ class ReaderActivity : BaseFullscreenActivity(), ReaderView, ChaptersDialog.OnCh
toolbar_bottom.setOnMenuItemClickListener(::onOptionsItemSelected) toolbar_bottom.setOnMenuItemClickListener(::onOptionsItemSelected)
state = savedInstanceState?.getParcelable(EXTRA_STATE) state = savedInstanceState?.getParcelable(EXTRA_STATE)
?: intent.getParcelableExtra<ReaderState>(EXTRA_STATE) ?: intent.getParcelableExtra(EXTRA_STATE)
?: let { ?: let {
Toast.makeText(this, R.string.error_occurred, Toast.LENGTH_SHORT).show() Toast.makeText(this, R.string.error_occurred, Toast.LENGTH_SHORT).show()
finish() finish()
@ -79,10 +80,7 @@ class ReaderActivity : BaseFullscreenActivity(), ReaderView, ChaptersDialog.OnCh
getString(R.string.chapter_d_of_d, state.chapter?.number ?: 0, size) getString(R.string.chapter_d_of_d, state.chapter?.number ?: 0, size)
} }
appbar_bottom.setOnApplyWindowInsetsListener { view, insets -> rootLayout.setOnApplyWindowInsetsListener(this)
view.updatePadding(bottom = insets.systemWindowInsetBottom)
insets
}
settings.subscribe(this) settings.subscribe(this)
loadSettings() loadSettings()
@ -356,6 +354,11 @@ class ReaderActivity : BaseFullscreenActivity(), ReaderView, ChaptersDialog.OnCh
} }
} }
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
appbar_top.updatePadding(top = insets.systemWindowInsetTop)
appbar_bottom.updatePadding(bottom = insets.systemWindowInsetBottom)
return insets.consumeSystemWindowInsets()
}
private fun loadSettings() { private fun loadSettings() {
settings.readerPageSwitch.let { settings.readerPageSwitch.let {

@ -27,7 +27,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/dim" android:background="@color/dim"
android:elevation="0dp" android:elevation="0dp"
android:fitsSystemWindows="true"
android:theme="@style/AppToolbarTheme" android:theme="@style/AppToolbarTheme"
app:elevation="0dp"> app:elevation="0dp">
@ -46,7 +45,6 @@
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="@color/dim" android:background="@color/dim"
android:elevation="0dp" android:elevation="0dp"
android:fitsSystemWindows="true"
android:theme="@style/AppToolbarTheme" android:theme="@style/AppToolbarTheme"
app:elevation="0dp"> app:elevation="0dp">

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="BaseAppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar"> <item name="windowActionModeOverlay">true</item>
<!-- Customize your theme here. --> </style>
<style name="AppTheme" parent="BaseAppTheme">
<item name="colorPrimary">@color/blue_primary</item> <item name="colorPrimary">@color/blue_primary</item>
<item name="colorPrimaryDark">@color/blue_primary_dark</item> <item name="colorPrimaryDark">@color/blue_primary_dark</item>
<item name="colorAccent">@color/red_accent</item> <item name="colorAccent">@color/red_accent</item>
<item name="windowActionModeOverlay">true</item>
</style> </style>
</resources> </resources>

@ -1,6 +1,6 @@
#Sun May 03 16:59:44 EEST 2020 #Sat May 09 10:22:49 EEST 2020
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-rc-4-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-all.zip

Loading…
Cancel
Save