1
0
Fork 0

For #1072: Adds grabber handle

master
Sawyer Blatz 2019-03-19 13:26:36 -07:00 committed by Colin Lee
parent 994d88542e
commit 4acd939289
3 changed files with 79 additions and 99 deletions

View File

@ -79,7 +79,7 @@ class BrowserFragment : Fragment(), BackHandler {
sessionId = BrowserFragmentArgs.fromBundle(arguments!!).sessionId
val view = inflater.inflate(R.layout.fragment_browser, container, false)
0
toolbarComponent = ToolbarComponent(
view.browserLayout,
ActionBusFactory.get(this), sessionId,

View File

@ -2,20 +2,15 @@ package org.mozilla.fenix.quickactionsheet
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.appcompat.widget.AppCompatImageButton
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.widget.NestedScrollView
import com.google.android.material.bottomsheet.BottomSheetBehavior
import kotlinx.android.synthetic.main.component_quickactionsheet.view.*
import mozilla.components.browser.toolbar.BrowserToolbar
import mozilla.components.feature.findinpage.view.FindInPageBar
import org.mozilla.fenix.R
import kotlin.math.absoluteValue
class QuickActionSheet @JvmOverloads constructor(
context: Context,
@ -24,56 +19,26 @@ class QuickActionSheet @JvmOverloads constructor(
defStyleRes: Int = 0
) : LinearLayout(context, attrs, defStyle, defStyleRes) {
var currentMargin : Float = 0f
var previousY : Float = 0f
init {
LayoutInflater.from(context)
.inflate(R.layout.component_quickactionsheet, this, true)
inflate(getContext(), R.layout.component_quickactionsheet, this)
//setupHandle()
}
/*
override fun onAttachedToWindow() {
super.onAttachedToWindow()
private fun setupHandle() {
val handle = findViewById<AppCompatImageButton>(R.id.quick_action_sheet_handle)
val linearLayout = findViewById<LinearLayout>(R.id.quick_action_sheet)
val bottomSheetBehavior = BottomSheetBehavior.from(linearLayout)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
}
*/
/*
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)
val quickActionSheetBehavior = BottomSheetBehavior.from(linearLayout) as QuickActionSheetBehavior
handle.setOnClickListener {
bounceSheet(quickActionSheetBehavior)
}
*/
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

View File

@ -5,60 +5,75 @@
<LinearLayout
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:orientation="horizontal"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@color/photonBlue50">
android:background="@color/photonRed50">
<ImageButton
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_screenshots_circle_background"
android:background="?android:attr/selectableItemBackground"/>
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/quick_action_sheet_handle"
android:layout_width="wrap_content"
android:layout_height="10dp"
android:layout_gravity="center"
android:src="@drawable/ic_close"/>
<ImageButton
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_downloads_circle_background"
android:background="?android:attr/selectableItemBackground"/>
<LinearLayout
android:orientation="horizontal"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@color/photonBlue50">
<ImageButton
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_favorites_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_screenshots_circle_background"
android:background="?android:attr/selectableItemBackground"/>
<ImageButton
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_downloads_circle_background"
android:background="?android:attr/selectableItemBackground"/>
<androidx.appcompat.widget.AppCompatImageButton
<ImageButton
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>
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_favorites_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"/>
<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>