Added download list
Added history search
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 5
|
versionCode 7
|
||||||
versionName "1.4"
|
versionName "2.1"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@@ -38,6 +38,7 @@ dependencies {
|
|||||||
implementation 'androidx.preference:preference:1.1.0-alpha05'
|
implementation 'androidx.preference:preference:1.1.0-alpha05'
|
||||||
implementation 'com.google.android.material:material:1.0.0'
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
implementation 'com.github.arimorty:floatingsearchview:2.1.1'
|
implementation 'com.github.arimorty:floatingsearchview:2.1.1'
|
||||||
|
implementation 'com.github.deano2390:MaterialShowcaseView:1.3.4'
|
||||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation "ru.noties.markwon:core:${markwonVersion}"
|
implementation "ru.noties.markwon:core:${markwonVersion}"
|
||||||
|
|||||||
@@ -42,19 +42,33 @@ import kotlin.collections.ArrayList
|
|||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
enum class Mode {
|
||||||
|
SEARCH,
|
||||||
|
HISTORY,
|
||||||
|
DOWNLOAD
|
||||||
|
}
|
||||||
|
|
||||||
private val galleries = ArrayList<Pair<GalleryBlock, Deferred<String>>>()
|
private val galleries = ArrayList<Pair<GalleryBlock, Deferred<String>>>()
|
||||||
|
|
||||||
private var query = ""
|
private var query = ""
|
||||||
|
private var mode = Mode.SEARCH
|
||||||
|
|
||||||
private val SETTINGS = 45162
|
private val SETTINGS = 45162
|
||||||
|
|
||||||
private var galleryIDs: Deferred<List<Int>>? = null
|
private var galleryIDs: Deferred<List<Int>>? = null
|
||||||
private var loadingJob: Job? = null
|
private var loadingJob: Job? = null
|
||||||
|
|
||||||
|
private lateinit var histories: Histories
|
||||||
|
private lateinit var downloads: Histories
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
Histories.default = Histories(File(cacheDir, "histories.json"))
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
with(application as Pupil) {
|
||||||
|
this@MainActivity.histories = histories
|
||||||
|
this@MainActivity.downloads = downloads
|
||||||
|
}
|
||||||
|
|
||||||
window.setFlags(
|
window.setFlags(
|
||||||
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
|
||||||
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||||
@@ -64,82 +78,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
checkUpdate()
|
checkUpdate()
|
||||||
|
|
||||||
main_appbar_layout.addOnOffsetChangedListener(
|
initView()
|
||||||
AppBarLayout.OnOffsetChangedListener { _, p1 ->
|
|
||||||
main_searchview.translationY = p1.toFloat()
|
|
||||||
main_recyclerview.translationY = p1.toFloat()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
with(main_swipe_layout) {
|
|
||||||
setProgressViewOffset(
|
|
||||||
false,
|
|
||||||
resources.getDimensionPixelSize(R.dimen.progress_view_start),
|
|
||||||
resources.getDimensionPixelSize(R.dimen.progress_view_offset)
|
|
||||||
)
|
|
||||||
|
|
||||||
setOnRefreshListener {
|
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
|
||||||
cancelFetch()
|
|
||||||
clearGalleries()
|
|
||||||
fetchGalleries(query)
|
|
||||||
loadBlocks()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main_nav_view.setNavigationItemSelectedListener {
|
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
|
||||||
main_drawer_layout.closeDrawers()
|
|
||||||
|
|
||||||
when(it.itemId) {
|
|
||||||
R.id.main_drawer_home -> {
|
|
||||||
cancelFetch()
|
|
||||||
clearGalleries()
|
|
||||||
query = query.replace("HISTORY", "")
|
|
||||||
fetchGalleries(query)
|
|
||||||
}
|
|
||||||
R.id.main_drawer_history -> {
|
|
||||||
cancelFetch()
|
|
||||||
clearGalleries()
|
|
||||||
query += "HISTORY"
|
|
||||||
fetchGalleries(query)
|
|
||||||
}
|
|
||||||
R.id.main_drawer_help -> {
|
|
||||||
AlertDialog.Builder(this@MainActivity).apply {
|
|
||||||
title = getString(R.string.help_dialog_title)
|
|
||||||
setMessage(R.string.help_dialog_message)
|
|
||||||
|
|
||||||
setPositiveButton(android.R.string.ok) { _, _ -> }
|
|
||||||
}.show()
|
|
||||||
}
|
|
||||||
R.id.main_drawer_github -> {
|
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.github))))
|
|
||||||
}
|
|
||||||
R.id.main_drawer_homepage -> {
|
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.home_page))))
|
|
||||||
}
|
|
||||||
R.id.main_drawer_email -> {
|
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.email))))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
loadBlocks()
|
|
||||||
}
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
setupSearchBar()
|
|
||||||
setupRecyclerView()
|
|
||||||
fetchGalleries(query)
|
|
||||||
loadBlocks()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (main_drawer_layout.isDrawerOpen(GravityCompat.START))
|
when {
|
||||||
main_drawer_layout.closeDrawer(GravityCompat.START)
|
main_drawer_layout.isDrawerOpen(GravityCompat.START) -> main_drawer_layout.closeDrawer(GravityCompat.START)
|
||||||
else if (query.isNotEmpty()) {
|
query.isNotEmpty() -> runOnUiThread {
|
||||||
runOnUiThread {
|
|
||||||
query = ""
|
query = ""
|
||||||
findViewById<SearchInputView>(R.id.search_bar_text).setText(query, TextView.BufferType.EDITABLE)
|
findViewById<SearchInputView>(R.id.search_bar_text).setText(query, TextView.BufferType.EDITABLE)
|
||||||
|
|
||||||
@@ -148,9 +93,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
fetchGalleries(query)
|
fetchGalleries(query)
|
||||||
loadBlocks()
|
loadBlocks()
|
||||||
}
|
}
|
||||||
|
else -> super.onBackPressed()
|
||||||
}
|
}
|
||||||
else
|
|
||||||
super.onBackPressed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
@@ -243,6 +187,91 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initView() {
|
||||||
|
main_appbar_layout.addOnOffsetChangedListener(
|
||||||
|
AppBarLayout.OnOffsetChangedListener { _, p1 ->
|
||||||
|
main_searchview.translationY = p1.toFloat()
|
||||||
|
main_recyclerview.translationY = p1.toFloat()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
//SwipeRefreshLayout
|
||||||
|
with(main_swipe_layout) {
|
||||||
|
setProgressViewOffset(
|
||||||
|
false,
|
||||||
|
resources.getDimensionPixelSize(R.dimen.progress_view_start),
|
||||||
|
resources.getDimensionPixelSize(R.dimen.progress_view_offset)
|
||||||
|
)
|
||||||
|
|
||||||
|
setOnRefreshListener {
|
||||||
|
post {
|
||||||
|
cancelFetch()
|
||||||
|
clearGalleries()
|
||||||
|
fetchGalleries(query)
|
||||||
|
loadBlocks()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//NavigationView
|
||||||
|
main_nav_view.setNavigationItemSelectedListener {
|
||||||
|
runOnUiThread {
|
||||||
|
main_drawer_layout.closeDrawers()
|
||||||
|
|
||||||
|
when(it.itemId) {
|
||||||
|
R.id.main_drawer_home -> {
|
||||||
|
cancelFetch()
|
||||||
|
clearGalleries()
|
||||||
|
query = ""
|
||||||
|
mode = Mode.SEARCH
|
||||||
|
fetchGalleries(query)
|
||||||
|
loadBlocks()
|
||||||
|
}
|
||||||
|
R.id.main_drawer_history -> {
|
||||||
|
cancelFetch()
|
||||||
|
clearGalleries()
|
||||||
|
query = ""
|
||||||
|
mode = Mode.HISTORY
|
||||||
|
fetchGalleries(query)
|
||||||
|
loadBlocks()
|
||||||
|
}
|
||||||
|
R.id.main_drawer_downloads -> {
|
||||||
|
cancelFetch()
|
||||||
|
clearGalleries()
|
||||||
|
query = ""
|
||||||
|
mode = Mode.DOWNLOAD
|
||||||
|
fetchGalleries(query)
|
||||||
|
loadBlocks()
|
||||||
|
}
|
||||||
|
R.id.main_drawer_help -> {
|
||||||
|
AlertDialog.Builder(this@MainActivity).apply {
|
||||||
|
title = getString(R.string.help_dialog_title)
|
||||||
|
setMessage(R.string.help_dialog_message)
|
||||||
|
|
||||||
|
setPositiveButton(android.R.string.ok) { _, _ -> }
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
R.id.main_drawer_github -> {
|
||||||
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.github))))
|
||||||
|
}
|
||||||
|
R.id.main_drawer_homepage -> {
|
||||||
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.home_page))))
|
||||||
|
}
|
||||||
|
R.id.main_drawer_email -> {
|
||||||
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.email))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
setupSearchBar()
|
||||||
|
setupRecyclerView()
|
||||||
|
fetchGalleries(query)
|
||||||
|
loadBlocks()
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupRecyclerView() {
|
private fun setupRecyclerView() {
|
||||||
with(main_recyclerview) {
|
with(main_recyclerview) {
|
||||||
adapter = GalleryBlockAdapter(galleries).apply {
|
adapter = GalleryBlockAdapter(galleries).apply {
|
||||||
@@ -281,8 +310,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
//TODO: Maybe sprinke some transitions will be nice :D
|
//TODO: Maybe sprinke some transitions will be nice :D
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
|
|
||||||
Histories.default.add(gallery.id)
|
histories.add(gallery.id)
|
||||||
}.setOnItemLongClickListener { recyclerView, position, v ->
|
}.setOnItemLongClickListener { recyclerView, position, _ ->
|
||||||
val galleryBlock = galleries[position].first
|
val galleryBlock = galleries[position].first
|
||||||
val view = LayoutInflater.from(this@MainActivity)
|
val view = LayoutInflater.from(this@MainActivity)
|
||||||
.inflate(R.layout.dialog_galleryblock, recyclerView, false)
|
.inflate(R.layout.dialog_galleryblock, recyclerView, false)
|
||||||
@@ -301,7 +330,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val downloader = GalleryDownloader.get(galleryBlock.id)
|
val downloader = GalleryDownloader.get(galleryBlock.id)
|
||||||
if (downloader == null) {
|
if (downloader == null) {
|
||||||
GalleryDownloader(context, galleryBlock, true).start()
|
GalleryDownloader(context, galleryBlock, true).start()
|
||||||
Histories.default.add(galleryBlock.id)
|
downloads.add(galleryBlock.id)
|
||||||
} else {
|
} else {
|
||||||
downloader.cancel()
|
downloader.cancel()
|
||||||
downloader.clearNotification()
|
downloader.clearNotification()
|
||||||
@@ -489,13 +518,33 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return
|
return
|
||||||
|
|
||||||
galleryIDs = CoroutineScope(Dispatchers.IO).async {
|
galleryIDs = CoroutineScope(Dispatchers.IO).async {
|
||||||
when {
|
when(mode) {
|
||||||
query.contains("HISTORY") ->
|
Mode.SEARCH -> {
|
||||||
Histories.default.toList()
|
when {
|
||||||
query.isEmpty() and defaultQuery.isEmpty() ->
|
query.isEmpty() and defaultQuery.isEmpty() ->
|
||||||
fetchNozomi(start = from, count = perPage)
|
fetchNozomi(start = from, count = perPage)
|
||||||
else ->
|
else ->
|
||||||
doSearch("$defaultQuery $query")
|
doSearch("$defaultQuery $query")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Mode.HISTORY -> {
|
||||||
|
when {
|
||||||
|
query.isEmpty() -> histories.toList()
|
||||||
|
else -> {
|
||||||
|
val result = doSearch(query).sorted()
|
||||||
|
histories.filter { result.binarySearch(it) >= 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Mode.DOWNLOAD -> {
|
||||||
|
when {
|
||||||
|
query.isEmpty() -> downloads.toList()
|
||||||
|
else -> {
|
||||||
|
val result = doSearch(query).sorted()
|
||||||
|
downloads.filter { result.binarySearch(it) >= 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,17 +6,23 @@ import android.app.NotificationManager
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.preference.PreferenceManager
|
import android.preference.PreferenceManager
|
||||||
import android.util.SparseArray
|
import androidx.core.content.ContextCompat
|
||||||
import com.finotes.android.finotescore.Fn
|
import com.finotes.android.finotescore.Fn
|
||||||
import com.finotes.android.finotescore.ObservableApplication
|
import com.finotes.android.finotescore.ObservableApplication
|
||||||
import com.finotes.android.finotescore.Severity
|
import xyz.quaver.pupil.util.Histories
|
||||||
import kotlinx.coroutines.Job
|
import java.io.File
|
||||||
|
|
||||||
class Pupil : ObservableApplication() {
|
class Pupil : ObservableApplication() {
|
||||||
|
|
||||||
|
lateinit var histories: Histories
|
||||||
|
lateinit var downloads: Histories
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
val preference = PreferenceManager.getDefaultSharedPreferences(this)
|
val preference = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
|
||||||
|
histories = Histories(File(ContextCompat.getDataDir(this), "histories.json"))
|
||||||
|
downloads = Histories(File(ContextCompat.getDataDir(this), "downloads.json"))
|
||||||
|
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
Fn.init(this)
|
Fn.init(this)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package xyz.quaver.pupil
|
|||||||
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -63,7 +62,7 @@ class ReaderActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
initView()
|
initView()
|
||||||
|
|
||||||
if (!downloader.notify)
|
if (!downloader.download)
|
||||||
downloader.start()
|
downloader.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +112,7 @@ class ReaderActivity : AppCompatActivity() {
|
|||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
|
||||||
if (!downloader.notify)
|
if (!downloader.download)
|
||||||
downloader.cancel()
|
downloader.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,18 +158,19 @@ class ReaderActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onDownloadedHandler = {
|
onDownloadedHandler = {
|
||||||
|
val item = it.toList()
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
if (images.isEmpty()) {
|
if (images.isEmpty()) {
|
||||||
images.addAll(it)
|
images.addAll(item)
|
||||||
reader_recyclerview.adapter?.notifyDataSetChanged()
|
reader_recyclerview.adapter?.notifyDataSetChanged()
|
||||||
} else {
|
} else {
|
||||||
images.add(it.last())
|
images.add(item.last())
|
||||||
reader_recyclerview.adapter?.notifyItemInserted(images.size-1)
|
reader_recyclerview.adapter?.notifyItemInserted(images.size-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onErrorHandler = {
|
onErrorHandler = {
|
||||||
downloader.notify = false
|
downloader.download = false
|
||||||
}
|
}
|
||||||
onCompleteHandler = {
|
onCompleteHandler = {
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
@@ -184,7 +184,7 @@ class ReaderActivity : AppCompatActivity() {
|
|||||||
val icon = AnimatedVectorDrawableCompat.create(this, R.drawable.ic_downloading)
|
val icon = AnimatedVectorDrawableCompat.create(this, R.drawable.ic_downloading)
|
||||||
icon?.registerAnimationCallback(object: Animatable2Compat.AnimationCallback() {
|
icon?.registerAnimationCallback(object: Animatable2Compat.AnimationCallback() {
|
||||||
override fun onAnimationEnd(drawable: Drawable?) {
|
override fun onAnimationEnd(drawable: Drawable?) {
|
||||||
if (downloader.notify)
|
if (downloader.download)
|
||||||
fab.post {
|
fab.post {
|
||||||
icon.start()
|
icon.start()
|
||||||
fab.labelText = getString(R.string.reader_fab_download_cancel)
|
fab.labelText = getString(R.string.reader_fab_download_cancel)
|
||||||
@@ -205,7 +205,7 @@ class ReaderActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (downloader.notify) {
|
if (downloader.download) {
|
||||||
downloader.invokeOnReaderLoaded()
|
downloader.invokeOnReaderLoaded()
|
||||||
downloader.invokeOnNotifyChanged()
|
downloader.invokeOnNotifyChanged()
|
||||||
}
|
}
|
||||||
@@ -255,9 +255,9 @@ class ReaderActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reader_fab_download.setOnClickListener {
|
reader_fab_download.setOnClickListener {
|
||||||
downloader.notify = !downloader.notify
|
downloader.download = !downloader.download
|
||||||
|
|
||||||
if (!downloader.notify)
|
if (!downloader.download)
|
||||||
downloader.clearNotification()
|
downloader.clearNotification()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import androidx.preference.Preference
|
|||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import kotlinx.android.synthetic.main.dialog_default_query.view.*
|
import kotlinx.android.synthetic.main.dialog_default_query.view.*
|
||||||
import xyz.quaver.pupil.types.Tags
|
import xyz.quaver.pupil.types.Tags
|
||||||
import xyz.quaver.pupil.util.Histories
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class SettingsActivity : AppCompatActivity() {
|
class SettingsActivity : AppCompatActivity() {
|
||||||
@@ -99,7 +98,7 @@ class SettingsActivity : AppCompatActivity() {
|
|||||||
with(findPreference<Preference>("clear_history")) {
|
with(findPreference<Preference>("clear_history")) {
|
||||||
this ?: return@with
|
this ?: return@with
|
||||||
|
|
||||||
val histories = Histories.default
|
val histories = (activity!!.application as Pupil).histories
|
||||||
|
|
||||||
summary = getString(R.string.settings_clear_history_summary, histories.size)
|
summary = getString(R.string.settings_clear_history_summary, histories.size)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package xyz.quaver.pupil.adapters
|
package xyz.quaver.pupil.adapters
|
||||||
|
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.graphics.PorterDuff
|
|
||||||
import android.util.Log
|
|
||||||
import android.util.SparseArray
|
import android.util.SparseArray
|
||||||
import android.util.SparseBooleanArray
|
import android.util.SparseBooleanArray
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ class ReaderAdapter(private val images: List<String>) : RecyclerView.Adapter<Rea
|
|||||||
|
|
||||||
val image = BitmapFactory.decodeFile(images[position], options)
|
val image = BitmapFactory.decodeFile(images[position], options)
|
||||||
|
|
||||||
launch(Dispatchers.Main) {
|
post { setImageBitmap(image) }
|
||||||
setImageBitmap(image)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class GalleryDownloader(
|
|||||||
_notify: Boolean = false
|
_notify: Boolean = false
|
||||||
) : ContextWrapper(base) {
|
) : ContextWrapper(base) {
|
||||||
|
|
||||||
var notify: Boolean = false
|
var download: Boolean = false
|
||||||
set(value) {
|
set(value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
field = true
|
field = true
|
||||||
@@ -67,7 +67,7 @@ class GalleryDownloader(
|
|||||||
initNotification()
|
initNotification()
|
||||||
|
|
||||||
reader = CoroutineScope(Dispatchers.IO).async {
|
reader = CoroutineScope(Dispatchers.IO).async {
|
||||||
notify = _notify
|
download = _notify
|
||||||
val json = Json(JsonConfiguration.Stable)
|
val json = Json(JsonConfiguration.Stable)
|
||||||
val serializer = ReaderItem.serializer().list
|
val serializer = ReaderItem.serializer().list
|
||||||
val preference = PreferenceManager.getDefaultSharedPreferences(this@GalleryDownloader)
|
val preference = PreferenceManager.getDefaultSharedPreferences(this@GalleryDownloader)
|
||||||
@@ -138,7 +138,7 @@ class GalleryDownloader(
|
|||||||
.setProgress(reader.size, index, false)
|
.setProgress(reader.size, index, false)
|
||||||
.setContentText("$index/${reader.size}")
|
.setContentText("$index/${reader.size}")
|
||||||
|
|
||||||
if (notify)
|
if (download)
|
||||||
notificationManager.notify(galleryBlock.id, notificationBuilder.build())
|
notificationManager.notify(galleryBlock.id, notificationBuilder.build())
|
||||||
|
|
||||||
async(Dispatchers.IO) {
|
async(Dispatchers.IO) {
|
||||||
@@ -188,10 +188,10 @@ class GalleryDownloader(
|
|||||||
.setContentText(getString(R.string.reader_notification_complete))
|
.setContentText(getString(R.string.reader_notification_complete))
|
||||||
.setProgress(0, 0, false)
|
.setProgress(0, 0, false)
|
||||||
|
|
||||||
if (notify)
|
if (download)
|
||||||
notificationManager.notify(galleryBlock.id, notificationBuilder.build())
|
notificationManager.notify(galleryBlock.id, notificationBuilder.build())
|
||||||
|
|
||||||
notify = false
|
download = false
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(galleryBlock.id)
|
remove(galleryBlock.id)
|
||||||
@@ -219,7 +219,7 @@ class GalleryDownloader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun invokeOnNotifyChanged() {
|
fun invokeOnNotifyChanged() {
|
||||||
onNotifyChangedHandler?.invoke(notify)
|
onNotifyChangedHandler?.invoke(download)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initNotification() {
|
private fun initNotification() {
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ class Histories(private val file: File) : ArrayList<Int>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
lateinit var default: Histories
|
|
||||||
}
|
|
||||||
|
|
||||||
@UseExperimental(ImplicitReflectionSerializer::class)
|
@UseExperimental(ImplicitReflectionSerializer::class)
|
||||||
fun load() : Histories {
|
fun load() : Histories {
|
||||||
return apply {
|
return apply {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package xyz.quaver.pupil.util
|
package xyz.quaver.pupil.util
|
||||||
|
|
||||||
import kotlinx.io.IOException
|
|
||||||
import kotlinx.serialization.json.*
|
import kotlinx.serialization.json.*
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
<item android:id="@+id/main_drawer_history"
|
<item android:id="@+id/main_drawer_history"
|
||||||
android:title="@string/main_drawer_history"
|
android:title="@string/main_drawer_history"
|
||||||
android:icon="@drawable/ic_history"/>
|
android:icon="@drawable/ic_history"/>
|
||||||
|
|
||||||
|
<item android:id="@+id/main_drawer_downloads"
|
||||||
|
android:title="@string/main_drawer_downloads"
|
||||||
|
android:icon="@drawable/ic_download"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<item android:title="@string/main_drawer_group_contact_title">
|
<item android:title="@string/main_drawer_group_contact_title">
|
||||||
|
|||||||
@@ -52,4 +52,5 @@
|
|||||||
<string name="reader_notification_error">ダウンロードエラー</string>
|
<string name="reader_notification_error">ダウンロードエラー</string>
|
||||||
<string name="reader_fab_download_cancel">バックグラウンドダウンロード中止</string>
|
<string name="reader_fab_download_cancel">バックグラウンドダウンロード中止</string>
|
||||||
<string name="main_dialog_delete">このギャラリーを削除</string>
|
<string name="main_dialog_delete">このギャラリーを削除</string>
|
||||||
|
<string name="main_drawer_downloads">ダウンロード</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -52,4 +52,5 @@
|
|||||||
<string name="reader_notification_error">다운로드 오류</string>
|
<string name="reader_notification_error">다운로드 오류</string>
|
||||||
<string name="reader_fab_download_cancel">백그라운드 다운로드 취소</string>
|
<string name="reader_fab_download_cancel">백그라운드 다운로드 취소</string>
|
||||||
<string name="main_dialog_delete">갤러리 삭제</string>
|
<string name="main_dialog_delete">갤러리 삭제</string>
|
||||||
|
<string name="main_drawer_downloads">다운로드</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
<string name="main_drawer_home">Home</string>
|
<string name="main_drawer_home">Home</string>
|
||||||
<string name="main_drawer_history">History</string>
|
<string name="main_drawer_history">History</string>
|
||||||
|
<string name="main_drawer_downloads">Downloads</string>
|
||||||
<string name="main_drawer_group_contact_title">Contact</string>
|
<string name="main_drawer_group_contact_title">Contact</string>
|
||||||
<string name="main_drawer_group_contact_help">Help</string>
|
<string name="main_drawer_group_contact_help">Help</string>
|
||||||
<string name="main_drawer_group_contact_homepage">Visit homepage</string>
|
<string name="main_drawer_group_contact_homepage">Visit homepage</string>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven { url "https://jitpack.io" }
|
||||||
maven {
|
maven {
|
||||||
url "s3://finotescore-android/release"
|
url "s3://finotescore-android/release"
|
||||||
credentials(AwsCredentials) {
|
credentials(AwsCredentials) {
|
||||||
|
|||||||
Reference in New Issue
Block a user