Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit 9937d7b

Browse files
hunterstichGerrit Code Review
authored andcommitted
Merge "BottomAppBar window inset fix."
2 parents cc9f061 + 180c391 commit 9937d7b

File tree

4 files changed

+8
-34
lines changed

4 files changed

+8
-34
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:supportsRtl="true"
1111
android:theme="@style/Theme.Reply.DayNight">
12-
<activity android:name="com.materialstudies.reply.ui.MainActivity">
12+
<activity android:name=".ui.MainActivity">
1313
<intent-filter>
1414
<action android:name="android.intent.action.MAIN" />
15-
1615
<category android:name="android.intent.category.LAUNCHER" />
1716
</intent-filter>
1817
</activity>

app/src/main/java/com/materialstudies/reply/ui/MainActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class MainActivity : AppCompatActivity(),
159159
private fun setBottomAppBarForHome(@MenuRes menuRes: Int) {
160160
binding.run {
161161
fab.setImageState(intArrayOf(-android.R.attr.state_activated), true)
162+
bottomAppBar.visibility = View.VISIBLE
162163
bottomAppBar.replaceMenu(menuRes)
163164
fab.contentDescription = getString(R.string.fab_compose_email_content_description)
164165
bottomAppBarTitle.visibility = View.VISIBLE
@@ -170,6 +171,7 @@ class MainActivity : AppCompatActivity(),
170171
private fun setBottomAppBarForEmail(@MenuRes menuRes: Int) {
171172
binding.run {
172173
fab.setImageState(intArrayOf(android.R.attr.state_activated), true)
174+
bottomAppBar.visibility = View.VISIBLE
173175
bottomAppBar.replaceMenu(menuRes)
174176
fab.contentDescription = getString(R.string.fab_reply_email_content_description)
175177
bottomAppBarTitle.visibility = View.INVISIBLE
@@ -182,6 +184,9 @@ class MainActivity : AppCompatActivity(),
182184
binding.run {
183185
bottomAppBar.performHide()
184186
fab.hide()
187+
// Hide the BottomAppBar to avoid it showing above the keyboard
188+
// when composing a new email.
189+
bottomAppBar.visibility = View.GONE
185190
}
186191
}
187192

app/src/main/java/com/materialstudies/reply/util/BindingAdapter.kt

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
package com.materialstudies.reply.util
1717

1818
import android.content.Context
19-
import android.graphics.Color
20-
import android.graphics.Rect
2119
import android.graphics.drawable.ColorDrawable
2220
import android.graphics.drawable.Drawable
23-
import android.graphics.drawable.GradientDrawable
2421
import android.view.View
2522
import android.view.View.GONE
2623
import android.view.View.VISIBLE
@@ -30,11 +27,6 @@ import android.widget.ImageView
3027
import android.widget.Spinner
3128
import android.widget.TextView
3229
import androidx.annotation.DrawableRes
33-
import androidx.core.content.ContextCompat
34-
import androidx.core.graphics.blue
35-
import androidx.core.graphics.green
36-
import androidx.core.graphics.red
37-
import androidx.core.view.doOnNextLayout
3830
import androidx.core.view.updateLayoutParams
3931
import androidx.databinding.BindingAdapter
4032
import com.bumptech.glide.Glide
@@ -180,26 +172,6 @@ fun View.bindLayoutFullscreen(previousFullscreen: Boolean, fullscreen: Boolean)
180172
}
181173
}
182174

183-
@BindingAdapter(
184-
"heightAdditiveTopSystemWindowInsets",
185-
"heightAdditiveBottomSystemWindowInsets",
186-
requireAll = false
187-
)
188-
fun View.bindSystemWindowInsetHeight(
189-
previousApplyTop: Boolean,
190-
previousApplyBottom: Boolean,
191-
applyTop: Boolean,
192-
applyBottom: Boolean
193-
) {
194-
if (previousApplyTop == applyTop && previousApplyBottom == applyBottom) return
195-
doOnApplyWindowInsets { view, insets, _, _, initialHeight ->
196-
val top = if (applyTop) insets.systemWindowInsetTop else 0
197-
val bottom = if (applyBottom) insets.systemWindowInsetBottom else 0
198-
199-
view.layoutParams.height = initialHeight + top + bottom
200-
}
201-
}
202-
203175
@BindingAdapter(
204176
"paddingLeftSystemWindowInsets",
205177
"paddingTopSystemWindowInsets",

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@
4141
<com.google.android.material.bottomappbar.BottomAppBar
4242
android:id="@+id/bottom_app_bar"
4343
android:layout_width="match_parent"
44-
android:layout_height="@dimen/bottom_app_bar_height"
44+
android:layout_height="wrap_content"
4545
android:layout_gravity="bottom"
46-
android:gravity="top"
4746
app:fabAlignmentMode="center"
4847
app:fabCradleRoundedCornerRadius="@dimen/bottom_app_bar_fab_cradle_corner_radius"
4948
app:fabCradleMargin="@dimen/bottom_app_bar_fab_cradle_margin"
50-
app:hideOnScroll="true"
51-
app:heightAdditiveBottomSystemWindowInsets="@{true}">
49+
app:hideOnScroll="true">
5250

5351
<LinearLayout
5452
android:id="@+id/bottom_app_bar_content_container"

0 commit comments

Comments
 (0)