Loading core/java/android/inputmethodservice/Keyboard.java +43 −3 Original line number Original line Diff line number Diff line Loading @@ -144,6 +144,8 @@ public class Keyboard { /** Number of key widths from current touch point to search for nearest keys. */ /** Number of key widths from current touch point to search for nearest keys. */ private static float SEARCH_DISTANCE = 1.8f; private static float SEARCH_DISTANCE = 1.8f; private ArrayList<Row> rows = new ArrayList<Row>(); /** /** * Container for keys in the keyboard. All keys in a row are at the same Y-coordinate. * Container for keys in the keyboard. All keys in a row are at the same Y-coordinate. * Some of the key size defaults can be overridden per row from what the {@link Keyboard} * Some of the key size defaults can be overridden per row from what the {@link Keyboard} Loading @@ -164,6 +166,9 @@ public class Keyboard { public int defaultHorizontalGap; public int defaultHorizontalGap; /** Vertical gap following this row. */ /** Vertical gap following this row. */ public int verticalGap; public int verticalGap; ArrayList<Key> mKeys = new ArrayList<Key>(); /** /** * Edge flags for this row of keys. Possible values that can be assigned are * Edge flags for this row of keys. Possible values that can be assigned are * {@link Keyboard#EDGE_TOP EDGE_TOP} and {@link Keyboard#EDGE_BOTTOM EDGE_BOTTOM} * {@link Keyboard#EDGE_TOP EDGE_TOP} and {@link Keyboard#EDGE_BOTTOM EDGE_BOTTOM} Loading Loading @@ -596,11 +601,44 @@ public class Keyboard { column++; column++; x += key.width + key.gap; x += key.width + key.gap; mKeys.add(key); mKeys.add(key); row.mKeys.add(key); if (x > mTotalWidth) { if (x > mTotalWidth) { mTotalWidth = x; mTotalWidth = x; } } } } mTotalHeight = y + mDefaultHeight; mTotalHeight = y + mDefaultHeight; rows.add(row); } final void resize(int newWidth, int newHeight) { int numRows = rows.size(); for (int rowIndex = 0; rowIndex < numRows; ++rowIndex) { Row row = rows.get(rowIndex); int numKeys = row.mKeys.size(); int totalGap = 0; int totalWidth = 0; for (int keyIndex = 0; keyIndex < numKeys; ++keyIndex) { Key key = row.mKeys.get(keyIndex); if (keyIndex > 0) { totalGap += key.gap; } totalWidth += key.width; } if (totalGap + totalWidth > newWidth) { int x = 0; float scaleFactor = (float)(newWidth - totalGap) / totalWidth; for (int keyIndex = 0; keyIndex < numKeys; ++keyIndex) { Key key = row.mKeys.get(keyIndex); key.width *= scaleFactor; key.x = x; x += key.width + key.gap; } } } mTotalWidth = newWidth; // TODO: This does not adjust the vertical placement according to the new size. // The main problem in the previous code was horizontal placement/size, but we should // also recalculate the vertical sizes/positions when we get this resize call. } } public List<Key> getKeys() { public List<Key> getKeys() { Loading Loading @@ -759,6 +797,7 @@ public class Keyboard { inRow = true; inRow = true; x = 0; x = 0; currentRow = createRowFromXml(res, parser); currentRow = createRowFromXml(res, parser); rows.add(currentRow); skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode; skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode; if (skipRow) { if (skipRow) { skipToEndOfRow(parser); skipToEndOfRow(parser); Loading @@ -781,6 +820,7 @@ public class Keyboard { } else if (key.codes[0] == KEYCODE_ALT) { } else if (key.codes[0] == KEYCODE_ALT) { mModifierKeys.add(key); mModifierKeys.add(key); } } currentRow.mKeys.add(key); } else if (TAG_KEYBOARD.equals(tag)) { } else if (TAG_KEYBOARD.equals(tag)) { parseKeyboardAttributes(res, parser); parseKeyboardAttributes(res, parser); } } Loading core/java/android/inputmethodservice/KeyboardView.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -376,6 +376,7 @@ public class KeyboardView extends View implements View.OnClickListener { initGestureDetector(); initGestureDetector(); } } private void initGestureDetector() { private void initGestureDetector() { mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override @Override Loading Loading @@ -615,6 +616,9 @@ public class KeyboardView extends View implements View.OnClickListener { @Override @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { public void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); super.onSizeChanged(w, h, oldw, oldh); if (mKeyboard != null) { mKeyboard.resize(w, h); } // Release the buffer, if any and it will be reallocated on the next draw // Release the buffer, if any and it will be reallocated on the next draw mBuffer = null; mBuffer = null; } } Loading core/res/res/layout/keyguard_screen_password_landscape.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -170,6 +170,7 @@ <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard" <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard" android:layout_width="270dip" android:layout_width="270dip" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:layout_marginRight="4dip" android:background="#40000000" android:background="#40000000" android:layout_marginTop="5dip" android:layout_marginTop="5dip" Loading core/res/res/layout/keyguard_screen_password_portrait.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -132,7 +132,7 @@ <!-- Numeric keyboard --> <!-- Numeric keyboard --> <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard" <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:layout_marginRight="4dip" android:paddingTop="4dip" android:paddingTop="4dip" android:paddingBottom="4dip" android:paddingBottom="4dip" Loading Loading
core/java/android/inputmethodservice/Keyboard.java +43 −3 Original line number Original line Diff line number Diff line Loading @@ -144,6 +144,8 @@ public class Keyboard { /** Number of key widths from current touch point to search for nearest keys. */ /** Number of key widths from current touch point to search for nearest keys. */ private static float SEARCH_DISTANCE = 1.8f; private static float SEARCH_DISTANCE = 1.8f; private ArrayList<Row> rows = new ArrayList<Row>(); /** /** * Container for keys in the keyboard. All keys in a row are at the same Y-coordinate. * Container for keys in the keyboard. All keys in a row are at the same Y-coordinate. * Some of the key size defaults can be overridden per row from what the {@link Keyboard} * Some of the key size defaults can be overridden per row from what the {@link Keyboard} Loading @@ -164,6 +166,9 @@ public class Keyboard { public int defaultHorizontalGap; public int defaultHorizontalGap; /** Vertical gap following this row. */ /** Vertical gap following this row. */ public int verticalGap; public int verticalGap; ArrayList<Key> mKeys = new ArrayList<Key>(); /** /** * Edge flags for this row of keys. Possible values that can be assigned are * Edge flags for this row of keys. Possible values that can be assigned are * {@link Keyboard#EDGE_TOP EDGE_TOP} and {@link Keyboard#EDGE_BOTTOM EDGE_BOTTOM} * {@link Keyboard#EDGE_TOP EDGE_TOP} and {@link Keyboard#EDGE_BOTTOM EDGE_BOTTOM} Loading Loading @@ -596,11 +601,44 @@ public class Keyboard { column++; column++; x += key.width + key.gap; x += key.width + key.gap; mKeys.add(key); mKeys.add(key); row.mKeys.add(key); if (x > mTotalWidth) { if (x > mTotalWidth) { mTotalWidth = x; mTotalWidth = x; } } } } mTotalHeight = y + mDefaultHeight; mTotalHeight = y + mDefaultHeight; rows.add(row); } final void resize(int newWidth, int newHeight) { int numRows = rows.size(); for (int rowIndex = 0; rowIndex < numRows; ++rowIndex) { Row row = rows.get(rowIndex); int numKeys = row.mKeys.size(); int totalGap = 0; int totalWidth = 0; for (int keyIndex = 0; keyIndex < numKeys; ++keyIndex) { Key key = row.mKeys.get(keyIndex); if (keyIndex > 0) { totalGap += key.gap; } totalWidth += key.width; } if (totalGap + totalWidth > newWidth) { int x = 0; float scaleFactor = (float)(newWidth - totalGap) / totalWidth; for (int keyIndex = 0; keyIndex < numKeys; ++keyIndex) { Key key = row.mKeys.get(keyIndex); key.width *= scaleFactor; key.x = x; x += key.width + key.gap; } } } mTotalWidth = newWidth; // TODO: This does not adjust the vertical placement according to the new size. // The main problem in the previous code was horizontal placement/size, but we should // also recalculate the vertical sizes/positions when we get this resize call. } } public List<Key> getKeys() { public List<Key> getKeys() { Loading Loading @@ -759,6 +797,7 @@ public class Keyboard { inRow = true; inRow = true; x = 0; x = 0; currentRow = createRowFromXml(res, parser); currentRow = createRowFromXml(res, parser); rows.add(currentRow); skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode; skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode; if (skipRow) { if (skipRow) { skipToEndOfRow(parser); skipToEndOfRow(parser); Loading @@ -781,6 +820,7 @@ public class Keyboard { } else if (key.codes[0] == KEYCODE_ALT) { } else if (key.codes[0] == KEYCODE_ALT) { mModifierKeys.add(key); mModifierKeys.add(key); } } currentRow.mKeys.add(key); } else if (TAG_KEYBOARD.equals(tag)) { } else if (TAG_KEYBOARD.equals(tag)) { parseKeyboardAttributes(res, parser); parseKeyboardAttributes(res, parser); } } Loading
core/java/android/inputmethodservice/KeyboardView.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -376,6 +376,7 @@ public class KeyboardView extends View implements View.OnClickListener { initGestureDetector(); initGestureDetector(); } } private void initGestureDetector() { private void initGestureDetector() { mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override @Override Loading Loading @@ -615,6 +616,9 @@ public class KeyboardView extends View implements View.OnClickListener { @Override @Override public void onSizeChanged(int w, int h, int oldw, int oldh) { public void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); super.onSizeChanged(w, h, oldw, oldh); if (mKeyboard != null) { mKeyboard.resize(w, h); } // Release the buffer, if any and it will be reallocated on the next draw // Release the buffer, if any and it will be reallocated on the next draw mBuffer = null; mBuffer = null; } } Loading
core/res/res/layout/keyguard_screen_password_landscape.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -170,6 +170,7 @@ <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard" <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard" android:layout_width="270dip" android:layout_width="270dip" android:layout_height="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:layout_marginRight="4dip" android:background="#40000000" android:background="#40000000" android:layout_marginTop="5dip" android:layout_marginTop="5dip" Loading
core/res/res/layout/keyguard_screen_password_portrait.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -132,7 +132,7 @@ <!-- Numeric keyboard --> <!-- Numeric keyboard --> <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard" <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:layout_marginRight="4dip" android:paddingTop="4dip" android:paddingTop="4dip" android:paddingBottom="4dip" android:paddingBottom="4dip" Loading