Merge "Dim keyboard when more suggestions are shown"
commit
78778ca9df
|
@ -103,6 +103,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
private ViewGroup mPreviewPlacer;
|
private ViewGroup mPreviewPlacer;
|
||||||
|
|
||||||
// Drawing
|
// 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. **/
|
/** Whether the keyboard bitmap buffer needs to be redrawn before it's blitted. **/
|
||||||
private boolean mBufferNeedsUpdate;
|
private boolean mBufferNeedsUpdate;
|
||||||
/** The dirty region in the keyboard bitmap */
|
/** 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
|
// Overlay a dark rectangle to dim the entire keyboard
|
||||||
if (needsToDimKeyboard()) {
|
if (mNeedsToDimBackground) {
|
||||||
mPaint.setColor((int) (mBackgroundDimAmount * 0xFF) << 24);
|
mPaint.setColor((int) (mBackgroundDimAmount * 0xFF) << 24);
|
||||||
canvas.drawRect(0, 0, width, height, mPaint);
|
canvas.drawRect(0, 0, width, height, mPaint);
|
||||||
}
|
}
|
||||||
|
@ -491,8 +493,12 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
mDirtyRect.setEmpty();
|
mDirtyRect.setEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean needsToDimKeyboard() {
|
public void dimEntireKeyboard(boolean dimmed) {
|
||||||
return false;
|
final boolean needsRedrawing = mNeedsToDimBackground != dimmed;
|
||||||
|
mNeedsToDimBackground = dimmed;
|
||||||
|
if (needsRedrawing) {
|
||||||
|
invalidateAllKeys();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void onBufferDrawKey(final Key key, final Keyboard keyboard, final Canvas canvas,
|
private static void onBufferDrawKey(final Key key, final Keyboard keyboard, final Canvas canvas,
|
||||||
|
|
|
@ -373,11 +373,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
return miniKeyboardView;
|
return miniKeyboardView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean needsToDimKeyboard() {
|
|
||||||
return mMoreKeysPanel != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboard oldKeyboard) {
|
public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboard oldKeyboard) {
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
// We should not set text fade factor to the keyboard which does not display the language on
|
// 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());
|
final int translatedY = moreKeysPanel.translateY(tracker.getLastY());
|
||||||
tracker.onShowMoreKeysPanel(
|
tracker.onShowMoreKeysPanel(
|
||||||
translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel);
|
translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel);
|
||||||
|
dimEntireKeyboard(true);
|
||||||
invalidateAllKeys();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,7 +614,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
mMoreKeysWindow.dismiss();
|
mMoreKeysWindow.dismiss();
|
||||||
mMoreKeysPanel = null;
|
mMoreKeysPanel = null;
|
||||||
mMoreKeysPanelPointerTrackerId = -1;
|
mMoreKeysPanelPointerTrackerId = -1;
|
||||||
invalidateAllKeys();
|
dimEntireKeyboard(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -50,6 +50,7 @@ import android.widget.TextView;
|
||||||
import com.android.inputmethod.compat.FrameLayoutCompatUtils;
|
import com.android.inputmethod.compat.FrameLayoutCompatUtils;
|
||||||
import com.android.inputmethod.compat.LinearLayoutCompatUtils;
|
import com.android.inputmethod.compat.LinearLayoutCompatUtils;
|
||||||
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
|
import com.android.inputmethod.keyboard.KeyboardView;
|
||||||
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker;
|
import com.android.inputmethod.keyboard.PointerTracker;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
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 mSuggestionsPlacer;
|
||||||
private final ViewGroup mSuggestionsStrip;
|
private final ViewGroup mSuggestionsStrip;
|
||||||
private View mKeyboardView;
|
private KeyboardView mKeyboardView;
|
||||||
|
|
||||||
private final View mMoreSuggestionsContainer;
|
private final View mMoreSuggestionsContainer;
|
||||||
private final MoreSuggestionsView mMoreSuggestionsView;
|
private final MoreSuggestionsView mMoreSuggestionsView;
|
||||||
|
@ -515,7 +516,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
*/
|
*/
|
||||||
public void setListener(Listener listener, View inputView) {
|
public void setListener(Listener listener, View inputView) {
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
mKeyboardView = inputView.findViewById(R.id.keyboard_view);
|
mKeyboardView = (KeyboardView)inputView.findViewById(R.id.keyboard_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSuggestions(SuggestedWords suggestions) {
|
public void setSuggestions(SuggestedWords suggestions) {
|
||||||
|
@ -658,7 +659,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
mSuggestionsPlacer.removeAllViews();
|
mSuggestionsPlacer.removeAllViews();
|
||||||
mSuggestionsPlacer.addView(mSuggestionsStrip);
|
mSuggestionsPlacer.addView(mSuggestionsStrip);
|
||||||
mSuggestionsStrip.removeAllViews();
|
mSuggestionsStrip.removeAllViews();
|
||||||
mMoreSuggestionsWindow.dismiss();
|
dismissMoreSuggestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hidePreview() {
|
private void hidePreview() {
|
||||||
|
@ -702,13 +703,13 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
final int index = requestCode;
|
final int index = requestCode;
|
||||||
final CharSequence word = mSuggestions.getWord(index);
|
final CharSequence word = mSuggestions.getWord(index);
|
||||||
mListener.pickSuggestionManually(index, word);
|
mListener.pickSuggestionManually(index, word);
|
||||||
mMoreSuggestionsView.dismissMoreKeysPanel();
|
dismissMoreSuggestions();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancelInput() {
|
public void onCancelInput() {
|
||||||
mMoreSuggestionsView.dismissMoreKeysPanel();
|
dismissMoreSuggestions();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -716,13 +717,18 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
new MoreKeysPanel.Controller() {
|
new MoreKeysPanel.Controller() {
|
||||||
@Override
|
@Override
|
||||||
public boolean dismissMoreKeysPanel() {
|
public boolean dismissMoreKeysPanel() {
|
||||||
|
return dismissMoreSuggestions();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private boolean dismissMoreSuggestions() {
|
||||||
if (mMoreSuggestionsWindow.isShowing()) {
|
if (mMoreSuggestionsWindow.isShowing()) {
|
||||||
mMoreSuggestionsWindow.dismiss();
|
mMoreSuggestionsWindow.dismiss();
|
||||||
|
mKeyboardView.dimEntireKeyboard(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View view) {
|
public boolean onLongClick(View view) {
|
||||||
|
@ -754,7 +760,7 @@ public class SuggestionsView extends LinearLayout implements OnClickListener, On
|
||||||
tracker.onShowMoreKeysPanel(
|
tracker.onShowMoreKeysPanel(
|
||||||
translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel);
|
translatedX, translatedY, SystemClock.uptimeMillis(), moreKeysPanel);
|
||||||
view.setPressed(false);
|
view.setPressed(false);
|
||||||
// TODO: Should gray out the keyboard here as well?
|
mKeyboardView.dimEntireKeyboard(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue