Fix missing snackbar in sync settings fragment (#1325)

This commit is contained in:
Rafał Borcz 2021-05-03 16:42:59 +02:00 committed by GitHub
parent 56e4e9be5e
commit 075cfb20b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 24 deletions

View File

@ -13,13 +13,10 @@ import android.os.Build.VERSION_CODES.P
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.ViewGroup
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.core.view.updateMargins
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.preference.Preference import androidx.preference.Preference
@ -76,7 +73,7 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
private val overlayProvider by lazy { ElevationOverlayProvider(this) } private val overlayProvider by lazy { ElevationOverlayProvider(this) }
private val navController = private val navController =
FragNavController(supportFragmentManager, R.id.mainFragmentContainer) FragNavController(supportFragmentManager, R.id.main_fragment_container)
companion object { companion object {
const val EXTRA_START_MENU = "extraStartMenu" const val EXTRA_START_MENU = "extraStartMenu"
@ -118,7 +115,7 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(ActivityMainBinding.inflate(layoutInflater).apply { binding = this }.root) setContentView(ActivityMainBinding.inflate(layoutInflater).apply { binding = this }.root)
setSupportActionBar(binding.mainToolbar) setSupportActionBar(binding.mainToolbar)
messageContainer = binding.mainFragmentContainer messageContainer = binding.mainMessageContainer
updateHelper.messageContainer = binding.mainFragmentContainer updateHelper.messageContainer = binding.mainFragmentContainer
val section = MainView.Section.values() val section = MainView.Section.values()
@ -237,18 +234,12 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
setOnViewChangeListener { section, name -> setOnViewChangeListener { section, name ->
if (section == MainView.Section.ACCOUNT || section == MainView.Section.STUDENT_INFO) { if (section == MainView.Section.ACCOUNT || section == MainView.Section.STUDENT_INFO) {
binding.mainBottomNav.isVisible = false binding.mainBottomNav.isVisible = false
binding.mainFragmentContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
updateMargins(bottom = 0)
}
if (appInfo.systemVersion >= P) { if (appInfo.systemVersion >= P) {
window.navigationBarColor = getThemeAttrColor(R.attr.colorSurface) window.navigationBarColor = getThemeAttrColor(R.attr.colorSurface)
} }
} else { } else {
binding.mainBottomNav.isVisible = true binding.mainBottomNav.isVisible = true
binding.mainFragmentContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> {
updateMargins(bottom = dpToPx(56f).toInt())
}
if (appInfo.systemVersion >= P) { if (appInfo.systemVersion >= P) {
window.navigationBarColor = window.navigationBarColor =

View File

@ -1,30 +1,37 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainContainer" android:id="@+id/main_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/mainToolbar" android:id="@+id/main_toolbar"
style="@style/Widget.MaterialComponents.Toolbar.Surface" style="@style/Widget.MaterialComponents.Toolbar.Surface"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:contentInsetStartWithNavigation="0dp" /> app:contentInsetStartWithNavigation="0dp"
app:layout_constraintTop_toTopOf="parent" />
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView
android:id="@+id/mainFragmentContainer" android:id="@+id/main_fragment_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:layout_marginTop="?actionBarSize" app:layout_constraintBottom_toTopOf="@id/main_bottom_nav"
android:layout_marginBottom="56dp" /> app:layout_constraintTop_toBottomOf="@id/main_toolbar" />
<com.google.android.material.bottomnavigation.BottomNavigationView <androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/mainBottomNav" android:id="@+id/main_message_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/main_bottom_nav" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/main_bottom_nav"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:itemTextAppearanceActive="@style/WulkanowyTheme.TextAppearanceBottomNavigation" app:itemTextAppearanceActive="@style/WulkanowyTheme.TextAppearanceBottomNavigation"
app:itemTextAppearanceInactive="@style/WulkanowyTheme.TextAppearanceBottomNavigation" app:itemTextAppearanceInactive="@style/WulkanowyTheme.TextAppearanceBottomNavigation"
app:labelVisibilityMode="labeled" /> app:labelVisibilityMode="labeled"
</androidx.coordinatorlayout.widget.CoordinatorLayout> app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>