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"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
versionCode 14
|
||||
versionName "2.7"
|
||||
versionCode 15
|
||||
versionName "3.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
||||
@@ -39,7 +39,6 @@ import kotlinx.serialization.json.JsonConfiguration
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.content
|
||||
import kotlinx.serialization.list
|
||||
import kotlinx.serialization.parseList
|
||||
import kotlinx.serialization.stringify
|
||||
import ru.noties.markwon.Markwon
|
||||
import xyz.quaver.hitomi.*
|
||||
@@ -116,6 +115,13 @@ class MainActivity : AppCompatActivity() {
|
||||
initView()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
if (cacheDir.exists())
|
||||
cacheDir.deleteRecursively()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
when {
|
||||
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)
|
||||
setMessage(Markwon.create(context).toMarkdown(msg))
|
||||
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) { _, _ ->}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package xyz.quaver.pupil.adapters
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.util.Log
|
||||
@@ -7,6 +9,7 @@ import android.util.SparseBooleanArray
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.LinearLayout
|
||||
import androidx.cardview.widget.CardView
|
||||
import androidx.core.content.ContextCompat
|
||||
@@ -23,6 +26,7 @@ import kotlinx.serialization.json.JsonConfiguration
|
||||
import kotlinx.serialization.list
|
||||
import xyz.quaver.hitomi.GalleryBlock
|
||||
import xyz.quaver.hitomi.ReaderItem
|
||||
import xyz.quaver.pupil.BuildConfig
|
||||
import xyz.quaver.pupil.Pupil
|
||||
import xyz.quaver.pupil.R
|
||||
import xyz.quaver.pupil.types.Tag
|
||||
@@ -64,7 +68,10 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
||||
if (!File(cache).exists())
|
||||
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 {
|
||||
galleryblock_thumbnail.setImageBitmap(bitmap)
|
||||
@@ -157,6 +164,19 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
||||
artists.isNotEmpty() -> View.VISIBLE
|
||||
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) {
|
||||
text =
|
||||
@@ -167,8 +187,31 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
||||
series.isNotEmpty() -> View.VISIBLE
|
||||
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) {
|
||||
text =
|
||||
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
|
||||
else -> View.GONE
|
||||
}
|
||||
setOnClickListener {
|
||||
setOnClickListener {
|
||||
for(callback in onChipClickedHandler)
|
||||
callback.invoke(Tag("language", gallery.language))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
galleryblock_tag_group.removeAllViews()
|
||||
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)
|
||||
.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_id.text = gallery.id.toString()
|
||||
|
||||
if (!::favorites.isInitialized)
|
||||
favorites = (context.applicationContext as Pupil).favorites
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import xyz.quaver.pupil.BuildConfig
|
||||
import xyz.quaver.pupil.R
|
||||
|
||||
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
|
||||
|
||||
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) }
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:layout_constraintLeft_toRightOf="@id/galleryblock_thumbnail"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/galleryblock_title"/>
|
||||
@@ -79,6 +81,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/galleryblock_artist"
|
||||
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
@@ -89,6 +93,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/galleryblock_series"
|
||||
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail" />
|
||||
|
||||
@@ -99,6 +105,8 @@
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/galleryblock_type"
|
||||
app:layout_constraintBottom_toTopOf="@id/galleryblock_padding"
|
||||
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail" />
|
||||
@@ -135,16 +143,25 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="end">
|
||||
android:paddingLeft="8dp"
|
||||
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
|
||||
android:id="@+id/galleryblock_favorite"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/avd_star"
|
||||
android:backgroundTint="@color/material_orange_500"
|
||||
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_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="github" translatable="false">https://github.com/tom5079/Pupil-issue/issues/new/choose</string>
|
||||
<string name="email" translatable="false">mailto:pupil.hentai@gmail.com</string>
|
||||
|
||||
Reference in New Issue
Block a user