package org.wikimedia.wikipedia;

import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

public class QuickReturnHandler implements  ObservableWebView.OnScrollChangeListener {
    private final ObservableWebView webview;
    private final View quickReturnView;

    public QuickReturnHandler(ObservableWebView webview, View quickReturnView) {
        this.webview = webview;
        this.quickReturnView =  quickReturnView;

        webview.setOnScrollChangeListener(this);
    }

    @Override
    public void onScrollChanged(int oldScrollY, int scrollY) {
        int animMargin;
        if (oldScrollY > scrollY) {
            int minMargin = 0;
            int scrollDelta = (oldScrollY - scrollY) / 2;
            int newMargin = (int)quickReturnView.getTranslationY() + scrollDelta;
            animMargin = Math.min(minMargin, newMargin);
        } else {
            // scroll downn!
            int minMargin = -quickReturnView.getHeight();
            int scrollDelta = (scrollY - oldScrollY) / 2;
            int newMargin = (int)quickReturnView.getTranslationY() - scrollDelta;
            animMargin = Math.max(minMargin, newMargin);
        }
        quickReturnView.setTranslationY(animMargin);
    }
}

@@ -317,16 +317,112 @@
 Listener
+, ObservableWebView.OnUpOrCancelMotionEventListener, ObservableWebView.OnDownMotionEventListener
  %7B%0A    p
@@ -722,87 +722,528 @@
     
-%7D%0A%0A    @Override%0A    public void onScrollChanged(int oldScrollY, int scrollY) %7B
+    webview.setOnDownMotionEventListener(this);%0A        webview.setOnUpOrCancelMotionEventListener(this);%0A    %7D%0A%0A    @Override%0A    public void onScrollChanged(int oldScrollY, int scrollY) %7B%0A        if (scrollY %3C= webview.getHeight()) %7B%0A            // For the first screenful, ensure it always exists.%0A            if (quickReturnView.getTranslationY() != 0) %7B%0A                quickReturnView.animate().translationY(0).setDuration(WikipediaApp.SHORT_ANIMATION_DURATION).start();%0A            %7D%0A            return;%0A        %7D
 %0A   
@@ -1896,11 +1896,727 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void onUpOrCancelMotionEvent() %7B%0A        int transY = (int)quickReturnView.getTranslationY();%0A        int height = quickReturnView.getHeight();%0A        if (transY != 0 && transY %3E -height) %7B%0A            if (transY %3E -height / 2 ) %7B%0A                // Fully display it%0A                quickReturnView.animate().translationY(0).setDuration(WikipediaApp.SHORT_ANIMATION_DURATION).start();%0A            %7D else %7B%0A                // Fully hide it%0A                quickReturnView.animate().translationY(-height).setDuration(WikipediaApp.SHORT_ANIMATION_DURATION).start();%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void onDownMotionEvent() %7B%0A        // Don't do anything for now%0A    %7D
 %0A%7D%0A

Make sure that the Search bar is never in 'indeterminate' state