Эх сурвалжийг харах

use native view bindings in activities

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 3 жил өмнө
parent
commit
833ebbc9e3

+ 19 - 23
app/src/main/java/com/nextcloud/talk/activities/FullScreenImageActivity.kt

@@ -3,6 +3,8 @@
  *
  * @author Marcel Hibbe
  * @author Dariusz Olszewski
+ * @author Andy Scherzinger
+ * Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
  * Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
  * Copyright (C) 2021 Dariusz Olszewski
  *
@@ -28,22 +30,18 @@ import android.os.Bundle
 import android.view.Menu
 import android.view.MenuItem
 import android.view.View
-import android.widget.FrameLayout
 import androidx.appcompat.app.AppCompatActivity
 import androidx.core.content.FileProvider
-import com.github.chrisbanes.photoview.PhotoView
 import com.nextcloud.talk.BuildConfig
 import com.nextcloud.talk.R
+import com.nextcloud.talk.databinding.ActivityFullScreenImageBinding
 import pl.droidsonroids.gif.GifDrawable
-import pl.droidsonroids.gif.GifImageView
 import java.io.File
 
 class FullScreenImageActivity : AppCompatActivity() {
+    lateinit var binding: ActivityFullScreenImageBinding
 
     private lateinit var path: String
-    private lateinit var imageWrapperView: FrameLayout
-    private lateinit var photoView: PhotoView
-    private lateinit var gifView: GifImageView
 
     private var showFullscreen = false
 
@@ -77,42 +75,40 @@ class FullScreenImageActivity : AppCompatActivity() {
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
-        setContentView(R.layout.activity_full_screen_image)
-        setSupportActionBar(findViewById(R.id.imageview_toolbar))
-        supportActionBar?.setDisplayShowTitleEnabled(false)
+        binding = ActivityFullScreenImageBinding.inflate(layoutInflater)
+        setContentView(binding.root)
 
-        imageWrapperView = findViewById(R.id.image_wrapper_view)
-        photoView = findViewById(R.id.photo_view)
-        gifView = findViewById(R.id.gif_view)
+        setSupportActionBar(binding.imageviewToolbar)
+        supportActionBar?.setDisplayShowTitleEnabled(false)
 
-        photoView.setOnPhotoTapListener { view, x, y ->
+        binding.photoView.setOnPhotoTapListener { view, x, y ->
             toggleFullscreen()
         }
-        photoView.setOnOutsidePhotoTapListener {
+        binding.photoView.setOnOutsidePhotoTapListener {
             toggleFullscreen()
         }
-        gifView.setOnClickListener {
+        binding.gifView.setOnClickListener {
             toggleFullscreen()
         }
 
         // Enable enlarging the image more than default 3x maximumScale.
         // Medium scale adapted to make double-tap behaviour more consistent.
-        photoView.maximumScale = 6.0f
-        photoView.mediumScale = 2.45f
+        binding.photoView.maximumScale = 6.0f
+        binding.photoView.mediumScale = 2.45f
 
         val fileName = intent.getStringExtra("FILE_NAME")
         val isGif = intent.getBooleanExtra("IS_GIF", false)
 
         path = applicationContext.cacheDir.absolutePath + "/" + fileName
         if (isGif) {
-            photoView.visibility = View.INVISIBLE
-            gifView.visibility = View.VISIBLE
+            binding.photoView.visibility = View.INVISIBLE
+            binding.gifView.visibility = View.VISIBLE
             val gifFromUri = GifDrawable(path)
-            gifView.setImageDrawable(gifFromUri)
+            binding.gifView.setImageDrawable(gifFromUri)
         } else {
-            gifView.visibility = View.INVISIBLE
-            photoView.visibility = View.VISIBLE
-            photoView.setImageURI(Uri.parse(path))
+            binding.gifView.visibility = View.INVISIBLE
+            binding.photoView.visibility = View.VISIBLE
+            binding.photoView.setImageURI(Uri.parse(path))
         }
     }
 

+ 12 - 10
app/src/main/java/com/nextcloud/talk/activities/FullScreenMediaActivity.kt

@@ -2,6 +2,8 @@
  * Nextcloud Talk application
  *
  * @author Marcel Hibbe
+ * @author Andy Scherzinger
+ * Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
  * Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
  *
  * This program is free software: you can redistribute it and/or modify
@@ -32,17 +34,17 @@ import autodagger.AutoInjector
 import com.google.android.exoplayer2.MediaItem
 import com.google.android.exoplayer2.Player
 import com.google.android.exoplayer2.SimpleExoPlayer
-import com.google.android.exoplayer2.ui.StyledPlayerView
 import com.nextcloud.talk.BuildConfig
 import com.nextcloud.talk.R
 import com.nextcloud.talk.application.NextcloudTalkApplication
+import com.nextcloud.talk.databinding.ActivityFullScreenMediaBinding
 import java.io.File
 
 @AutoInjector(NextcloudTalkApplication::class)
 class FullScreenMediaActivity : AppCompatActivity(), Player.EventListener {
+    lateinit var binding: ActivityFullScreenMediaBinding
 
     private lateinit var path: String
-    private lateinit var playerView: StyledPlayerView
     private lateinit var player: SimpleExoPlayer
 
     override fun onCreateOptionsMenu(menu: Menu?): Boolean {
@@ -80,20 +82,20 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.EventListener {
 
         path = applicationContext.cacheDir.absolutePath + "/" + fileName
 
-        setContentView(R.layout.activity_full_screen_media)
-        setSupportActionBar(findViewById(R.id.mediaview_toolbar))
-        supportActionBar?.setDisplayShowTitleEnabled(false)
+        binding = ActivityFullScreenMediaBinding.inflate(layoutInflater)
+        setContentView(binding.root)
 
-        playerView = findViewById(R.id.player_view)
+        setSupportActionBar(binding.mediaviewToolbar)
+        supportActionBar?.setDisplayShowTitleEnabled(false)
 
         window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
 
-        playerView.showController()
+        binding.playerView.showController()
         if (isAudioOnly) {
-            playerView.controllerShowTimeoutMs = 0
+            binding.playerView.controllerShowTimeoutMs = 0
         }
 
-        playerView.setControllerVisibilityListener { v ->
+        binding.playerView.setControllerVisibilityListener { v ->
             if (v != 0) {
                 hideSystemUI()
                 supportActionBar?.hide()
@@ -121,7 +123,7 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.EventListener {
 
     private fun initializePlayer() {
         player = SimpleExoPlayer.Builder(applicationContext).build()
-        playerView.player = player
+        binding.playerView.player = player
         player.playWhenReady = true
         player.addListener(this)
     }

+ 11 - 8
app/src/main/java/com/nextcloud/talk/activities/FullScreenTextViewerActivity.kt

@@ -2,6 +2,8 @@
  * Nextcloud Talk application
  *
  * @author Marcel Hibbe
+ * @author Andy Scherzinger
+ * Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
  * Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
  *
  * This program is free software: you can redistribute it and/or modify
@@ -24,21 +26,21 @@ import android.content.Intent
 import android.os.Bundle
 import android.view.Menu
 import android.view.MenuItem
-import android.widget.TextView
 import androidx.appcompat.app.AppCompatActivity
 import androidx.core.content.FileProvider
 import autodagger.AutoInjector
 import com.nextcloud.talk.BuildConfig
 import com.nextcloud.talk.R
 import com.nextcloud.talk.application.NextcloudTalkApplication
+import com.nextcloud.talk.databinding.ActivityFullScreenTextBinding
 import io.noties.markwon.Markwon
 import java.io.File
 
 @AutoInjector(NextcloudTalkApplication::class)
 class FullScreenTextViewerActivity : AppCompatActivity() {
+    lateinit var binding: ActivityFullScreenTextBinding
 
     private lateinit var path: String
-    private lateinit var textView: TextView
 
     override fun onCreateOptionsMenu(menu: Menu?): Boolean {
         menuInflater.inflate(R.menu.menu_preview, menu)
@@ -70,21 +72,22 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
-        setContentView(R.layout.activity_full_screen_text)
-        setSupportActionBar(findViewById(R.id.textview_toolbar))
+        binding = ActivityFullScreenTextBinding.inflate(layoutInflater)
+        setContentView(binding.root)
+
+        setSupportActionBar(binding.textviewToolbar)
         supportActionBar?.setDisplayShowTitleEnabled(false)
-        textView = findViewById(R.id.text_view)
 
         val fileName = intent.getStringExtra("FILE_NAME")
         val isMarkdown = intent.getBooleanExtra("IS_MARKDOWN", false)
         path = applicationContext.cacheDir.absolutePath + "/" + fileName
-        var text = readFile(path)
+        val text = readFile(path)
 
         if (isMarkdown) {
             val markwon = Markwon.create(applicationContext)
-            markwon.setMarkdown(textView, text)
+            markwon.setMarkdown(binding.textView, text)
         } else {
-            textView.text = text
+            binding.textView.text = text
         }
     }
 

+ 12 - 17
app/src/main/java/com/nextcloud/talk/activities/MagicCallActivity.kt

@@ -2,6 +2,8 @@
  * Nextcloud Talk application
  *
  * @author Mario Danic
+ * @author Andy Scherzinger
+ * Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
  * Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
  *
  * This program is free software: you can redistribute it and/or modify
@@ -23,12 +25,9 @@ package com.nextcloud.talk.activities
 import android.content.res.Configuration
 import android.os.Bundle
 import android.view.View
-import android.view.ViewGroup
 import android.view.Window
 import android.view.WindowManager
 import autodagger.AutoInjector
-import butterknife.BindView
-import butterknife.ButterKnife
 import com.bluelinelabs.conductor.Conductor
 import com.bluelinelabs.conductor.Router
 import com.bluelinelabs.conductor.RouterTransaction
@@ -38,20 +37,16 @@ import com.nextcloud.talk.application.NextcloudTalkApplication
 import com.nextcloud.talk.controllers.CallController
 import com.nextcloud.talk.controllers.CallNotificationController
 import com.nextcloud.talk.controllers.ChatController
+import com.nextcloud.talk.databinding.ActivityMagicCallBinding
 import com.nextcloud.talk.events.ConfigurationChangeEvent
 import com.nextcloud.talk.utils.bundle.BundleKeys
 
 @AutoInjector(NextcloudTalkApplication::class)
 class MagicCallActivity : BaseActivity() {
+    lateinit var binding: ActivityMagicCallBinding
 
     private lateinit var chatController: ChatController
 
-    @BindView(R.id.controller_container)
-    lateinit var container: ViewGroup
-
-    @BindView(R.id.chatControllerView)
-    lateinit var chatContainer: ViewGroup
-
     private var router: Router? = null
     private var chatRouter: Router? = null
 
@@ -69,10 +64,10 @@ class MagicCallActivity : BaseActivity() {
         )
         window.decorView.systemUiVisibility = systemUiVisibility
 
-        setContentView(R.layout.activity_magic_call)
+        binding = ActivityMagicCallBinding.inflate(layoutInflater)
+        setContentView(binding.root)
 
-        ButterKnife.bind(this)
-        router = Conductor.attachRouter(this, container, savedInstanceState)
+        router = Conductor.attachRouter(this, binding.controllerContainer, savedInstanceState)
         router!!.setPopsLastView(false)
 
         if (!router!!.hasRootController()) {
@@ -95,7 +90,7 @@ class MagicCallActivity : BaseActivity() {
         extras.putBoolean("showToggleChat", true)
 
         chatController = ChatController(extras)
-        chatRouter = Conductor.attachRouter(this, chatContainer, savedInstanceState)
+        chatRouter = Conductor.attachRouter(this, binding.chatControllerView, savedInstanceState)
         chatRouter!!.setRoot(
             RouterTransaction.with(chatController)
                 .pushChangeHandler(HorizontalChangeHandler())
@@ -104,15 +99,15 @@ class MagicCallActivity : BaseActivity() {
     }
 
     fun showChat() {
-        chatContainer.visibility = View.VISIBLE
-        container.visibility = View.GONE
+        binding.chatControllerView.visibility = View.VISIBLE
+        binding.controllerContainer.visibility = View.GONE
         chatController.wasDetached = false
         chatController.pullChatMessages(1)
     }
 
     fun showCall() {
-        container.visibility = View.VISIBLE
-        chatContainer.visibility = View.GONE
+        binding.controllerContainer.visibility = View.VISIBLE
+        binding.chatControllerView.visibility = View.GONE
         chatController.wasDetached = true
     }
 

+ 10 - 31
app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt

@@ -3,6 +3,8 @@
  *   Nextcloud Talk application
  *
  *   @author Mario Danic
+ *   @author Andy Scherzinger
+ *   Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
  *   Copyright (C) 2017 Mario Danic (mario@lovelyhq.com)
  *
  *   This program is free software: you can redistribute it and/or modify
@@ -27,22 +29,14 @@ import android.os.Build
 import android.os.Bundle
 import android.provider.ContactsContract
 import android.text.TextUtils
-import android.view.ViewGroup
 import androidx.annotation.RequiresApi
 import autodagger.AutoInjector
-import butterknife.BindView
-import butterknife.ButterKnife
 import com.bluelinelabs.conductor.Conductor
 import com.bluelinelabs.conductor.Router
 import com.bluelinelabs.conductor.RouterTransaction
 import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
 import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler
-import com.google.android.material.appbar.AppBarLayout
-import com.google.android.material.appbar.MaterialToolbar
-import com.google.android.material.button.MaterialButton
-import com.google.android.material.card.MaterialCardView
 import com.google.android.material.snackbar.Snackbar
-import com.google.android.material.textview.MaterialTextView
 import com.nextcloud.talk.R
 import com.nextcloud.talk.api.NcApi
 import com.nextcloud.talk.application.NextcloudTalkApplication
@@ -53,6 +47,7 @@ import com.nextcloud.talk.controllers.ServerSelectionController
 import com.nextcloud.talk.controllers.SettingsController
 import com.nextcloud.talk.controllers.WebViewLoginController
 import com.nextcloud.talk.controllers.base.providers.ActionBarProvider
+import com.nextcloud.talk.databinding.ActivityMainBinding
 import com.nextcloud.talk.models.json.conversations.RoomOverall
 import com.nextcloud.talk.utils.ApiUtils
 import com.nextcloud.talk.utils.ConductorRemapping
@@ -76,24 +71,7 @@ import javax.inject.Inject
 
 @AutoInjector(NextcloudTalkApplication::class)
 class MainActivity : BaseActivity(), ActionBarProvider {
-
-    @BindView(R.id.appBar)
-    lateinit var appBar: AppBarLayout
-
-    @BindView(R.id.toolbar)
-    lateinit var toolbar: MaterialToolbar
-
-    @BindView(R.id.home_toolbar)
-    lateinit var searchCardView: MaterialCardView
-
-    @BindView(R.id.search_text)
-    lateinit var searchInputText: MaterialTextView
-
-    @BindView(R.id.switch_account_button)
-    lateinit var settingsButton: MaterialButton
-
-    @BindView(R.id.controller_container)
-    lateinit var container: ViewGroup
+    lateinit var binding: ActivityMainBinding
 
     @Inject
     lateinit var userUtils: UserUtils
@@ -113,14 +91,14 @@ class MainActivity : BaseActivity(), ActionBarProvider {
         super.onCreate(savedInstanceState)
         // Set the default theme to replace the launch screen theme.
         setTheme(R.style.AppTheme)
-        setContentView(R.layout.activity_main)
+        binding = ActivityMainBinding.inflate(layoutInflater)
+        setContentView(binding.root)
 
         NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
-        ButterKnife.bind(this)
 
-        setSupportActionBar(toolbar)
+        setSupportActionBar(binding.toolbar)
 
-        router = Conductor.attachRouter(this, container, savedInstanceState)
+        router = Conductor.attachRouter(this, binding.controllerContainer, savedInstanceState)
 
         var hasDb = true
 
@@ -242,7 +220,8 @@ class MainActivity : BaseActivity(), ActionBarProvider {
                         startConversation(user)
                     } else {
                         Snackbar.make(
-                            container, R.string.nc_phone_book_integration_account_not_found,
+                            binding.controllerContainer,
+                            R.string.nc_phone_book_integration_account_not_found,
                             Snackbar.LENGTH_LONG
                         ).show()
                     }

+ 21 - 23
app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java

@@ -274,7 +274,7 @@ public class ConversationsListController extends BaseController implements Searc
             credentials = ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken());
             shouldUseLastMessageLayout = currentUser.hasSpreedFeatureCapability("last-room-activity");
             if (getActivity() != null && getActivity() instanceof MainActivity) {
-                loadUserAvatar(((MainActivity) getActivity()).settingsButton);
+                loadUserAvatar(((MainActivity) getActivity()).binding.switchAccountButton);
             }
             fetchData(false);
         }
@@ -331,7 +331,7 @@ public class ConversationsListController extends BaseController implements Searc
         }
 
         if (activity != null) {
-            activity.getSearchInputText().setOnClickListener(v -> {
+            activity.binding.searchText.setOnClickListener(v -> {
                 showSearchView(activity, searchView, searchItem);
                 if (getResources() != null) {
                     DisplayUtils.applyColorToStatusBar(
@@ -368,12 +368,12 @@ public class ConversationsListController extends BaseController implements Searc
                 searchView.onActionViewCollapsed();
                 MainActivity activity = (MainActivity) getActivity();
                 if (activity != null) {
-                    activity.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
-                            activity.appBar.getContext(),
+                    activity.binding.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
+                            activity.binding.appBar.getContext(),
                             R.animator.appbar_elevation_off)
                                                         );
-                    activity.toolbar.setVisibility(View.GONE);
-                    activity.searchCardView.setVisibility(View.VISIBLE);
+                    activity.binding.toolbar.setVisibility(View.GONE);
+                    activity.binding.searchToolbar.setVisibility(View.VISIBLE);
                     if (getResources() != null) {
                         DisplayUtils.applyColorToStatusBar(
                                 activity,
@@ -398,11 +398,11 @@ public class ConversationsListController extends BaseController implements Searc
     }
 
     public void showSearchView(MainActivity activity, SearchView searchView, MenuItem searchItem) {
-        activity.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
-                activity.appBar.getContext(),
+        activity.binding.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
+                activity.binding.appBar.getContext(),
                 R.animator.appbar_elevation_on));
-        activity.toolbar.setVisibility(View.VISIBLE);
-        activity.searchCardView.setVisibility(View.GONE);
+        activity.binding.toolbar.setVisibility(View.VISIBLE);
+        activity.binding.searchToolbar.setVisibility(View.GONE);
         searchItem.expandActionView();
     }
 
@@ -562,19 +562,17 @@ public class ConversationsListController extends BaseController implements Searc
         if (getActivity() != null && getActivity() instanceof MainActivity) {
             MainActivity activity = (MainActivity) getActivity();
 
-            if (activity.settingsButton != null) {
-                activity.settingsButton.setOnClickListener(v -> {
-                    if (getResources() != null && getResources().getBoolean(R.bool.multiaccount_support)) {
-                        DialogFragment newFragment = ChooseAccountDialogFragment.newInstance();
-                        newFragment.show(((MainActivity) getActivity()).getSupportFragmentManager(),
-                                         "ChooseAccountDialogFragment");
-                    } else {
-                        getRouter().pushController((RouterTransaction.with(new SettingsController())
-                                .pushChangeHandler(new HorizontalChangeHandler())
-                                .popChangeHandler(new HorizontalChangeHandler())));
-                    }
-                });
-            }
+            activity.binding.switchAccountButton.setOnClickListener(v -> {
+                if (getResources() != null && getResources().getBoolean(R.bool.multiaccount_support)) {
+                    DialogFragment newFragment = ChooseAccountDialogFragment.newInstance();
+                    newFragment.show(((MainActivity) getActivity()).getSupportFragmentManager(),
+                                     "ChooseAccountDialogFragment");
+                } else {
+                    getRouter().pushController((RouterTransaction.with(new SettingsController())
+                            .pushChangeHandler(new HorizontalChangeHandler())
+                            .popChangeHandler(new HorizontalChangeHandler())));
+                }
+            });
         }
     }
 

+ 15 - 14
app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java

@@ -117,7 +117,7 @@ public abstract class BaseController extends ButterKnifeController {
 
             if (getActivity() != null && getActivity() instanceof MainActivity) {
                 MainActivity activity = (MainActivity) getActivity();
-                disableKeyboardPersonalisedLearning(activity.appBar);
+                disableKeyboardPersonalisedLearning(activity.binding.appBar);
             }
         }
     }
@@ -152,32 +152,33 @@ public abstract class BaseController extends ButterKnifeController {
             MainActivity activity = (MainActivity) getActivity();
 
             if (getAppBarLayoutType() == AppBarLayoutType.EMPTY) {
-                activity.toolbar.setVisibility(View.GONE);
-                activity.getSearchCardView().setVisibility(View.GONE);
+                activity.binding.toolbar.setVisibility(View.GONE);
+                activity.binding.searchToolbar.setVisibility(View.GONE);
             } else {
-                AppBarLayout.LayoutParams layoutParams = (AppBarLayout.LayoutParams) activity.searchCardView.getLayoutParams();
+                AppBarLayout.LayoutParams layoutParams =
+                        (AppBarLayout.LayoutParams) activity.binding.searchToolbar.getLayoutParams();
 
                 if (showSearchBar) {
-                    activity.getSearchCardView().setVisibility(View.VISIBLE);
-                    activity.getSearchInputText().setHint(getSearchHint());
-                    activity.toolbar.setVisibility(View.GONE);
+                    activity.binding.searchToolbar.setVisibility(View.VISIBLE);
+                    activity.binding.searchText.setHint(getSearchHint());
+                    activity.binding.toolbar.setVisibility(View.GONE);
                     //layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
                     layoutParams.setScrollFlags(0);
-                    activity.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
-                            activity.appBar.getContext(),
+                    activity.binding.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
+                            activity.binding.appBar.getContext(),
                             R.animator.appbar_elevation_off)
                     );
                 } else {
-                    activity.getSearchCardView().setVisibility(View.GONE);
-                    activity.toolbar.setVisibility(View.VISIBLE);
+                    activity.binding.searchToolbar.setVisibility(View.GONE);
+                    activity.binding.toolbar.setVisibility(View.VISIBLE);
                     layoutParams.setScrollFlags(0);
-                    activity.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
-                            activity.appBar.getContext(),
+                    activity.binding.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
+                            activity.binding.appBar.getContext(),
                             R.animator.appbar_elevation_on)
                     );
                 }
 
-                activity.searchCardView.setLayoutParams(layoutParams);
+                activity.binding.searchToolbar.setLayoutParams(layoutParams);
 
                 if ((getResources() != null)) {
                     if (showSearchBar) {

+ 90 - 3
app/src/main/res/layout/activity_main.xml

@@ -40,9 +40,96 @@
         android:windowContentOverlay="@null"
         app:elevation="0dp">
 
-        <include
-            layout="@layout/search_layout"
-            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+        <com.google.android.material.card.MaterialCardView
+            android:id="@+id/search_toolbar"
+            android:layout_width="match_parent"
+            android:layout_height="50dp"
+            android:layout_marginStart="16dp"
+            android:layout_marginTop="5dp"
+            android:layout_marginEnd="16dp"
+            android:layout_marginBottom="1dp"
+            android:visibility="gone"
+            app:cardCornerRadius="8dp"
+            app:cardElevation="2dp"
+            app:strokeWidth="0dp"
+            tools:visibility="visible">
+
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+                <com.google.android.material.button.MaterialButton
+                    android:id="@+id/menu_button"
+                    style="@style/Widget.AppTheme.Button.IconButton"
+                    android:layout_width="3dp"
+                    android:layout_height="1dp"
+                    android:layout_marginStart="5dp"
+                    android:contentDescription="@string/nc_action_open_main_menu"
+                    android:visibility="gone"
+                    app:cornerRadius="@dimen/button_corner_radius"
+                    app:icon="@drawable/ic_menu"
+                    app:iconTint="@color/fontAppbar"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <com.google.android.material.textview.MaterialTextView
+                    android:id="@+id/search_text"
+                    android:layout_width="0dp"
+                    android:layout_height="48dp"
+                    android:layout_marginStart="13dp"
+                    android:layout_marginEnd="18dp"
+                    android:ellipsize="end"
+                    android:gravity="start|center_vertical"
+                    android:lines="1"
+                    android:textColor="@color/fontSecondaryAppbar"
+                    android:textSize="16sp"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintLeft_toRightOf="@id/menu_button"
+                    app:layout_constraintRight_toLeftOf="@id/rightContainer"
+                    app:layout_constraintTop_toTopOf="parent"
+                    tools:text="Search in Nextcloud" />
+
+                <FrameLayout
+                    android:id="@+id/rightContainer"
+                    android:layout_width="wrap_content"
+                    android:layout_height="match_parent"
+                    android:layout_alignParentEnd="true"
+                    android:minWidth="48dp"
+                    android:layout_centerVertical="true"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintTop_toTopOf="parent">
+
+                    <com.google.android.material.button.MaterialButton
+                        android:id="@+id/switch_account_button"
+                        style="@style/Widget.AppTheme.Button.IconButton"
+                        android:layout_width="48dp"
+                        android:layout_height="48dp"
+                        android:layout_gravity="center"
+                        android:contentDescription="@string/nc_settings"
+                        android:scaleType="fitCenter"
+                        android:transitionName="userAvatar.transitionTag"
+                        app:cornerRadius="@dimen/button_corner_radius"
+                        app:iconSize="@dimen/avatar_size_app_bar"
+                        tools:visibility="gone" />
+
+                    <ProgressBar
+                        android:id="@+id/searchProgressBar"
+                        android:layout_width="32dp"
+                        android:layout_height="32dp"
+                        android:padding="4dp"
+                        android:layout_gravity="center"
+                        android:indeterminate="true"
+                        android:indeterminateTint="@color/colorPrimary"
+                        android:scaleType="fitCenter"
+                        android:visibility="gone" />
+
+                </FrameLayout>
+
+            </androidx.constraintlayout.widget.ConstraintLayout>
+
+        </com.google.android.material.card.MaterialCardView>
 
         <com.google.android.material.appbar.MaterialToolbar
             android:id="@+id/toolbar"