Forgot to handle error :P

This commit is contained in:
Pupil
2020-01-15 10:58:53 +09:00
parent 93228459d7
commit e0ccac13c1
6 changed files with 21 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ android {
minSdkVersion 16
targetSdkVersion 29
versionCode 32
versionName "4.3"
versionName "4.3-beta1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true

View File

@@ -151,13 +151,26 @@ fun checkUpdate(context: AppCompatActivity, force: Boolean = false) {
priority = NotificationCompat.PRIORITY_LOW
}
CoroutineScope(Dispatchers.IO).launch {
CoroutineScope(Dispatchers.IO).launch io@{
val target = File(getDownloadDirectory(context), "Pupil.apk")
try {
URL(url).download(target) { progress, fileSize ->
builder.setProgress(fileSize.toInt(), progress.toInt(), false)
notificationManager.notify(UPDATE_NOTIFICATION_ID, builder.build())
}
} catch (e: Exception) {
builder.apply {
setContentText(context.getString(R.string.update_failed))
setMessage(context.getString(R.string.update_failed_message))
setSmallIcon(android.R.drawable.stat_sys_download_done)
}
notificationManager.cancel(UPDATE_NOTIFICATION_ID)
notificationManager.notify(UPDATE_NOTIFICATION_ID, builder.build())
return@io
}
val install = Intent(Intent.ACTION_VIEW).apply {
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_GRANT_READ_URI_PERMISSION

View File

@@ -84,7 +84,7 @@
<string name="main_menu_sort_newest">投稿日時順</string>
<string name="main_menu_sort_popular">人気順</string>
<string name="update_failed">アップデートに失敗しました</string>
<string name="update_failed_message">マニュアルインストールが必要です。APKファイルは</string>
<string name="update_failed_message">アップデート中エラーが発生しました</string>
<string name="ignore_update">無視</string>
<string name="lock_corrupted">ロックファイルが破損されています。Pupilを再再インストールしてください。</string>
<string name="update_no_permission">権限がないため自動アップデートを行えません。ホームページで直接ダウンロードしてください。</string>

View File

@@ -83,8 +83,8 @@
<string name="main_menu_sort">정렬</string>
<string name="main_menu_sort_popular">인기순</string>
<string name="main_menu_sort_newest">시간순</string>
<string name="update_failed">"업데이트 "</string>
<string name="update_failed_message">수동 업데이트가 필요합니다. APK 파일은 다운로드 폴더에 있습니다.</string>
<string name="update_failed">"업데이트 에러</string>
<string name="update_failed_message">업데이트 중 에러가 발생했습니다</string>
<string name="ignore_update">무시</string>
<string name="lock_corrupted">잠금 파일이 손상되었습니다! 앱을 재설치 해 주시기 바랍니다.</string>
<string name="update_no_permission">권한이 부여되어 있지 않아 자동 업데이트를 진행할 수 없습니다. 홈페이지에서 직접 다운로드 받으시기 바랍니다.</string>

View File

@@ -28,7 +28,7 @@
<string name="https_block_alert">(Korean only)</string>
<string name="update_failed">Update failed</string>
<string name="update_failed_message">Please install manually. APK file is in the Downloads folder.</string>
<string name="update_failed_message">Please install manually by visiting github release page :{ (or try again!)</string>
<string name="update_no_permission">Cannot auto update because permission is denied. Please download manually from the webpage.</string>
<string name="ignore_update">Ignore</string>

View File

@@ -20,7 +20,6 @@ import kotlinx.serialization.Serializable
import org.jsoup.Jsoup
fun getReferer(galleryID: Int) = "https://hitomi.la/reader/$galleryID.html"
fun webpUrlFromUrl(url: String) = url.replace("/galleries/", "/webp/") + ".webp"
@Serializable
data class GalleryInfo(