Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 committed Oct 5, 2021
2 parents 3f5d9b9 + 99aa3f5 commit b683de3
Show file tree
Hide file tree
Showing 68 changed files with 1,564 additions and 794 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
I acknowledge that:

- I have updated:
- To the latest version of the app
- To the latest version of the app (stable is v0.12.3.1)
- All extensions
- If this is an issue with an anime extension, that I should be opening an issue in https://github.com/jmir1/aniyomi-extensions
- I have searched the existing issues and this is new ticket **NOT** a duplicate or related to another open issue
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/report_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ body:
label: Aniyomi version
description: You can find your Aniyomi version in **More → About**.
placeholder: |
Example: "0.12.2.4"
Example: "0.12.3.1"
validations:
required: true

Expand Down Expand Up @@ -97,7 +97,7 @@ body:
required: true
- label: I have tried the [troubleshooting guide](https://tachiyomi.org/help/guides/troubleshooting/).
required: true
- label: I have updated the app to version **[0.12.2.4](https://github.com/jmir1/aniyomi/releases)**.
- label: I have updated the app to version **[0.12.3.1](https://github.com/jmir1/aniyomi/releases/latest)**.
required: true
- label: I have updated all installed extensions.
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/request_feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ body:
required: true
- label: If this is an issue with an extension, I should be opening an issue in the [extensions repository](https://github.com/jmir1/aniyomi-extensions/issues/new/choose).
required: true
- label: I have updated the app to version **[0.12.2.4](https://github.com/jmir1/aniyomi/releases)**.
- label: I have updated the app to version **[0.12.3.1](https://github.com/jmir1/aniyomi/releases/latest)**.
required: true
- label: I will fill out all of the requested information in this form.
required: true
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
minSdk = AndroidConfig.minSdk
targetSdk = AndroidConfig.targetSdk
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
versionCode = 68
versionName = "0.12.2.5"
versionCode = 69
versionName = "0.12.3.1"

buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.util.lang.plusAssign
import eu.kanade.tachiyomi.util.lang.withUIContext
import eu.kanade.tachiyomi.util.system.acquireWakeLock
import eu.kanade.tachiyomi.util.system.isConnectedToWifi
import eu.kanade.tachiyomi.util.system.isOnline
import eu.kanade.tachiyomi.util.system.isServiceRunning
import eu.kanade.tachiyomi.util.system.notification
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.system.wifiManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
Expand All @@ -29,6 +29,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import ru.beryukhov.reactivenetwork.ReactiveNetwork
import rx.subscriptions.CompositeSubscription
import timber.log.Timber
import uy.kohesive.injekt.injectLazy

/**
Expand Down Expand Up @@ -143,8 +144,9 @@ class AnimeDownloadService : Service() {
onNetworkStateChanged()
}
}
.catch {
.catch { error ->
withUIContext {
Timber.e(error)
toast(R.string.download_queue_error)
stopSelf()
}
Expand All @@ -157,7 +159,7 @@ class AnimeDownloadService : Service() {
*/
private fun onNetworkStateChanged() {
if (isOnline()) {
if (preferences.downloadOnlyOverWifi() && !wifiManager.isWifiEnabled) {
if (preferences.downloadOnlyOverWifi() && !isConnectedToWifi()) {
stopDownloads(R.string.download_notifier_text_only_wifi)
} else {
val started = downloadManager.startDownloads()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.util.lang.plusAssign
import eu.kanade.tachiyomi.util.lang.withUIContext
import eu.kanade.tachiyomi.util.system.acquireWakeLock
import eu.kanade.tachiyomi.util.system.isConnectedToWifi
import eu.kanade.tachiyomi.util.system.isOnline
import eu.kanade.tachiyomi.util.system.isServiceRunning
import eu.kanade.tachiyomi.util.system.notification
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.system.wifiManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
Expand All @@ -29,6 +29,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import ru.beryukhov.reactivenetwork.ReactiveNetwork
import rx.subscriptions.CompositeSubscription
import timber.log.Timber
import uy.kohesive.injekt.injectLazy

/**
Expand Down Expand Up @@ -140,8 +141,9 @@ class DownloadService : Service() {
onNetworkStateChanged()
}
}
.catch {
.catch { error ->
withUIContext {
Timber.e(error)
toast(R.string.download_queue_error)
stopSelf()
}
Expand All @@ -154,7 +156,7 @@ class DownloadService : Service() {
*/
private fun onNetworkStateChanged() {
if (isOnline()) {
if (preferences.downloadOnlyOverWifi() && !wifiManager.isWifiEnabled) {
if (preferences.downloadOnlyOverWifi() && !isConnectedToWifi()) {
stopDownloads(R.string.download_notifier_text_only_wifi)
} else {
val started = downloadManager.startDownloads()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import android.view.ViewGroup
import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.databinding.AnimelibCategoryBinding
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
import eu.kanade.tachiyomi.widget.RecyclerViewPagerAdapter
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get

Expand Down Expand Up @@ -45,15 +49,28 @@ class AnimelibAdapter(

private var boundViews = arrayListOf<View>()

private val isPerCategory by lazy { preferences.categorisedDisplaySettings().get() }
private var currentDisplayMode = preferences.libraryDisplayMode().get()

init {
preferences.libraryDisplayMode()
.asFlow()
.drop(1)
.onEach {
currentDisplayMode = it
}
.launchIn(controller.viewScope)
}

/**
* Creates a new view for this adapter.
*
* @return a new view.
*/
override fun createView(container: ViewGroup): View {
override fun inflateView(container: ViewGroup, viewType: Int): View {
val binding = AnimelibCategoryBinding.inflate(LayoutInflater.from(container.context), container, false)
val view: AnimelibCategoryView = binding.root
view.onCreate(controller, binding)
view.onCreate(controller, binding, viewType)
return view
}

Expand Down Expand Up @@ -120,4 +137,26 @@ class AnimelibAdapter(
}
}
}

override fun getViewType(position: Int): Int {
val category = categories[position]
return if (isPerCategory && category.id != 0) {
if (DisplayModeSetting.fromFlag(category.displayMode) == DisplayModeSetting.LIST) {
LIST_DISPLAY_MODE
} else {
GRID_DISPLAY_MODE
}
} else {
if (currentDisplayMode == DisplayModeSetting.LIST) {
LIST_DISPLAY_MODE
} else {
GRID_DISPLAY_MODE
}
}
}

companion object {
const val LIST_DISPLAY_MODE = 1
const val GRID_DISPLAY_MODE = 2
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import androidx.recyclerview.widget.LinearLayoutManager
import dev.chrisbanes.insetter.applyInsetter
import dev.chrisbanes.insetter.Insetter
import dev.chrisbanes.insetter.windowInsetTypesOf
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.SelectableAdapter
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.animelib.AnimelibUpdateService
import eu.kanade.tachiyomi.data.database.models.Anime
import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.databinding.AnimelibCategoryBinding
import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.util.lang.plusAssign
Expand All @@ -27,9 +27,7 @@ import kotlinx.coroutines.flow.onEach
import reactivecircus.flowbinding.recyclerview.scrollStateChanges
import reactivecircus.flowbinding.swiperefreshlayout.refreshes
import rx.subscriptions.CompositeSubscription
import uy.kohesive.injekt.injectLazy
import java.util.ArrayDeque
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting as DisplayMode

/**
* Fragment containing the animelib anime for a certain category.
Expand All @@ -41,8 +39,6 @@ class AnimelibCategoryView @JvmOverloads constructor(context: Context, attrs: At

private val scope = MainScope()

private val preferences: PreferencesHelper by injectLazy()

/**
* The fragment containing this view.
*/
Expand Down Expand Up @@ -71,12 +67,10 @@ class AnimelibCategoryView @JvmOverloads constructor(context: Context, attrs: At

private var lastClickPositionStack = ArrayDeque(listOf(-1))

fun onCreate(controller: AnimelibController, binding: AnimelibCategoryBinding) {
fun onCreate(controller: AnimelibController, binding: AnimelibCategoryBinding, viewType: Int) {
this.controller = controller

recycler = if (preferences.libraryDisplayMode().get() == DisplayMode.LIST &&
!preferences.categorisedDisplaySettings().get()
) {
recycler = if (viewType == AnimelibAdapter.LIST_DISPLAY_MODE) {
(binding.swipeRefresh.inflate(R.layout.library_list_recycler) as AutofitRecyclerView).apply {
spanCount = 1
}
Expand All @@ -86,11 +80,9 @@ class AnimelibCategoryView @JvmOverloads constructor(context: Context, attrs: At
}
}

recycler.applyInsetter {
type(navigationBars = true) {
padding()
}
}
Insetter.builder()
.paddingBottom(windowInsetTypesOf(navigationBars = true))
.applyToView(recycler)

adapter = AnimelibCategoryAdapter(this)

Expand Down Expand Up @@ -129,15 +121,6 @@ class AnimelibCategoryView @JvmOverloads constructor(context: Context, attrs: At
fun onBind(category: Category) {
this.category = category

// If displayMode should be set from category adjust manga count per row
if (preferences.categorisedDisplaySettings().get()) {
recycler.spanCount = if (DisplayMode.fromFlag(category.displayMode) == DisplayMode.LIST || (preferences.libraryDisplayMode().get() == DisplayMode.LIST && category.id == 0)) {
1
} else {
controller.animePerRow
}
}

adapter.mode = if (controller.selectedAnimes.isNotEmpty()) {
SelectableAdapter.Mode.MULTI
} else {
Expand Down
43 changes: 41 additions & 2 deletions app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import android.view.ViewGroup
import eu.kanade.tachiyomi.data.database.models.Category
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.databinding.LibraryCategoryBinding
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
import eu.kanade.tachiyomi.widget.RecyclerViewPagerAdapter
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get

Expand Down Expand Up @@ -45,15 +49,28 @@ class LibraryAdapter(

private var boundViews = arrayListOf<View>()

private val isPerCategory by lazy { preferences.categorisedDisplaySettings().get() }
private var currentDisplayMode = preferences.libraryDisplayMode().get()

init {
preferences.libraryDisplayMode()
.asFlow()
.drop(1)
.onEach {
currentDisplayMode = it
}
.launchIn(controller.viewScope)
}

/**
* Creates a new view for this adapter.
*
* @return a new view.
*/
override fun createView(container: ViewGroup): View {
override fun inflateView(container: ViewGroup, viewType: Int): View {
val binding = LibraryCategoryBinding.inflate(LayoutInflater.from(container.context), container, false)
val view: LibraryCategoryView = binding.root
view.onCreate(controller, binding)
view.onCreate(controller, binding, viewType)
return view
}

Expand Down Expand Up @@ -120,4 +137,26 @@ class LibraryAdapter(
}
}
}

override fun getViewType(position: Int): Int {
val category = categories[position]
return if (isPerCategory && category.id != 0) {
if (DisplayModeSetting.fromFlag(category.displayMode) == DisplayModeSetting.LIST) {
LIST_DISPLAY_MODE
} else {
GRID_DISPLAY_MODE
}
} else {
if (currentDisplayMode == DisplayModeSetting.LIST) {
LIST_DISPLAY_MODE
} else {
GRID_DISPLAY_MODE
}
}
}

companion object {
const val LIST_DISPLAY_MODE = 1
const val GRID_DISPLAY_MODE = 2
}
}
Loading

0 comments on commit b683de3

Please sign in to comment.