Show transparent status bar
This commit is contained in:
@@ -4,16 +4,10 @@ import android.graphics.BitmapFactory
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import xyz.quaver.hiyobi.getReader
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instrumented test, which will execute on an Android device.
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package xyz.quaver.pupil
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.ContextMenu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -26,6 +27,7 @@ class GalleryActivity : AppCompatActivity() {
|
|||||||
private var screenMode = 0
|
private var screenMode = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
Log.d("Pupil", "Reader Opened")
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
window.setFlags(
|
window.setFlags(
|
||||||
@@ -39,6 +41,7 @@ class GalleryActivity : AppCompatActivity() {
|
|||||||
galleryID = intent.getIntExtra("GALLERY_ID", 0)
|
galleryID = intent.getIntExtra("GALLERY_ID", 0)
|
||||||
CoroutineScope(Dispatchers.Unconfined).launch {
|
CoroutineScope(Dispatchers.Unconfined).launch {
|
||||||
reader = async(Dispatchers.IO) {
|
reader = async(Dispatchers.IO) {
|
||||||
|
Log.d("Pupil", "Loading reader")
|
||||||
val preference = PreferenceManager.getDefaultSharedPreferences(this@GalleryActivity)
|
val preference = PreferenceManager.getDefaultSharedPreferences(this@GalleryActivity)
|
||||||
if (preference.getBoolean("use_hiyobi", false)) {
|
if (preference.getBoolean("use_hiyobi", false)) {
|
||||||
try {
|
try {
|
||||||
@@ -53,6 +56,7 @@ class GalleryActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initView()
|
initView()
|
||||||
|
Log.d("Pupil", "Reader view init complete")
|
||||||
loadImages()
|
loadImages()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +77,10 @@ class GalleryActivity : AppCompatActivity() {
|
|||||||
loadJob?.cancel()
|
loadJob?.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreateContextMenu(menu: ContextMenu?, v: View?, menuInfo: ContextMenu.ContextMenuInfo?) {
|
||||||
|
super.onCreateContextMenu(menu, v, menuInfo)
|
||||||
|
}
|
||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
gallery_recyclerview.adapter = GalleryAdapter(images).apply {
|
gallery_recyclerview.adapter = GalleryAdapter(images).apply {
|
||||||
setOnClick {
|
setOnClick {
|
||||||
@@ -96,12 +104,14 @@ class GalleryActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadImages() {
|
private fun loadImages() {
|
||||||
|
|
||||||
fun webpUrlFromUrl(url: URL) = URL(url.toString().replace("/galleries/", "/webp/") + ".webp")
|
fun webpUrlFromUrl(url: URL) = URL(url.toString().replace("/galleries/", "/webp/") + ".webp")
|
||||||
|
|
||||||
loadJob = CoroutineScope(Dispatchers.Default).launch {
|
loadJob = CoroutineScope(Dispatchers.Default).launch {
|
||||||
|
Log.d("Pupil", "Reader Waiting for the data")
|
||||||
val reader = reader.await()
|
val reader = reader.await()
|
||||||
|
|
||||||
|
Log.d("Pupil", "Reader Data recieved")
|
||||||
|
|
||||||
launch(Dispatchers.Main) {
|
launch(Dispatchers.Main) {
|
||||||
with(gallery_progressbar) {
|
with(gallery_progressbar) {
|
||||||
max = reader.size
|
max = reader.size
|
||||||
|
|||||||
@@ -7,23 +7,18 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.BitmapFactory
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.preference.PreferenceManager
|
import android.preference.PreferenceManager
|
||||||
import android.text.*
|
import android.text.*
|
||||||
import android.text.style.AlignmentSpan
|
import android.text.style.AlignmentSpan
|
||||||
import android.util.Log
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.app.NotificationCompat
|
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.core.content.res.ResourcesCompat
|
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.checkUpdate
|
||||||
import xyz.quaver.pupil.util.getApkUrl
|
import xyz.quaver.pupil.util.getApkUrl
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.lang.StringBuilder
|
import java.io.FileOutputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.net.ssl.HttpsURLConnection
|
import javax.net.ssl.HttpsURLConnection
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
@@ -56,7 +51,7 @@ import kotlin.collections.ArrayList
|
|||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private val permissionRequestCode = 4585
|
private val permissionRequestCode = 4585
|
||||||
private val galleries = ArrayList<Pair<GalleryBlock, Bitmap?>>()
|
private val galleries = ArrayList<Pair<GalleryBlock, Deferred<String>>>()
|
||||||
|
|
||||||
private var query = ""
|
private var query = ""
|
||||||
|
|
||||||
@@ -67,6 +62,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Histories.default = Histories(File(cacheDir, "histories.json"))
|
Histories.default = Histories(File(cacheDir, "histories.json"))
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
window.setFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||||
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||||
|
)
|
||||||
|
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
|
||||||
checkPermission()
|
checkPermission()
|
||||||
@@ -81,7 +81,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
with(main_swipe_layout) {
|
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 {
|
setOnRefreshListener {
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
@@ -485,10 +489,19 @@ class MainActivity : AppCompatActivity() {
|
|||||||
chunked.map {
|
chunked.map {
|
||||||
async {
|
async {
|
||||||
val galleryBlock = getGalleryBlock(it)
|
val galleryBlock = getGalleryBlock(it)
|
||||||
val thumbnail: Bitmap
|
|
||||||
|
|
||||||
with(galleryBlock.thumbnails[0].openConnection() as HttpsURLConnection) {
|
val thumbnail = async {
|
||||||
thumbnail = BitmapFactory.decodeStream(inputStream)
|
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)
|
Pair(galleryBlock, thumbnail)
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
package xyz.quaver.pupil.adapters
|
package xyz.quaver.pupil.adapters
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.BitmapFactory
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.cardview.widget.CardView
|
import androidx.cardview.widget.CardView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import kotlinx.android.synthetic.main.item_galleryblock.view.*
|
import kotlinx.android.synthetic.main.item_galleryblock.view.*
|
||||||
|
import kotlinx.coroutines.*
|
||||||
import xyz.quaver.hitomi.GalleryBlock
|
import xyz.quaver.hitomi.GalleryBlock
|
||||||
import xyz.quaver.hitomi.toTag
|
import xyz.quaver.hitomi.toTag
|
||||||
import xyz.quaver.pupil.R
|
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 {
|
private enum class ViewType {
|
||||||
VIEW_ITEM,
|
VIEW_ITEM,
|
||||||
@@ -70,21 +73,47 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Bitmap?
|
|||||||
}.toMap()
|
}.toMap()
|
||||||
val (gallery, thumbnail) = galleries[position]
|
val (gallery, thumbnail) = galleries[position]
|
||||||
|
|
||||||
val artists = gallery.artists.ifEmpty { listOf("N/A") }
|
val artists = gallery.artists
|
||||||
val series = gallery.series.ifEmpty { listOf("N/A") }
|
val series = gallery.series
|
||||||
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
callback?.invoke(gallery.id, gallery.title)
|
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_title.text = gallery.title
|
||||||
galleryblock_artist.text = artists.joinToString(", ") { it.wordCapitalize() }
|
with(galleryblock_artist) {
|
||||||
galleryblock_series.text =
|
text = artists.joinToString(", ") { it.wordCapitalize() }
|
||||||
resources.getString(R.string.galleryblock_series, series.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_type.text = resources.getString(R.string.galleryblock_type, gallery.type).wordCapitalize()
|
||||||
galleryblock_language.text =
|
with(galleryblock_language) {
|
||||||
resources.getString(R.string.galleryblock_language, languages[gallery.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()
|
galleryblock_tag_group.removeAllViews()
|
||||||
gallery.relatedTags.forEach {
|
gallery.relatedTags.forEach {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
android:id="@+id/main_drawer_layout"
|
android:id="@+id/main_drawer_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
tools:openDrawer="start">
|
tools:openDrawer="start">
|
||||||
|
|
||||||
<include layout="@layout/activity_main_content"
|
<include layout="@layout/activity_main_content"
|
||||||
@@ -18,7 +17,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
app:headerLayout="@layout/nav_header_main"
|
app:headerLayout="@layout/nav_header_main"
|
||||||
app:menu="@menu/activity_main_drawer"/>
|
app:menu="@menu/activity_main_drawer"/>
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="64dp"
|
android:layout_height="80dp"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
android:background="@color/transparent"
|
android:background="@color/transparent"
|
||||||
app:layout_scrollFlags="scroll|enterAlways"
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:floatingSearch_searchBarMarginLeft="8dp"
|
app:floatingSearch_searchBarMarginLeft="8dp"
|
||||||
app:floatingSearch_searchBarMarginRight="8dp"
|
app:floatingSearch_searchBarMarginRight="8dp"
|
||||||
app:floatingSearch_searchBarMarginTop="8dp"
|
app:floatingSearch_searchBarMarginTop="24dp"
|
||||||
app:floatingSearch_searchHint="@string/search_hint"
|
app:floatingSearch_searchHint="@string/search_hint"
|
||||||
app:floatingSearch_suggestionsListAnimDuration="250"
|
app:floatingSearch_suggestionsListAnimDuration="250"
|
||||||
app:floatingSearch_showSearchKey="true"
|
app:floatingSearch_showSearchKey="true"
|
||||||
|
|||||||
@@ -78,8 +78,17 @@
|
|||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/galleryblock_type"
|
app:layout_constraintTop_toBottomOf="@id/galleryblock_type"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/galleryblock_padding"
|
||||||
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail" />
|
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/galleryblock_padding"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/galleryblock_thumbnail"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/galleryblock_language"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/galleryblock_tag_group"/>
|
||||||
|
|
||||||
<com.google.android.material.chip.ChipGroup
|
<com.google.android.material.chip.ChipGroup
|
||||||
android:id="@+id/galleryblock_tag_group"
|
android:id="@+id/galleryblock_tag_group"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
@@ -90,7 +99,7 @@
|
|||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
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_language"
|
app:layout_constraintTop_toBottomOf="@id/galleryblock_padding"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="NoActionBarAppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
|
<style name="NoActionBarAppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||||
|
<item name="android:windowTranslucentStatus">true</item>
|
||||||
|
<item name="android:windowTranslucentNavigation">true</item>
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
|
||||||
<item name="android:statusBarColor">@color/transparent</item>
|
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="appbar_padding">64dp</dimen>
|
<dimen name="appbar_padding">64dp</dimen>
|
||||||
<dimen name="progress_view_offset">80dp</dimen>
|
<dimen name="progress_view_start">32dp</dimen>
|
||||||
|
<dimen name="progress_view_offset">96dp</dimen>
|
||||||
|
|
||||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
|||||||
Reference in New Issue
Block a user