Skip to content

Commit 4d3affa

Browse files
authored
Merge pull request #4782 from nextcloud/feature/2737/maintenanceModeWarningConvList
show maintenance warning in conv list on top
2 parents 5650a14 + af0294b commit 4d3affa

File tree

3 files changed

+19
-39
lines changed

3 files changed

+19
-39
lines changed

app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,10 @@ class ConversationsListActivity :
10451045
binding.chatListConnectionLost.visibility = if (show) View.VISIBLE else View.GONE
10461046
}
10471047

1048+
private fun showMaintenanceModeWarning(show: Boolean) {
1049+
binding.chatListMaintenanceWarning.visibility = if (show) View.VISIBLE else View.GONE
1050+
}
1051+
10481052
private fun handleUI(show: Boolean) {
10491053
binding.floatingActionButton.isEnabled = show
10501054
binding.searchText.isEnabled = show
@@ -1133,6 +1137,8 @@ class ConversationsListActivity :
11331137
private fun prepareViews() {
11341138
hideLogoForBrandedClients()
11351139

1140+
showMaintenanceModeWarning(false)
1141+
11361142
layoutManager = SmoothScrollLinearLayoutManager(this)
11371143
binding.recyclerView.layoutManager = layoutManager
11381144
binding.recyclerView.setHasFixedSize(true)
@@ -1156,6 +1162,7 @@ class ConversationsListActivity :
11561162
false
11571163
}
11581164
binding.swipeRefreshLayoutView.setOnRefreshListener {
1165+
showMaintenanceModeWarning(false)
11591166
fetchRooms()
11601167
fetchPendingInvitations()
11611168
}
@@ -1931,44 +1938,7 @@ class ConversationsListActivity :
19311938

19321939
private fun showServiceUnavailableDialog(httpException: HttpException) {
19331940
if (httpException.response()?.headers()?.get(MAINTENANCE_MODE_HEADER_KEY) == "1") {
1934-
binding.floatingActionButton.let {
1935-
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
1936-
.setIcon(
1937-
viewThemeUtils.dialog.colorMaterialAlertDialogIcon(
1938-
context,
1939-
R.drawable.ic_info_white_24dp
1940-
)
1941-
)
1942-
.setTitle(R.string.nc_dialog_maintenance_mode)
1943-
.setMessage(R.string.nc_dialog_maintenance_mode_description)
1944-
.setCancelable(false)
1945-
.setNegativeButton(R.string.nc_settings_remove_account) { _, _ ->
1946-
deleteUserAndRestartApp()
1947-
}
1948-
1949-
if (resources!!.getBoolean(R.bool.multiaccount_support) && userManager.users.blockingGet().size > 1) {
1950-
dialogBuilder.setPositiveButton(R.string.nc_switch_account) { _, _ ->
1951-
val newFragment: DialogFragment = ChooseAccountDialogFragment.newInstance()
1952-
newFragment.show(supportFragmentManager, ChooseAccountDialogFragment.TAG)
1953-
}
1954-
}
1955-
1956-
if (resources!!.getBoolean(R.bool.multiaccount_support)) {
1957-
dialogBuilder.setNeutralButton(R.string.nc_account_chooser_add_account) { _, _ ->
1958-
val intent = Intent(this, ServerSelectionActivity::class.java)
1959-
intent.putExtra(ADD_ADDITIONAL_ACCOUNT, true)
1960-
startActivity(intent)
1961-
}
1962-
}
1963-
1964-
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(it.context, dialogBuilder)
1965-
val dialog = dialogBuilder.show()
1966-
viewThemeUtils.platform.colorTextButtons(
1967-
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
1968-
dialog.getButton(AlertDialog.BUTTON_NEGATIVE),
1969-
dialog.getButton(AlertDialog.BUTTON_NEUTRAL)
1970-
)
1971-
}
1941+
showMaintenanceModeWarning(true)
19721942
} else {
19731943
showErrorDialog()
19741944
}

app/src/main/res/layout/activity_conversations.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@
3737
android:visibility="gone"
3838
tools:visibility="visible" />
3939

40+
<com.google.android.material.textview.MaterialTextView
41+
android:id="@+id/chat_list_maintenance_warning"
42+
android:layout_width="match_parent"
43+
android:layout_height="wrap_content"
44+
android:background="@color/hwSecurityRed"
45+
android:gravity="center"
46+
android:text="@string/nc_dialog_maintenance_mode_description"
47+
android:textColor="@color/white"
48+
android:visibility="gone"
49+
tools:visibility="visible" />
50+
4051
<com.google.android.material.card.MaterialCardView
4152
android:id="@+id/search_toolbar"
4253
android:layout_width="match_parent"

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,6 @@ How to translate with transifex:
652652
<string name="nc_dialog_outdated_client_description">The app is too old and no longer supported by this server. Please update.</string>
653653
<string name="nc_dialog_outdated_client_option_update">Update</string>
654654
<string name="nc_switch_account">Switch account</string>
655-
<string name="nc_dialog_maintenance_mode">Maintenance mode</string>
656655
<string name="nc_dialog_maintenance_mode_description">Server is currently in maintenance mode.</string>
657656

658657
<!-- Take photo -->

0 commit comments

Comments
 (0)