Skip to content

Commit

Permalink
Make SearchActivity draw edge-to-edge.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Jun 14, 2019
1 parent f028b69 commit c29dee5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions search/src/main/java/io/plaidapp/search/ui/SearchActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import android.transition.TransitionSet
import android.util.SparseArray
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.MarginLayoutParams
import android.view.ViewStub
import android.view.inputmethod.EditorInfo
import android.widget.Button
Expand All @@ -45,6 +46,9 @@ import androidx.annotation.TransitionRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.text.set
import androidx.core.text.toSpannable
import androidx.core.view.marginBottom
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -104,6 +108,7 @@ class SearchActivity : AppCompatActivity() {
setContentView(R.layout.activity_search)
bindResources()
setupSearchView()
setupInsets()

Injector.inject(this)

Expand Down Expand Up @@ -199,6 +204,26 @@ class SearchActivity : AppCompatActivity() {
columns = resources.getInteger(io.plaidapp.core.R.integer.num_columns)
}

private fun setupInsets() {
container.apply {
systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
val stableFabMarginBottom = fab.marginBottom
setOnApplyWindowInsetsListener { _, insets ->
updatePadding(top = insets.systemWindowInsetTop)
results.updatePadding(bottom = insets.systemWindowInsetBottom)
fab.updateLayoutParams<MarginLayoutParams> {
stableFabMarginBottom + insets.systemWindowInsetBottom
}
confirmSaveContainer.updateLayoutParams<MarginLayoutParams> {
stableFabMarginBottom + insets.systemWindowInsetBottom
}
insets
}
}
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
if (intent.hasExtra(SearchManager.QUERY)) {
Expand Down
2 changes: 1 addition & 1 deletion search/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<style name="Plaid.Translucent.Search">
<item name="android:windowAnimationStyle">@style/SearchWindowAnimations</item>
<item name="android:statusBarColor">@color/background_super_dark</item>
<item name="android:navigationBarColor">@color/background_super_dark</item>
<item name="android:navigationBarColor">@color/nav_bar</item>
<item name="android:windowEnterTransition">@transition/search_enter</item>
<item name="android:windowReturnTransition">@transition/search_return</item>
<item name="android:windowSharedElementEnterTransition">@transition/search_shared_enter</item>
Expand Down

0 comments on commit c29dee5

Please sign in to comment.