Skip to content
Snippets Groups Projects
Commit e49bd1c4 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

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
parent ada7ad2b
No related branches found
No related tags found
No related merge requests found
Showing
with 261 additions and 380 deletions
java/res/drawable-hdpi/btn_candidate_normal.9.png

215 B

java/res/drawable-mdpi/btn_candidate_normal.9.png

205 B

<?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>
<?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>
<?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>
......@@ -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>
......@@ -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>
......@@ -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>
......@@ -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>
......@@ -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. -->
......
This diff is collapsed.
......@@ -51,8 +51,10 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.util.PrintWriterPrinter;
import android.util.Printer;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
......@@ -65,6 +67,7 @@ import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import java.io.FileDescriptor;
......@@ -127,7 +130,7 @@ public class LatinIME extends InputMethodService
SUGGESTION_VISIBILILTY_HIDE_VALUE
};
private LinearLayout mCandidateViewContainer;
private View mCandidateViewContainer;
private CandidateView mCandidateView;
private Suggest mSuggest;
private CompletionInfo[] mCompletions;
......@@ -496,12 +499,19 @@ public class LatinIME extends InputMethodService
@Override
public View onCreateCandidatesView() {
mCandidateViewContainer = (LinearLayout) getLayoutInflater().inflate(
R.layout.candidates, null);
mCandidateView = (CandidateView) mCandidateViewContainer.findViewById(R.id.candidates);
LayoutInflater inflater = getLayoutInflater();
LinearLayout container = (LinearLayout)inflater.inflate(R.layout.candidates, null);
mCandidateViewContainer = container;
if (container.getPaddingRight() != 0) {
HorizontalScrollView scrollView =
(HorizontalScrollView) container.findViewById(R.id.candidates_scroll_view);
scrollView.setOverScrollMode(View.OVER_SCROLL_NEVER);
container.setGravity(Gravity.CENTER_HORIZONTAL);
}
mCandidateView = (CandidateView) container.findViewById(R.id.candidates);
mCandidateView.setService(this);
setCandidatesViewShown(true);
return mCandidateViewContainer;
return container;
}
private static boolean isPasswordVariation(int variation) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment