Most Visited custom homepage

Change-Id: Ic57762855e5d187aa0fe3a8eab2757b5a76ff08d
diff --git a/res/raw/most_visited.ktpl b/res/raw/most_visited.ktpl
new file mode 100644
index 0000000..04b9eee
--- /dev/null
+++ b/res/raw/most_visited.ktpl
@@ -0,0 +1,85 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

+

+<html>

+<head>

+<title><%@ string/new_tab %></title>

+<meta name="viewport" content="width=device-width; initial-scale=1.0;" />

+

+<style type="text/css">

+

+* {

+    padding: 0;

+    margin: 0;

+}

+

+body {

+    text-align: center;

+    margin: 16px auto;

+    padding: 0 8px 0 8px;

+    max-width: <%@ dimen/mv_max_width %>px;

+}

+

+#most_visited h3 {

+    text-align: center;

+    padding: 0;

+    margin: 5px 0 5px 0px;

+}

+

+.thumbwrap li {

+    display: inline-block;

+    margin: 0 7px 15px 7px;

+    padding: 0;

+}

+

+@media all and (orientation:portrait) {

+.thumbwrap li {

+    width: <%@ dimen/mv_item_width_portrait %>px;

+}

+}

+

+@media all and (orientation:landscape) {

+.thumbwrap li {

+    width: <%@ dimen/mv_item_width %>px;

+}

+}

+

+.thumbwrap a {

+    display: block;

+    text-decoration: none;

+    color: #000;

+}

+

+.thumbwrap img {

+    border: <%@ dimen/mv_border_width %>px solid #e0e0e0;

+    border-radius: 5px;

+    width: 100%;

+}

+

+.thumbwrap .caption {

+    margin-top: 2px;

+    margin-left: 4px;

+    white-space: nowrap;

+    overflow: hidden;

+    text-overflow: ellipsis;

+    display: block;

+    font-size: .8em;

+    text-align: left;

+}

+

+</style>

+

+</head>

+<body>

+    <h3><%@ string/tab_most_visited %></h3>

+    <ul class="thumbwrap">

+        <%{ most_visited %>

+            <li>

+                <a href="<%= url %>">

+                    <img class="wrimg" src="<%= thumbnail %>" />

+                    <span class="caption"><%= title %></span>

+                </a>

+            </li>

+        <%} most_visited %>

+    </ul>

+</body>

+</html>

diff --git a/res/values-xlarge/dimensions.xml b/res/values-xlarge/dimensions.xml
index 5b86c86..9f5a602 100644
--- a/res/values-xlarge/dimensions.xml
+++ b/res/values-xlarge/dimensions.xml
@@ -14,4 +14,9 @@
     <dimen name="bookmarkThumbnailWidth">180dip</dimen>
     <dimen name="bookmarkThumbnailHeight">120dip</dimen>
     <dimen name="favicon_padded_size">24dip</dimen>
+    <!-- For the most visited page -->
+    <dimen name="mv_max_width">1010dp</dimen>
+    <dimen name="mv_item_width">231dp</dimen>
+    <dimen name="mv_item_width_portrait">213dp</dimen>
+    <dimen name="mv_border_width">3dp</dimen>
 </resources>
diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml
index 03127dd..d50ce13 100644
--- a/res/values/dimensions.xml
+++ b/res/values/dimensions.xml
@@ -33,4 +33,9 @@
     <dimen name="qc_slop">15dip</dimen>
     <dimen name="bookmark_widget_thumb_size">32dip</dimen>
     <dimen name="bookmark_widget_favicon_size">26dip</dimen>
+    <!-- For the most visited page -->
+    <dimen name="mv_max_width">830dp</dimen>
+    <dimen name="mv_item_width">96dp</dimen>
+    <dimen name="mv_item_width_portrait">96dp</dimen>
+    <dimen name="mv_border_width">3dp</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b8a45bf..9c12dc3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -609,6 +609,11 @@
     <!-- Summary for lab quick controls feature [CHAR LIMIT=80] -->
     <string name="pref_lab_quick_controls_summary">
         Swipe thumb from left or right edge to access quick controls</string>
+    <!-- Title for lab "Most Visited" homepage feature [CHAR LIMIT=40] -->
+    <string name="pref_lab_most_visited_homepage">Most Visited Homepage</string>
+    <!-- Summary for lab "Most Visited" homepage feature [CHAR LIMIT=80] -->
+    <string name="pref_lab_most_visited_homepage_summary">
+        Sets your homepage to show the most visited pages.</string>
     <!-- Title for a dialog displayed when the browser has a data connectivity
             problem -->
     <string name="browserFrameNetworkErrorLabel">Data connectivity problem</string>
diff --git a/res/xml/lab_preferences.xml b/res/xml/lab_preferences.xml
index 2168471..16a5169 100644
--- a/res/xml/lab_preferences.xml
+++ b/res/xml/lab_preferences.xml
@@ -23,4 +23,10 @@
         android:title="@string/pref_lab_quick_controls"
         android:summary="@string/pref_lab_quick_controls_summary" />
 
+    <CheckBoxPreference
+        android:key="use_most_visited_homepage"
+        android:defaultValue="false"
+        android:title="@string/pref_lab_most_visited_homepage"
+        android:summary="@string/pref_lab_most_visited_homepage_summary" />
+
 </PreferenceScreen>