Add some animations
This commit is contained in:
1
.idea/codeStyles/Project.xml
generated
1
.idea/codeStyles/Project.xml
generated
@@ -23,7 +23,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</AndroidXmlCodeStyleSettings>
|
</AndroidXmlCodeStyleSettings>
|
||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
<option name="ALLOW_TRAILING_COMMA" value="true" />
|
|
||||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
</JetCodeStyleSettings>
|
</JetCodeStyleSettings>
|
||||||
<codeStyleSettings language="CMake">
|
<codeStyleSettings language="CMake">
|
||||||
|
|||||||
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="TrailingComma" enabled="true" level="INFORMATION" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
@@ -61,16 +61,16 @@ dependencies {
|
|||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
|
||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.3.0-beta01'
|
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'
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
|
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-beta01'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-rc01'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha02'
|
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha02'
|
||||||
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
|
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
|
||||||
implementation 'androidx.preference:preference:1.1.0'
|
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||||
implementation 'androidx.work:work-runtime-ktx:2.3.4'
|
implementation 'androidx.work:work-runtime-ktx:2.3.4'
|
||||||
implementation 'com.google.android.material:material:1.2.0-alpha05'
|
implementation 'com.google.android.material:material:1.2.0-alpha06'
|
||||||
|
|
||||||
implementation 'androidx.room:room-runtime:2.2.5'
|
implementation 'androidx.room:room-runtime:2.2.5'
|
||||||
implementation 'androidx.room:room-ktx:2.2.5'
|
implementation 'androidx.room:room-ktx:2.2.5'
|
||||||
@@ -86,7 +86,7 @@ dependencies {
|
|||||||
implementation 'com.squareup.okio:okio:2.5.0'
|
implementation 'com.squareup.okio:okio:2.5.0'
|
||||||
implementation 'org.jsoup:jsoup:1.13.1'
|
implementation 'org.jsoup:jsoup:1.13.1'
|
||||||
|
|
||||||
implementation 'org.koin:koin-android:2.1.4'
|
implementation 'org.koin:koin-android:2.1.5'
|
||||||
implementation 'io.coil-kt:coil:0.9.5'
|
implementation 'io.coil-kt:coil:0.9.5'
|
||||||
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
|
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
|
||||||
implementation 'com.tomclaw.cache:cache:1.0'
|
implementation 'com.tomclaw.cache:cache:1.0'
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ class AppSettings private constructor(resources: Resources, private val prefs: S
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val readerAnimation by BoolPreferenceDelegate(
|
||||||
|
resources.getString(R.string.key_reader_animation),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
private var sourcesOrderStr by NullableStringPreferenceDelegate(resources.getString(R.string.key_sources_order))
|
private var sourcesOrderStr by NullableStringPreferenceDelegate(resources.getString(R.string.key_sources_order))
|
||||||
|
|
||||||
var sourcesOrder: List<Int>
|
var sourcesOrder: List<Int>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.koitharu.kotatsu.ui.details
|
package org.koitharu.kotatsu.ui.details
|
||||||
|
|
||||||
|
import android.app.ActivityOptions
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
@@ -68,12 +69,19 @@ class ChaptersFragment : BaseFragment(R.layout.fragment_chapters), MangaDetailsV
|
|||||||
override fun onFavouriteChanged(categories: List<FavouriteCategory>) = Unit
|
override fun onFavouriteChanged(categories: List<FavouriteCategory>) = Unit
|
||||||
|
|
||||||
override fun onItemClick(item: MangaChapter, position: Int, view: View) {
|
override fun onItemClick(item: MangaChapter, position: Int, view: View) {
|
||||||
|
val options = ActivityOptions.makeScaleUpAnimation(
|
||||||
|
view,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
view.measuredWidth,
|
||||||
|
view.measuredHeight
|
||||||
|
)
|
||||||
startActivity(
|
startActivity(
|
||||||
ReaderActivity.newIntent(
|
ReaderActivity.newIntent(
|
||||||
context ?: return,
|
context ?: return,
|
||||||
manga ?: return,
|
manga ?: return,
|
||||||
item.id
|
item.id
|
||||||
)
|
), options.toBundle()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package org.koitharu.kotatsu.ui.main
|
package org.koitharu.kotatsu.ui.main
|
||||||
|
|
||||||
|
import android.app.ActivityOptions
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
@@ -45,7 +47,6 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
|
||||||
drawerToggle =
|
drawerToggle =
|
||||||
ActionBarDrawerToggle(this, drawer, toolbar, R.string.open_menu, R.string.close_menu)
|
ActionBarDrawerToggle(this, drawer, toolbar, R.string.open_menu, R.string.close_menu)
|
||||||
drawer.addDrawerListener(drawerToggle)
|
drawer.addDrawerListener(drawerToggle)
|
||||||
@@ -119,7 +120,16 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onOpenReader(state: ReaderState) {
|
override fun onOpenReader(state: ReaderState) {
|
||||||
startActivity(ReaderActivity.newIntent(this, state))
|
val options = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
ActivityOptions.makeClipRevealAnimation(
|
||||||
|
fab, 0, 0, fab.measuredWidth, fab.measuredHeight
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ActivityOptions.makeScaleUpAnimation(
|
||||||
|
fab, 0, 0, fab.measuredWidth, fab.measuredHeight
|
||||||
|
)
|
||||||
|
}
|
||||||
|
startActivity(ReaderActivity.newIntent(this, state), options?.toBundle())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ abstract class MangaListFragment<E> : BaseFragment(R.layout.fragment_list), Mang
|
|||||||
ListMode.GRID -> GridLayoutManager(ctx, UiUtils.resolveGridSpanCount(ctx))
|
ListMode.GRID -> GridLayoutManager(ctx, UiUtils.resolveGridSpanCount(ctx))
|
||||||
else -> LinearLayoutManager(ctx)
|
else -> LinearLayoutManager(ctx)
|
||||||
}
|
}
|
||||||
|
recyclerView.recycledViewPool.clear()
|
||||||
recyclerView.adapter = adapter
|
recyclerView.adapter = adapter
|
||||||
recyclerView.addItemDecoration(
|
recyclerView.addItemDecoration(
|
||||||
when (mode) {
|
when (mode) {
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package org.koitharu.kotatsu.ui.reader.standard
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
|
|
||||||
|
class PageAnimTransformer : ViewPager2.PageTransformer {
|
||||||
|
|
||||||
|
override fun transformPage(page: View, position: Float) {
|
||||||
|
page.apply {
|
||||||
|
val pageWidth = width
|
||||||
|
when {
|
||||||
|
position < -1 -> alpha = 0f
|
||||||
|
position <= 0 -> { // [-1,0]
|
||||||
|
alpha = 1f
|
||||||
|
translationX = 0f
|
||||||
|
translationZ = 0f
|
||||||
|
scaleX = 1 + FACTOR * position
|
||||||
|
scaleY = 1f
|
||||||
|
}
|
||||||
|
position <= 1 -> { // (0,1]
|
||||||
|
alpha = 1f
|
||||||
|
translationX = pageWidth * -position
|
||||||
|
translationZ = -1f
|
||||||
|
scaleX = 1f
|
||||||
|
scaleY = 1f
|
||||||
|
}
|
||||||
|
else -> alpha = 0f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
|
||||||
|
const val FACTOR = 0.1f
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
package org.koitharu.kotatsu.ui.reader.standard
|
package org.koitharu.kotatsu.ui.reader.standard
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import kotlinx.android.synthetic.main.fragment_reader_standard.*
|
import kotlinx.android.synthetic.main.fragment_reader_standard.*
|
||||||
|
import org.koin.android.ext.android.inject
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.model.MangaPage
|
import org.koitharu.kotatsu.core.model.MangaPage
|
||||||
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.ui.reader.ReaderState
|
import org.koitharu.kotatsu.ui.reader.ReaderState
|
||||||
import org.koitharu.kotatsu.ui.reader.base.AbstractReader
|
import org.koitharu.kotatsu.ui.reader.base.AbstractReader
|
||||||
import org.koitharu.kotatsu.ui.reader.base.BaseReaderAdapter
|
import org.koitharu.kotatsu.ui.reader.base.BaseReaderAdapter
|
||||||
@@ -12,19 +16,34 @@ import org.koitharu.kotatsu.ui.reader.base.GroupedList
|
|||||||
import org.koitharu.kotatsu.utils.ext.doOnPageChanged
|
import org.koitharu.kotatsu.utils.ext.doOnPageChanged
|
||||||
import org.koitharu.kotatsu.utils.ext.withArgs
|
import org.koitharu.kotatsu.utils.ext.withArgs
|
||||||
|
|
||||||
class PagerReaderFragment : AbstractReader(R.layout.fragment_reader_standard) {
|
class PagerReaderFragment : AbstractReader(R.layout.fragment_reader_standard),
|
||||||
|
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private var paginationListener: PagerPaginationListener? = null
|
private var paginationListener: PagerPaginationListener? = null
|
||||||
|
private val settings by inject<AppSettings>()
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
paginationListener = PagerPaginationListener(adapter!!, 2, this)
|
paginationListener = PagerPaginationListener(adapter!!, 2, this)
|
||||||
pager.adapter = adapter
|
pager.adapter = adapter
|
||||||
|
if (settings.readerAnimation) {
|
||||||
|
pager.setPageTransformer(PageAnimTransformer())
|
||||||
|
}
|
||||||
pager.offscreenPageLimit = 2
|
pager.offscreenPageLimit = 2
|
||||||
pager.registerOnPageChangeCallback(paginationListener!!)
|
pager.registerOnPageChangeCallback(paginationListener!!)
|
||||||
pager.doOnPageChanged(::notifyPageChanged)
|
pager.doOnPageChanged(::notifyPageChanged)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
super.onAttach(context)
|
||||||
|
settings.subscribe(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetach() {
|
||||||
|
settings.unsubscribe(this)
|
||||||
|
super.onDetach()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
paginationListener = null
|
paginationListener = null
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
@@ -47,6 +66,18 @@ class PagerReaderFragment : AbstractReader(R.layout.fragment_reader_standard) {
|
|||||||
|
|
||||||
override fun restorePageScroll(position: Int, scroll: Float) = Unit
|
override fun restorePageScroll(position: Int, scroll: Float) = Unit
|
||||||
|
|
||||||
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
|
when (key) {
|
||||||
|
getString(R.string.key_reader_animation) -> {
|
||||||
|
if (settings.readerAnimation) {
|
||||||
|
pager.setPageTransformer(PageAnimTransformer())
|
||||||
|
} else {
|
||||||
|
pager.setPageTransformer(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun newInstance(state: ReaderState) = PagerReaderFragment().withArgs(1) {
|
fun newInstance(state: ReaderState) = PagerReaderFragment().withArgs(1) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
|
android:overScrollMode="never"
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
tools:listitem="@layout/item_category_checkable" />
|
tools:listitem="@layout/item_category_checkable" />
|
||||||
|
|
||||||
|
|||||||
@@ -131,5 +131,6 @@
|
|||||||
<string name="text_history_holder">Здесь будет оборажаться манга, которую Вы читаете. Вы можете найти, что почитать, в боковом меню</string>
|
<string name="text_history_holder">Здесь будет оборажаться манга, которую Вы читаете. Вы можете найти, что почитать, в боковом меню</string>
|
||||||
<string name="text_local_holder">У Вас пока нет сохранённой манги. Вы можете сохранить мангу из онлайн каталога или импортировать из файла</string>
|
<string name="text_local_holder">У Вас пока нет сохранённой манги. Вы можете сохранить мангу из онлайн каталога или импортировать из файла</string>
|
||||||
<string name="manga_shelf">Полка с мангой</string>
|
<string name="manga_shelf">Полка с мангой</string>
|
||||||
<string name="recent_manga">Recent manga</string>
|
<string name="recent_manga">Недавняя манга</string>
|
||||||
|
<string name="pages_animation">Анимация листания</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
<string name="key_notifications_sound">notifications_sound</string>
|
<string name="key_notifications_sound">notifications_sound</string>
|
||||||
<string name="key_notifications_vibrate">notifications_vibrate</string>
|
<string name="key_notifications_vibrate">notifications_vibrate</string>
|
||||||
<string name="key_notifications_light">notifications_light</string>
|
<string name="key_notifications_light">notifications_light</string>
|
||||||
|
<string name="key_reader_animation">reader_animation</string>
|
||||||
|
|
||||||
<string name="key_parser_domain">domain</string>
|
<string name="key_parser_domain">domain</string>
|
||||||
<string-array name="values_theme">
|
<string-array name="values_theme">
|
||||||
|
|||||||
@@ -133,4 +133,5 @@
|
|||||||
<string name="text_local_holder">You have not any saved manga yet. You can save it from online sources or import from file</string>
|
<string name="text_local_holder">You have not any saved manga yet. You can save it from online sources or import from file</string>
|
||||||
<string name="manga_shelf">Manga shelf</string>
|
<string name="manga_shelf">Manga shelf</string>
|
||||||
<string name="recent_manga">Recent manga</string>
|
<string name="recent_manga">Recent manga</string>
|
||||||
|
<string name="pages_animation">Pages animation</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -51,6 +51,12 @@
|
|||||||
app:allowDividerAbove="true"
|
app:allowDividerAbove="true"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:title="@string/pages_animation"
|
||||||
|
android:key="@string/key_reader_animation"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/notifications"
|
android:title="@string/notifications"
|
||||||
app:allowDividerAbove="true"
|
app:allowDividerAbove="true"
|
||||||
|
|||||||
@@ -11,4 +11,10 @@
|
|||||||
android:title="@string/switch_pages"
|
android:title="@string/switch_pages"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:title="@string/pages_animation"
|
||||||
|
android:key="@string/key_reader_animation"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
@@ -9,7 +9,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.0-alpha05'
|
classpath 'com.android.tools.build:gradle:4.1.0-alpha06'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Sat Mar 28 11:01:15 EET 2020
|
#Sat Apr 18 10:00:24 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.3-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-rc-1-all.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user