diff --git a/java/res/drawable-hdpi/sym_keyboard_info_holo_dark.png b/java/res/drawable-hdpi/sym_keyboard_info_holo_dark.png new file mode 100644 index 000000000..f52f5af7a Binary files /dev/null and b/java/res/drawable-hdpi/sym_keyboard_info_holo_dark.png differ diff --git a/java/res/drawable-hdpi/sym_keyboard_more_holo_dark.png b/java/res/drawable-hdpi/sym_keyboard_more_holo_dark.png new file mode 100644 index 000000000..72e2b297d Binary files /dev/null and b/java/res/drawable-hdpi/sym_keyboard_more_holo_dark.png differ diff --git a/java/res/drawable-mdpi/sym_keyboard_info_holo_dark.png b/java/res/drawable-mdpi/sym_keyboard_info_holo_dark.png new file mode 100644 index 000000000..fa4e2390f Binary files /dev/null and b/java/res/drawable-mdpi/sym_keyboard_info_holo_dark.png differ diff --git a/java/res/drawable-mdpi/sym_keyboard_more_holo_dark.png b/java/res/drawable-mdpi/sym_keyboard_more_holo_dark.png new file mode 100644 index 000000000..58e27a2df Binary files /dev/null and b/java/res/drawable-mdpi/sym_keyboard_more_holo_dark.png differ diff --git a/java/res/drawable-xhdpi/sym_keyboard_info_holo_dark.png b/java/res/drawable-xhdpi/sym_keyboard_info_holo_dark.png new file mode 100644 index 000000000..513892fb9 Binary files /dev/null and b/java/res/drawable-xhdpi/sym_keyboard_info_holo_dark.png differ diff --git a/java/res/drawable-xhdpi/sym_keyboard_more_holo_dark.png b/java/res/drawable-xhdpi/sym_keyboard_more_holo_dark.png new file mode 100644 index 000000000..07e9bee38 Binary files /dev/null and b/java/res/drawable-xhdpi/sym_keyboard_more_holo_dark.png differ diff --git a/java/res/drawable-xxhdpi/sym_keyboard_info_holo_dark.png b/java/res/drawable-xxhdpi/sym_keyboard_info_holo_dark.png new file mode 100644 index 000000000..b214d0eca Binary files /dev/null and b/java/res/drawable-xxhdpi/sym_keyboard_info_holo_dark.png differ diff --git a/java/res/drawable-xxhdpi/sym_keyboard_more_holo_dark.png b/java/res/drawable-xxhdpi/sym_keyboard_more_holo_dark.png new file mode 100644 index 000000000..702da2720 Binary files /dev/null and b/java/res/drawable-xxhdpi/sym_keyboard_more_holo_dark.png differ diff --git a/java/res/layout/suggestions_strip.xml b/java/res/layout/suggestions_strip.xml index 9c83542a6..9ffd231de 100644 --- a/java/res/layout/suggestions_strip.xml +++ b/java/res/layout/suggestions_strip.xml @@ -45,4 +45,17 @@ android:textAlignment="viewStart" style="?attr/suggestionWordStyle" /> + + + diff --git a/java/res/values/strings-config-important-notice.xml b/java/res/values/strings-config-important-notice.xml index 8ee0b99c3..da206a37c 100644 --- a/java/res/values/strings-config-important-notice.xml +++ b/java/res/values/strings-config-important-notice.xml @@ -20,5 +20,8 @@ 0 - + + + + diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 8f4b2d67e..208cf22a6 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1157,6 +1157,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mInputLogic.mSuggest.mDictionaryFacilitator.addWordToUserDictionary(wordToEdit); } + // Callback for the {@link SuggestionStripView}, to call when the important notice strip is + // pressed. + @Override + public void showImportantNoticeContents() { + // TODO: Show dialog to display important notice contents. + } + public void displaySettingsDialog() { if (isShowingOptionDialog()) return; showSubtypeSelectorAndSettings(); diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java index 5ed42ab00..da084e1e9 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java @@ -28,7 +28,6 @@ import android.graphics.Rect; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; -import android.support.v4.view.GravityCompat; import android.support.v4.view.ViewCompat; import android.text.Spannable; import android.text.SpannableString; @@ -45,6 +44,7 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; +import com.android.inputmethod.compat.TextViewCompatUtils; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SuggestedWords; @@ -492,7 +492,24 @@ final class SuggestionStripLayoutHelper { hintView, 1.0f - mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT); } - private static void setLayoutWeight(final View v, final float weight, final int height) { + public void layoutImportantNotice(final View importantNoticeStrip, final int stripWidth) { + final Resources res = importantNoticeStrip.getResources(); + final Drawable infoIcon = res.getDrawable(R.drawable.sym_keyboard_info_holo_dark); + final Drawable moreIcon = res.getDrawable(R.drawable.sym_keyboard_more_holo_dark); + final int width = stripWidth - infoIcon.getIntrinsicWidth() - moreIcon.getIntrinsicWidth(); + final TextView titleView = (TextView)importantNoticeStrip.findViewById( + R.id.important_notice_title); + titleView.setTextColor(mColorAutoCorrect); + TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( + titleView, infoIcon, null, moreIcon, null); + final CharSequence importantNoticeTitle = res.getText(R.string.important_notice_title); + titleView.setTextScaleX(1.0f); // Reset textScaleX. + final float titleScaleX = getTextScaleX(importantNoticeTitle, width, titleView.getPaint()); + titleView.setText(importantNoticeTitle); + titleView.setTextScaleX(titleScaleX); + } + + static void setLayoutWeight(final View v, final float weight, final int height) { final ViewGroup.LayoutParams lp = v.getLayoutParams(); if (lp instanceof LinearLayout.LayoutParams) { final LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp; diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java index 22804fce1..fe95d6781 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java @@ -54,6 +54,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick OnLongClickListener { public interface Listener { public void addWordToUserDictionary(String word); + public void showImportantNoticeContents(); public void pickSuggestionManually(int index, SuggestedWordInfo word); } @@ -62,6 +63,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick private final ViewGroup mSuggestionsStrip; private final ViewGroup mAddToDictionaryStrip; + private final View mImportantNoticeStrip; MainKeyboardView mMainKeyboardView; private final View mMoreSuggestionsContainer; @@ -81,10 +83,13 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick private static class StripVisibilityGroup { private final View mSuggestionsStrip; private final View mAddToDictionaryStrip; + private final View mImportantNoticeStrip; - public StripVisibilityGroup(final View suggestionsStrip, final View addToDictionaryStrip) { + public StripVisibilityGroup(final View suggestionsStrip, final View addToDictionaryStrip, + final View importantNoticeStrip) { mSuggestionsStrip = suggestionsStrip; mAddToDictionaryStrip = addToDictionaryStrip; + mImportantNoticeStrip = importantNoticeStrip; showSuggestionsStrip(); } @@ -93,16 +98,25 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick : ViewCompat.LAYOUT_DIRECTION_LTR; ViewCompat.setLayoutDirection(mSuggestionsStrip, layoutDirection); ViewCompat.setLayoutDirection(mAddToDictionaryStrip, layoutDirection); + ViewCompat.setLayoutDirection(mImportantNoticeStrip, layoutDirection); } public void showSuggestionsStrip() { mSuggestionsStrip.setVisibility(VISIBLE); mAddToDictionaryStrip.setVisibility(INVISIBLE); + mImportantNoticeStrip.setVisibility(INVISIBLE); } public void showAddToDictionaryStrip() { mSuggestionsStrip.setVisibility(INVISIBLE); mAddToDictionaryStrip.setVisibility(VISIBLE); + mImportantNoticeStrip.setVisibility(INVISIBLE); + } + + public void showImportantNoticeStrip() { + mSuggestionsStrip.setVisibility(INVISIBLE); + mAddToDictionaryStrip.setVisibility(INVISIBLE); + mImportantNoticeStrip.setVisibility(VISIBLE); } public boolean isShowingAddToDictionaryStrip() { @@ -128,7 +142,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip); mAddToDictionaryStrip = (ViewGroup)findViewById(R.id.add_to_dictionary_strip); - mStripVisibilityGroup = new StripVisibilityGroup(mSuggestionsStrip, mAddToDictionaryStrip); + mImportantNoticeStrip = findViewById(R.id.important_notice_strip); + mStripVisibilityGroup = new StripVisibilityGroup(mSuggestionsStrip, mAddToDictionaryStrip, + mImportantNoticeStrip); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); @@ -176,6 +192,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { ResearchLogger.suggestionStripView_setSuggestions(mSuggestedWords); } + mStripVisibilityGroup.showSuggestionsStrip(); } public int setMoreSuggestionsHeight(final int remainingHeight) { @@ -203,6 +220,12 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick return false; } + public void showImportantNoticeTitle() { + mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, getWidth()); + mStripVisibilityGroup.showImportantNoticeStrip(); + mImportantNoticeStrip.setOnClickListener(this); + } + public void clear() { mSuggestionsStrip.removeAllViews(); removeAllDebugInfoViews(); @@ -360,6 +383,10 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick @Override public void onClick(final View view) { + if (view == mImportantNoticeStrip) { + mListener.showImportantNoticeContents(); + return; + } final Object tag = view.getTag(); // {@link String} tag is set at {@link #showAddToDictionaryHint(String,CharSequence)}. if (tag instanceof String) {