Replace AboutLibraries activity with custom controller
This commit is contained in:
parent
9b00e91773
commit
1d10d29fa9
@ -253,7 +253,7 @@ dependencies {
|
|||||||
"standardImplementation"("com.google.firebase:firebase-analytics:19.0.0")
|
"standardImplementation"("com.google.firebase:firebase-analytics:19.0.0")
|
||||||
|
|
||||||
// Licenses
|
// Licenses
|
||||||
implementation("com.mikepenz:aboutlibraries:${BuildPluginsVersion.ABOUTLIB_PLUGIN}")
|
implementation("com.mikepenz:aboutlibraries-core:${BuildPluginsVersion.ABOUTLIB_PLUGIN}")
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
|
@ -7,11 +7,11 @@ import android.view.LayoutInflater
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.progressindicator.BaseProgressIndicator
|
import com.google.android.material.progressindicator.BaseProgressIndicator
|
||||||
import com.mikepenz.aboutlibraries.util.getThemeColor
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.databinding.ChapterDownloadViewBinding
|
import eu.kanade.tachiyomi.databinding.ChapterDownloadViewBinding
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
|
import eu.kanade.tachiyomi.util.system.getThemeColor
|
||||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||||
|
|
||||||
class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class ChapterDownloadView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
|
@ -5,7 +5,6 @@ import android.os.Bundle
|
|||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.mikepenz.aboutlibraries.LibsBuilder
|
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.updater.GithubUpdateChecker
|
import eu.kanade.tachiyomi.data.updater.GithubUpdateChecker
|
||||||
@ -14,6 +13,8 @@ import eu.kanade.tachiyomi.data.updater.UpdaterService
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
|
import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.openInBrowser
|
import eu.kanade.tachiyomi.ui.base.controller.openInBrowser
|
||||||
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
|
import eu.kanade.tachiyomi.ui.more.licenses.LicensesController
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||||
import eu.kanade.tachiyomi.util.CrashLogUtil
|
import eu.kanade.tachiyomi.util.CrashLogUtil
|
||||||
import eu.kanade.tachiyomi.util.lang.launchNow
|
import eu.kanade.tachiyomi.util.lang.launchNow
|
||||||
@ -84,13 +85,7 @@ class AboutController : SettingsController(), NoToolbarElevationController {
|
|||||||
key = "pref_about_licenses"
|
key = "pref_about_licenses"
|
||||||
titleRes = R.string.licenses
|
titleRes = R.string.licenses
|
||||||
onClick {
|
onClick {
|
||||||
LibsBuilder()
|
router.pushController(LicensesController().withFadeTransaction())
|
||||||
.withActivityTitle(activity!!.getString(R.string.licenses))
|
|
||||||
.withAboutIconShown(false)
|
|
||||||
.withAboutVersionShown(false)
|
|
||||||
.withLicenseShown(true)
|
|
||||||
.withEdgeToEdge(true)
|
|
||||||
.start(activity!!)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.more.licenses
|
||||||
|
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
|
||||||
|
class LicensesAdapter(controller: LicensesController) :
|
||||||
|
FlexibleAdapter<LicensesItem>(null, controller, true)
|
@ -0,0 +1,63 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.more.licenses
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.mikepenz.aboutlibraries.Libs
|
||||||
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.databinding.LicensesControllerBinding
|
||||||
|
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||||
|
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||||
|
|
||||||
|
class LicensesController :
|
||||||
|
BaseController<LicensesControllerBinding>(),
|
||||||
|
FlexibleAdapter.OnItemClickListener {
|
||||||
|
|
||||||
|
private var adapter: LicensesAdapter? = null
|
||||||
|
|
||||||
|
override fun getTitle(): String? {
|
||||||
|
return resources?.getString(R.string.licenses)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createBinding(inflater: LayoutInflater) = LicensesControllerBinding.inflate(inflater)
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View) {
|
||||||
|
super.onViewCreated(view)
|
||||||
|
binding.recycler.applyInsetter {
|
||||||
|
type(navigationBars = true) {
|
||||||
|
padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||||
|
adapter = LicensesAdapter(this)
|
||||||
|
binding.recycler.adapter = adapter
|
||||||
|
|
||||||
|
val licenseItems = Libs(view.context).libraries
|
||||||
|
.sortedBy { it.libraryName.lowercase() }
|
||||||
|
.map { LicensesItem(it) }
|
||||||
|
adapter?.updateDataSet(licenseItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView(view: View) {
|
||||||
|
adapter = null
|
||||||
|
super.onDestroyView(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemClick(view: View, position: Int): Boolean {
|
||||||
|
val adapter = adapter ?: return false
|
||||||
|
|
||||||
|
val item = adapter.getItem(position) ?: return false
|
||||||
|
openLicenseWebsite(item)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun openLicenseWebsite(item: LicensesItem) {
|
||||||
|
val website = item.library.libraryWebsite
|
||||||
|
if (website.isNotEmpty()) {
|
||||||
|
activity?.openInBrowser(website)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.more.licenses
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.view.View
|
||||||
|
import com.mikepenz.aboutlibraries.entity.Library
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
|
import eu.kanade.tachiyomi.databinding.LicensesItemBinding
|
||||||
|
|
||||||
|
class LicensesHolder(view: View, adapter: FlexibleAdapter<*>) :
|
||||||
|
FlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
|
private val binding = LicensesItemBinding.bind(view)
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
fun bind(library: Library) {
|
||||||
|
binding.name.text = "${library.libraryName} ${library.libraryVersion}"
|
||||||
|
binding.artifactId.text = library.libraryArtifactId
|
||||||
|
binding.license.text = library.licenses?.joinToString { it.licenseName }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.more.licenses
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.mikepenz.aboutlibraries.entity.Library
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||||
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
|
||||||
|
class LicensesItem(val library: Library) : AbstractFlexibleItem<LicensesHolder>() {
|
||||||
|
|
||||||
|
override fun getLayoutRes(): Int {
|
||||||
|
return R.layout.licenses_item
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): LicensesHolder {
|
||||||
|
return LicensesHolder(view, adapter)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bindViewHolder(
|
||||||
|
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||||
|
holder: LicensesHolder,
|
||||||
|
position: Int,
|
||||||
|
payloads: List<Any?>?
|
||||||
|
) {
|
||||||
|
holder.bind(library)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (other is LicensesItem) {
|
||||||
|
return library.hashCode() == other.hashCode()
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return library.hashCode()
|
||||||
|
}
|
||||||
|
}
|
@ -35,7 +35,6 @@ import androidx.core.view.isVisible
|
|||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import com.mikepenz.aboutlibraries.util.getThemeColor
|
|
||||||
import dev.chrisbanes.insetter.applyInsetter
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
@ -62,6 +61,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
|||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
||||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||||
import eu.kanade.tachiyomi.util.system.GLUtil
|
import eu.kanade.tachiyomi.util.system.GLUtil
|
||||||
|
import eu.kanade.tachiyomi.util.system.getThemeColor
|
||||||
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
||||||
import eu.kanade.tachiyomi.util.system.isNightMode
|
import eu.kanade.tachiyomi.util.system.isNightMode
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
@ -6,8 +6,8 @@ import android.graphics.Canvas
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import androidx.appcompat.widget.AppCompatSeekBar
|
import androidx.appcompat.widget.AppCompatSeekBar
|
||||||
import com.mikepenz.aboutlibraries.util.getThemeColor
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.util.system.getThemeColor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seekbar to show current chapter progress.
|
* Seekbar to show current chapter progress.
|
||||||
|
@ -18,6 +18,7 @@ import android.net.ConnectivityManager
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import android.util.TypedValue
|
||||||
import android.view.Display
|
import android.view.Display
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
@ -140,6 +141,19 @@ fun Context.hasPermission(permission: String) = ContextCompat.checkSelfPermissio
|
|||||||
return color
|
return color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ColorInt fun Context.getThemeColor(attr: Int): Int {
|
||||||
|
val tv = TypedValue()
|
||||||
|
return if (this.theme.resolveAttribute(attr, tv, true)) {
|
||||||
|
if (tv.resourceId != 0) {
|
||||||
|
ContextCompat.getColor(this, tv.resourceId)
|
||||||
|
} else {
|
||||||
|
tv.data
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts to dp.
|
* Converts to dp.
|
||||||
*/
|
*/
|
||||||
|
@ -11,9 +11,9 @@ import androidx.annotation.StringRes
|
|||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.button.MaterialButton
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.mikepenz.aboutlibraries.util.getThemeColor
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.databinding.CommonViewEmptyBinding
|
import eu.kanade.tachiyomi.databinding.CommonViewEmptyBinding
|
||||||
|
import eu.kanade.tachiyomi.util.system.getThemeColor
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
|
@ -3,8 +3,8 @@ package eu.kanade.tachiyomi.widget
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.mikepenz.aboutlibraries.util.getThemeColor
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.util.system.getThemeColor
|
||||||
|
|
||||||
class ThemedSwipeRefreshLayout @JvmOverloads constructor(
|
class ThemedSwipeRefreshLayout @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -4,8 +4,8 @@ import android.content.Context
|
|||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.appcompat.widget.AppCompatTextView
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
import com.mikepenz.aboutlibraries.util.getThemeColor
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.util.system.getThemeColor
|
||||||
|
|
||||||
class QuadStateTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class QuadStateTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
AppCompatTextView(context, attrs) {
|
AppCompatTextView(context, attrs) {
|
||||||
|
7
app/src/main/res/layout/licenses_controller.xml
Normal file
7
app/src/main/res/layout/licenses_controller.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/recycler"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:listitem="@layout/licenses_item" />
|
30
app/src/main/res/layout/licenses_item.xml
Normal file
30
app/src/main/res/layout/licenses_item.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/list_item_selector_background"
|
||||||
|
android:paddingHorizontal="16dp"
|
||||||
|
android:paddingVertical="8dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/name"
|
||||||
|
style="@style/TextAppearance.Regular.Body1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:text="Library name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/artifact_id"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:text="artifact:id:1.0" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/license"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:text="Apache Version 2.0" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -6,8 +6,7 @@
|
|||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="@drawable/list_item_selector_background"
|
android:background="@drawable/list_item_selector_background"
|
||||||
android:paddingStart="8dp"
|
android:paddingHorizontal="8dp">
|
||||||
android:paddingEnd="8dp">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/thumbnail"
|
android:id="@+id/thumbnail"
|
||||||
|
Loading…
Reference in New Issue
Block a user