Show transparent status bar
This commit is contained in:
@@ -2,6 +2,7 @@ package xyz.quaver.pupil
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.ContextMenu
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@@ -26,6 +27,7 @@ class GalleryActivity : AppCompatActivity() {
|
||||
private var screenMode = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Log.d("Pupil", "Reader Opened")
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
window.setFlags(
|
||||
@@ -39,6 +41,7 @@ class GalleryActivity : AppCompatActivity() {
|
||||
galleryID = intent.getIntExtra("GALLERY_ID", 0)
|
||||
CoroutineScope(Dispatchers.Unconfined).launch {
|
||||
reader = async(Dispatchers.IO) {
|
||||
Log.d("Pupil", "Loading reader")
|
||||
val preference = PreferenceManager.getDefaultSharedPreferences(this@GalleryActivity)
|
||||
if (preference.getBoolean("use_hiyobi", false)) {
|
||||
try {
|
||||
@@ -53,6 +56,7 @@ class GalleryActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
initView()
|
||||
Log.d("Pupil", "Reader view init complete")
|
||||
loadImages()
|
||||
}
|
||||
|
||||
@@ -73,6 +77,10 @@ class GalleryActivity : AppCompatActivity() {
|
||||
loadJob?.cancel()
|
||||
}
|
||||
|
||||
override fun onCreateContextMenu(menu: ContextMenu?, v: View?, menuInfo: ContextMenu.ContextMenuInfo?) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo)
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
gallery_recyclerview.adapter = GalleryAdapter(images).apply {
|
||||
setOnClick {
|
||||
@@ -96,12 +104,14 @@ class GalleryActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun loadImages() {
|
||||
|
||||
fun webpUrlFromUrl(url: URL) = URL(url.toString().replace("/galleries/", "/webp/") + ".webp")
|
||||
|
||||
loadJob = CoroutineScope(Dispatchers.Default).launch {
|
||||
Log.d("Pupil", "Reader Waiting for the data")
|
||||
val reader = reader.await()
|
||||
|
||||
Log.d("Pupil", "Reader Data recieved")
|
||||
|
||||
launch(Dispatchers.Main) {
|
||||
with(gallery_progressbar) {
|
||||
max = reader.size
|
||||
|
||||
@@ -7,23 +7,18 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.preference.PreferenceManager
|
||||
import android.text.*
|
||||
import android.text.style.AlignmentSpan
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
@@ -48,7 +43,7 @@ import xyz.quaver.pupil.util.SetLineOverlap
|
||||
import xyz.quaver.pupil.util.checkUpdate
|
||||
import xyz.quaver.pupil.util.getApkUrl
|
||||
import java.io.File
|
||||
import java.lang.StringBuilder
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
import javax.net.ssl.HttpsURLConnection
|
||||
import kotlin.collections.ArrayList
|
||||
@@ -56,7 +51,7 @@ import kotlin.collections.ArrayList
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private val permissionRequestCode = 4585
|
||||
private val galleries = ArrayList<Pair<GalleryBlock, Bitmap?>>()
|
||||
private val galleries = ArrayList<Pair<GalleryBlock, Deferred<String>>>()
|
||||
|
||||
private var query = ""
|
||||
|
||||
@@ -67,6 +62,11 @@ class MainActivity : AppCompatActivity() {
|
||||
Histories.default = Histories(File(cacheDir, "histories.json"))
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
window.setFlags(
|
||||
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||
)
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
checkPermission()
|
||||
@@ -81,7 +81,11 @@ class MainActivity : AppCompatActivity() {
|
||||
)
|
||||
|
||||
with(main_swipe_layout) {
|
||||
setProgressViewOffset(false, 0, resources.getDimensionPixelSize(R.dimen.progress_view_offset))
|
||||
setProgressViewOffset(
|
||||
false,
|
||||
resources.getDimensionPixelSize(R.dimen.progress_view_start),
|
||||
resources.getDimensionPixelSize(R.dimen.progress_view_offset)
|
||||
)
|
||||
|
||||
setOnRefreshListener {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
@@ -485,10 +489,19 @@ class MainActivity : AppCompatActivity() {
|
||||
chunked.map {
|
||||
async {
|
||||
val galleryBlock = getGalleryBlock(it)
|
||||
val thumbnail: Bitmap
|
||||
|
||||
with(galleryBlock.thumbnails[0].openConnection() as HttpsURLConnection) {
|
||||
thumbnail = BitmapFactory.decodeStream(inputStream)
|
||||
val thumbnail = async {
|
||||
val cache = File(cacheDir, "imageCache/$it/thumbnail.${galleryBlock.thumbnails[0].path.split('.').last()}")
|
||||
|
||||
if (!cache.exists())
|
||||
with(galleryBlock.thumbnails[0].openConnection() as HttpsURLConnection) {
|
||||
if (!cache.parentFile.exists())
|
||||
cache.parentFile.mkdirs()
|
||||
|
||||
inputStream.copyTo(FileOutputStream(cache))
|
||||
}
|
||||
|
||||
cache.absolutePath
|
||||
}
|
||||
|
||||
Pair(galleryBlock, thumbnail)
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
package xyz.quaver.pupil.adapters
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.cardview.widget.CardView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.chip.Chip
|
||||
import kotlinx.android.synthetic.main.item_galleryblock.view.*
|
||||
import kotlinx.coroutines.*
|
||||
import xyz.quaver.hitomi.GalleryBlock
|
||||
import xyz.quaver.hitomi.toTag
|
||||
import xyz.quaver.pupil.R
|
||||
import java.io.File
|
||||
|
||||
class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Bitmap?>>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferred<String>>>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
private enum class ViewType {
|
||||
VIEW_ITEM,
|
||||
@@ -70,21 +73,47 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Bitmap?
|
||||
}.toMap()
|
||||
val (gallery, thumbnail) = galleries[position]
|
||||
|
||||
val artists = gallery.artists.ifEmpty { listOf("N/A") }
|
||||
val series = gallery.series.ifEmpty { listOf("N/A") }
|
||||
val artists = gallery.artists
|
||||
val series = gallery.series
|
||||
|
||||
setOnClickListener {
|
||||
callback?.invoke(gallery.id, gallery.title)
|
||||
}
|
||||
|
||||
galleryblock_thumbnail.setImageBitmap(thumbnail)
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
val bitmap = BitmapFactory.decodeFile(thumbnail.await())
|
||||
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
galleryblock_thumbnail.setImageBitmap(bitmap)
|
||||
}
|
||||
}
|
||||
galleryblock_title.text = gallery.title
|
||||
galleryblock_artist.text = artists.joinToString(", ") { it.wordCapitalize() }
|
||||
galleryblock_series.text =
|
||||
resources.getString(R.string.galleryblock_series, series.joinToString(", ") { it.wordCapitalize() })
|
||||
with(galleryblock_artist) {
|
||||
text = artists.joinToString(", ") { it.wordCapitalize() }
|
||||
visibility = when {
|
||||
artists.isNotEmpty() -> View.VISIBLE
|
||||
else -> View.GONE
|
||||
}
|
||||
}
|
||||
with(galleryblock_series) {
|
||||
text =
|
||||
resources.getString(
|
||||
R.string.galleryblock_series,
|
||||
series.joinToString(", ") { it.wordCapitalize() })
|
||||
visibility = when {
|
||||
series.isNotEmpty() -> View.VISIBLE
|
||||
else -> View.GONE
|
||||
}
|
||||
}
|
||||
galleryblock_type.text = resources.getString(R.string.galleryblock_type, gallery.type).wordCapitalize()
|
||||
galleryblock_language.text =
|
||||
resources.getString(R.string.galleryblock_language, languages[gallery.language])
|
||||
with(galleryblock_language) {
|
||||
text =
|
||||
resources.getString(R.string.galleryblock_language, languages[gallery.language])
|
||||
visibility = when {
|
||||
gallery.language.isNotEmpty() -> View.VISIBLE
|
||||
else -> View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
galleryblock_tag_group.removeAllViews()
|
||||
gallery.relatedTags.forEach {
|
||||
|
||||
Reference in New Issue
Block a user