Merge pull request #60 from tom5079/Pupil-25

Pupil-25 Add option to download jpg instead of webp files
This commit is contained in:
Pupil
2020-01-22 11:08:49 +09:00
committed by GitHub
9 changed files with 42 additions and 22 deletions

View File

@@ -19,7 +19,6 @@
package xyz.quaver.pupil.ui.dialog
import android.annotation.SuppressLint
import android.app.AlertDialog
import android.content.Context
import android.os.Bundle
import android.text.Editable
@@ -27,6 +26,7 @@ import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.widget.ArrayAdapter
import androidx.appcompat.app.AlertDialog
import androidx.preference.PreferenceManager
import kotlinx.android.synthetic.main.dialog_default_query.view.*
import xyz.quaver.pupil.R

View File

@@ -137,6 +137,8 @@ class SettingsFragment :
onPositiveButtonClickListener = { newTags ->
sharedPreferences.edit().putString("default_query", newTags.toString()).apply()
summary = newTags.toString()
dismiss() //This sucks
// TODO: make dialog dissmiss itself :P
}
}.show()
}

View File

@@ -166,6 +166,8 @@ class GalleryDownloader(
fun start() {
downloadJob = CoroutineScope(Dispatchers.Default).launch {
val reader = reader!!.await() ?: return@launch
val lowQuality = PreferenceManager.getDefaultSharedPreferences(this@GalleryDownloader)
.getBoolean("low_quality", false)
notificationBuilder.setContentTitle(reader.title)
@@ -177,15 +179,15 @@ class GalleryDownloader(
.setProgress(reader.galleryInfo.size, 0, false)
.setContentText("0/${reader.galleryInfo.size}")
reader.galleryInfo.chunked(4).forEachIndexed { chunkIndex, chunked ->
chunked.mapIndexed { i, galleryInfo ->
reader.galleryInfo.chunked(4).forEachIndexed { chunkIndex, chunk ->
chunk.mapIndexed { i, galleryInfo ->
val index = chunkIndex*4+i
async(Dispatchers.IO) {
val url = when(useHiyobi) {
true -> createImgList(galleryID, reader)[index].path
true -> createImgList(galleryID, reader, lowQuality)[index].path
false -> when {
(!galleryInfo.hash.isNullOrBlank()) and (galleryInfo.haswebp == 1) ->
(!galleryInfo.hash.isNullOrBlank()) && (galleryInfo.haswebp == 1) && lowQuality ->
urlFromUrlFromHash(galleryID, galleryInfo, "webp")
else ->
urlFromUrlFromHash(galleryID, galleryInfo)

View File

@@ -19,7 +19,6 @@
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"

View File

@@ -118,4 +118,6 @@
<string name="update_download_completed_description">ここをクリックしてアップデートを行えます</string>
<string name="settings_beta">ベータチャンネルでアップデートを受信</string>
<string name="settings_app_version_description">v%s</string>
<string name="settings_low_quality">低解像度イメージ</string>
<string name="settings_low_quality_summary">ロード速度とデータ使用料を改善するため低解像度イメージをロード</string>
</resources>

View File

@@ -118,4 +118,6 @@
<string name="update_download_completed_description">여기를 클릭해서 업데이트를 진행할 수 있습니다</string>
<string name="settings_beta">베타 채널에서 업데이트</string>
<string name="settings_app_version_description">v%s</string>
<string name="settings_low_quality">저해상도 이미지</string>
<string name="settings_low_quality_summary">로드 속도와 데이터 사용량을 줄이기 위해 저해상도 이미지를 로드</string>
</resources>

View File

@@ -140,6 +140,8 @@
<string name="settings_dl_location_removable">Removable Storage</string>
<string name="settings_dl_location_internal">Internal Storage</string>
<string name="settings_dl_location_available">%s available</string>
<string name="settings_low_quality">Low quality images</string>
<string name="settings_low_quality_summary">Load low quality images to improve load speed and data usage</string>
<!-- SETTINGS/APP LOCK -->

View File

@@ -3,12 +3,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference
app:title="@string/settings_app_version_title"
app:key="app_version"/>
app:key="app_version"
app:title="@string/settings_app_version_title"/>
<SwitchPreferenceCompat
app:title="@string/settings_beta"
app:key="beta"/>
app:key="beta"
app:title="@string/settings_beta"/>
<PreferenceCategory
app:title="@string/settings_search_title">
@@ -32,20 +32,25 @@
app:title="@string/settings_storage">
<Preference
app:title="@string/settings_clear_cache"
app:key="delete_cache"/>
app:key="delete_cache"
app:title="@string/settings_clear_cache"/>
<Preference
app:title="@string/settings_clear_downloads"
app:key="delete_downloads"/>
app:key="delete_downloads"
app:title="@string/settings_clear_downloads"/>
<Preference
app:title="@string/settings_clear_history"
app:key="clear_history"/>
app:key="clear_history"
app:title="@string/settings_clear_history"/>
<Preference
app:title="@string/settings_dl_location"
app:key="dl_location"/>
app:key="dl_location"
app:title="@string/settings_dl_location"/>
<SwitchPreferenceCompat
app:key="dl_low_quality"
app:title="@string/settings_low_quality"
app:summary="@string/settings_low_quality_summary"/>
</PreferenceCategory>
@@ -53,8 +58,8 @@
app:title="@string/settings_app_lock">
<Preference
app:title="@string/settings_app_lock_type"
app:key="app_lock"/>
app:key="app_lock"
app:title="@string/settings_app_lock_type"/>
</PreferenceCategory>