From 833ebbc9e330d24e1f90e3bdc7ca17bd23e85f80 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 18 May 2021 17:58:09 +0200 Subject: [PATCH] use native view bindings in activities Signed-off-by: Andy Scherzinger --- .../activities/FullScreenImageActivity.kt | 42 ++++----- .../activities/FullScreenMediaActivity.kt | 22 +++-- .../FullScreenTextViewerActivity.kt | 19 ++-- .../talk/activities/MagicCallActivity.kt | 29 +++--- .../nextcloud/talk/activities/MainActivity.kt | 41 ++------ .../ConversationsListController.java | 44 +++++---- .../talk/controllers/base/BaseController.java | 29 +++--- app/src/main/res/layout/activity_main.xml | 93 ++++++++++++++++++- 8 files changed, 190 insertions(+), 129 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/FullScreenImageActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/FullScreenImageActivity.kt index 61ebf843b..4b1410d28 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/FullScreenImageActivity.kt +++ b/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 * 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)) + binding = ActivityFullScreenImageBinding.inflate(layoutInflater) + setContentView(binding.root) + + setSupportActionBar(binding.imageviewToolbar) supportActionBar?.setDisplayShowTitleEnabled(false) - imageWrapperView = findViewById(R.id.image_wrapper_view) - photoView = findViewById(R.id.photo_view) - gifView = findViewById(R.id.gif_view) - - 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)) } } diff --git a/app/src/main/java/com/nextcloud/talk/activities/FullScreenMediaActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/FullScreenMediaActivity.kt index d5a689624..caad124b9 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/FullScreenMediaActivity.kt +++ b/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 * * 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) } diff --git a/app/src/main/java/com/nextcloud/talk/activities/FullScreenTextViewerActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/FullScreenTextViewerActivity.kt index 867fb9b39..1949e5dd7 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/FullScreenTextViewerActivity.kt +++ b/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 * * 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 } } diff --git a/app/src/main/java/com/nextcloud/talk/activities/MagicCallActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/MagicCallActivity.kt index 55e2b57e5..1676f2c32 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/MagicCallActivity.kt +++ b/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 * * 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 } diff --git a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt index ea0ff0737..83122dcc9 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt +++ b/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() } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 7c076c198..2b5e9afa1 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/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()))); + } + }); } } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java b/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java index f445e356d..8282bf63a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java +++ b/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) { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 0f5474204..e5171a4ad 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -40,9 +40,96 @@ android:windowContentOverlay="@null" app:elevation="0dp"> - + + + + + + + + + + + + + + + + + + +