For #6820: Updates background, shadow, & snackbars of toolbar
parent
4b3effdfab
commit
9f342fca9e
|
@ -10,6 +10,7 @@ import android.content.DialogInterface
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -96,6 +97,15 @@ import kotlin.math.min
|
||||||
@ExperimentalCoroutinesApi
|
@ExperimentalCoroutinesApi
|
||||||
@SuppressWarnings("TooManyFunctions", "LargeClass")
|
@SuppressWarnings("TooManyFunctions", "LargeClass")
|
||||||
class HomeFragment : Fragment() {
|
class HomeFragment : Fragment() {
|
||||||
|
private val snackbarAnchorView: View?
|
||||||
|
get() {
|
||||||
|
return if (requireContext().settings().shouldUseBottomToolbar) {
|
||||||
|
toolbarLayout
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val browsingModeManager get() = (activity as HomeActivity).browsingModeManager
|
private val browsingModeManager get() = (activity as HomeActivity).browsingModeManager
|
||||||
|
|
||||||
private val singleSessionObserver = object : Session.Observer {
|
private val singleSessionObserver = object : Session.Observer {
|
||||||
|
@ -210,24 +220,23 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateLayout(view: View) {
|
private fun updateLayout(view: View) {
|
||||||
var shouldUseBottomToolbar = view.context.settings().shouldUseBottomToolbar
|
val shouldUseBottomToolbar = view.context.settings().shouldUseBottomToolbar
|
||||||
|
|
||||||
ConstraintSet().apply {
|
ConstraintSet().apply {
|
||||||
clone(view.homeLayout)
|
clone(view.homeLayout)
|
||||||
|
|
||||||
|
|
||||||
if (shouldUseBottomToolbar) {
|
if (shouldUseBottomToolbar) {
|
||||||
connect(sessionControlView.view.id, TOP, view.wordmark.id, BOTTOM)
|
connect(sessionControlView.view.id, TOP, view.wordmark.id, BOTTOM)
|
||||||
connect(sessionControlView.view.id, BOTTOM, view.bottom_bar.id, TOP)
|
connect(sessionControlView.view.id, BOTTOM, view.toolbarLayout.id, TOP)
|
||||||
|
|
||||||
connect(view.bottom_bar.id, BOTTOM, PARENT_ID, BOTTOM)
|
connect(view.toolbarLayout.id, BOTTOM, PARENT_ID, BOTTOM)
|
||||||
connect(view.bottomBarShadow.id, BOTTOM, view.bottom_bar.id, TOP)
|
|
||||||
connect(view.privateBrowsingButton.id, TOP, PARENT_ID, TOP)
|
connect(view.privateBrowsingButton.id, TOP, PARENT_ID, TOP)
|
||||||
} else {
|
} else {
|
||||||
connect(sessionControlView.view.id, TOP, view.wordmark.id, TOP)
|
connect(sessionControlView.view.id, TOP, view.wordmark.id, TOP)
|
||||||
connect(sessionControlView.view.id, BOTTOM, PARENT_ID, BOTTOM)
|
connect(sessionControlView.view.id, BOTTOM, PARENT_ID, BOTTOM)
|
||||||
|
|
||||||
connect(view.bottomBarShadow.id, BOTTOM, view.bottom_bar.id, BOTTOM)
|
connect(view.privateBrowsingButton.id, TOP, view.toolbarLayout.id, BOTTOM)
|
||||||
connect(view.privateBrowsingButton.id, TOP, view.bottomBarShadow.id, TOP)
|
|
||||||
}
|
}
|
||||||
connect(sessionControlView.view.id, START, PARENT_ID, START)
|
connect(sessionControlView.view.id, START, PARENT_ID, START)
|
||||||
connect(sessionControlView.view.id, END, PARENT_ID, END)
|
connect(sessionControlView.view.id, END, PARENT_ID, END)
|
||||||
|
@ -235,8 +244,8 @@ class HomeFragment : Fragment() {
|
||||||
applyTo(view.homeLayout)
|
applyTo(view.homeLayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
var headingsTopMargins = if (shouldUseBottomToolbar) { HEADER_MARGIN } else { TOP_TOOLBAR_HEADER_MARGIN }
|
val headingsTopMargins = if (shouldUseBottomToolbar) { HEADER_MARGIN } else { TOP_TOOLBAR_HEADER_MARGIN }
|
||||||
var sessionControlViewTopMargin = if (shouldUseBottomToolbar) {
|
val sessionControlViewTopMargin = if (shouldUseBottomToolbar) {
|
||||||
SESSION_CONTROL_VIEW_TOP_MARGIN
|
SESSION_CONTROL_VIEW_TOP_MARGIN
|
||||||
} else {
|
} else {
|
||||||
SESSION_CONTROL_VIEW_TOP_TOOLBAR_MARGIN
|
SESSION_CONTROL_VIEW_TOP_TOOLBAR_MARGIN
|
||||||
|
@ -341,9 +350,6 @@ class HomeFragment : Fragment() {
|
||||||
HomeFragmentAction.ModeChange(Mode.fromBrowsingMode(newMode)))
|
HomeFragmentAction.ModeChange(Mode.fromBrowsingMode(newMode)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need the shadow to be above the components.
|
|
||||||
bottomBarShadow.bringToFront()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
@ -368,7 +374,7 @@ class HomeFragment : Fragment() {
|
||||||
view?.let {
|
view?.let {
|
||||||
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT)
|
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT)
|
||||||
.setText(it.context.getString(R.string.onboarding_firefox_account_sync_is_on))
|
.setText(it.context.getString(R.string.onboarding_firefox_account_sync_is_on))
|
||||||
.setAnchorView(bottom_bar)
|
.setAnchorView(toolbarLayout)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -648,7 +654,7 @@ class HomeFragment : Fragment() {
|
||||||
emitSessionChanges()
|
emitSessionChanges()
|
||||||
},
|
},
|
||||||
operation = deleteOperation,
|
operation = deleteOperation,
|
||||||
anchorView = bottom_bar
|
anchorView = snackbarAnchorView
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,7 +684,7 @@ class HomeFragment : Fragment() {
|
||||||
emitSessionChanges()
|
emitSessionChanges()
|
||||||
},
|
},
|
||||||
operation = deleteOperation,
|
operation = deleteOperation,
|
||||||
anchorView = bottom_bar
|
anchorView = snackbarAnchorView
|
||||||
)
|
)
|
||||||
|
|
||||||
// Update the UI with the tab removed, but don't remove it from storage yet
|
// Update the UI with the tab removed, but don't remove it from storage yet
|
||||||
|
|
|
@ -39,83 +39,87 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/bottomBarShadow"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="@color/bottom_bar_shadow"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/bottom_bar" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/bottom_bar"
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/toolbarLayout"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="56dp"
|
android:elevation="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:background="?bottomBarBackground"
|
android:background="?bottomBarBackground"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
<org.mozilla.fenix.home.SearchView
|
<View
|
||||||
android:id="@+id/toolbar_wrapper"
|
android:id="@+id/bottom_bar"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="56dp"
|
||||||
android:layout_marginStart="8dp"
|
android:background="?bottomBarBackground"
|
||||||
android:layout_marginEnd="0dp"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:background="@drawable/home_search_background_normal"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:clickable="true"
|
app:layout_constraintTop_toBottomOf="parent"/>
|
||||||
android:contentDescription="@string/search_hint"
|
|
||||||
android:focusable="true"
|
|
||||||
android:transitionName="toolbar_wrapper_transition"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@id/bottom_bar"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/add_tab_button"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/bottom_bar">
|
|
||||||
|
|
||||||
<ImageView
|
<org.mozilla.fenix.home.SearchView
|
||||||
android:id="@+id/search_engine_icon"
|
android:id="@+id/toolbar_wrapper"
|
||||||
android:layout_width="24dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="start|center_vertical"
|
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:clickable="false"
|
android:layout_marginEnd="0dp"
|
||||||
android:focusable="false"
|
android:background="@drawable/home_search_background_normal"
|
||||||
android:importantForAccessibility="no" />
|
android:clickable="true"
|
||||||
|
android:contentDescription="@string/search_hint"
|
||||||
|
android:focusable="true"
|
||||||
|
android:transitionName="toolbar_wrapper_transition"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/add_tab_button"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/search_engine_icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="24dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="24dp"
|
||||||
android:layout_gravity="start|center_vertical"
|
android:layout_gravity="start|center_vertical"
|
||||||
android:layout_marginStart="44dp"
|
android:layout_marginStart="8dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:ellipsize="end"
|
android:focusable="false"
|
||||||
android:focusable="false"
|
android:importantForAccessibility="no" />
|
||||||
android:importantForAccessibility="no"
|
|
||||||
android:lines="1"
|
|
||||||
android:text="@string/search_hint"
|
|
||||||
android:textColor="?primaryText"
|
|
||||||
android:textSize="15sp" />
|
|
||||||
</org.mozilla.fenix.home.SearchView>
|
|
||||||
|
|
||||||
<ImageButton
|
<TextView
|
||||||
android:id="@+id/add_tab_button"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="48dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
android:layout_gravity="start|center_vertical"
|
||||||
android:contentDescription="@string/add_tab"
|
android:layout_marginStart="44dp"
|
||||||
app:srcCompat="@drawable/ic_new"
|
android:clickable="false"
|
||||||
app:layout_constraintTop_toTopOf="@id/bottom_bar"
|
android:ellipsize="end"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/bottom_bar"
|
android:focusable="false"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/menuButton"
|
android:importantForAccessibility="no"
|
||||||
app:layout_constraintStart_toEndOf="@id/toolbar_wrapper"/>
|
android:lines="1"
|
||||||
|
android:text="@string/search_hint"
|
||||||
<mozilla.components.browser.menu.view.MenuButton
|
android:textColor="?primaryText"
|
||||||
android:id="@+id/menuButton"
|
android:textSize="15sp" />
|
||||||
android:layout_width="36dp"
|
</org.mozilla.fenix.home.SearchView>
|
||||||
android:layout_height="48dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
<ImageButton
|
||||||
app:layout_constraintTop_toTopOf="@id/bottom_bar"
|
android:id="@+id/add_tab_button"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/bottom_bar"/>
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="@string/add_tab"
|
||||||
|
app:srcCompat="@drawable/ic_new"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/menuButton"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/toolbar_wrapper"/>
|
||||||
|
|
||||||
|
<mozilla.components.browser.menu.view.MenuButton
|
||||||
|
android:id="@+id/menuButton"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.motion.widget.MotionLayout>
|
</androidx.constraintlayout.motion.widget.MotionLayout>
|
||||||
|
|
Loading…
Reference in New Issue