Merge "Add important notice strip"

main
Tadashi G. Takaoka 2014-01-31 11:23:51 +00:00 committed by Android (Google) Code Review
commit 2abe1cedc8
13 changed files with 72 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -45,4 +45,17 @@
android:textAlignment="viewStart"
style="?attr/suggestionWordStyle" />
</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>

View File

@ -20,5 +20,8 @@
<resources>
<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>

View File

@ -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();

View File

@ -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;

View File

@ -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) {