diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
index 489a99ec4..74b45f786 100644
--- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
+++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
@@ -30,6 +30,7 @@ package com.nextcloud.talk.conversationlist
import android.animation.AnimatorInflater
import android.annotation.SuppressLint
import android.app.SearchManager
+import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
@@ -562,7 +563,6 @@ class ConversationsListActivity :
}, { throwable: Throwable ->
handleHttpExceptions(throwable)
binding?.swipeRefreshLayoutView?.isRefreshing = false
- showErrorDialog()
dispose(roomsQueryDisposable)
}) {
dispose(roomsQueryDisposable)
@@ -627,7 +627,7 @@ class ConversationsListActivity :
}
private fun showErrorDialog() {
- binding?.floatingActionButton?.let {
+ binding.floatingActionButton.let {
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
.setIcon(
viewThemeUtils.dialog.colorMaterialAlertDialogIcon(
@@ -639,6 +639,13 @@ class ConversationsListActivity :
.setCancelable(false)
.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)
val dialog = dialogBuilder.show()
viewThemeUtils.platform.colorTextButtons(
@@ -701,9 +708,11 @@ class ConversationsListActivity :
if (throwable is HttpException) {
when (throwable.code()) {
HTTP_UNAUTHORIZED -> showUnauthorizedDialog()
+ HTTP_CLIENT_UPGRADE_REQUIRED -> showOutdatedClientDialog()
+ HTTP_SERVICE_UNAVAILABLE -> showServiceUnavailableDialog(throwable)
else -> {
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() {
binding?.floatingActionButton?.let {
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
@@ -1378,5 +1464,10 @@ class ConversationsListActivity :
const val SEARCH_DEBOUNCE_INTERVAL_MS = 300
const val SEARCH_MIN_CHARS = 2
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"
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d54185c2a..46a285c05 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -560,6 +560,14 @@ How to translate with transifex:
Invalid password
Do you want to reauthorize or delete this account?
+ App is outdated
+ The app is too old and no longer supported by this server. Please update.
+ Update
+ Switch account
+ Maintenance mode
+ Server is currently in maintenance mode.
+ Close app
+
Take a photo
Switch camera
diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt
index dd9daf562..3694e6bcc 100644
--- a/scripts/analysis/lint-results.txt
+++ b/scripts/analysis/lint-results.txt
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
- Lint Report: 109 warnings
+ Lint Report: 108 warnings