diff --git a/java/res/layout/suggestions_strip.xml b/java/res/layout/suggestions_strip.xml
index bff9a1ef9..36898c890 100644
--- a/java/res/layout/suggestions_strip.xml
+++ b/java/res/layout/suggestions_strip.xml
@@ -64,4 +64,12 @@
android:textSize="16sp"
style="?attr/suggestionWordStyle" />
+
diff --git a/java/res/values-land/config.xml b/java/res/values-land/config.xml
index f72d64ff7..37bf22fb0 100644
--- a/java/res/values-land/config.xml
+++ b/java/res/values-land/config.xml
@@ -59,6 +59,7 @@
36dp
54dp
+ 54dp
36dp
2
60%
diff --git a/java/res/values-sw600dp-land/config.xml b/java/res/values-sw600dp-land/config.xml
index 8789e729f..ba8b52f0b 100644
--- a/java/res/values-sw600dp-land/config.xml
+++ b/java/res/values-sw600dp-land/config.xml
@@ -50,6 +50,7 @@
44dp
180.0dp
+ 54dp
5
50%
diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml
index 12e9832f9..d97538de0 100644
--- a/java/res/values-sw600dp/config.xml
+++ b/java/res/values-sw600dp/config.xml
@@ -63,7 +63,8 @@
27%
44dp
- 0dp
+ 54dp
+ 54dp
44dp
6
90%
diff --git a/java/res/values-sw768dp-land/config.xml b/java/res/values-sw768dp-land/config.xml
index 17733f099..63f86ba81 100644
--- a/java/res/values-sw768dp-land/config.xml
+++ b/java/res/values-sw768dp-land/config.xml
@@ -51,6 +51,7 @@
44dp
340dp
+ 54dp
50%
diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml
index 647cca94b..94b38d850 100644
--- a/java/res/values-sw768dp/config.xml
+++ b/java/res/values-sw768dp/config.xml
@@ -62,6 +62,7 @@
44dp
100dp
+ 54dp
44dp
6
90%
diff --git a/java/res/values/config.xml b/java/res/values/config.xml
index 1ab49279c..9f556a6e4 100644
--- a/java/res/values/config.xml
+++ b/java/res/values/config.xml
@@ -64,7 +64,8 @@
41%
40dp
- 0dp
+ 36dp
+ 36dp
40dp
6
90%
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index a578fa4a4..d4f7f36da 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -18,7 +18,9 @@ package com.android.inputmethod.latin.suggestions;
import android.content.Context;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.Color;
+import android.graphics.drawable.Drawable;
import android.support.v4.view.ViewCompat;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -31,6 +33,7 @@ import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.ViewParent;
+import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -59,12 +62,14 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
public void addWordToUserDictionary(String word);
public void showImportantNoticeContents();
public void pickSuggestionManually(int index, SuggestedWordInfo word);
+ public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat);
}
static final boolean DBG = LatinImeLogger.sDBG;
private static final float DEBUG_INFO_TEXT_SIZE_IN_DIP = 6.0f;
private final ViewGroup mSuggestionsStrip;
+ private final ImageButton mVoiceKey;
private final ViewGroup mAddToDictionaryStrip;
private final View mImportantNoticeStrip;
MainKeyboardView mMainKeyboardView;
@@ -86,39 +91,42 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
private static class StripVisibilityGroup {
private final View mSuggestionsStrip;
+ private final View mVoiceKey;
private final View mAddToDictionaryStrip;
private final View mImportantNoticeStrip;
- public StripVisibilityGroup(final View suggestionsStrip, final View addToDictionaryStrip,
- final View importantNoticeStrip) {
+ public StripVisibilityGroup(final View suggestionsStrip, final View voiceKey,
+ final View addToDictionaryStrip, final View importantNoticeStrip) {
mSuggestionsStrip = suggestionsStrip;
+ mVoiceKey = voiceKey;
mAddToDictionaryStrip = addToDictionaryStrip;
mImportantNoticeStrip = importantNoticeStrip;
- showSuggestionsStrip();
+ showSuggestionsStrip(false /* voiceKeyEnabled */);
}
- public void setLayoutDirection(final boolean isRtlLanguage) {
- final int layoutDirection = isRtlLanguage ? ViewCompat.LAYOUT_DIRECTION_RTL
- : ViewCompat.LAYOUT_DIRECTION_LTR;
+ public void setLayoutDirection(final int layoutDirection) {
ViewCompat.setLayoutDirection(mSuggestionsStrip, layoutDirection);
ViewCompat.setLayoutDirection(mAddToDictionaryStrip, layoutDirection);
ViewCompat.setLayoutDirection(mImportantNoticeStrip, layoutDirection);
}
- public void showSuggestionsStrip() {
+ public void showSuggestionsStrip(final boolean enableVoiceKey) {
mSuggestionsStrip.setVisibility(VISIBLE);
+ mVoiceKey.setVisibility(enableVoiceKey ? VISIBLE : INVISIBLE);
mAddToDictionaryStrip.setVisibility(INVISIBLE);
mImportantNoticeStrip.setVisibility(INVISIBLE);
}
public void showAddToDictionaryStrip() {
mSuggestionsStrip.setVisibility(INVISIBLE);
+ mVoiceKey.setVisibility(INVISIBLE);
mAddToDictionaryStrip.setVisibility(VISIBLE);
mImportantNoticeStrip.setVisibility(INVISIBLE);
}
public void showImportantNoticeStrip() {
mSuggestionsStrip.setVisibility(INVISIBLE);
+ mVoiceKey.setVisibility(INVISIBLE);
mAddToDictionaryStrip.setVisibility(INVISIBLE);
mImportantNoticeStrip.setVisibility(VISIBLE);
}
@@ -145,10 +153,11 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
inflater.inflate(R.layout.suggestions_strip, this);
mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
+ mVoiceKey = (ImageButton)findViewById(R.id.suggestions_strip_voice_key);
mAddToDictionaryStrip = (ViewGroup)findViewById(R.id.add_to_dictionary_strip);
mImportantNoticeStrip = findViewById(R.id.important_notice_strip);
- mStripVisibilityGroup = new StripVisibilityGroup(mSuggestionsStrip, mAddToDictionaryStrip,
- mImportantNoticeStrip);
+ mStripVisibilityGroup = new StripVisibilityGroup(mSuggestionsStrip, mVoiceKey,
+ mAddToDictionaryStrip, mImportantNoticeStrip);
for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
final TextView word = new TextView(context, null, R.attr.suggestionWordStyle);
@@ -177,6 +186,13 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
R.dimen.config_more_suggestions_modal_tolerance);
mMoreSuggestionsSlidingDetector = new GestureDetector(
context, mMoreSuggestionsSlidingListener);
+
+ final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs,
+ R.styleable.Keyboard, defStyle, R.style.SuggestionStripView);
+ final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey);
+ keyboardAttr.recycle();
+ mVoiceKey.setImageDrawable(iconVoice);
+ mVoiceKey.setOnClickListener(this);
}
/**
@@ -188,16 +204,30 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mMainKeyboardView = (MainKeyboardView)inputView.findViewById(R.id.keyboard_view);
}
+ private boolean isVoiceKeyEnabled() {
+ if (mMainKeyboardView == null) {
+ return false;
+ }
+ final Keyboard keyboard = mMainKeyboardView.getKeyboard();
+ if (keyboard == null) {
+ return false;
+ }
+ return keyboard.mId.mHasShortcutKey;
+ }
+
public void setSuggestions(final SuggestedWords suggestedWords, final boolean isRtlLanguage) {
clear();
- mStripVisibilityGroup.setLayoutDirection(isRtlLanguage);
+ final int layoutDirection = isRtlLanguage ? ViewCompat.LAYOUT_DIRECTION_RTL
+ : ViewCompat.LAYOUT_DIRECTION_LTR;
+ setLayoutDirection(layoutDirection);
+ mStripVisibilityGroup.setLayoutDirection(layoutDirection);
mSuggestedWords = suggestedWords;
mSuggestionsCountInStrip = mLayoutHelper.layoutAndReturnSuggestionCountInStrip(
mSuggestedWords, mSuggestionsStrip, this);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.suggestionStripView_setSuggestions(mSuggestedWords);
}
- mStripVisibilityGroup.showSuggestionsStrip();
+ mStripVisibilityGroup.showSuggestionsStrip(isVoiceKeyEnabled());
}
public int setMoreSuggestionsHeight(final int remainingHeight) {
@@ -252,7 +282,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
public void clear() {
mSuggestionsStrip.removeAllViews();
removeAllDebugInfoViews();
- mStripVisibilityGroup.showSuggestionsStrip();
+ mStripVisibilityGroup.showSuggestionsStrip(false /* enableVoiceKey */);
dismissMoreSuggestionsPanel();
}
@@ -415,6 +445,12 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mListener.showImportantNoticeContents();
return;
}
+ if (view == mVoiceKey) {
+ mListener.onCodeInput(Constants.CODE_SHORTCUT,
+ Constants.SUGGESTION_STRIP_COORDINATE, Constants.SUGGESTION_STRIP_COORDINATE,
+ false /* isKeyRepeat */);
+ return;
+ }
final Object tag = view.getTag();
// {@link String} tag is set at {@link #showAddToDictionaryHint(String,CharSequence)}.
if (tag instanceof String) {