Show gallery ID
Fixed paging problem when tag searched made gallery info clickable
This commit is contained in:
@@ -9,8 +9,8 @@ android {
|
|||||||
applicationId "xyz.quaver.pupil"
|
applicationId "xyz.quaver.pupil"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 14
|
versionCode 15
|
||||||
versionName "2.7"
|
versionName "3.0"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import kotlinx.serialization.json.JsonConfiguration
|
|||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.json.content
|
import kotlinx.serialization.json.content
|
||||||
import kotlinx.serialization.list
|
import kotlinx.serialization.list
|
||||||
import kotlinx.serialization.parseList
|
|
||||||
import kotlinx.serialization.stringify
|
import kotlinx.serialization.stringify
|
||||||
import ru.noties.markwon.Markwon
|
import ru.noties.markwon.Markwon
|
||||||
import xyz.quaver.hitomi.*
|
import xyz.quaver.hitomi.*
|
||||||
@@ -116,6 +115,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
initView()
|
initView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
|
||||||
|
if (cacheDir.exists())
|
||||||
|
cacheDir.deleteRecursively()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
when {
|
when {
|
||||||
main_drawer_layout.isDrawerOpen(GravityCompat.START) -> main_drawer_layout.closeDrawer(GravityCompat.START)
|
main_drawer_layout.isDrawerOpen(GravityCompat.START) -> main_drawer_layout.closeDrawer(GravityCompat.START)
|
||||||
@@ -249,7 +255,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val msg = extractReleaseNote(update, Locale.getDefault().language)
|
val msg = extractReleaseNote(update, Locale.getDefault().language)
|
||||||
setMessage(Markwon.create(context).toMarkdown(msg))
|
setMessage(Markwon.create(context).toMarkdown(msg))
|
||||||
setPositiveButton(android.R.string.yes) { _, _ ->
|
setPositiveButton(android.R.string.yes) { _, _ ->
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.home_page))))
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.update))))
|
||||||
}
|
}
|
||||||
setNegativeButton(android.R.string.no) { _, _ ->}
|
setNegativeButton(android.R.string.no) { _, _ ->}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package xyz.quaver.pupil.adapters
|
package xyz.quaver.pupil.adapters
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.graphics.drawable.Animatable
|
import android.graphics.drawable.Animatable
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -7,6 +9,7 @@ import android.util.SparseBooleanArray
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.cardview.widget.CardView
|
import androidx.cardview.widget.CardView
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@@ -23,6 +26,7 @@ import kotlinx.serialization.json.JsonConfiguration
|
|||||||
import kotlinx.serialization.list
|
import kotlinx.serialization.list
|
||||||
import xyz.quaver.hitomi.GalleryBlock
|
import xyz.quaver.hitomi.GalleryBlock
|
||||||
import xyz.quaver.hitomi.ReaderItem
|
import xyz.quaver.hitomi.ReaderItem
|
||||||
|
import xyz.quaver.pupil.BuildConfig
|
||||||
import xyz.quaver.pupil.Pupil
|
import xyz.quaver.pupil.Pupil
|
||||||
import xyz.quaver.pupil.R
|
import xyz.quaver.pupil.R
|
||||||
import xyz.quaver.pupil.types.Tag
|
import xyz.quaver.pupil.types.Tag
|
||||||
@@ -64,7 +68,10 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
|||||||
if (!File(cache).exists())
|
if (!File(cache).exists())
|
||||||
return@launch
|
return@launch
|
||||||
|
|
||||||
val bitmap = BitmapFactory.decodeFile(thumbnail.await())
|
val bitmap = when {
|
||||||
|
BuildConfig.DEBUG -> Bitmap.createScaledBitmap(BitmapFactory.decodeFile(thumbnail.await()), 5, 8, true)
|
||||||
|
else -> BitmapFactory.decodeFile(thumbnail.await())
|
||||||
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
galleryblock_thumbnail.setImageBitmap(bitmap)
|
galleryblock_thumbnail.setImageBitmap(bitmap)
|
||||||
@@ -157,6 +164,19 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
|||||||
artists.isNotEmpty() -> View.VISIBLE
|
artists.isNotEmpty() -> View.VISIBLE
|
||||||
else -> View.GONE
|
else -> View.GONE
|
||||||
}
|
}
|
||||||
|
setOnClickListener {
|
||||||
|
if (artists.size > 1) {
|
||||||
|
AlertDialog.Builder(context).apply {
|
||||||
|
setAdapter(ArrayAdapter(context, android.R.layout.select_dialog_item, artists)) { _, index ->
|
||||||
|
for (callback in onChipClickedHandler)
|
||||||
|
callback.invoke(Tag("artist", artists[index]))
|
||||||
|
}
|
||||||
|
}.show()
|
||||||
|
} else {
|
||||||
|
for(callback in onChipClickedHandler)
|
||||||
|
callback.invoke(Tag("artist", artists.first()))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
with(galleryblock_series) {
|
with(galleryblock_series) {
|
||||||
text =
|
text =
|
||||||
@@ -167,8 +187,31 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
|||||||
series.isNotEmpty() -> View.VISIBLE
|
series.isNotEmpty() -> View.VISIBLE
|
||||||
else -> View.GONE
|
else -> View.GONE
|
||||||
}
|
}
|
||||||
|
setOnClickListener {
|
||||||
|
setOnClickListener {
|
||||||
|
if (series.size > 1) {
|
||||||
|
AlertDialog.Builder(context).apply {
|
||||||
|
setAdapter(ArrayAdapter(context, android.R.layout.select_dialog_item, series)) { _, index ->
|
||||||
|
for (callback in onChipClickedHandler)
|
||||||
|
callback.invoke(Tag("series", series[index]))
|
||||||
|
}
|
||||||
|
}.show()
|
||||||
|
} else {
|
||||||
|
for(callback in onChipClickedHandler)
|
||||||
|
callback.invoke(Tag("series", series.first()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
with(galleryblock_type) {
|
||||||
|
text = resources.getString(R.string.galleryblock_type, gallery.type).wordCapitalize()
|
||||||
|
setOnClickListener {
|
||||||
|
setOnClickListener {
|
||||||
|
for(callback in onChipClickedHandler)
|
||||||
|
callback.invoke(Tag("type", gallery.type))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
galleryblock_type.text = resources.getString(R.string.galleryblock_type, gallery.type).wordCapitalize()
|
|
||||||
with(galleryblock_language) {
|
with(galleryblock_language) {
|
||||||
text =
|
text =
|
||||||
resources.getString(R.string.galleryblock_language, languages[gallery.language])
|
resources.getString(R.string.galleryblock_language, languages[gallery.language])
|
||||||
@@ -176,11 +219,22 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
|||||||
gallery.language.isNotEmpty() -> View.VISIBLE
|
gallery.language.isNotEmpty() -> View.VISIBLE
|
||||||
else -> View.GONE
|
else -> View.GONE
|
||||||
}
|
}
|
||||||
|
setOnClickListener {
|
||||||
|
setOnClickListener {
|
||||||
|
for(callback in onChipClickedHandler)
|
||||||
|
callback.invoke(Tag("language", gallery.language))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
galleryblock_tag_group.removeAllViews()
|
galleryblock_tag_group.removeAllViews()
|
||||||
gallery.relatedTags.forEach {
|
gallery.relatedTags.forEach {
|
||||||
val tag = Tag.parse(it)
|
val tag = Tag.parse(it).let { tag ->
|
||||||
|
when {
|
||||||
|
tag.area != null -> tag
|
||||||
|
else -> Tag("tag", it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val chip = LayoutInflater.from(context)
|
val chip = LayoutInflater.from(context)
|
||||||
.inflate(R.layout.tag_chip, this, false) as Chip
|
.inflate(R.layout.tag_chip, this, false) as Chip
|
||||||
@@ -209,6 +263,8 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
|||||||
galleryblock_tag_group.addView(chip)
|
galleryblock_tag_group.addView(chip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
galleryblock_id.text = gallery.id.toString()
|
||||||
|
|
||||||
if (!::favorites.isInitialized)
|
if (!::favorites.isInitialized)
|
||||||
favorites = (context.applicationContext as Pupil).favorites
|
favorites = (context.applicationContext as Pupil).favorites
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import xyz.quaver.pupil.BuildConfig
|
||||||
import xyz.quaver.pupil.R
|
import xyz.quaver.pupil.R
|
||||||
|
|
||||||
class ReaderAdapter(private val images: List<String>) : RecyclerView.Adapter<ReaderAdapter.ViewHolder>() {
|
class ReaderAdapter(private val images: List<String>) : RecyclerView.Adapter<ReaderAdapter.ViewHolder>() {
|
||||||
@@ -37,7 +38,10 @@ class ReaderAdapter(private val images: List<String>) : RecyclerView.Adapter<Rea
|
|||||||
|
|
||||||
options.inJustDecodeBounds = false
|
options.inJustDecodeBounds = false
|
||||||
|
|
||||||
val image = BitmapFactory.decodeFile(images[position], options)
|
val image = when {
|
||||||
|
BuildConfig.DEBUG -> Bitmap.createScaledBitmap(BitmapFactory.decodeFile(images[position], options), 5, 8, true)
|
||||||
|
else -> BitmapFactory.decodeFile(images[position], options)
|
||||||
|
}
|
||||||
|
|
||||||
post { setImageBitmap(image) }
|
post { setImageBitmap(image) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
app:layout_constraintLeft_toRightOf="@id/galleryblock_thumbnail"
|
app:layout_constraintLeft_toRightOf="@id/galleryblock_thumbnail"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/galleryblock_title"/>
|
app:layout_constraintTop_toBottomOf="@id/galleryblock_title"/>
|
||||||
@@ -79,6 +81,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
app:layout_constraintTop_toBottomOf="@id/galleryblock_artist"
|
app:layout_constraintTop_toBottomOf="@id/galleryblock_artist"
|
||||||
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail"
|
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail"
|
||||||
app:layout_constraintEnd_toEndOf="parent"/>
|
app:layout_constraintEnd_toEndOf="parent"/>
|
||||||
@@ -89,6 +93,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
app:layout_constraintTop_toBottomOf="@id/galleryblock_series"
|
app:layout_constraintTop_toBottomOf="@id/galleryblock_series"
|
||||||
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail" />
|
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail" />
|
||||||
|
|
||||||
@@ -99,6 +105,8 @@
|
|||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
app:layout_constraintTop_toBottomOf="@id/galleryblock_type"
|
app:layout_constraintTop_toBottomOf="@id/galleryblock_type"
|
||||||
app:layout_constraintBottom_toTopOf="@id/galleryblock_padding"
|
app:layout_constraintBottom_toTopOf="@id/galleryblock_padding"
|
||||||
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail" />
|
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail" />
|
||||||
@@ -135,16 +143,25 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:paddingLeft="8dp"
|
||||||
android:gravity="end">
|
android:paddingRight="8dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/galleryblock_id"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
android:id="@+id/galleryblock_favorite"
|
android:id="@+id/galleryblock_favorite"
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="32dp"
|
android:layout_height="32dp"
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:layout_marginRight="8dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:background="@drawable/avd_star"
|
android:background="@drawable/avd_star"
|
||||||
android:backgroundTint="@color/material_orange_500"
|
android:backgroundTint="@color/material_orange_500"
|
||||||
android:text=""
|
android:text=""
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
<string name="release_url" translatable="false">https://api.github.com/repos/tom5079/Pupil-issue/releases</string>
|
<string name="release_url" translatable="false">https://api.github.com/repos/tom5079/Pupil-issue/releases</string>
|
||||||
<string name="release_name" translatable="false">Pupil-v(\\d+\\.)+\\d+\\.apk</string>
|
<string name="release_name" translatable="false">Pupil-v(\\d+\\.)+\\d+\\.apk</string>
|
||||||
|
|
||||||
<string name="home_page" translatable="false">http://bit.ly/2ZlOjXJ</string>
|
<string name="home_page" translatable="false">http://bit.ly/2EZDClw</string>
|
||||||
|
<string name="update" translatable="false">http://bit.ly/2ZlOjXJ</string>
|
||||||
<string name="help" translatable="false">http://bit.ly/2Z7lNZE</string>
|
<string name="help" translatable="false">http://bit.ly/2Z7lNZE</string>
|
||||||
<string name="github" translatable="false">https://github.com/tom5079/Pupil-issue/issues/new/choose</string>
|
<string name="github" translatable="false">https://github.com/tom5079/Pupil-issue/issues/new/choose</string>
|
||||||
<string name="email" translatable="false">mailto:pupil.hentai@gmail.com</string>
|
<string name="email" translatable="false">mailto:pupil.hentai@gmail.com</string>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ fun getGalleryBlock(galleryID: Int) : GalleryBlock? {
|
|||||||
|
|
||||||
val relatedTags = doc.select(".relatedtags a").map {
|
val relatedTags = doc.select(".relatedtags a").map {
|
||||||
val href = URLDecoder.decode(it.attr("href"), "UTF-8")
|
val href = URLDecoder.decode(it.attr("href"), "UTF-8")
|
||||||
href.slice(5 until href.indexOf('-'))
|
href.slice(5 until href.indexOf("-all"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return GalleryBlock(galleryID, thumbnails, title, artists, series, type, language, relatedTags)
|
return GalleryBlock(galleryID, thumbnails, title, artists, series, type, language, relatedTags)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class UnitTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun test_getBlock() {
|
fun test_getBlock() {
|
||||||
val galleryBlock = getGalleryBlock(1405716)
|
val galleryBlock = getGalleryBlock(1428250)
|
||||||
|
|
||||||
print(galleryBlock)
|
print(galleryBlock)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user