diff --git a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt index 212f4e044..305b4637f 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt @@ -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, diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarUIView.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarUIView.kt index 7fc709199..a0f94f519 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarUIView.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarUIView.kt @@ -33,7 +33,7 @@ class ToolbarUIView( .findViewById(R.id.toolbar) private val urlBackground = LayoutInflater.from(container.context) - .inflate(R.layout.layout_url_backround, container, false) + .inflate(R.layout.layout_url_background, container, false) init { view.apply { diff --git a/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt b/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt index 2b3f99730..2cf6750f6 100644 --- a/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/SessionBottomSheetFragment.kt @@ -18,7 +18,7 @@ class SessionBottomSheetFragment : BottomSheetDialogFragment(), LayoutContainer sealed class SessionType { data class Current(val titles: List) : SessionType() data class Archived(val archivedSession: ArchivedSession) : SessionType() - data class Private(val titles: List) : SessionType() + data class Private(val titles: List ) : SessionType() } private var sessionType: SessionType? = null diff --git a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt new file mode 100644 index 000000000..4001d072d --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt @@ -0,0 +1,109 @@ +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.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, + attrs: AttributeSet? = null, + defStyle: Int = 0, + 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) + } + + /* + override fun onAttachedToWindow() { + super.onAttachedToWindow() + + val linearLayout = findViewById(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(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 + } + */ +} + +@Suppress("unused") // Referenced from XML +class QuickActionSheetBehavior( + context: Context, + attrs: AttributeSet +) : BottomSheetBehavior(context, attrs) { + override fun layoutDependsOn(parent: CoordinatorLayout, child: NestedScrollView, dependency: View): Boolean { + if (dependency is BrowserToolbar) { + return true + } + + return super.layoutDependsOn(parent, child, dependency) + } + + override fun onDependentViewChanged( + parent: CoordinatorLayout, + child: NestedScrollView, + dependency: View + ): Boolean { + return if (dependency is BrowserToolbar) { + repositionQuickActionSheet(child, dependency) + true + } else { + false + } + } + + private fun repositionQuickActionSheet(quickActionSheetContainer: NestedScrollView, toolbar: BrowserToolbar) { + state = BottomSheetBehavior.STATE_COLLAPSED + quickActionSheetContainer.translationY = (toolbar.translationY + toolbar.height * -1.0).toFloat() + } +} \ No newline at end of file diff --git a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheetIntegration.kt b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheetIntegration.kt new file mode 100644 index 000000000..74cb8b97a --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheetIntegration.kt @@ -0,0 +1,39 @@ +package org.mozilla.fenix.quickactionsheet + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import androidx.coordinatorlayout.widget.CoordinatorLayout +import mozilla.components.browser.toolbar.BrowserToolbar +import mozilla.components.feature.findinpage.view.FindInPageBar + +/** + * [CoordinatorLayout.Behavior] that will always position the [QuickActionSheetBar] above the [BrowserToolbar] (including + * when the browser toolbar is scrolling or performing a snap animation). + */ +@Suppress("unused") // Referenced from XML +class QuickActionSheetIntegration( + context: Context, + attrs: AttributeSet +) : CoordinatorLayout.Behavior(context, attrs) { + override fun layoutDependsOn(parent: CoordinatorLayout, child: FindInPageBar, dependency: View): Boolean { + if (dependency is BrowserToolbar) { + return true + } + + return super.layoutDependsOn(parent, child, dependency) + } + + override fun onDependentViewChanged(parent: CoordinatorLayout, child: FindInPageBar, dependency: View): Boolean { + return if (dependency is BrowserToolbar) { + repositionFindInPageBar(child, dependency) + true + } else { + false + } + } + + private fun repositionFindInPageBar(findInPageView: FindInPageBar, toolbar: BrowserToolbar) { + findInPageView.translationY = (toolbar.translationY + toolbar.height * -1.0).toFloat() + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/library_icon_send_circle_background.xml b/app/src/main/res/drawable/library_icon_send_circle_background.xml new file mode 100644 index 000000000..29b092107 --- /dev/null +++ b/app/src/main/res/drawable/library_icon_send_circle_background.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/component_quickactionsheet.xml b/app/src/main/res/layout/component_quickactionsheet.xml new file mode 100644 index 000000000..cf84c0a69 --- /dev/null +++ b/app/src/main/res/layout/component_quickactionsheet.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_browser.xml b/app/src/main/res/layout/fragment_browser.xml index b821b73d9..ae4be69dc 100644 --- a/app/src/main/res/layout/fragment_browser.xml +++ b/app/src/main/res/layout/fragment_browser.xml @@ -14,7 +14,23 @@ + android:layout_height="match_parent"/> + + + + + +