Temporal edge navigation feature

- User can swipe from left and right edge to go
  back and forward in history of a tab

Change-Id: I941f91122510b004bdcb6a718eb6c05730694960
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 089c7f0..c24cc48 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -109,6 +109,9 @@
     private NavigationBarBase mNavigationBar;
     private boolean mBlockFocusAnimations;
 
+    private EdgeSwipeController mEdgeSwipeController;
+    private EdgeSwipeSettings mEdgeSwipeSettings;
+
     public BaseUi(Activity browser, UiController controller) {
         mActivity = browser;
         mUiController = controller;
@@ -205,6 +208,12 @@
     }
 
     public void onConfigurationChanged(Configuration config) {
+        if (mEdgeSwipeController != null) {
+            mEdgeSwipeController.onConfigurationChanged();
+        }
+        if (mEdgeSwipeSettings != null) {
+            mEdgeSwipeSettings.onConfigurationChanged();
+        }
     }
 
     public Activity getActivity() {
@@ -442,9 +451,49 @@
             }
             mContentView.addView(container, COVER_SCREEN_PARAMS);
         }
+
+        refreshEdgeSwipeController(container);
+
         mUiController.attachSubWindow(tab);
     }
 
+    public void refreshEdgeSwipeController(View container) {
+        if (mEdgeSwipeController != null) {
+            mEdgeSwipeController.cleanup();
+        }
+
+        mEdgeSwipeSettings = null;
+
+        String action = BrowserSettings.getInstance().getEdgeSwipeAction();
+
+        if (action.equalsIgnoreCase(
+                mActivity.getResources().getString(R.string.value_temporal_edge_swipe))) {
+            mEdgeSwipeController = new EdgeSwipeController(
+                    container,
+                    R.id.stationary_navview,
+                    R.id.sliding_navview,
+                    R.id.sliding_navview_shadow,
+                    R.id.navview_opacity,
+                    R.id.webview_wrapper,
+                    R.id.draggable_mainframe,
+                    this);
+        } else if (action.equalsIgnoreCase(
+                mActivity.getResources().getString(R.string.value_unknown_edge_swipe))) {
+            mEdgeSwipeSettings = new EdgeSwipeSettings(
+                    container,
+                    R.id.stationary_navview,
+                    R.id.edge_sliding_settings,
+                    R.id.sliding_navview_shadow,
+                    R.id.webview_wrapper,
+                    R.id.draggable_mainframe,
+                    this);
+        } else {
+            DraggableFrameLayout draggableView = (DraggableFrameLayout)
+                    container.findViewById(R.id.draggable_mainframe);
+            draggableView.setDragHelper(null);
+        }
+    }
+
     private void removeTabFromContentView(Tab tab) {
         hideTitleBar();
         // Remove the container that contains the main WebView.