Show important notice strip
Bug: 10587358 Change-Id: I1af3faa59afb2fc4cb90176acff1c2b0b1ba369c
This commit is contained in:
parent
6422f77e94
commit
8dda9e480b
3 changed files with 35 additions and 15 deletions
|
@ -1350,8 +1350,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow) {
|
public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow) {
|
||||||
mInputLogic.setSuggestedWords(suggestedWords);
|
mInputLogic.setSuggestedWords(suggestedWords);
|
||||||
if (mSuggestionStripView != null) {
|
if (mSuggestionStripView != null) {
|
||||||
mSuggestionStripView.setSuggestions(suggestedWords,
|
final boolean showSuggestions;
|
||||||
SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype()));
|
if (SuggestedWords.EMPTY == suggestedWords
|
||||||
|
|| suggestedWords.mIsPunctuationSuggestions) {
|
||||||
|
showSuggestions = !mSuggestionStripView.maybeShowImportantNoticeTitle();
|
||||||
|
} else {
|
||||||
|
showSuggestions = true;
|
||||||
|
}
|
||||||
|
if (showSuggestions) {
|
||||||
|
mSuggestionStripView.setSuggestions(suggestedWords,
|
||||||
|
SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype()));
|
||||||
|
}
|
||||||
mKeyboardSwitcher.onAutoCorrectionStateChanged(suggestedWords.mWillAutoCorrect);
|
mKeyboardSwitcher.onAutoCorrectionStateChanged(suggestedWords.mWillAutoCorrect);
|
||||||
setSuggestionStripShownInternal(shouldShow, true /* needsInputViewShown */);
|
setSuggestionStripShownInternal(shouldShow, true /* needsInputViewShown */);
|
||||||
}
|
}
|
||||||
|
|
|
@ -504,15 +504,9 @@ final class SuggestionStripLayoutHelper {
|
||||||
titleView, infoIcon, null, moreIcon, null);
|
titleView, infoIcon, null, moreIcon, null);
|
||||||
final CharSequence importantNoticeTitle = titleView.getText();
|
final CharSequence importantNoticeTitle = titleView.getText();
|
||||||
titleView.setTextScaleX(1.0f); // Reset textScaleX.
|
titleView.setTextScaleX(1.0f); // Reset textScaleX.
|
||||||
// When the suggestions strip is displayed first time, stripWidth may be zero.
|
final float titleScaleX = getTextScaleX(
|
||||||
// Then importantNoticeTitle will be displayed as is without auto text scaleX.
|
importantNoticeTitle, width, titleView.getPaint());
|
||||||
// TODO: Fix the logic to always have a correct value of stripWidth.
|
titleView.setTextScaleX(titleScaleX);
|
||||||
if (width > 0) {
|
|
||||||
// Auto text scaleX to show entire important notice title should be on the strip.
|
|
||||||
final float titleScaleX = getTextScaleX(
|
|
||||||
importantNoticeTitle, width, titleView.getPaint());
|
|
||||||
titleView.setTextScaleX(titleScaleX);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setLayoutWeight(final View v, final float weight, final int height) {
|
static void setLayoutWeight(final View v, final float weight, final int height) {
|
||||||
|
@ -529,7 +523,7 @@ final class SuggestionStripLayoutHelper {
|
||||||
final TextPaint paint) {
|
final TextPaint paint) {
|
||||||
paint.setTextScaleX(1.0f);
|
paint.setTextScaleX(1.0f);
|
||||||
final int width = getTextWidth(text, paint);
|
final int width = getTextWidth(text, paint);
|
||||||
if (width <= maxWidth) {
|
if (width <= maxWidth || maxWidth <= 0) {
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
return maxWidth / (float)width;
|
return maxWidth / (float)width;
|
||||||
|
|
|
@ -46,6 +46,7 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||||
import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener;
|
import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener;
|
||||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||||
|
import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
|
||||||
import com.android.inputmethod.research.ResearchLogger;
|
import com.android.inputmethod.research.ResearchLogger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -220,11 +221,20 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This method should be called after this View has been attached and displayed.
|
// This method checks if we should show the important notice (checks on permanent storage if
|
||||||
public void showImportantNoticeTitle() {
|
// it has been shown once already or not, and if in the setup wizard). If applicable, it shows
|
||||||
mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, getWidth());
|
// the notice. In all cases, it returns true if it was shown, false otherwise.
|
||||||
|
public boolean maybeShowImportantNoticeTitle() {
|
||||||
|
if (!ImportantNoticeUtils.hasNewImportantNotice(getContext())
|
||||||
|
|| ImportantNoticeUtils.isInSystemSetupWizard(getContext())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final int width = getWidth();
|
||||||
|
if (width <= 0) return false;
|
||||||
|
mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, width);
|
||||||
mStripVisibilityGroup.showImportantNoticeStrip();
|
mStripVisibilityGroup.showImportantNoticeStrip();
|
||||||
mImportantNoticeStrip.setOnClickListener(this);
|
mImportantNoticeStrip.setOnClickListener(this);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
@ -415,4 +425,11 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
dismissMoreSuggestionsPanel();
|
dismissMoreSuggestionsPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||||
|
// Called by the framework when the size is known. Show the important notice if applicable.
|
||||||
|
// This may be overriden by showing suggestions later, if applicable.
|
||||||
|
maybeShowImportantNoticeTitle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue