Implement CandidateView using HorizontalScrollView

This change re-implements CandidateView using HorizontalScrollView and
customized Button, so that the candidate strip can be flingable.

This change also introduces the following features.

- Highlighting candidate strip and space bar is configurable by
  @bool/config_candidate_highlight_enabled.
- Candidate strip can be centered with left/right padding if
  @dimen/candidate_strip_padding size is greater than 0.
- Candidate text size is configurable by @dimen/candidate_text_size.

Bug: 1575885
Bug: 3230726
Change-Id: Iedf78ff31bc9f2f6291a8e8fb7faa0e6b961dd6d
diff --git a/java/res/drawable-hdpi/btn_candidate_normal.9.png b/java/res/drawable-hdpi/btn_candidate_normal.9.png
new file mode 100644
index 0000000..0ccdb6a
--- /dev/null
+++ b/java/res/drawable-hdpi/btn_candidate_normal.9.png
Binary files differ
diff --git a/java/res/drawable-hdpi/list_selector_background_pressed.9.png b/java/res/drawable-hdpi/btn_candidate_pressed.9.png
similarity index 100%
rename from java/res/drawable-hdpi/list_selector_background_pressed.9.png
rename to java/res/drawable-hdpi/btn_candidate_pressed.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/btn_candidate_normal.9.png b/java/res/drawable-mdpi/btn_candidate_normal.9.png
new file mode 100644
index 0000000..fa6c0fe
--- /dev/null
+++ b/java/res/drawable-mdpi/btn_candidate_normal.9.png
Binary files differ
diff --git a/java/res/drawable-mdpi/list_selector_background_pressed.9.png b/java/res/drawable-mdpi/btn_candidate_pressed.9.png
similarity index 100%
rename from java/res/drawable-mdpi/list_selector_background_pressed.9.png
rename to java/res/drawable-mdpi/btn_candidate_pressed.9.png
Binary files differ
diff --git a/java/res/drawable/btn_candidate.xml b/java/res/drawable/btn_candidate.xml
new file mode 100644
index 0000000..b0c1c30
--- /dev/null
+++ b/java/res/drawable/btn_candidate.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2010, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<selector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+>
+    <item
+        android:state_pressed="true"
+        android:drawable="@drawable/btn_candidate_pressed" />
+    <item
+        android:drawable="@drawable/btn_candidate_normal" />
+</selector>
diff --git a/java/res/layout/candidate.xml b/java/res/layout/candidate.xml
new file mode 100644
index 0000000..37179d2
--- /dev/null
+++ b/java/res/layout/candidate.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2010, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="@dimen/candidate_strip_height"
+    android:orientation="horizontal"
+>
+    <ImageView
+        android:id="@+id/candidate_divider"
+        android:layout_width="wrap_content"
+        android:layout_height="@dimen/candidate_strip_height"
+        android:visibility="gone"
+        android:focusable="false"
+        android:clickable="false"
+        android:src="@drawable/keyboard_suggest_strip_divider"
+        android:gravity="center_vertical|center_horizontal" />
+    <Button
+        android:id="@+id/candidate_word"
+        android:layout_width="wrap_content"
+        android:layout_height="@dimen/candidate_strip_height"
+        android:minWidth="@dimen/candidate_min_touchable_width"
+        android:textSize="@dimen/candidate_text_size"
+        android:textColor="@color/candidate_normal"
+        android:background="@drawable/btn_candidate"
+        android:focusable="true"
+        android:clickable="true"
+        android:gravity="center_vertical|center_horizontal"
+        android:paddingLeft="12dip"
+        android:paddingRight="12dip" />
+</LinearLayout>
diff --git a/java/res/layout/candidates.xml b/java/res/layout/candidates.xml
index b89d442..1b8d041 100644
--- a/java/res/layout/candidates.xml
+++ b/java/res/layout/candidates.xml
@@ -1,38 +1,45 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-/* 
+/*
 **
-** Copyright 2008, The Android Open Source Project
+** Copyright 2010, The Android Open Source Project
 **
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
 **
-**     http://www.apache.org/licenses/LICENSE-2.0 
+**     http://www.apache.org/licenses/LICENSE-2.0
 **
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
 ** limitations under the License.
 */
 -->
 
 <LinearLayout
-        xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/candidate_strip_height"
-        android:background="@drawable/keyboard_suggest_strip"
-        >
-
-    <com.android.inputmethod.latin.CandidateView
-        android:id="@+id/candidates"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="horizontal"
+    android:layout_width="match_parent"
+    android:layout_height="@dimen/candidate_strip_height"
+    android:background="@drawable/keyboard_suggest_strip"
+    android:paddingRight="@dimen/candidate_strip_padding"
+    android:paddingLeft="@dimen/candidate_strip_padding"
+>
+    <HorizontalScrollView
+        android:id="@+id/candidates_scroll_view"
         android:layout_width="wrap_content"
         android:layout_height="@dimen/candidate_strip_height"
-        android:layout_weight="1"
         android:fadingEdge="horizontal"
         android:fadingEdgeLength="@dimen/candidate_strip_fading_edge_length"
-        />
-        
+        android:scrollbars="none"
+    >
+        <com.android.inputmethod.latin.CandidateView
+            android:id="@+id/candidates"
+            android:orientation="horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/candidate_strip_height"
+            android:background="@drawable/keyboard_suggest_strip" />
+    </HorizontalScrollView>
 </LinearLayout>
diff --git a/java/res/values-xlarge-land/dimens.xml b/java/res/values-xlarge-land/dimens.xml
index 45d6dfa..e1a53f9 100644
--- a/java/res/values-xlarge-land/dimens.xml
+++ b/java/res/values-xlarge-land/dimens.xml
@@ -22,4 +22,5 @@
     <dimen name="key_label_text_size">18dip</dimen>
     <!-- left or right padding of label alignment -->
     <dimen name="key_label_horizontal_alignment_padding">18dip</dimen>
+    <dimen name="candidate_strip_padding">40.0mm</dimen>
 </resources>
diff --git a/java/res/values-xlarge/bools.xml b/java/res/values-xlarge/bools.xml
index 8c68d9d..abacfa1 100644
--- a/java/res/values-xlarge/bools.xml
+++ b/java/res/values-xlarge/bools.xml
@@ -22,4 +22,5 @@
     <bool name="default_popup_preview">false</bool>
     <bool name="config_enable_show_settings_key_option">false</bool>
     <bool name="config_enable_show_voice_key_option">false</bool>
+    <bool name="config_candidate_highlight_font_color_enabled">false</bool>
 </resources>
diff --git a/java/res/values-xlarge/dimens.xml b/java/res/values-xlarge/dimens.xml
index f2d9ded..dc1b5c3 100644
--- a/java/res/values-xlarge/dimens.xml
+++ b/java/res/values-xlarge/dimens.xml
@@ -40,5 +40,7 @@
     <!-- left or right padding of label alignment -->
     <dimen name="key_label_horizontal_alignment_padding">4dip</dimen>
 
-    <dimen name="candidate_strip_height">46dip</dimen>
+    <dimen name="candidate_strip_height">56dip</dimen>
+    <dimen name="candidate_strip_padding">15.0mm</dimen>
+    <dimen name="candidate_text_size">22dip</dimen>
 </resources>
diff --git a/java/res/values/bools.xml b/java/res/values/bools.xml
index 2be9545..84b0fe1 100644
--- a/java/res/values/bools.xml
+++ b/java/res/values/bools.xml
@@ -32,4 +32,5 @@
     <bool name="config_long_press_comma_for_settings_enabled">true</bool>
     <bool name="config_enable_show_settings_key_option">true</bool>
     <bool name="config_enable_show_voice_key_option">true</bool>
+    <bool name="config_candidate_highlight_font_color_enabled">true</bool>
 </resources>
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index 3839ff0..833963c 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -46,6 +46,8 @@
 
     <dimen name="candidate_strip_height">42dip</dimen>
     <dimen name="candidate_strip_fading_edge_length">63dip</dimen>
+    <dimen name="candidate_strip_padding">0dip</dimen>
+    <dimen name="candidate_text_size">18dip</dimen>
     <dimen name="spacebar_vertical_correction">4dip</dimen>
     <!-- If the screen height in landscape is larger than the below value, then the keyboard
          will not go into extract (fullscreen) mode. -->