mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
Merge pull request #3080 from nextcloud/feature/3061/handleUpgradeRequired
Handle outdated app version and maintenance mode
This commit is contained in:
commit
9b28bae1ff
@ -30,6 +30,7 @@ package com.nextcloud.talk.conversationlist
|
|||||||
import android.animation.AnimatorInflater
|
import android.animation.AnimatorInflater
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.SearchManager
|
import android.app.SearchManager
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
@ -562,7 +563,6 @@ class ConversationsListActivity :
|
|||||||
}, { throwable: Throwable ->
|
}, { throwable: Throwable ->
|
||||||
handleHttpExceptions(throwable)
|
handleHttpExceptions(throwable)
|
||||||
binding?.swipeRefreshLayoutView?.isRefreshing = false
|
binding?.swipeRefreshLayoutView?.isRefreshing = false
|
||||||
showErrorDialog()
|
|
||||||
dispose(roomsQueryDisposable)
|
dispose(roomsQueryDisposable)
|
||||||
}) {
|
}) {
|
||||||
dispose(roomsQueryDisposable)
|
dispose(roomsQueryDisposable)
|
||||||
@ -627,7 +627,7 @@ class ConversationsListActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showErrorDialog() {
|
private fun showErrorDialog() {
|
||||||
binding?.floatingActionButton?.let {
|
binding.floatingActionButton.let {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
|
||||||
.setIcon(
|
.setIcon(
|
||||||
viewThemeUtils.dialog.colorMaterialAlertDialogIcon(
|
viewThemeUtils.dialog.colorMaterialAlertDialogIcon(
|
||||||
@ -639,6 +639,13 @@ class ConversationsListActivity :
|
|||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setNegativeButton(R.string.close, null)
|
.setNegativeButton(R.string.close, null)
|
||||||
|
|
||||||
|
if (resources!!.getBoolean(R.bool.multiaccount_support) && userManager.users.blockingGet().size > 1) {
|
||||||
|
dialogBuilder.setPositiveButton(R.string.nc_switch_account) { _, _ ->
|
||||||
|
val newFragment: DialogFragment = ChooseAccountDialogFragment.newInstance()
|
||||||
|
newFragment.show(supportFragmentManager, ChooseAccountDialogFragment.TAG)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(it.context, dialogBuilder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(it.context, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
@ -701,9 +708,11 @@ class ConversationsListActivity :
|
|||||||
if (throwable is HttpException) {
|
if (throwable is HttpException) {
|
||||||
when (throwable.code()) {
|
when (throwable.code()) {
|
||||||
HTTP_UNAUTHORIZED -> showUnauthorizedDialog()
|
HTTP_UNAUTHORIZED -> showUnauthorizedDialog()
|
||||||
|
HTTP_CLIENT_UPGRADE_REQUIRED -> showOutdatedClientDialog()
|
||||||
|
HTTP_SERVICE_UNAVAILABLE -> showServiceUnavailableDialog(throwable)
|
||||||
else -> {
|
else -> {
|
||||||
Log.e(TAG, "Http exception in ConversationListActivity", throwable)
|
Log.e(TAG, "Http exception in ConversationListActivity", throwable)
|
||||||
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
|
showErrorDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1279,6 +1288,83 @@ class ConversationsListActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showOutdatedClientDialog() {
|
||||||
|
binding.floatingActionButton.let {
|
||||||
|
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
|
||||||
|
.setIcon(
|
||||||
|
viewThemeUtils.dialog.colorMaterialAlertDialogIcon(
|
||||||
|
context,
|
||||||
|
R.drawable.ic_info_white_24dp
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setTitle(R.string.nc_dialog_outdated_client)
|
||||||
|
.setMessage(R.string.nc_dialog_outdated_client_description)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(R.string.nc_dialog_outdated_client_option_update) { _, _ ->
|
||||||
|
try {
|
||||||
|
startActivity(
|
||||||
|
Intent(Intent.ACTION_VIEW, Uri.parse(CLIENT_UPGRADE_MARKET_LINK + packageName))
|
||||||
|
)
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
startActivity(
|
||||||
|
Intent(Intent.ACTION_VIEW, Uri.parse(CLIENT_UPGRADE_GPLAY_LINK + packageName))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resources!!.getBoolean(R.bool.multiaccount_support) && userManager.users.blockingGet().size > 1) {
|
||||||
|
dialogBuilder.setNegativeButton(R.string.nc_switch_account) { _, _ ->
|
||||||
|
val newFragment: DialogFragment = ChooseAccountDialogFragment.newInstance()
|
||||||
|
newFragment.show(supportFragmentManager, ChooseAccountDialogFragment.TAG)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(it.context, dialogBuilder)
|
||||||
|
val dialog = dialogBuilder.show()
|
||||||
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showServiceUnavailableDialog(httpException: HttpException) {
|
||||||
|
if (httpException.response()?.headers()?.get(MAINTENANCE_MODE_HEADER_KEY) == "1") {
|
||||||
|
binding.floatingActionButton.let {
|
||||||
|
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
|
||||||
|
.setIcon(
|
||||||
|
viewThemeUtils.dialog.colorMaterialAlertDialogIcon(
|
||||||
|
context,
|
||||||
|
R.drawable.ic_info_white_24dp
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setTitle(R.string.nc_dialog_maintenance_mode)
|
||||||
|
.setMessage(R.string.nc_dialog_maintenance_mode_description)
|
||||||
|
.setCancelable(false)
|
||||||
|
|
||||||
|
if (resources!!.getBoolean(R.bool.multiaccount_support) && userManager.users.blockingGet().size > 1) {
|
||||||
|
dialogBuilder.setPositiveButton(R.string.nc_switch_account) { _, _ ->
|
||||||
|
val newFragment: DialogFragment = ChooseAccountDialogFragment.newInstance()
|
||||||
|
newFragment.show(supportFragmentManager, ChooseAccountDialogFragment.TAG)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dialogBuilder.setPositiveButton(R.string.nc_close_app) { _, _ ->
|
||||||
|
finishAffinity()
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(it.context, dialogBuilder)
|
||||||
|
val dialog = dialogBuilder.show()
|
||||||
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showErrorDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun showServerEOLDialog() {
|
private fun showServerEOLDialog() {
|
||||||
binding?.floatingActionButton?.let {
|
binding?.floatingActionButton?.let {
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
|
||||||
@ -1378,5 +1464,10 @@ class ConversationsListActivity :
|
|||||||
const val SEARCH_DEBOUNCE_INTERVAL_MS = 300
|
const val SEARCH_DEBOUNCE_INTERVAL_MS = 300
|
||||||
const val SEARCH_MIN_CHARS = 2
|
const val SEARCH_MIN_CHARS = 2
|
||||||
const val HTTP_UNAUTHORIZED = 401
|
const val HTTP_UNAUTHORIZED = 401
|
||||||
|
const val HTTP_CLIENT_UPGRADE_REQUIRED = 426
|
||||||
|
const val CLIENT_UPGRADE_MARKET_LINK = "market://details?id="
|
||||||
|
const val CLIENT_UPGRADE_GPLAY_LINK = "https://play.google.com/store/apps/details?id="
|
||||||
|
const val HTTP_SERVICE_UNAVAILABLE = 503
|
||||||
|
const val MAINTENANCE_MODE_HEADER_KEY = "X-Nextcloud-Maintenance-Mode"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -560,6 +560,14 @@ How to translate with transifex:
|
|||||||
<string name="nc_dialog_invalid_password">Invalid password</string>
|
<string name="nc_dialog_invalid_password">Invalid password</string>
|
||||||
<string name="nc_dialog_reauth_or_delete">Do you want to reauthorize or delete this account?</string>
|
<string name="nc_dialog_reauth_or_delete">Do you want to reauthorize or delete this account?</string>
|
||||||
|
|
||||||
|
<string name="nc_dialog_outdated_client">App is outdated</string>
|
||||||
|
<string name="nc_dialog_outdated_client_description">The app is too old and no longer supported by this server. Please update.</string>
|
||||||
|
<string name="nc_dialog_outdated_client_option_update">Update</string>
|
||||||
|
<string name="nc_switch_account">Switch account</string>
|
||||||
|
<string name="nc_dialog_maintenance_mode">Maintenance mode</string>
|
||||||
|
<string name="nc_dialog_maintenance_mode_description">Server is currently in maintenance mode.</string>
|
||||||
|
<string name="nc_close_app">Close app</string>
|
||||||
|
|
||||||
<!-- Take photo -->
|
<!-- Take photo -->
|
||||||
<string name="take_photo">Take a photo</string>
|
<string name="take_photo">Take a photo</string>
|
||||||
<string name="take_photo_switch_camera">Switch camera</string>
|
<string name="take_photo_switch_camera">Switch camera</string>
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
DO NOT TOUCH; GENERATED BY DRONE
|
DO NOT TOUCH; GENERATED BY DRONE
|
||||||
<span class="mdl-layout-title">Lint Report: 109 warnings</span>
|
<span class="mdl-layout-title">Lint Report: 108 warnings</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user