am 2abe1ced: Merge "Add important notice strip"
* commit '2abe1cedc87768a5639bfef83c4217addd877f92': Add important notice stripmain
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 797 B |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
|
@ -45,4 +45,17 @@
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
style="?attr/suggestionWordStyle" />
|
style="?attr/suggestionWordStyle" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/important_notice_strip"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/important_notice_title"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1.0"
|
||||||
|
android:textSize="14sp"
|
||||||
|
style="?attr/suggestionWordStyle" />
|
||||||
|
</LinearLayout>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -20,5 +20,8 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<integer name="config_important_notice_version">0</integer>
|
<integer name="config_important_notice_version">0</integer>
|
||||||
<!-- TODO: Add important notice title and description string resources. -->
|
<!-- The title of the important notice displayed on the suggestion strip. -->
|
||||||
|
<string name="important_notice_title"></string>
|
||||||
|
<!-- The contents of the important notice. -->
|
||||||
|
<string name="important_notice_contents"></string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1157,6 +1157,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mInputLogic.mSuggest.mDictionaryFacilitator.addWordToUserDictionary(wordToEdit);
|
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() {
|
public void displaySettingsDialog() {
|
||||||
if (isShowingOptionDialog()) return;
|
if (isShowingOptionDialog()) return;
|
||||||
showSubtypeSelectorAndSettings();
|
showSubtypeSelectorAndSettings();
|
||||||
|
|
|
@ -28,7 +28,6 @@ import android.graphics.Rect;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.v4.view.GravityCompat;
|
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
|
@ -45,6 +44,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.inputmethod.compat.TextViewCompatUtils;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
|
@ -492,7 +492,24 @@ final class SuggestionStripLayoutHelper {
|
||||||
hintView, 1.0f - mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
|
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();
|
final ViewGroup.LayoutParams lp = v.getLayoutParams();
|
||||||
if (lp instanceof LinearLayout.LayoutParams) {
|
if (lp instanceof LinearLayout.LayoutParams) {
|
||||||
final LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp;
|
final LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp;
|
||||||
|
|
|
@ -54,6 +54,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
OnLongClickListener {
|
OnLongClickListener {
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
public void addWordToUserDictionary(String word);
|
public void addWordToUserDictionary(String word);
|
||||||
|
public void showImportantNoticeContents();
|
||||||
public void pickSuggestionManually(int index, SuggestedWordInfo word);
|
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 mSuggestionsStrip;
|
||||||
private final ViewGroup mAddToDictionaryStrip;
|
private final ViewGroup mAddToDictionaryStrip;
|
||||||
|
private final View mImportantNoticeStrip;
|
||||||
MainKeyboardView mMainKeyboardView;
|
MainKeyboardView mMainKeyboardView;
|
||||||
|
|
||||||
private final View mMoreSuggestionsContainer;
|
private final View mMoreSuggestionsContainer;
|
||||||
|
@ -81,10 +83,13 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
private static class StripVisibilityGroup {
|
private static class StripVisibilityGroup {
|
||||||
private final View mSuggestionsStrip;
|
private final View mSuggestionsStrip;
|
||||||
private final View mAddToDictionaryStrip;
|
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;
|
mSuggestionsStrip = suggestionsStrip;
|
||||||
mAddToDictionaryStrip = addToDictionaryStrip;
|
mAddToDictionaryStrip = addToDictionaryStrip;
|
||||||
|
mImportantNoticeStrip = importantNoticeStrip;
|
||||||
showSuggestionsStrip();
|
showSuggestionsStrip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,16 +98,25 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
: ViewCompat.LAYOUT_DIRECTION_LTR;
|
: ViewCompat.LAYOUT_DIRECTION_LTR;
|
||||||
ViewCompat.setLayoutDirection(mSuggestionsStrip, layoutDirection);
|
ViewCompat.setLayoutDirection(mSuggestionsStrip, layoutDirection);
|
||||||
ViewCompat.setLayoutDirection(mAddToDictionaryStrip, layoutDirection);
|
ViewCompat.setLayoutDirection(mAddToDictionaryStrip, layoutDirection);
|
||||||
|
ViewCompat.setLayoutDirection(mImportantNoticeStrip, layoutDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showSuggestionsStrip() {
|
public void showSuggestionsStrip() {
|
||||||
mSuggestionsStrip.setVisibility(VISIBLE);
|
mSuggestionsStrip.setVisibility(VISIBLE);
|
||||||
mAddToDictionaryStrip.setVisibility(INVISIBLE);
|
mAddToDictionaryStrip.setVisibility(INVISIBLE);
|
||||||
|
mImportantNoticeStrip.setVisibility(INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAddToDictionaryStrip() {
|
public void showAddToDictionaryStrip() {
|
||||||
mSuggestionsStrip.setVisibility(INVISIBLE);
|
mSuggestionsStrip.setVisibility(INVISIBLE);
|
||||||
mAddToDictionaryStrip.setVisibility(VISIBLE);
|
mAddToDictionaryStrip.setVisibility(VISIBLE);
|
||||||
|
mImportantNoticeStrip.setVisibility(INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showImportantNoticeStrip() {
|
||||||
|
mSuggestionsStrip.setVisibility(INVISIBLE);
|
||||||
|
mAddToDictionaryStrip.setVisibility(INVISIBLE);
|
||||||
|
mImportantNoticeStrip.setVisibility(VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingAddToDictionaryStrip() {
|
public boolean isShowingAddToDictionaryStrip() {
|
||||||
|
@ -128,7 +142,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
|
|
||||||
mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
|
mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
|
||||||
mAddToDictionaryStrip = (ViewGroup)findViewById(R.id.add_to_dictionary_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++) {
|
for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
|
||||||
final TextView word = new TextView(context, null, R.attr.suggestionWordStyle);
|
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) {
|
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
||||||
ResearchLogger.suggestionStripView_setSuggestions(mSuggestedWords);
|
ResearchLogger.suggestionStripView_setSuggestions(mSuggestedWords);
|
||||||
}
|
}
|
||||||
|
mStripVisibilityGroup.showSuggestionsStrip();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int setMoreSuggestionsHeight(final int remainingHeight) {
|
public int setMoreSuggestionsHeight(final int remainingHeight) {
|
||||||
|
@ -203,6 +220,12 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showImportantNoticeTitle() {
|
||||||
|
mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, getWidth());
|
||||||
|
mStripVisibilityGroup.showImportantNoticeStrip();
|
||||||
|
mImportantNoticeStrip.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
mSuggestionsStrip.removeAllViews();
|
mSuggestionsStrip.removeAllViews();
|
||||||
removeAllDebugInfoViews();
|
removeAllDebugInfoViews();
|
||||||
|
@ -360,6 +383,10 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View view) {
|
public void onClick(final View view) {
|
||||||
|
if (view == mImportantNoticeStrip) {
|
||||||
|
mListener.showImportantNoticeContents();
|
||||||
|
return;
|
||||||
|
}
|
||||||
final Object tag = view.getTag();
|
final Object tag = view.getTag();
|
||||||
// {@link String} tag is set at {@link #showAddToDictionaryHint(String,CharSequence)}.
|
// {@link String} tag is set at {@link #showAddToDictionaryHint(String,CharSequence)}.
|
||||||
if (tag instanceof String) {
|
if (tag instanceof String) {
|
||||||
|
|