From 3473d669d30980f60d11babdd09931d9746ca1af Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 10 Jun 2021 20:25:00 +0200 Subject: [PATCH] Use MaterialToolbar and AppBarLayout in all screens --- .../check/forbidden_strings_in_resources.txt | 4 + .../root/src/app_package/Activity.kt.ftl | 4 +- .../layout/activity_test_material_theme.xml | 20 +- .../app/core/platform/ToolbarConfigurable.kt | 4 +- .../app/core/platform/VectorBaseActivity.kt | 4 +- .../app/core/platform/VectorBaseFragment.kt | 4 +- .../preview/AttachmentsPreviewActivity.kt | 4 +- .../vector/app/features/home/HomeActivity.kt | 4 +- .../home/room/detail/RoomDetailActivity.kt | 4 +- .../app/features/login/LoginActivity.kt | 4 +- .../app/features/login2/LoginActivity2.kt | 4 +- .../im/vector/app/features/pin/PinActivity.kt | 4 +- .../reactions/EmojiReactionPickerActivity.kt | 5 +- .../createroom/CreateRoomActivity.kt | 4 +- .../roompreview/RoomPreviewActivity.kt | 4 +- .../RoomMemberProfileActivity.kt | 4 +- .../roomprofile/RoomProfileActivity.kt | 4 +- .../features/share/IncomingShareActivity.kt | 4 +- .../spaces/manage/SpaceManageActivity.kt | 4 +- .../app/features/widgets/WidgetActivity.kt | 4 +- vector/src/main/res/layout/activity.xml | 15 +- .../res/layout/activity_big_image_viewer.xml | 19 +- .../main/res/layout/activity_bug_report.xml | 12 +- .../res/layout/activity_call_transfer.xml | 30 +-- .../layout/activity_emoji_reaction_picker.xml | 7 +- .../res/layout/activity_filtered_rooms.xml | 35 ++-- .../res/layout/activity_incoming_share.xml | 35 ++-- .../src/main/res/layout/activity_search.xml | 35 ++-- .../res/layout/activity_vector_settings.xml | 21 ++- .../res/layout/activity_vector_web_view.xml | 19 +- .../src/main/res/layout/activity_widget.xml | 15 +- .../layout/fragment_attachments_preview.xml | 21 ++- .../res/layout/fragment_contacts_book.xml | 172 ++++++++--------- ...ent_create_direct_room_directory_users.xml | 122 ++++++------ .../main/res/layout/fragment_create_room.xml | 82 +++++---- .../main/res/layout/fragment_home_detail.xml | 173 +++++++++--------- .../res/layout/fragment_incoming_share.xml | 35 ++-- .../main/res/layout/fragment_login_web.xml | 17 +- .../res/layout/fragment_matrix_profile.xml | 4 +- .../main/res/layout/fragment_public_rooms.xml | 12 +- .../fragment_recyclerview_with_search.xml | 7 +- .../main/res/layout/fragment_room_detail.xml | 133 +++++++------- .../layout/fragment_room_directory_picker.xml | 14 +- .../fragment_room_preview_no_preview.xml | 89 ++++----- .../layout/fragment_room_setting_generic.xml | 92 +++++----- .../main/res/layout/fragment_room_uploads.xml | 6 +- .../res/layout/fragment_space_add_rooms.xml | 13 +- .../res/layout/fragment_space_preview.xml | 115 ++++++------ .../res/layout/fragment_user_code_show.xml | 84 +++++---- .../res/layout/fragment_user_directory.xml | 125 ++++++------- .../main/res/layout/fragment_user_list.xml | 162 ++++++++-------- vector/src/main/res/values/styles_riot.xml | 4 - vector/src/main/res/values/styles_toolbar.xml | 8 +- 53 files changed, 956 insertions(+), 874 deletions(-) diff --git a/tools/check/forbidden_strings_in_resources.txt b/tools/check/forbidden_strings_in_resources.txt index 92eec6cdfd..4ebc4008c1 100644 --- a/tools/check/forbidden_strings_in_resources.txt +++ b/tools/check/forbidden_strings_in_resources.txt @@ -98,6 +98,10 @@ layout_constraintLeft_ ### Use com.google.android.material.switchmaterial.SwitchMaterial instead of Switch, the inflater will not automatically inflate Material Views for Switch. - + app:layout_constraintTop_toTopOf="parent"> + + + + + app:layout_constraintTop_toBottomOf="@+id/appBarLayout"> : AppCompatActivity(), HasScr /** * Configure the Toolbar, with default back button. */ - protected fun configureToolbar(toolbar: Toolbar, displayBack: Boolean = true) { + protected fun configureToolbar(toolbar: MaterialToolbar, displayBack: Boolean = true) { setSupportActionBar(toolbar) supportActionBar?.let { it.setDisplayShowHomeEnabled(displayBack) diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt index b5b6937aad..c513007c3d 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt @@ -29,7 +29,7 @@ import android.view.View import android.view.ViewGroup import androidx.annotation.CallSuper import androidx.annotation.MainThread -import androidx.appcompat.widget.Toolbar +import com.google.android.material.appbar.MaterialToolbar import androidx.lifecycle.ViewModelProvider import androidx.viewbinding.ViewBinding import com.airbnb.mvrx.BaseMvRxFragment @@ -224,7 +224,7 @@ abstract class VectorBaseFragment : BaseMvRxFragment(), HasScre /** * Configure the Toolbar. */ - protected fun setupToolbar(toolbar: Toolbar) { + protected fun setupToolbar(toolbar: MaterialToolbar) { val parentActivity = vectorBaseActivity if (parentActivity is ToolbarConfigurable) { parentActivity.configure(toolbar) diff --git a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewActivity.kt b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewActivity.kt index f282cc3358..6c25f688bd 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewActivity.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewActivity.kt @@ -19,7 +19,7 @@ package im.vector.app.features.attachments.preview import android.content.Context import android.content.Intent -import androidx.appcompat.widget.Toolbar +import com.google.android.material.appbar.MaterialToolbar import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.ToolbarConfigurable @@ -72,7 +72,7 @@ class AttachmentsPreviewActivity : VectorBaseActivity(), finish() } - override fun configure(toolbar: Toolbar) { + override fun configure(toolbar: MaterialToolbar) { configureToolbar(toolbar) } } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index 64c87d00e9..4a563b563a 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -24,7 +24,7 @@ import android.os.Bundle import android.os.Parcelable import android.view.Menu import android.view.MenuItem -import androidx.appcompat.widget.Toolbar +import com.google.android.material.appbar.MaterialToolbar import androidx.core.view.GravityCompat import androidx.core.view.isVisible import androidx.drawerlayout.widget.DrawerLayout @@ -437,7 +437,7 @@ class HomeActivity : serverBackupStatusViewModel.refreshRemoteStateIfNeeded() } - override fun configure(toolbar: Toolbar) { + override fun configure(toolbar: MaterialToolbar) { configureToolbar(toolbar, false) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt index 640e9a62ff..ce3346f8a6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt @@ -20,7 +20,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.widget.Toast -import androidx.appcompat.widget.Toolbar +import com.google.android.material.appbar.MaterialToolbar import androidx.core.view.GravityCompat import androidx.drawerlayout.widget.DrawerLayout import com.airbnb.mvrx.viewModel @@ -132,7 +132,7 @@ class RoomDetailActivity : super.onDestroy() } - override fun configure(toolbar: Toolbar) { + override fun configure(toolbar: MaterialToolbar) { configureToolbar(toolbar) } diff --git a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt index ae099dba3f..07dfc62602 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt @@ -21,7 +21,7 @@ import android.content.Intent import android.view.View import android.view.ViewGroup import androidx.annotation.CallSuper -import androidx.appcompat.widget.Toolbar +import com.google.android.material.appbar.MaterialToolbar import androidx.core.view.ViewCompat import androidx.core.view.children import androidx.core.view.isVisible @@ -356,7 +356,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo } } - override fun configure(toolbar: Toolbar) { + override fun configure(toolbar: MaterialToolbar) { configureToolbar(toolbar) } diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt index 9adf4bd6c2..60eb1934d0 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt @@ -21,7 +21,7 @@ import android.content.Intent import android.view.View import android.view.ViewGroup import androidx.annotation.CallSuper -import androidx.appcompat.widget.Toolbar +import com.google.android.material.appbar.MaterialToolbar import androidx.core.view.ViewCompat import androidx.core.view.children import androidx.core.view.isVisible @@ -388,7 +388,7 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC } } - override fun configure(toolbar: Toolbar) { + override fun configure(toolbar: MaterialToolbar) { configureToolbar(toolbar) } diff --git a/vector/src/main/java/im/vector/app/features/pin/PinActivity.kt b/vector/src/main/java/im/vector/app/features/pin/PinActivity.kt index 66ebfa929d..6866afa0a6 100644 --- a/vector/src/main/java/im/vector/app/features/pin/PinActivity.kt +++ b/vector/src/main/java/im/vector/app/features/pin/PinActivity.kt @@ -18,7 +18,7 @@ package im.vector.app.features.pin import android.content.Context import android.content.Intent -import androidx.appcompat.widget.Toolbar +import com.google.android.material.appbar.MaterialToolbar import com.airbnb.mvrx.MvRx import im.vector.app.R import im.vector.app.core.extensions.addFragment @@ -47,7 +47,7 @@ class PinActivity : VectorBaseActivity(), ToolbarConfigur } } - override fun configure(toolbar: Toolbar) { + override fun configure(toolbar: MaterialToolbar) { configureToolbar(toolbar) } } diff --git a/vector/src/main/java/im/vector/app/features/reactions/EmojiReactionPickerActivity.kt b/vector/src/main/java/im/vector/app/features/reactions/EmojiReactionPickerActivity.kt index b2f1c3c15a..ecfaf93747 100644 --- a/vector/src/main/java/im/vector/app/features/reactions/EmojiReactionPickerActivity.kt +++ b/vector/src/main/java/im/vector/app/features/reactions/EmojiReactionPickerActivity.kt @@ -24,7 +24,6 @@ import android.view.Menu import android.view.MenuInflater import android.view.MenuItem import android.widget.SearchView -import androidx.appcompat.widget.Toolbar import androidx.core.view.isVisible import com.airbnb.mvrx.viewModel import com.google.android.material.tabs.TabLayout @@ -150,13 +149,13 @@ class EmojiReactionPickerActivity : VectorBaseActivity