aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-09-01 22:21:22 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-01 22:21:22 -0700
commit78778ca9df9e75ece5beadd314ed0ed77dbd2a02 (patch)
treefcfddf43617dea54edd726954e10eaad212471b8 /java/src
parent2e58804a98e92aa134ed748d2de12ff885f27e14 (diff)
parent1b087064c07975c5e2b9c17d4ca80c56e01c35c0 (diff)
downloadlatinime-78778ca9df9e75ece5beadd314ed0ed77dbd2a02.tar.gz
latinime-78778ca9df9e75ece5beadd314ed0ed77dbd2a02.tar.xz
latinime-78778ca9df9e75ece5beadd314ed0ed77dbd2a02.zip
Merge "Dim keyboard when more suggestions are shown"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java14
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java10
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestionsView.java28
3 files changed, 29 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index ceadc919c..96eb69407 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -103,6 +103,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
private ViewGroup mPreviewPlacer;
// Drawing
+ /** True if the entire keyboard needs to be dimmed. */
+ private boolean mNeedsToDimBackground;
/** Whether the keyboard bitmap buffer needs to be redrawn before it's blitted. **/
private boolean mBufferNeedsUpdate;
/** The dirty region in the keyboard bitmap */
@@ -481,8 +483,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
}
- // Overlay a dark rectangle to dim the keyboard
- if (needsToDimKeyboard()) {
+ // Overlay a dark rectangle to dim the entire keyboard
+ if (mNeedsToDimBackground) {
mPaint.setColor((int) (mBackgroundDimAmount * 0xFF) << 24);
canvas.drawRect(0, 0, width, height, mPaint);
}
@@ -491,8 +493,12 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
mDirtyRect.setEmpty();
}
- protected boolean needsToDimKeyboard() {
- return false;
+ public void dimEntireKeyboard(boolean dimmed) {
+ final boolean needsRedrawing = mNeedsToDimBackground != dimmed;
+ mNeedsToDimBackground = dimmed;
+ if (needsRedrawing) {
+ invalidateAllKeys();
+ }
}
private static void onBufferDrawKey(final Key key, final Keyboard keyboard, final Canvas canvas,
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 777bae3b0..d9089e199 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -373,11 +373,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
return miniKeyboardView;
}
- @Override
- protected boolean needsToDimKeyboard() {
- return mMoreKeysPanel != null;
- }
-
public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboard oldKeyboard) {
final Keyboard keyboard = getKeyboard();
// We should not set text fade factor to the keyboard which does not display the language on
@@ -460,8 +455,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
final int translatedY = moreKeysPanel.translateY(tracker.getLastY());
tracker.onShowMoreKeysPanel(
translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel);
-
- invalidateAllKeys();
+ dimEntireKeyboard(true);
return true;
}
@@ -620,7 +614,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
mMoreKeysWindow.dismiss();
mMoreKeysPanel = null;
mMoreKeysPanelPointerTrackerId = -1;
- invalidateAllKeys();
+ dimEntireKeyboard(false);
return true;
}
return false;
diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java
index 617d7f1f2..07a44f72d 100644
--- a/java/src/com/android/inputmethod/latin/SuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java
@@ -50,6 +50,7 @@ import android.widget.TextView;
import com.android.inputmethod.compat.FrameLayoutCompatUtils;
import com.android.inputmethod.compat.LinearLayoutCompatUtils;
import com.android.inputmethod.keyboard.KeyboardActionListener;
+import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.MoreKeysPanel;
import com.android.inputmethod.keyboard.PointerTracker;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
@@ -70,7 +71,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
private final ViewGroup mSuggestionsPlacer;
private final ViewGroup mSuggestionsStrip;
- private View mKeyboardView;
+ private KeyboardView mKeyboardView;
private final View mMoreSuggestionsContainer;
private final MoreSuggestionsView mMoreSuggestionsView;
@@ -515,7 +516,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
*/
public void setListener(Listener listener, View inputView) {
mListener = listener;
- mKeyboardView = inputView.findViewById(R.id.keyboard_view);
+ mKeyboardView = (KeyboardView)inputView.findViewById(R.id.keyboard_view);
}
public void setSuggestions(SuggestedWords suggestions) {
@@ -658,7 +659,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
mSuggestionsPlacer.removeAllViews();
mSuggestionsPlacer.addView(mSuggestionsStrip);
mSuggestionsStrip.removeAllViews();
- mMoreSuggestionsWindow.dismiss();
+ dismissMoreSuggestions();
}
private void hidePreview() {
@@ -702,13 +703,13 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
final int index = requestCode;
final CharSequence word = mSuggestions.getWord(index);
mListener.pickSuggestionManually(index, word);
- mMoreSuggestionsView.dismissMoreKeysPanel();
+ dismissMoreSuggestions();
return true;
}
@Override
public void onCancelInput() {
- mMoreSuggestionsView.dismissMoreKeysPanel();
+ dismissMoreSuggestions();
}
};
@@ -716,14 +717,19 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
new MoreKeysPanel.Controller() {
@Override
public boolean dismissMoreKeysPanel() {
- if (mMoreSuggestionsWindow.isShowing()) {
- mMoreSuggestionsWindow.dismiss();
- return true;
- }
- return false;
+ return dismissMoreSuggestions();
}
};
+ private boolean dismissMoreSuggestions() {
+ if (mMoreSuggestionsWindow.isShowing()) {
+ mMoreSuggestionsWindow.dismiss();
+ mKeyboardView.dimEntireKeyboard(false);
+ return true;
+ }
+ return false;
+ }
+
@Override
public boolean onLongClick(View view) {
final SuggestionsStripParams params = mStripParams;
@@ -754,7 +760,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
tracker.onShowMoreKeysPanel(
translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel);
view.setPressed(false);
- // TODO: Should gray out the keyboard here as well?
+ mKeyboardView.dimEntireKeyboard(true);
return true;
}
return false;