am de102ede: am 15281adb: Show gesture floating preview text by default

* commit 'de102ede499cd3baf93561d06c5fe3e663276d2e':
  Show gesture floating preview text by default
main
Tadashi G. Takaoka 2012-10-01 23:38:12 -07:00 committed by Android Git Automerger
commit 58e1be74a9
4 changed files with 20 additions and 9 deletions

View File

@ -88,11 +88,11 @@
android:persistent="true" android:persistent="true"
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference <CheckBoxPreference
android:key="pref_show_gesture_floating_preview_text" android:key="pref_gesture_floating_preview_text"
android:title="@string/gesture_floating_preview_text" android:title="@string/gesture_floating_preview_text"
android:summary="@string/gesture_floating_preview_text_summary" android:summary="@string/gesture_floating_preview_text_summary"
android:persistent="true" android:persistent="true"
android:defaultValue="false" /> android:defaultValue="true" />
<CheckBoxPreference <CheckBoxPreference
android:key="pref_gesture_preview_trail" android:key="pref_gesture_preview_trail"
android:title="@string/gesture_preview_trail" android:title="@string/gesture_preview_trail"

View File

@ -30,6 +30,7 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Message; import android.os.Message;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.TypedValue; import android.util.TypedValue;
@ -824,10 +825,19 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
if (mPreviewPlacerView.getParent() != null) { if (mPreviewPlacerView.getParent() != null) {
return; return;
} }
final int width = getWidth();
final int height = getHeight();
if (width == 0 || height == 0) {
// In transient state.
return;
}
final int[] viewOrigin = new int[2]; final int[] viewOrigin = new int[2];
getLocationInWindow(viewOrigin); getLocationInWindow(viewOrigin);
mPreviewPlacerView.setKeyboardViewGeometry( final DisplayMetrics dm = getResources().getDisplayMetrics();
viewOrigin[0], viewOrigin[1], getWidth(), getHeight()); if (viewOrigin[1] < dm.heightPixels / 4) {
// In transient state.
return;
}
final View rootView = getRootView(); final View rootView = getRootView();
if (rootView == null) { if (rootView == null) {
Log.w(TAG, "Cannot find root view"); Log.w(TAG, "Cannot find root view");
@ -839,6 +849,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
Log.w(TAG, "Cannot find android.R.id.content view to add PreviewPlacerView"); Log.w(TAG, "Cannot find android.R.id.content view to add PreviewPlacerView");
} else { } else {
windowContentView.addView(mPreviewPlacerView); windowContentView.addView(mPreviewPlacerView);
mPreviewPlacerView.setKeyboardViewGeometry(viewOrigin[0], viewOrigin[1], width, height);
} }
} }

View File

@ -74,8 +74,8 @@ public final class Settings extends InputMethodSettingsFragment
public static final String PREF_KEYPRESS_SOUND_VOLUME = public static final String PREF_KEYPRESS_SOUND_VOLUME =
"pref_keypress_sound_volume"; "pref_keypress_sound_volume";
public static final String PREF_GESTURE_PREVIEW_TRAIL = "pref_gesture_preview_trail"; public static final String PREF_GESTURE_PREVIEW_TRAIL = "pref_gesture_preview_trail";
public static final String PREF_SHOW_GESTURE_FLOATING_PREVIEW_TEXT = public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT =
"pref_show_gesture_floating_preview_text"; "pref_gesture_floating_preview_text";
public static final String PREF_INPUT_LANGUAGE = "input_language"; public static final String PREF_INPUT_LANGUAGE = "input_language";
public static final String PREF_SELECTED_LANGUAGES = "selected_languages"; public static final String PREF_SELECTED_LANGUAGES = "selected_languages";
@ -208,7 +208,7 @@ public final class Settings extends InputMethodSettingsFragment
R.bool.config_gesture_input_enabled_by_build_config); R.bool.config_gesture_input_enabled_by_build_config);
final Preference gesturePreviewTrail = findPreference(PREF_GESTURE_PREVIEW_TRAIL); final Preference gesturePreviewTrail = findPreference(PREF_GESTURE_PREVIEW_TRAIL);
final Preference gestureFloatingPreviewText = findPreference( final Preference gestureFloatingPreviewText = findPreference(
PREF_SHOW_GESTURE_FLOATING_PREVIEW_TEXT); PREF_GESTURE_FLOATING_PREVIEW_TEXT);
if (!gestureInputEnabledByBuildConfig) { if (!gestureInputEnabledByBuildConfig) {
miscSettings.removePreference(findPreference(PREF_GESTURE_INPUT)); miscSettings.removePreference(findPreference(PREF_GESTURE_INPUT));
miscSettings.removePreference(gesturePreviewTrail); miscSettings.removePreference(gesturePreviewTrail);
@ -287,7 +287,7 @@ public final class Settings extends InputMethodSettingsFragment
PREF_GESTURE_INPUT, true); PREF_GESTURE_INPUT, true);
setPreferenceEnabled(findPreference(PREF_GESTURE_PREVIEW_TRAIL), setPreferenceEnabled(findPreference(PREF_GESTURE_PREVIEW_TRAIL),
gestureInputEnabledByUser); gestureInputEnabledByUser);
setPreferenceEnabled(findPreference(PREF_SHOW_GESTURE_FLOATING_PREVIEW_TEXT), setPreferenceEnabled(findPreference(PREF_GESTURE_FLOATING_PREVIEW_TEXT),
gestureInputEnabledByUser); gestureInputEnabledByUser);
} }
} }

View File

@ -178,7 +178,7 @@ public final class SettingsValues {
&& prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true); && prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true);
mGesturePreviewTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true); mGesturePreviewTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true);
mGestureFloatingPreviewTextEnabled = prefs.getBoolean( mGestureFloatingPreviewTextEnabled = prefs.getBoolean(
Settings.PREF_SHOW_GESTURE_FLOATING_PREVIEW_TEXT, false); Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true);
mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect; mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
mSuggestionVisibility = createSuggestionVisibility(res); mSuggestionVisibility = createSuggestionVisibility(res);
} }