Don’t draw app behind navbar

Fixes #1164
This commit is contained in:
Phillip Thelen 2019-06-03 17:12:29 +02:00
parent b456c7829e
commit f6d6308601
29 changed files with 62 additions and 102 deletions

View file

@ -34,7 +34,7 @@
<activity
android:name=".ui.activities.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:theme="@style/MainAppTheme"
android:windowSoftInputMode="stateHidden|adjustResize">
<nav-graph android:value="@navigation/navigation" />
<intent-filter>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/brand_100"/>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/login_logo"/>
</item>
</layer-list>

View file

@ -10,8 +10,7 @@
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:gravity="center">
android:gravity="center">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/main_content"
@ -52,8 +51,7 @@
android:layout_marginTop="?attr/actionBarSize"
android:adjustViewBounds="true"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
app:layout_collapseMode="parallax">

View file

@ -30,7 +30,6 @@
android:layout_marginTop="5dp"
android:adjustViewBounds="true"
android:background="@color/transparent"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">

View file

@ -9,8 +9,7 @@
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:gravity="center">
android:gravity="center">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/main_content"

View file

@ -10,8 +10,7 @@
android:layout_height="match_parent" />
<RelativeLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
android:layout_height="match_parent">
<com.viewpagerindicator.IconPageIndicator
android:id="@+id/view_pager_indicator"
android:layout_height="wrap_content"

View file

@ -10,8 +10,7 @@
android:layout_height="match_parent"
android:id="@+id/background_container"
android:scrollIndicators="none"
android:scrollbars="none"
>
android:scrollbars="none">
<com.habitrpg.android.habitica.ui.views.login.LoginBackgroundView
android:id="@+id/background_view"
@ -67,8 +66,7 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -78,8 +76,7 @@
android:id="@+id/login_intro_view"
android:orientation="vertical"
android:background="@color/transparent"
android:fitsSystemWindows="true"
>
>
<ImageView
android:id="@+id/logo_view"

View file

@ -16,8 +16,7 @@
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activities.MainActivity"
android:fitsSystemWindows="false">
tools:context=".ui.activities.MainActivity">
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
@ -140,7 +139,6 @@
app:bb_tabXmlResource="@xml/main_menu_tasks"
app:bb_inActiveTabColor="?colorPrimaryDistinct"
app:bb_activeTabColor="@color/white"
app:bb_behavior="underNavbar"
app:bb_badgesHideWhenActive="true"
app:bb_badgeBackgroundColor="?colorBadgeBackground"
android:layout_gravity="bottom"
@ -154,7 +152,6 @@
android:layout_height="match_parent"
android:id="@+id/overlayFrameLayout"
android:clickable="false"
android:fitsSystemWindows="true"
/>
</FrameLayout>

View file

@ -5,7 +5,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.activities.NotificationsActivity">
tools:context=".ui.activities.NotificationsActivity"
android:background="@color/white">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"

View file

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
android:background="@color/white">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
@ -42,6 +42,5 @@ android:id="@+id/snackbar_view"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/spacing_large"
android:fitsSystemWindows="true" />
android:layout_marginBottom="@dimen/spacing_large"/>
</FrameLayout>

View file

@ -5,7 +5,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activities.PrefsActivity"
android:orientation="vertical">
android:orientation="vertical"
android:background="@color/white">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"

View file

@ -2,8 +2,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -98,7 +98,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@"
android:text="\@"
android:gravity="center_vertical"
android:textColor="@color/gray_400"/>
<EditText android:id="@+id/username_edit_text"
@ -166,6 +166,5 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginBottom="@dimen/spacing_large"
android:layout_gravity="bottom"
android:fitsSystemWindows="true"/>
android:layout_gravity="bottom"/>
</FrameLayout>

View file

@ -13,7 +13,7 @@
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical"
android:layout_marginTop="@dimen/spacing_large"
android:paddingBottom="?attr/actionBarSize">
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -13,7 +13,7 @@
android:clipToPadding="false"
android:divider="@null"
android:scrollbars="vertical"
android:paddingBottom="?attr/actionBarSize" />
/>
<LinearLayout
android:id="@+id/emptyView"
android:layout_width="match_parent"

View file

@ -11,7 +11,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="?attr/actionBarSize">
>
<TextView
android:layout_width="match_parent"

View file

@ -13,7 +13,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="?attr/actionBarSize">
>
<TextView
android:layout_width="wrap_content"

View file

@ -9,7 +9,7 @@
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="?attr/actionBarSize">
>
<com.habitrpg.android.habitica.ui.views.PaddedLinearLayout
android:id="@+id/inbox_messages"
android:layout_width="match_parent"

View file

@ -7,8 +7,7 @@
android:layout_height="match_parent"
android:gravity="center_vertical"
android:background="@color/brand_300"
android:id="@+id/container_view"
android:fitsSystemWindows="true">
android:id="@+id/container_view">
<TextView
android:layout_width="wrap_content"

View file

@ -25,7 +25,7 @@
android:scrollbarSize="3dp"
android:scrollbarThumbVertical="@color/scrollbarThumb"
android:scrollbars="vertical"
android:paddingBottom="?attr/actionBarSize" />
/>
<TextView
android:layout_width="match_parent"

View file

@ -12,7 +12,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="?attr/actionBarSize">
>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -8,7 +8,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="?attr/actionBarSize">
>
<LinearLayout
android:background="@color/white"
android:layout_width="match_parent"

View file

@ -13,7 +13,6 @@
android:scrollbarThumbVertical="@color/scrollbarThumb"
android:scrollbars="vertical"
android:clipToPadding="false"
android:paddingBottom="?attr/actionBarSize"
android:background="@color/white"/>
<TextView

View file

@ -18,8 +18,7 @@
android:scrollbarSize="3dp"
android:scrollbarThumbVertical="@color/scrollbarThumb"
android:scrollbars="vertical"
android:clipToPadding="false"
android:paddingBottom="?attr/actionBarSize" />
android:clipToPadding="false" />
<LinearLayout
android:id="@+id/emptyView"

View file

@ -25,7 +25,7 @@
android:scrollbarSize="3dp"
android:scrollbarThumbVertical="@color/scrollbarThumb"
android:scrollbars="vertical"
android:paddingBottom="?attr/actionBarSize" />
/>
<FrameLayout
android:id="@+id/emptyView"

View file

@ -4,8 +4,7 @@
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:clickable="true"
android:fitsSystemWindows="true"
android:id="@+id/background">
android:id="@+id/background">
<View android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@android:color/black"
@ -17,8 +16,7 @@
android:paddingRight="16dp"
android:paddingBottom="24dp"
android:layout_alignParentBottom="true"
android:fitsSystemWindows="true"
android:layout_marginBottom="?actionBarSize">
android:layout_marginBottom="?actionBarSize">
<com.habitrpg.android.habitica.ui.SpeechBubbleView
android:id="@+id/speech_bubble"
android:layout_width="match_parent"

View file

@ -4,14 +4,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows="true"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/snackbar_view"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingStart="6dp"
android:gravity="center"
tools:background="@drawable/snackbar_background_green"
android:layout_marginBottom="16dp"
@ -29,8 +28,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="12dp"
android:paddingRight="18dp"
android:paddingStart="12dp"
android:paddingEnd="18dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<TextView
@ -77,7 +76,7 @@
android:id="@+id/rightTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4dp"
android:paddingStart="4dp"
tools:text="12"/>
</LinearLayout>
</LinearLayout>

View file

@ -2,11 +2,6 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="@+id/chatBarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/chatBarContent"
android:layout_width="match_parent"
@ -96,10 +91,4 @@
style="@style/HabiticaButton.Blue"
android:text="@string/i_agree_to_follow_the_guidelines"/>
</LinearLayout>
<Space
android:id="@+id/spacing"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</merge>

View file

@ -42,6 +42,7 @@
<item name="alertDialogTheme">@style/AlertDialogTheme</item>
</style>
<style name="BottomSheetTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
@ -60,9 +61,7 @@
<style name="AppTheme.ActionBar.Transparent" parent="AppTheme.ActionBar">
<item name="actionBarStyle">@style/ActionBarTransparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:navigationBarColor">@color/brand_50</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="windowNoTitle">true</item>
@ -76,13 +75,15 @@
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:navigationBarColor">@color/brand_50</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="MainAppTheme" parent="AppTheme.NoActionBar">
<item name="android:windowBackground">@drawable/activity_launch_background</item>
</style>
<style name="AppTheme.NoActionBar.Green">
<item name="colorPrimary">@color/green_10</item>
<item name="colorPrimaryDark">@color/green_5</item>

View file

@ -1,13 +1,14 @@
package com.habitrpg.android.habitica.ui.views.social
import android.content.Context
import android.os.Build
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.*
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.MultiAutoCompleteTextView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.view.updateLayoutParams
import com.habitrpg.android.habitica.HabiticaBaseApplication
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.data.SocialRepository
@ -16,12 +17,11 @@ import com.habitrpg.android.habitica.helpers.AppConfigManager
import com.habitrpg.android.habitica.models.social.ChatMessage
import com.habitrpg.android.habitica.ui.helpers.AutocompleteAdapter
import com.habitrpg.android.habitica.ui.helpers.AutocompleteTokenizer
import com.habitrpg.android.habitica.ui.helpers.NavbarUtils
import com.habitrpg.android.habitica.ui.helpers.bindView
import javax.inject.Inject
class ChatBarView : FrameLayout {
class ChatBarView : LinearLayout {
@Inject
lateinit var socialRepository: SocialRepository
@ -33,8 +33,6 @@ class ChatBarView : FrameLayout {
private val chatEditText: MultiAutoCompleteTextView by bindView(R.id.chatEditText)
private val textIndicator: TextView by bindView(R.id.text_indicator)
private val indicatorSpacing: View by bindView(R.id.indicator_spacing)
private val spacing: Space by bindView(R.id.spacing)
private var navBarAccountedHeightCalculated = false
var chatMessages: List<ChatMessage>
get() = autocompleteAdapter?.chatMessages ?: listOf()
@ -67,6 +65,7 @@ class ChatBarView : FrameLayout {
private var autocompleteAdapter: AutocompleteAdapter? = null
private fun setupView(context: Context) {
orientation = LinearLayout.VERTICAL
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
inflater?.inflate(R.layout.tavern_chat_new_entry_item, this)
this.setBackgroundResource(R.color.white)
@ -80,8 +79,6 @@ class ChatBarView : FrameLayout {
sendButton.setOnClickListener { sendButtonPressed() }
resizeForDrawingUnderNavbar()
autocompleteAdapter = AutocompleteAdapter(context, socialRepository, autocompleteContext, groupID, appConfigManager.enableUsernameAutocomplete())
chatEditText.setAdapter(autocompleteAdapter)
chatEditText.threshold = 2
@ -106,29 +103,6 @@ class ChatBarView : FrameLayout {
}
}
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
super.onLayout(changed, left, top, right, bottom)
if (changed) {
resizeForDrawingUnderNavbar()
}
}
//https://github.com/roughike/BottomBar/blob/master/bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java#L834
private fun resizeForDrawingUnderNavbar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
val currentHeight = height
if (currentHeight != 0 && !navBarAccountedHeightCalculated) {
navBarAccountedHeightCalculated = true
val navbarHeight = NavbarUtils.getNavbarHeight(context)
spacing.updateLayoutParams<LinearLayout.LayoutParams> {
height = navbarHeight
}
}
}
}
private fun setSendButtonEnabled(enabled: Boolean) {
val tintColor: Int = if (enabled) {
ContextCompat.getColor(context, R.color.brand_400)