For #1072: Adds grabber handle
parent
994d88542e
commit
4acd939289
|
@ -79,7 +79,7 @@ class BrowserFragment : Fragment(), BackHandler {
|
||||||
sessionId = BrowserFragmentArgs.fromBundle(arguments!!).sessionId
|
sessionId = BrowserFragmentArgs.fromBundle(arguments!!).sessionId
|
||||||
|
|
||||||
val view = inflater.inflate(R.layout.fragment_browser, container, false)
|
val view = inflater.inflate(R.layout.fragment_browser, container, false)
|
||||||
0
|
|
||||||
toolbarComponent = ToolbarComponent(
|
toolbarComponent = ToolbarComponent(
|
||||||
view.browserLayout,
|
view.browserLayout,
|
||||||
ActionBusFactory.get(this), sessionId,
|
ActionBusFactory.get(this), sessionId,
|
||||||
|
|
|
@ -2,20 +2,15 @@ package org.mozilla.fenix.quickactionsheet
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MotionEvent
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import androidx.appcompat.widget.AppCompatImageButton
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import kotlinx.android.synthetic.main.component_quickactionsheet.view.*
|
|
||||||
import mozilla.components.browser.toolbar.BrowserToolbar
|
import mozilla.components.browser.toolbar.BrowserToolbar
|
||||||
import mozilla.components.feature.findinpage.view.FindInPageBar
|
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import kotlin.math.absoluteValue
|
|
||||||
|
|
||||||
class QuickActionSheet @JvmOverloads constructor(
|
class QuickActionSheet @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -24,56 +19,26 @@ class QuickActionSheet @JvmOverloads constructor(
|
||||||
defStyleRes: Int = 0
|
defStyleRes: Int = 0
|
||||||
) : LinearLayout(context, attrs, defStyle, defStyleRes) {
|
) : LinearLayout(context, attrs, defStyle, defStyleRes) {
|
||||||
|
|
||||||
var currentMargin : Float = 0f
|
|
||||||
var previousY : Float = 0f
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
LayoutInflater.from(context)
|
inflate(getContext(), R.layout.component_quickactionsheet, this)
|
||||||
.inflate(R.layout.component_quickactionsheet, this, true)
|
//setupHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
private fun setupHandle() {
|
||||||
override fun onAttachedToWindow() {
|
val handle = findViewById<AppCompatImageButton>(R.id.quick_action_sheet_handle)
|
||||||
super.onAttachedToWindow()
|
|
||||||
|
|
||||||
val linearLayout = findViewById<LinearLayout>(R.id.quick_action_sheet)
|
val linearLayout = findViewById<LinearLayout>(R.id.quick_action_sheet)
|
||||||
val bottomSheetBehavior = BottomSheetBehavior.from(linearLayout)
|
val quickActionSheetBehavior = BottomSheetBehavior.from(linearLayout) as QuickActionSheetBehavior
|
||||||
bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
handle.setOnClickListener {
|
||||||
}
|
bounceSheet(quickActionSheetBehavior)
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
|
|
||||||
Log.d("touchEvent", "starting: " + rootView.y)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
|
||||||
/*
|
|
||||||
val layout = findViewById<LinearLayout>(R.id.quick_action_sheet)
|
|
||||||
|
|
||||||
val params = layout.layoutParams as ViewGroup.MarginLayoutParams
|
|
||||||
|
|
||||||
when (event?.action) {
|
|
||||||
MotionEvent.ACTION_MOVE -> {
|
|
||||||
Log.d("touchEvent", "handle move: " + (currentMargin))
|
|
||||||
|
|
||||||
|
|
||||||
previousY = event.y
|
|
||||||
|
|
||||||
params.bottomMargin += diff.toInt()
|
|
||||||
requestLayout()
|
|
||||||
}
|
|
||||||
MotionEvent.ACTION_UP -> Log.d("touchEvent", "handle up")
|
|
||||||
MotionEvent.ACTION_DOWN -> Log.d("touchEvent", "handle down")
|
|
||||||
else -> Log.d("touchEvent", "" + event?.action)
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
private fun bounceSheet(quickActionSheetBehavior: QuickActionSheetBehavior) {
|
||||||
|
quickActionSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
|
||||||
|
quickActionSheetBehavior.peekHeight = height
|
||||||
|
quickActionSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused") // Referenced from XML
|
@Suppress("unused") // Referenced from XML
|
||||||
|
|
|
@ -5,60 +5,75 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/quick_action_sheet"
|
android:id="@+id/quick_action_sheet"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:background="@color/photonBlue50">
|
android:background="@color/photonRed50">
|
||||||
|
|
||||||
<ImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:layout_weight="1"
|
android:id="@+id/quick_action_sheet_handle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="10dp"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_gravity="center"
|
||||||
android:layout_marginEnd="10dp"
|
android:src="@drawable/ic_close"/>
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:src="@drawable/library_icon_screenshots_circle_background"
|
|
||||||
android:background="?android:attr/selectableItemBackground"/>
|
|
||||||
|
|
||||||
<ImageButton
|
<LinearLayout
|
||||||
android:layout_weight="1"
|
android:orientation="horizontal"
|
||||||
android:layout_width="0dp"
|
android:layout_gravity="bottom"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_height="70dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:background="@color/photonBlue50">
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:src="@drawable/library_icon_downloads_circle_background"
|
|
||||||
android:background="?android:attr/selectableItemBackground"/>
|
|
||||||
|
|
||||||
<ImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:src="@drawable/library_icon_favorites_circle_background"
|
android:src="@drawable/library_icon_screenshots_circle_background"
|
||||||
android:background="?android:attr/selectableItemBackground"/>
|
android:background="?android:attr/selectableItemBackground"/>
|
||||||
|
|
||||||
<ImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:src="@drawable/library_icon_history_circle_background"
|
android:src="@drawable/library_icon_downloads_circle_background"
|
||||||
android:background="?android:attr/selectableItemBackground"/>
|
android:background="?android:attr/selectableItemBackground"/>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:src="@drawable/library_icon_history_circle_background"
|
android:src="@drawable/library_icon_favorites_circle_background"
|
||||||
android:background="?android:attr/selectableItemBackground"/>
|
android:background="?android:attr/selectableItemBackground"/>
|
||||||
</LinearLayout>
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/library_icon_history_circle_background"
|
||||||
|
android:background="?android:attr/selectableItemBackground"/>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/library_icon_history_circle_background"
|
||||||
|
android:background="?android:attr/selectableItemBackground"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
Loading…
Reference in New Issue