diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt
index 0deb4c02a..cab4a9628 100644
--- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt
+++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt
@@ -172,8 +172,9 @@ fun Throwable.getCauseUrl(): String? = when (this) {
}
private fun getHttpDisplayMessage(statusCode: Int, resources: Resources): String? = when (statusCode) {
- 404 -> resources.getString(R.string.not_found_404)
- 403 -> resources.getString(R.string.access_denied_403)
+ HttpURLConnection.HTTP_NOT_FOUND -> resources.getString(R.string.not_found_404)
+ HttpURLConnection.HTTP_FORBIDDEN -> resources.getString(R.string.access_denied_403)
+ HttpURLConnection.HTTP_GATEWAY_TIMEOUT -> resources.getString(R.string.network_unavailable)
in 500..599 -> resources.getString(R.string.server_error, statusCode)
else -> null
}
diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/CoverImageView.kt b/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/CoverImageView.kt
index 0b6f8be25..6ab8c74e6 100644
--- a/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/CoverImageView.kt
+++ b/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/CoverImageView.kt
@@ -1,13 +1,16 @@
package org.koitharu.kotatsu.image.ui
import android.content.Context
+import android.graphics.drawable.LayerDrawable
import android.os.Build
import android.util.AttributeSet
+import android.view.Gravity
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.ViewTreeObserver.OnPreDrawListener
import androidx.annotation.AttrRes
import androidx.annotation.RequiresApi
+import androidx.core.content.ContextCompat
import androidx.core.content.withStyledAttributes
import androidx.core.graphics.ColorUtils
import androidx.core.graphics.drawable.toDrawable
@@ -33,6 +36,7 @@ import org.koitharu.kotatsu.core.ui.image.TrimTransformation
import org.koitharu.kotatsu.core.util.ext.bookmarkExtra
import org.koitharu.kotatsu.core.util.ext.decodeRegion
import org.koitharu.kotatsu.core.util.ext.getThemeColor
+import org.koitharu.kotatsu.core.util.ext.isNetworkError
import org.koitharu.kotatsu.core.util.ext.mangaExtra
import org.koitharu.kotatsu.core.util.ext.mangaSourceExtra
import org.koitharu.kotatsu.favourites.domain.model.Cover
@@ -185,8 +189,17 @@ class CoverImageView @JvmOverloads constructor(
override fun onError(request: ImageRequest, result: ErrorResult) {
super.onError(request, result)
- foreground = result.throwable.getShortMessage()?.let { text ->
- TextDrawable.create(context, text, materialR.attr.textAppearanceTitleSmall)
+ foreground = if (result.throwable.isNetworkError()) {
+ ContextCompat.getDrawable(context, R.drawable.ic_offline)?.let {
+ LayerDrawable(arrayOf(it)).apply {
+ setLayerGravity(0, Gravity.CENTER)
+ setTint(ContextCompat.getColor(context, R.color.dim_lite))
+ }
+ }
+ } else {
+ result.throwable.getShortMessage()?.let { text ->
+ TextDrawable.create(context, text, materialR.attr.textAppearanceTitleSmall)
+ }
}
}
diff --git a/app/src/main/res/drawable/ic_offline.xml b/app/src/main/res/drawable/ic_offline.xml
new file mode 100644
index 000000000..a444424ce
--- /dev/null
+++ b/app/src/main/res/drawable/ic_offline.xml
@@ -0,0 +1,11 @@
+
+
+
diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml
index 0813f4e7f..b9c85a21a 100644
--- a/app/src/main/res/values-night/colors.xml
+++ b/app/src/main/res/values-night/colors.xml
@@ -11,6 +11,7 @@
#FFF176
#E57373
#C8000000
+ #66FFFFFF
#BF360C
#FF6F00
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 1f254ab59..5d702e8b7 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -16,6 +16,7 @@
#424242
#99000000
#C8FFFFFF
+ #66000000
#E65100
#FFFFFF
#388E3C