am 776d46a7: Merge "Show "Touch again to save" in system locale"
* commit '776d46a771089482c68be56e81219bbd7bb559e4': Show "Touch again to save" in system localemain
commit
0f218b066d
|
@ -42,6 +42,7 @@
|
||||||
android:id="@+id/hint_add_to_dictionary"
|
android:id="@+id/hint_add_to_dictionary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
style="?attr/suggestionWordStyle" />
|
style="?attr/suggestionWordStyle" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -1498,8 +1498,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
if (showingAddToDictionaryHint
|
if (showingAddToDictionaryHint
|
||||||
&& suggest.mDictionaryFacilitator.isUserDictionaryEnabled()) {
|
&& suggest.mDictionaryFacilitator.isUserDictionaryEnabled()) {
|
||||||
mSuggestionStripView.showAddToDictionaryHint(
|
mSuggestionStripView.showAddToDictionaryHint(suggestion);
|
||||||
suggestion, currentSettings.mHintToSaveText);
|
|
||||||
} else {
|
} else {
|
||||||
// If we're not showing the "Touch again to save", then update the suggestion strip.
|
// If we're not showing the "Touch again to save", then update the suggestion strip.
|
||||||
mHandler.postUpdateSuggestionStrip();
|
mHandler.postUpdateSuggestionStrip();
|
||||||
|
|
|
@ -49,7 +49,6 @@ public final class SettingsValues {
|
||||||
// From resources:
|
// From resources:
|
||||||
public final SpacingAndPunctuations mSpacingAndPunctuations;
|
public final SpacingAndPunctuations mSpacingAndPunctuations;
|
||||||
public final int mDelayUpdateOldSuggestions;
|
public final int mDelayUpdateOldSuggestions;
|
||||||
public final CharSequence mHintToSaveText;
|
|
||||||
|
|
||||||
// From preferences, in the same order as xml/prefs.xml:
|
// From preferences, in the same order as xml/prefs.xml:
|
||||||
public final boolean mAutoCap;
|
public final boolean mAutoCap;
|
||||||
|
@ -101,7 +100,6 @@ public final class SettingsValues {
|
||||||
// Get the resources
|
// Get the resources
|
||||||
mDelayUpdateOldSuggestions = res.getInteger(R.integer.config_delay_update_old_suggestions);
|
mDelayUpdateOldSuggestions = res.getInteger(R.integer.config_delay_update_old_suggestions);
|
||||||
mSpacingAndPunctuations = new SpacingAndPunctuations(res);
|
mSpacingAndPunctuations = new SpacingAndPunctuations(res);
|
||||||
mHintToSaveText = res.getText(R.string.hint_add_to_dictionary);
|
|
||||||
|
|
||||||
// Store the input attributes
|
// Store the input attributes
|
||||||
if (null == inputAttributes) {
|
if (null == inputAttributes) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.ResourceUtils;
|
import com.android.inputmethod.latin.utils.ResourceUtils;
|
||||||
|
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||||
import com.android.inputmethod.latin.utils.ViewLayoutUtils;
|
import com.android.inputmethod.latin.utils.ViewLayoutUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -459,7 +460,7 @@ final class SuggestionStripLayoutHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip,
|
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip,
|
||||||
final int stripWidth, final CharSequence hintText) {
|
final int stripWidth) {
|
||||||
final int width = stripWidth - mDividerWidth - mPadding * 2;
|
final int width = stripWidth - mDividerWidth - mPadding * 2;
|
||||||
|
|
||||||
final TextView wordView = (TextView)addToDictionaryStrip.findViewById(R.id.word_to_save);
|
final TextView wordView = (TextView)addToDictionaryStrip.findViewById(R.id.word_to_save);
|
||||||
|
@ -473,13 +474,17 @@ final class SuggestionStripLayoutHelper {
|
||||||
|
|
||||||
final TextView hintView = (TextView)addToDictionaryStrip.findViewById(
|
final TextView hintView = (TextView)addToDictionaryStrip.findViewById(
|
||||||
R.id.hint_add_to_dictionary);
|
R.id.hint_add_to_dictionary);
|
||||||
hintView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL | GravityCompat.START);
|
|
||||||
hintView.setTextColor(mColorAutoCorrect);
|
hintView.setTextColor(mColorAutoCorrect);
|
||||||
final boolean isRtlLanguage = (ViewCompat.getLayoutDirection(addToDictionaryStrip)
|
final boolean isRtlLanguage = (ViewCompat.getLayoutDirection(addToDictionaryStrip)
|
||||||
== ViewCompat.LAYOUT_DIRECTION_RTL);
|
== ViewCompat.LAYOUT_DIRECTION_RTL);
|
||||||
final String hintWithArrow = (isRtlLanguage ? RIGHTWARDS_ARROW : LEFTWARDS_ARROW)
|
final String arrow = isRtlLanguage ? RIGHTWARDS_ARROW : LEFTWARDS_ARROW;
|
||||||
+ hintText;
|
final Resources res = addToDictionaryStrip.getResources();
|
||||||
|
final boolean isRtlSystem = SubtypeLocaleUtils.isRtlLanguage(res.getConfiguration().locale);
|
||||||
|
final CharSequence hintText = res.getText(R.string.hint_add_to_dictionary);
|
||||||
|
final String hintWithArrow = (isRtlLanguage == isRtlSystem)
|
||||||
|
? (arrow + hintText) : (hintText + arrow);
|
||||||
final int hintWidth = width - wordWidth;
|
final int hintWidth = width - wordWidth;
|
||||||
|
hintView.setTextScaleX(1.0f); // Reset textScaleX.
|
||||||
final float hintScaleX = getTextScaleX(hintWithArrow, hintWidth, hintView.getPaint());
|
final float hintScaleX = getTextScaleX(hintWithArrow, hintWidth, hintView.getPaint());
|
||||||
hintView.setText(hintWithArrow);
|
hintView.setText(hintWithArrow);
|
||||||
hintView.setTextScaleX(hintScaleX);
|
hintView.setTextScaleX(hintScaleX);
|
||||||
|
|
|
@ -186,8 +186,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
return mStripVisibilityGroup.isShowingAddToDictionaryStrip();
|
return mStripVisibilityGroup.isShowingAddToDictionaryStrip();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAddToDictionaryHint(final String word, final CharSequence hintText) {
|
public void showAddToDictionaryHint(final String word) {
|
||||||
mLayoutHelper.layoutAddToDictionaryHint(word, mAddToDictionaryStrip, getWidth(), hintText);
|
mLayoutHelper.layoutAddToDictionaryHint(word, mAddToDictionaryStrip, getWidth());
|
||||||
// {@link TextView#setTag()} is used to hold the word to be added to dictionary. The word
|
// {@link TextView#setTag()} is used to hold the word to be added to dictionary. The word
|
||||||
// will be extracted at {@link #onClick(View)}.
|
// will be extracted at {@link #onClick(View)}.
|
||||||
mAddToDictionaryStrip.setTag(word);
|
mAddToDictionaryStrip.setTag(word);
|
||||||
|
|
|
@ -347,9 +347,12 @@ public final class SubtypeLocaleUtils {
|
||||||
Arrays.sort(SORTED_RTL_LANGUAGES);
|
Arrays.sort(SORTED_RTL_LANGUAGES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRtlLanguage(final InputMethodSubtype subtype) {
|
public static boolean isRtlLanguage(final Locale locale) {
|
||||||
final Locale locale = getSubtypeLocale(subtype);
|
|
||||||
final String language = locale.getLanguage();
|
final String language = locale.getLanguage();
|
||||||
return Arrays.binarySearch(SORTED_RTL_LANGUAGES, language) >= 0;
|
return Arrays.binarySearch(SORTED_RTL_LANGUAGES, language) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isRtlLanguage(final InputMethodSubtype subtype) {
|
||||||
|
return isRtlLanguage(getSubtypeLocale(subtype));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue