Bug fix
Remember thin mode preference TagChip favorites
This commit is contained in:
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -61,5 +61,10 @@
|
|||||||
<option name="name" value="MavenLocal" />
|
<option name="name" value="MavenLocal" />
|
||||||
<option name="url" value="file:/$USER_HOME$/.m2/repository" />
|
<option name="url" value="file:/$USER_HOME$/.m2/repository" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven3" />
|
||||||
|
<option name="name" value="maven3" />
|
||||||
|
<option name="url" value="https://dl.bintray.com/tom5079/maven" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -64,7 +64,7 @@ dependencies {
|
|||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
|
||||||
//implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC"
|
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC2"
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation "androidx.activity:activity-ktx:1.2.0-alpha08"
|
implementation "androidx.activity:activity-ktx:1.2.0-alpha08"
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.3.0-alpha08'
|
implementation 'androidx.fragment:fragment-ktx:1.3.0-alpha08'
|
||||||
@@ -88,6 +88,9 @@ dependencies {
|
|||||||
implementation ("com.github.bumptech.glide:okhttp3-integration:4.11.0") {
|
implementation ("com.github.bumptech.glide:okhttp3-integration:4.11.0") {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
|
implementation ("com.github.bumptech.glide:recyclerview-integration:4.11.0") {
|
||||||
|
transitive = false
|
||||||
|
}
|
||||||
implementation 'com.github.bumptech.glide:annotations:4.11.0'
|
implementation 'com.github.bumptech.glide:annotations:4.11.0'
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||||
kapt 'com.github.bumptech.glide:compiler:4.11.0'
|
kapt 'com.github.bumptech.glide:compiler:4.11.0'
|
||||||
@@ -105,7 +108,7 @@ dependencies {
|
|||||||
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-serialization-core-jvm'
|
exclude group: 'org.jetbrains.kotlinx', module: 'kotlinx-serialization-core-jvm'
|
||||||
}
|
}
|
||||||
implementation "xyz.quaver:documentfilex:0.2.15"
|
implementation "xyz.quaver:documentfilex:0.2.15"
|
||||||
implementation "xyz.quaver:floatingsearchview:1.0"
|
implementation "xyz.quaver:floatingsearchview:1.0.3"
|
||||||
testImplementation 'junit:junit:4.13'
|
testImplementation 'junit:junit:4.13'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
androidTestImplementation 'androidx.test:rules:1.3.0'
|
androidTestImplementation 'androidx.test:rules:1.3.0'
|
||||||
|
|||||||
Binary file not shown.
@@ -25,6 +25,7 @@
|
|||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
tools:replace="android:theme"
|
tools:replace="android:theme"
|
||||||
|
android:largeHeap="true"
|
||||||
tools:ignore="UnusedAttribute">
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package xyz.quaver.pupil.adapters
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.util.Log
|
|
||||||
import android.util.SparseBooleanArray
|
import android.util.SparseBooleanArray
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -70,7 +69,7 @@ class GalleryBlockAdapter(private val glide: RequestManager, private val galleri
|
|||||||
|
|
||||||
val timer = Timer()
|
val timer = Timer()
|
||||||
|
|
||||||
var isThin = false
|
var thin: Boolean = Preferences["thin"]
|
||||||
|
|
||||||
inner class GalleryViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
|
inner class GalleryViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
|
||||||
var timerTask: TimerTask? = null
|
var timerTask: TimerTask? = null
|
||||||
@@ -88,7 +87,7 @@ class GalleryBlockAdapter(private val glide: RequestManager, private val galleri
|
|||||||
with(view.galleryblock_progressbar) {
|
with(view.galleryblock_progressbar) {
|
||||||
val imageList = cache.metadata.imageList!!
|
val imageList = cache.metadata.imageList!!
|
||||||
|
|
||||||
progress = imageList.filterNotNull().size
|
progress = imageList.count { it != null }
|
||||||
max = imageList.size
|
max = imageList.size
|
||||||
|
|
||||||
with(view.galleryblock_progressbar_layout) {
|
with(view.galleryblock_progressbar_layout) {
|
||||||
@@ -96,7 +95,7 @@ class GalleryBlockAdapter(private val glide: RequestManager, private val galleri
|
|||||||
visibility = View.VISIBLE
|
visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progress == max) {
|
if (!imageList.contains(null)) {
|
||||||
val downloadManager = DownloadManager.getInstance(context)
|
val downloadManager = DownloadManager.getInstance(context)
|
||||||
|
|
||||||
if (completeFlag.get(galleryID, false)) {
|
if (completeFlag.get(galleryID, false)) {
|
||||||
@@ -143,7 +142,7 @@ class GalleryBlockAdapter(private val glide: RequestManager, private val galleri
|
|||||||
val artists = galleryBlock.artists
|
val artists = galleryBlock.artists
|
||||||
val series = galleryBlock.series
|
val series = galleryBlock.series
|
||||||
|
|
||||||
if (isThin)
|
if (thin)
|
||||||
galleryblock_thumbnail.layoutParams.width = context.resources.getDimensionPixelSize(
|
galleryblock_thumbnail.layoutParams.width = context.resources.getDimensionPixelSize(
|
||||||
R.dimen.galleryblock_thumbnail_thin
|
R.dimen.galleryblock_thumbnail_thin
|
||||||
)
|
)
|
||||||
@@ -273,7 +272,7 @@ class GalleryBlockAdapter(private val glide: RequestManager, private val galleri
|
|||||||
|
|
||||||
|
|
||||||
// Make some views invisible to make it thinner
|
// Make some views invisible to make it thinner
|
||||||
if (isThin) {
|
if (thin) {
|
||||||
galleryblock_language.visibility = View.GONE
|
galleryblock_language.visibility = View.GONE
|
||||||
galleryblock_type.visibility = View.GONE
|
galleryblock_type.visibility = View.GONE
|
||||||
galleryblock_tag_group.visibility = View.GONE
|
galleryblock_tag_group.visibility = View.GONE
|
||||||
|
|||||||
@@ -311,25 +311,15 @@ class DownloadService : Service() {
|
|||||||
|
|
||||||
progress.put(galleryID, MutableList(reader.galleryInfo.files.size) { 0F })
|
progress.put(galleryID, MutableList(reader.galleryInfo.files.size) { 0F })
|
||||||
|
|
||||||
FirebaseCrashlytics.getInstance().log(
|
|
||||||
"""
|
|
||||||
GALLERYID: $galleryID
|
|
||||||
CACHE: ${cache.findFile(".metadata")}
|
|
||||||
PATTERN: ${Preferences["download_folder_name", ""]}
|
|
||||||
READER ID: ${reader.galleryInfo.id}
|
|
||||||
READER SIZE: ${reader.galleryInfo.files.size}
|
|
||||||
CACHE READER ID: ${cache.metadata.reader?.galleryInfo?.id}}
|
|
||||||
CACHE READER SIZE: ${cache.metadata.reader?.galleryInfo?.files?.size}
|
|
||||||
""".trimIndent()
|
|
||||||
)
|
|
||||||
|
|
||||||
cache.metadata.imageList?.let {
|
cache.metadata.imageList?.let {
|
||||||
if (progress[galleryID]?.size != it.size) {
|
if (progress[galleryID]?.size != it.size) {
|
||||||
cache.metadata.imageList?.filterNotNull()?.forEach { file ->
|
FirebaseCrashlytics.getInstance().log(
|
||||||
cache.findFile(file)?.delete()
|
"""
|
||||||
}
|
GALLERYID: $galleryID
|
||||||
cache.metadata.imageList = MutableList(reader.galleryInfo.files.size) { null }
|
${it.size} - ${progress[galleryID]?.size}
|
||||||
return@let
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
error("ImageList Size does not match")
|
||||||
}
|
}
|
||||||
|
|
||||||
it.forEachIndexed { index, image ->
|
it.forEachIndexed { index, image ->
|
||||||
@@ -361,7 +351,17 @@ class DownloadService : Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.requestBuilders.forEachIndexed { index, it ->
|
reader.requestBuilders.also {
|
||||||
|
if (it.size != progress[galleryID]?.size) {
|
||||||
|
FirebaseCrashlytics.getInstance().log(
|
||||||
|
"""
|
||||||
|
GALLERYID: $galleryID
|
||||||
|
${it.size} - ${progress[galleryID]?.size}
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
error("Requests Size does not match")
|
||||||
|
}
|
||||||
|
}.forEachIndexed { index, it ->
|
||||||
if (progress[galleryID]?.get(index)?.isInfinite() != true) {
|
if (progress[galleryID]?.get(index)?.isInfinite() != true) {
|
||||||
val request = it.tag(Tag(galleryID, index, startId)).build()
|
val request = it.tag(Tag(galleryID, index, startId)).build()
|
||||||
client.newCall(request).enqueue(callback)
|
client.newCall(request).enqueue(callback)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import kotlinx.android.synthetic.main.activity_main_content.*
|
|||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import xyz.quaver.floatingsearchview.FloatingSearchView
|
import xyz.quaver.floatingsearchview.FloatingSearchView
|
||||||
import xyz.quaver.floatingsearchview.suggestions.model.SearchSuggestion
|
import xyz.quaver.floatingsearchview.suggestions.model.SearchSuggestion
|
||||||
|
import xyz.quaver.floatingsearchview.util.view.MenuView
|
||||||
import xyz.quaver.floatingsearchview.util.view.SearchInputView
|
import xyz.quaver.floatingsearchview.util.view.SearchInputView
|
||||||
import xyz.quaver.hitomi.doSearch
|
import xyz.quaver.hitomi.doSearch
|
||||||
import xyz.quaver.hitomi.getGalleryIDsFromNozomi
|
import xyz.quaver.hitomi.getGalleryIDsFromNozomi
|
||||||
@@ -635,6 +636,14 @@ class MainActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
findViewById<MenuView>(R.id.menu_view).menuItems.firstOrNull {
|
||||||
|
(it as MenuItem).itemId == R.id.main_menu_thin
|
||||||
|
}?.let {
|
||||||
|
(it as MenuItem).isChecked = Preferences["thin"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onHistoryDeleteClickedListener = {
|
onHistoryDeleteClickedListener = {
|
||||||
searchHistory.remove(it)
|
searchHistory.remove(it)
|
||||||
swapSuggestions(defaultSuggestions)
|
swapSuggestions(defaultSuggestions)
|
||||||
@@ -709,9 +718,14 @@ class MainActivity :
|
|||||||
when(item?.itemId) {
|
when(item?.itemId) {
|
||||||
R.id.main_menu_settings -> startActivityForResult(Intent(this@MainActivity, SettingsActivity::class.java), R.id.request_settings.normalizeID())
|
R.id.main_menu_settings -> startActivityForResult(Intent(this@MainActivity, SettingsActivity::class.java), R.id.request_settings.normalizeID())
|
||||||
R.id.main_menu_thin -> {
|
R.id.main_menu_thin -> {
|
||||||
|
val thin = !item.isChecked
|
||||||
|
|
||||||
|
item.isChecked = thin
|
||||||
main_recyclerview.apply {
|
main_recyclerview.apply {
|
||||||
(adapter as GalleryBlockAdapter).apply {
|
(adapter as GalleryBlockAdapter).apply {
|
||||||
isThin = !isThin
|
this.thin = thin
|
||||||
|
|
||||||
|
Preferences["thin"] = thin
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter = adapter // Force to redraw
|
adapter = adapter // Force to redraw
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import android.content.Context
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import xyz.quaver.pupil.R
|
import xyz.quaver.pupil.R
|
||||||
|
import xyz.quaver.pupil.favoriteTags
|
||||||
import xyz.quaver.pupil.types.Tag
|
import xyz.quaver.pupil.types.Tag
|
||||||
import xyz.quaver.pupil.util.wordCapitalize
|
import xyz.quaver.pupil.util.wordCapitalize
|
||||||
|
|
||||||
@@ -56,6 +57,34 @@ class TagChip(context: Context, tag: Tag) : Chip(context) {
|
|||||||
ContextCompat.getDrawable(context, R.drawable.gender_female_white)
|
ContextCompat.getDrawable(context, R.drawable.gender_female_white)
|
||||||
}
|
}
|
||||||
else -> null
|
else -> null
|
||||||
|
}.also {
|
||||||
|
if (favoriteTags.contains(tag))
|
||||||
|
setChipBackgroundColorResource(R.color.material_orange_500)
|
||||||
|
}
|
||||||
|
|
||||||
|
isCloseIconVisible = true
|
||||||
|
closeIcon = ContextCompat.getDrawable(context,
|
||||||
|
if (favoriteTags.contains(tag))
|
||||||
|
R.drawable.ic_star_filled
|
||||||
|
else
|
||||||
|
R.drawable.ic_star_empty
|
||||||
|
)
|
||||||
|
|
||||||
|
setOnCloseIconClickListener {
|
||||||
|
if (favoriteTags.contains(tag)) {
|
||||||
|
favoriteTags.remove(tag)
|
||||||
|
closeIcon = ContextCompat.getDrawable(context, R.drawable.ic_star_empty)
|
||||||
|
|
||||||
|
when(tag.area) {
|
||||||
|
"male" -> setChipBackgroundColorResource(R.color.material_blue_700)
|
||||||
|
"female" -> setChipBackgroundColorResource(R.color.material_pink_600)
|
||||||
|
else -> chipBackgroundColor = null
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
favoriteTags.add(tag)
|
||||||
|
closeIcon = ContextCompat.getDrawable(context, R.drawable.ic_star_filled)
|
||||||
|
setChipBackgroundColorResource(R.color.material_orange_500)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text = when (tag.area) {
|
text = when (tag.area) {
|
||||||
|
|||||||
@@ -212,7 +212,9 @@ class Cache private constructor(context: Context, val galleryID: Int) : ContextW
|
|||||||
return@forEach
|
return@forEach
|
||||||
|
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
target.createNewFile()
|
if (!target.exists())
|
||||||
|
target.createNewFile()
|
||||||
|
|
||||||
target.outputStream()?.use { target -> source.inputStream()?.use { source ->
|
target.outputStream()?.use { target -> source.inputStream()?.use { source ->
|
||||||
source.copyTo(target)
|
source.copyTo(target)
|
||||||
} }
|
} }
|
||||||
@@ -224,7 +226,9 @@ class Cache private constructor(context: Context, val galleryID: Int) : ContextW
|
|||||||
|
|
||||||
if (cacheThumbnail.exists() && !downloadThumbnail.exists()) {
|
if (cacheThumbnail.exists() && !downloadThumbnail.exists()) {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
downloadThumbnail.createNewFile()
|
if (!downloadThumbnail.exists())
|
||||||
|
downloadThumbnail.createNewFile()
|
||||||
|
|
||||||
downloadThumbnail.outputStream()?.use { target -> cacheThumbnail.inputStream()?.use { source ->
|
downloadThumbnail.outputStream()?.use { target -> cacheThumbnail.inputStream()?.use { source ->
|
||||||
source.copyTo(target)
|
source.copyTo(target)
|
||||||
} }
|
} }
|
||||||
@@ -237,7 +241,9 @@ class Cache private constructor(context: Context, val galleryID: Int) : ContextW
|
|||||||
|
|
||||||
if (cacheMetadata.exists() && !downloadMetadata.exists()) {
|
if (cacheMetadata.exists() && !downloadMetadata.exists()) {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
downloadMetadata.createNewFile()
|
if (!downloadMetadata.exists())
|
||||||
|
downloadMetadata.createNewFile()
|
||||||
|
|
||||||
downloadMetadata.writeText(Json.encodeToString(metadata))
|
downloadMetadata.writeText(Json.encodeToString(metadata))
|
||||||
cacheMetadata.delete()
|
cacheMetadata.delete()
|
||||||
}
|
}
|
||||||
|
|||||||
8
app/src/main/res/drawable/sort_variant.xml
Normal file
8
app/src/main/res/drawable/sort_variant.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<!-- drawable/sort_variant.xml -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:height="24dp"
|
||||||
|
android:width="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path android:fillColor="#000" android:pathData="M3,13H15V11H3M3,6V8H21V6M3,18H9V16H3V18Z" />
|
||||||
|
</vector>
|
||||||
@@ -20,10 +20,10 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item android:id="@+id/main_menu_thin"
|
<item android:id="@+id/sort"
|
||||||
android:title="@string/main_menu_thin"/>
|
android:title="@string/main_menu_sort"
|
||||||
|
android:icon="@drawable/sort_variant"
|
||||||
<item android:title="@string/main_menu_sort">
|
app:showAsAction="ifRoom">
|
||||||
<menu>
|
<menu>
|
||||||
<group android:checkableBehavior="single">
|
<group android:checkableBehavior="single">
|
||||||
<item android:id="@+id/main_menu_sort_newest"
|
<item android:id="@+id/main_menu_sort_newest"
|
||||||
@@ -41,4 +41,9 @@
|
|||||||
android:title="@string/main_settings"
|
android:title="@string/main_settings"
|
||||||
app:showAsAction="always"/>
|
app:showAsAction="always"/>
|
||||||
|
|
||||||
|
<item android:id="@+id/main_menu_thin"
|
||||||
|
android:title="@string/main_menu_thin"
|
||||||
|
app:showAsAction="never"
|
||||||
|
android:checkable="true"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
<string name="proxy_dialog_error">잘못된 값</string>
|
<string name="proxy_dialog_error">잘못된 값</string>
|
||||||
<string name="proxy_dialog_addr_hint">서버 주소</string>
|
<string name="proxy_dialog_addr_hint">서버 주소</string>
|
||||||
<string name="proxy_dialog_server">서버</string>
|
<string name="proxy_dialog_server">서버</string>
|
||||||
<string name="main_menu_thin">간단히 보기 모드</string>
|
<string name="main_menu_thin">간단히 보기</string>
|
||||||
<string name="main_fab_cancel">다운로드 모두 취소</string>
|
<string name="main_fab_cancel">다운로드 모두 취소</string>
|
||||||
<string name="channel_update">업데이트</string>
|
<string name="channel_update">업데이트</string>
|
||||||
<string name="channel_update_description">업데이트 진행상황 표시</string>
|
<string name="channel_update_description">업데이트 진행상황 표시</string>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
<string name="main_drawer_group_contact_email">Email me!</string>
|
<string name="main_drawer_group_contact_email">Email me!</string>
|
||||||
<string name="main_drawer_grouop_contact_discord">Discord</string>
|
<string name="main_drawer_grouop_contact_discord">Discord</string>
|
||||||
|
|
||||||
<string name="main_menu_thin">Toggle Thin Mode</string>
|
<string name="main_menu_thin">Thin Mode</string>
|
||||||
|
|
||||||
<string name="main_menu_sort">Sort</string>
|
<string name="main_menu_sort">Sort</string>
|
||||||
<string name="main_menu_sort_newest">Newest</string>
|
<string name="main_menu_sort_newest">Newest</string>
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenLocal()
|
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
maven { url 'https://guardian.github.com/maven/repo-releases' }
|
maven { url 'https://guardian.github.com/maven/repo-releases' }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user