Update page loading ui
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
package org.koitharu.kotatsu.core.exceptions
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
|
||||||
|
class NonFileUriException(
|
||||||
|
val uri: Uri,
|
||||||
|
) : IllegalArgumentException("Cannot resolve file name of \"$uri\"")
|
||||||
@@ -22,6 +22,7 @@ import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
|
|||||||
import org.koitharu.kotatsu.core.exceptions.EmptyHistoryException
|
import org.koitharu.kotatsu.core.exceptions.EmptyHistoryException
|
||||||
import org.koitharu.kotatsu.core.exceptions.IncompatiblePluginException
|
import org.koitharu.kotatsu.core.exceptions.IncompatiblePluginException
|
||||||
import org.koitharu.kotatsu.core.exceptions.NoDataReceivedException
|
import org.koitharu.kotatsu.core.exceptions.NoDataReceivedException
|
||||||
|
import org.koitharu.kotatsu.core.exceptions.NonFileUriException
|
||||||
import org.koitharu.kotatsu.core.exceptions.ProxyConfigException
|
import org.koitharu.kotatsu.core.exceptions.ProxyConfigException
|
||||||
import org.koitharu.kotatsu.core.exceptions.SyncApiException
|
import org.koitharu.kotatsu.core.exceptions.SyncApiException
|
||||||
import org.koitharu.kotatsu.core.exceptions.UnsupportedFileException
|
import org.koitharu.kotatsu.core.exceptions.UnsupportedFileException
|
||||||
@@ -91,6 +92,7 @@ private fun Throwable.getDisplayMessageOrNull(resources: Resources): String? = w
|
|||||||
is BadBackupFormatException -> resources.getString(R.string.unsupported_backup_message)
|
is BadBackupFormatException -> resources.getString(R.string.unsupported_backup_message)
|
||||||
is FileNotFoundException -> parseMessage(resources) ?: message
|
is FileNotFoundException -> parseMessage(resources) ?: message
|
||||||
is AccessDeniedException -> resources.getString(R.string.no_access_to_file)
|
is AccessDeniedException -> resources.getString(R.string.no_access_to_file)
|
||||||
|
is NonFileUriException -> resources.getString(R.string.error_non_file_uri)
|
||||||
is EmptyHistoryException -> resources.getString(R.string.history_is_empty)
|
is EmptyHistoryException -> resources.getString(R.string.history_is_empty)
|
||||||
is ProxyConfigException -> resources.getString(R.string.invalid_proxy_configuration)
|
is ProxyConfigException -> resources.getString(R.string.invalid_proxy_configuration)
|
||||||
is SyncApiException,
|
is SyncApiException,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.runInterruptible
|
import kotlinx.coroutines.runInterruptible
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import okhttp3.Cache
|
import okhttp3.Cache
|
||||||
|
import org.koitharu.kotatsu.core.exceptions.NonFileUriException
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.core.util.ext.computeSize
|
import org.koitharu.kotatsu.core.util.ext.computeSize
|
||||||
import org.koitharu.kotatsu.core.util.ext.getStorageName
|
import org.koitharu.kotatsu.core.util.ext.getStorageName
|
||||||
@@ -92,11 +93,11 @@ class LocalStorageManager @Inject constructor(
|
|||||||
getAvailableStorageDirs()
|
getAvailableStorageDirs()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun resolveUri(uri: Uri): File? = runInterruptible(Dispatchers.IO) {
|
suspend fun resolveUri(uri: Uri): File = runInterruptible(Dispatchers.IO) {
|
||||||
if (uri.isFileUri()) {
|
if (uri.isFileUri()) {
|
||||||
uri.toFile()
|
uri.toFile()
|
||||||
} else {
|
} else {
|
||||||
uri.resolveFile(context)
|
uri.resolveFile(context) ?: throw NonFileUriException(uri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ abstract class BasePageHolder<B : ViewBinding>(
|
|||||||
|
|
||||||
protected open fun onStateChanged(state: PageState) {
|
protected open fun onStateChanged(state: PageState) {
|
||||||
bindingInfo.layoutError.isVisible = state is PageState.Error
|
bindingInfo.layoutError.isVisible = state is PageState.Error
|
||||||
bindingInfo.progressBar.isGone = state.isFinalState()
|
bindingInfo.layoutProgress.isGone = state.isFinalState()
|
||||||
bindingInfo.textViewStatus.isGone = state.isFinalState()
|
|
||||||
val progress = (state as? PageState.Loading)?.progress ?: -1
|
val progress = (state as? PageState.Loading)?.progress ?: -1
|
||||||
if (progress in 0..100) {
|
if (progress in 0..100) {
|
||||||
bindingInfo.progressBar.isIndeterminate = false
|
bindingInfo.progressBar.isIndeterminate = false
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ class MangaDirectorySelectViewModel @Inject constructor(
|
|||||||
fun onCustomDirectoryPicked(uri: Uri) {
|
fun onCustomDirectoryPicked(uri: Uri) {
|
||||||
launchJob(Dispatchers.Default) {
|
launchJob(Dispatchers.Default) {
|
||||||
storageManager.takePermissions(uri)
|
storageManager.takePermissions(uri)
|
||||||
val dir = requireNotNull(storageManager.resolveUri(uri)) {
|
val dir = storageManager.resolveUri(uri)
|
||||||
"Cannot resolve file name of \"$uri\""
|
|
||||||
}
|
|
||||||
if (!dir.isWriteable()) {
|
if (!dir.isWriteable()) {
|
||||||
throw AccessDeniedException(dir)
|
throw AccessDeniedException(dir)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,7 @@ class MangaDirectoriesViewModel @Inject constructor(
|
|||||||
launchLoadingJob(Dispatchers.Default) {
|
launchLoadingJob(Dispatchers.Default) {
|
||||||
loadingJob?.cancelAndJoin()
|
loadingJob?.cancelAndJoin()
|
||||||
storageManager.takePermissions(uri)
|
storageManager.takePermissions(uri)
|
||||||
val dir = requireNotNull(storageManager.resolveUri(uri)) {
|
val dir = storageManager.resolveUri(uri)
|
||||||
"Cannot resolve file name of \"$uri\""
|
|
||||||
}
|
|
||||||
if (!dir.canRead()) {
|
if (!dir.canRead()) {
|
||||||
throw AccessDeniedException(dir)
|
throw AccessDeniedException(dir)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,34 +5,42 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:parentTag="android.widget.FrameLayout">
|
tools:parentTag="android.widget.FrameLayout">
|
||||||
|
|
||||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
<LinearLayout
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/layout_progress"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="top"
|
|
||||||
android:indeterminate="true"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:hideAnimationBehavior="escape"
|
|
||||||
app:trackCornerRadius="0dp"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView_status"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginHorizontal="60dp"
|
android:gravity="center_horizontal"
|
||||||
android:gravity="center"
|
android:orientation="vertical"
|
||||||
android:textAppearance="?textAppearanceBodyLarge"
|
android:visibility="gone"
|
||||||
tools:text="72%" />
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/badge_offset"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView_status"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAppearance="?textAppearanceBodyLarge"
|
||||||
|
tools:text="72%" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/layout_error"
|
android:id="@+id/layout_error"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginStart="60dp"
|
android:layout_marginStart="56dp"
|
||||||
android:layout_marginEnd="60dp"
|
android:layout_marginEnd="56dp"
|
||||||
android:background="@drawable/bg_card"
|
android:background="@drawable/bg_card"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
|||||||
@@ -825,4 +825,5 @@
|
|||||||
<string name="suggestions_disabled_sources_summary">Show suggestions from all manga sources, including disabled ones</string>
|
<string name="suggestions_disabled_sources_summary">Show suggestions from all manga sources, including disabled ones</string>
|
||||||
<string name="tags_warnings">Highlight dangerous genres</string>
|
<string name="tags_warnings">Highlight dangerous genres</string>
|
||||||
<string name="tags_warnings_summary">Highlight genres that may be inappropriate for most users</string>
|
<string name="tags_warnings_summary">Highlight genres that may be inappropriate for most users</string>
|
||||||
|
<string name="error_non_file_uri">The selected path cannot be used because it does not denote a file or directory</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ collections = "1.5.0"
|
|||||||
conscrypt = "2.5.2"
|
conscrypt = "2.5.2"
|
||||||
constraintlayout = "2.2.1"
|
constraintlayout = "2.2.1"
|
||||||
coreKtx = "1.15.0"
|
coreKtx = "1.15.0"
|
||||||
coroutines = "1.10.1"
|
coroutines = "1.10.2"
|
||||||
desugar = "2.1.5"
|
desugar = "2.1.5"
|
||||||
diskLruCache = "1.5"
|
diskLruCache = "1.5"
|
||||||
fragment = "1.8.6"
|
fragment = "1.8.6"
|
||||||
@@ -30,8 +30,8 @@ markwon = "4.6.2"
|
|||||||
material = "1.13.0-alpha12"
|
material = "1.13.0-alpha12"
|
||||||
moshi = "1.15.2"
|
moshi = "1.15.2"
|
||||||
okhttp = "4.12.0"
|
okhttp = "4.12.0"
|
||||||
okio = "3.10.2"
|
okio = "3.11.0"
|
||||||
parsers = "20a24db949"
|
parsers = "e874837efb"
|
||||||
preference = "1.2.1"
|
preference = "1.2.1"
|
||||||
recyclerview = "1.4.0"
|
recyclerview = "1.4.0"
|
||||||
room = "2.6.1"
|
room = "2.6.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user