mKeys = new ArrayList<>();
+
+ /**
+ * Edge flags for this row of keys. Possible values that can be assigned are
+ * {@link Comprehend#EDGE_TOP EDGE_TOP} and {@link Comprehend#EDGE_BOTTOM EDGE_BOTTOM}
+ */
+ public int rowEdgeFlags;
+
+ /** The keyboard mode for this row */
+ public int mode;
+
+ private Comprehend parent;
+
+ public Row(Comprehend parent) {
+ this.parent = parent;
+ }
+
+ public Row(Resources res, Comprehend parent, XmlResourceParser parser) {
+ this.parent = parent;
+ TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser),
+ R.styleable.My_Keyboard_view);
+ defaultWidth = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_keyWidth,
+ parent.mDisplayWidth, parent.mDefaultWidth);
+ defaultHeight = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_keyHeight,
+ parent.mDisplayHeight, parent.mDefaultHeight);
+ defaultHorizontalGap = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_horizontalGap,
+ parent.mDisplayWidth, parent.mDefaultHorizontalGap);
+ verticalGap = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_verticalGap,
+ parent.mDisplayHeight, parent.mDefaultVerticalGap);
+ a.recycle();
+ a = res.obtainAttributes(Xml.asAttributeSet(parser),
+ R.styleable.Kil_Keyboard_Row);
+ rowEdgeFlags = a.getInt(R.styleable.Kil_Keyboard_Row_android_rowEdgeFlags, 0);
+ mode = a.getResourceId(R.styleable.Kil_Keyboard_Row_android_keyboardMode,
+ 0);
+ }
+ }
+
+ /**
+ * Class for describing the position and characteristics of a single key in the keyboard.
+ *
+ * @attr ref android.R.styleable#King_Keyboard_keyWidth
+ * @attr ref android.R.styleable#King_Keyboard_keyHeight
+ * @attr ref android.R.styleable#King_Keyboard_horizontalGap
+ * @attr ref android.R.styleable#King_Keyboard_Key_codes
+ * @attr ref android.R.styleable#King_Keyboard_Key_keyIcon
+ * @attr ref android.R.styleable#King_Keyboard_Key_keyLabel
+ * @attr ref android.R.styleable#King_Keyboard_Key_iconPreview
+ * @attr ref android.R.styleable#King_Keyboard_Key_isSticky
+ * @attr ref android.R.styleable#King_Keyboard_Key_isRepeatable
+ * @attr ref android.R.styleable#King_Keyboard_Key_isModifier
+ * @attr ref android.R.styleable#King_Keyboard_Key_popupKeyboard
+ * @attr ref android.R.styleable#King_Keyboard_Key_popupCharacters
+ * @attr ref android.R.styleable#King_Keyboard_Key_keyOutputText
+ * @attr ref android.R.styleable#King_Keyboard_Key_keyEdgeFlags
+ */
+ public static class Key {
+ /**
+ * All the key codes (unicode or custom code) that this key could generate, zero'th
+ * being the most important.
+ */
+ public int[] codes;
+
+ /** Label to display */
+ public CharSequence label;
+
+ /** Icon to display instead of a label. Icon takes precedence over a label */
+ public Drawable icon;
+ /** Preview version of the icon, for the preview popup */
+ public Drawable iconPreview;
+ /** Width of the key, not including the gap */
+ public int width;
+ /** Height of the key, not including the gap */
+ public int height;
+ /** The horizontal gap before this key */
+ public int gap;
+ /** Whether this key is sticky, i.e., a toggle key */
+ public boolean sticky;
+ /** X coordinate of the key in the keyboard layout */
+ public int x;
+ /** Y coordinate of the key in the keyboard layout */
+ public int y;
+ /** The current pressed state of this key */
+ public boolean pressed;
+ /** If this is a sticky key, is it on? */
+ public boolean on;
+ /** Text to output when pressed. This can be multiple characters, like ".com" */
+ public CharSequence text;
+ /** Popup characters */
+ public CharSequence popupCharacters;
+
+ /**
+ * Flags that specify the anchoring to edges of the keyboard for detecting touch events
+ * that are just out of the boundary of the key. This is a bit mask of
+ * {@link Comprehend#EDGE_LEFT}, {@link Comprehend#EDGE_RIGHT}, {@link Comprehend#EDGE_TOP} and
+ * {@link Comprehend#EDGE_BOTTOM}.
+ */
+ public int edgeFlags;
+ /** Whether this is a modifier key, such as Shift or Alt */
+ public boolean modifier;
+ /** The keyboard that this key belongs to */
+ private Comprehend keyboard;
+ /**
+ * If this key pops up a mini keyboard, this is the resource id for the XML layout for that
+ * keyboard.
+ */
+ public int popupResId;
+ /** Whether this key repeats itself when held down */
+ public boolean repeatable;
+
+
+ private final static int[] KEY_STATE_NORMAL_ON = {
+ android.R.attr.state_checkable,
+ android.R.attr.state_checked
+ };
+
+ private final static int[] KEY_STATE_PRESSED_ON = {
+ android.R.attr.state_pressed,
+ android.R.attr.state_checkable,
+ android.R.attr.state_checked
+ };
+
+ private final static int[] KEY_STATE_NORMAL_OFF = {
+ android.R.attr.state_checkable
+ };
+
+ private final static int[] KEY_STATE_PRESSED_OFF = {
+ android.R.attr.state_pressed,
+ android.R.attr.state_checkable
+ };
+
+ private final static int[] KEY_STATE_NORMAL = {
+ };
+
+ private final static int[] KEY_STATE_PRESSED = {
+ android.R.attr.state_pressed
+ };
+
+ /** Create an empty key with no attributes. */
+ public Key(Comprehend.Row parent) {
+ keyboard = parent.parent;
+ height = parent.defaultHeight;
+ width = parent.defaultWidth;
+ gap = parent.defaultHorizontalGap;
+ edgeFlags = parent.rowEdgeFlags;
+ }
+
+ /** Create a key with the given top-left coordinate and extract its attributes from
+ * the XML parser.
+ * @param res resources associated with the caller's context
+ * @param parent the row that this key belongs to. The row must already be attached to
+ * a {@link Comprehend}.
+ * @param x the x coordinate of the top-left
+ * @param y the y coordinate of the top-left
+ * @param parser the XML parser containing the attributes for this key
+ */
+ public Key(Resources res, Comprehend.Row parent, int x, int y, XmlResourceParser parser) {
+ this(parent);
+
+ this.x = x;
+ this.y = y;
+
+ TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser),
+ R.styleable.My_Keyboard_view);
+
+ width = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_keyWidth,
+ keyboard.mDisplayWidth, parent.defaultWidth);
+ height = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_keyHeight,
+ keyboard.mDisplayHeight, parent.defaultHeight);
+ gap = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_horizontalGap,
+ keyboard.mDisplayWidth, parent.defaultHorizontalGap);
+ a.recycle();
+ a = res.obtainAttributes(Xml.asAttributeSet(parser),
+ R.styleable.K_Keyboard_Key);
+ this.x += gap;
+ TypedValue codesValue = new TypedValue();
+ a.getValue(R.styleable.K_Keyboard_Key_android_codes,
+ codesValue);
+ if (codesValue.type == TypedValue.TYPE_INT_DEC
+ || codesValue.type == TypedValue.TYPE_INT_HEX) {
+ codes = new int[] { codesValue.data };
+ } else if (codesValue.type == TypedValue.TYPE_STRING) {
+ codes = parseCSV(codesValue.string.toString());
+ }
+
+ iconPreview = a.getDrawable(R.styleable.K_Keyboard_Key_android_iconPreview);
+ if (iconPreview != null) {
+ iconPreview.setBounds(0, 0, iconPreview.getIntrinsicWidth(),
+ iconPreview.getIntrinsicHeight());
+ }
+ popupCharacters = a.getText(
+ R.styleable.K_Keyboard_Key_android_popupCharacters);
+ popupResId = a.getResourceId(
+ R.styleable.K_Keyboard_Key_android_popupKeyboard, 0);
+ repeatable = a.getBoolean(
+ R.styleable.K_Keyboard_Key_android_isRepeatable, false);
+ modifier = a.getBoolean(
+ R.styleable.K_Keyboard_Key_android_isModifier, false);
+ sticky = a.getBoolean(
+ R.styleable.K_Keyboard_Key_android_isSticky, false);
+ edgeFlags = a.getInt(R.styleable.K_Keyboard_Key_android_keyEdgeFlags, 0);
+ edgeFlags |= parent.rowEdgeFlags;
+
+ icon = a.getDrawable(
+ R.styleable.K_Keyboard_Key_android_keyIcon);
+ if (icon != null) {
+ icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
+ }
+ label = a.getText(R.styleable.K_Keyboard_Key_android_keyLabel);
+ text = a.getText(R.styleable.K_Keyboard_Key_android_keyOutputText);
+
+ if (codes == null && !TextUtils.isEmpty(label)) {
+ codes = new int[] { label.charAt(0) };
+ }
+ a.recycle();
+ }
+
+ /**
+ * Informs the key that it has been pressed, in case it needs to change its appearance or
+ * state.
+ * @see #onReleased(boolean)
+ */
+ public void onPressed() {
+ pressed = !pressed;
+ }
+
+ /**
+ * Changes the pressed state of the key.
+ *
+ * Toggled state of the key will be flipped when all the following conditions are
+ * fulfilled:
+ *
+ *
+ * - This is a sticky key, that is, {@link #sticky} is {@code true}.
+ *
- The parameter {@code inside} is {@code true}.
+ *
- {@link android.os.Build.VERSION#SDK_INT} is greater than
+ * {@link android.os.Build.VERSION_CODES#LOLLIPOP_MR1}.
+ *
+ *
+ * @param inside whether the finger was released inside the key. Works only on Android M and
+ * later. See the method document for details.
+ * @see #onPressed()
+ */
+ public void onReleased(boolean inside) {
+ pressed = !pressed;
+ if (sticky && inside) {
+ on = !on;
+ }
+ }
+
+ int[] parseCSV(String value) {
+ int count = 0;
+ int lastIndex = 0;
+ if (value.length() > 0) {
+ count++;
+ while ((lastIndex = value.indexOf(",", lastIndex + 1)) > 0) {
+ count++;
+ }
+ }
+ int[] values = new int[count];
+ count = 0;
+ StringTokenizer st = new StringTokenizer(value, ",");
+ while (st.hasMoreTokens()) {
+ try {
+ values[count++] = Integer.parseInt(st.nextToken());
+ } catch (NumberFormatException nfe) {
+
+ }
+ }
+ return values;
+ }
+
+ /**
+ * Detects if a point falls inside this key.
+ * @param x the x-coordinate of the point
+ * @param y the y-coordinate of the point
+ * @return whether or not the point falls inside the key. If the key is attached to an edge,
+ * it will assume that all points between the key and the edge are considered to be inside
+ * the key.
+ */
+ public boolean isInside(int x, int y) {
+ boolean leftEdge = (edgeFlags & EDGE_LEFT) > 0;
+ boolean rightEdge = (edgeFlags & EDGE_RIGHT) > 0;
+ boolean topEdge = (edgeFlags & EDGE_TOP) > 0;
+ boolean bottomEdge = (edgeFlags & EDGE_BOTTOM) > 0;
+ if ((x >= this.x || (leftEdge && x <= this.x + this.width))
+ && (x < this.x + this.width || (rightEdge && x >= this.x))
+ && (y >= this.y || (topEdge && y <= this.y + this.height))
+ && (y < this.y + this.height || (bottomEdge && y >= this.y))) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the square of the distance between the center of the key and the given point.
+ * @param x the x-coordinate of the point
+ * @param y the y-coordinate of the point
+ * @return the square of the distance of the point from the center of the key
+ */
+ public int squaredDistanceFrom(int x, int y) {
+ int xDist = this.x + width / 2 - x;
+ int yDist = this.y + height / 2 - y;
+ return xDist * xDist + yDist * yDist;
+ }
+
+ /**
+ * Returns the drawable state for the key, based on the current state and type of the key.
+ * @return the drawable state of the key.
+ * @see android.graphics.drawable.StateListDrawable#setState(int[])
+ */
+ public int[] getCurrentDrawableState() {
+ int[] states = KEY_STATE_NORMAL;
+
+ if (on) {
+ if (pressed) {
+ states = KEY_STATE_PRESSED_ON;
+ } else {
+ states = KEY_STATE_NORMAL_ON;
+ }
+ } else {
+ if (sticky) {
+ if (pressed) {
+ states = KEY_STATE_PRESSED_OFF;
+ } else {
+ states = KEY_STATE_NORMAL_OFF;
+ }
+ } else {
+ if (pressed) {
+ states = KEY_STATE_PRESSED;
+ }
+ }
+ }
+ return states;
+ }
+ }
+
+ /**
+ * Creates a keyboard from the given xml key layout file.
+ * @param context the application or service context
+ * @param xmlLayoutResId the resource file that contains the keyboard layout and keys.
+ */
+ public Comprehend(Context context, int xmlLayoutResId) {
+ this(context, xmlLayoutResId, 0);
+ }
+
+ /**
+ * Creates a keyboard from the given xml key layout file. Weeds out rows
+ * that have a keyboard mode defined but don't match the specified mode.
+ * @param context the application or service context
+ * @param xmlLayoutResId the resource file that contains the keyboard layout and keys.
+ * @param modeId keyboard mode identifier
+ * @param width sets width of keyboard
+ * @param height sets height of keyboard
+ */
+ public Comprehend(Context context, @XmlRes int xmlLayoutResId, int modeId, int width,
+ int height) {
+ mDisplayWidth = width;
+ mDisplayHeight = height;
+
+ mDefaultHorizontalGap = 0;
+ mDefaultWidth = mDisplayWidth / 10;
+ mDefaultVerticalGap = 0;
+ mDefaultHeight = mDefaultWidth;
+ mKeys = new ArrayList<>();
+ mModifierKeys = new ArrayList<>();
+ mKeyboardMode = modeId;
+ loadKeyboard(context, context.getResources().getXml(xmlLayoutResId));
+ }
+
+ /**
+ * Creates a keyboard from the given xml key layout file. Weeds out rows
+ * that have a keyboard mode defined but don't match the specified mode.
+ * @param context the application or service context
+ * @param xmlLayoutResId the resource file that contains the keyboard layout and keys.
+ * @param modeId keyboard mode identifier
+ */
+ public Comprehend(Context context, @XmlRes int xmlLayoutResId, int modeId) {
+ DisplayMetrics dm = context.getResources().getDisplayMetrics();
+ mDisplayWidth = dm.widthPixels;
+ mDisplayHeight = dm.heightPixels;
+ //Log.v(TAG, "keyboard's display metrics:" + dm);
+
+ mDefaultHorizontalGap = 0;
+ mDefaultWidth = mDisplayWidth / 10;
+ mDefaultVerticalGap = 0;
+ mDefaultHeight = mDefaultWidth;
+ mKeys = new ArrayList<>();
+ mModifierKeys = new ArrayList<>();
+ mKeyboardMode = modeId;
+ loadKeyboard(context, context.getResources().getXml(xmlLayoutResId));
+ }
+
+ public Comprehend(Context context, int layoutTemplateResId,
+ CharSequence characters, int columns, int horizontalPadding) {
+ this(context, layoutTemplateResId);
+ int x = 0;
+ int y = 0;
+ int column = 0;
+ mTotalWidth = 0;
+
+ Comprehend.Row row = new Comprehend.Row(this);
+ row.defaultHeight = mDefaultHeight;
+ row.defaultWidth = mDefaultWidth;
+ row.defaultHorizontalGap = mDefaultHorizontalGap;
+ row.verticalGap = mDefaultVerticalGap;
+ row.rowEdgeFlags = EDGE_TOP | EDGE_BOTTOM;
+ final int maxColumns = columns == -1 ? Integer.MAX_VALUE : columns;
+ for (int i = 0; i < characters.length(); i++) {
+ char c = characters.charAt(i);
+ if (column >= maxColumns
+ || x + mDefaultWidth + horizontalPadding > mDisplayWidth) {
+ x = 0;
+ y += mDefaultVerticalGap + mDefaultHeight;
+ column = 0;
+ }
+ final Comprehend.Key key = new Comprehend.Key(row);
+ key.x = x;
+ key.y = y;
+ key.label = String.valueOf(c);
+ key.codes = new int[] { c };
+ column++;
+ x += key.width + key.gap;
+ mKeys.add(key);
+ row.mKeys.add(key);
+ if (x > mTotalWidth) {
+ mTotalWidth = x;
+ }
+ }
+ mTotalHeight = y + mDefaultHeight;
+ rows.add(row);
+ }
+
+ final void resize(int newWidth, int newHeight) {
+ int numRows = rows.size();
+ for (int rowIndex = 0; rowIndex < numRows; ++rowIndex) {
+ Comprehend.Row row = rows.get(rowIndex);
+ int numKeys = row.mKeys.size();
+ int totalGap = 0;
+ int totalWidth = 0;
+ for (int keyIndex = 0; keyIndex < numKeys; ++keyIndex) {
+ Comprehend.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) {
+ Comprehend.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 getKeys() {
+ return mKeys;
+ }
+
+ public List getModifierKeys() {
+ return mModifierKeys;
+ }
+
+ protected int getHorizontalGap() {
+ return mDefaultHorizontalGap;
+ }
+
+ protected void setHorizontalGap(int gap) {
+ mDefaultHorizontalGap = gap;
+ }
+
+ protected int getVerticalGap() {
+ return mDefaultVerticalGap;
+ }
+
+ protected void setVerticalGap(int gap) {
+ mDefaultVerticalGap = gap;
+ }
+
+ protected int getKeyHeight() {
+ return mDefaultHeight;
+ }
+
+ protected void setKeyHeight(int height) {
+ mDefaultHeight = height;
+ }
+
+ protected int getKeyWidth() {
+ return mDefaultWidth;
+ }
+
+ protected void setKeyWidth(int width) {
+ mDefaultWidth = width;
+ }
+
+ /**
+ * Returns the total height of the keyboard
+ * @return the total height of the keyboard
+ */
+ public int getHeight() {
+ return mTotalHeight;
+ }
+
+ public int getMinWidth() {
+ return mTotalWidth;
+ }
+
+ public boolean setShifted(boolean shiftState) {
+ for (Comprehend.Key shiftKey : mShiftKeys) {
+ if (shiftKey != null) {
+ shiftKey.on = shiftState;
+ }
+ }
+ if (mShifted != shiftState) {
+ mShifted = shiftState;
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isShifted() {
+ return mShifted;
+ }
+
+ /**
+ * @hide
+ */
+ public int[] getShiftKeyIndices() {
+ return mShiftKeyIndices;
+ }
+
+ public int getShiftKeyIndex() {
+ return mShiftKeyIndices[0];
+ }
+
+ private void computeNearestNeighbors() {
+ // Round-up so we don't have any pixels outside the grid
+ mCellWidth = (getMinWidth() + GRID_WIDTH - 1) / GRID_WIDTH;
+ mCellHeight = (getHeight() + GRID_HEIGHT - 1) / GRID_HEIGHT;
+ mGridNeighbors = new int[GRID_SIZE][];
+ int[] indices = new int[mKeys.size()];
+ final int gridWidth = GRID_WIDTH * mCellWidth;
+ final int gridHeight = GRID_HEIGHT * mCellHeight;
+ for (int x = 0; x < gridWidth; x += mCellWidth) {
+ for (int y = 0; y < gridHeight; y += mCellHeight) {
+ int count = 0;
+ for (int i = 0; i < mKeys.size(); i++) {
+ final Comprehend.Key key = mKeys.get(i);
+ if (key.squaredDistanceFrom(x, y) < mProximityThreshold ||
+ key.squaredDistanceFrom(x + mCellWidth - 1, y) < mProximityThreshold ||
+ key.squaredDistanceFrom(x + mCellWidth - 1, y + mCellHeight - 1)
+ < mProximityThreshold ||
+ key.squaredDistanceFrom(x, y + mCellHeight - 1) < mProximityThreshold) {
+ indices[count++] = i;
+ }
+ }
+ int [] cell = new int[count];
+ System.arraycopy(indices, 0, cell, 0, count);
+ mGridNeighbors[(y / mCellHeight) * GRID_WIDTH + (x / mCellWidth)] = cell;
+ }
+ }
+ }
+
+ /**
+ * Returns the indices of the keys that are closest to the given point.
+ * @param x the x-coordinate of the point
+ * @param y the y-coordinate of the point
+ * @return the array of integer indices for the nearest keys to the given point. If the given
+ * point is out of range, then an array of size zero is returned.
+ */
+ public int[] getNearestKeys(int x, int y) {
+ if (mGridNeighbors == null) computeNearestNeighbors();
+ if (x >= 0 && x < getMinWidth() && y >= 0 && y < getHeight()) {
+ int index = (y / mCellHeight) * GRID_WIDTH + (x / mCellWidth);
+ if (index < GRID_SIZE) {
+ return mGridNeighbors[index];
+ }
+ }
+ return new int[0];
+ }
+
+ protected Comprehend.Row createRowFromXml(Resources res, XmlResourceParser parser) {
+ return new Comprehend.Row(res, this, parser);
+ }
+
+ protected Comprehend.Key createKeyFromXml(Resources res, Comprehend.Row parent, int x, int y,
+ XmlResourceParser parser) {
+ return new Comprehend.Key(res, parent, x, y, parser);
+ }
+
+ private void loadKeyboard(Context context, XmlResourceParser parser) {
+ boolean inKey = false;
+ boolean inRow = false;
+ boolean leftMostKey = false;
+ int row = 0;
+ int x = 0;
+ int y = 0;
+ Comprehend.Key key = null;
+ Comprehend.Row currentRow = null;
+ Resources res = context.getResources();
+ boolean skipRow = false;
+
+ try {
+ int event;
+ while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) {
+ if (event == XmlResourceParser.START_TAG) {
+ String tag = parser.getName();
+ if (TAG_ROW.equals(tag)) {
+ inRow = true;
+ x = 0;
+ currentRow = createRowFromXml(res, parser);
+ rows.add(currentRow);
+ skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode;
+ if (skipRow) {
+ skipToEndOfRow(parser);
+ inRow = false;
+ }
+ } else if (TAG_KEY.equals(tag)) {
+ inKey = true;
+ key = createKeyFromXml(res, currentRow, x, y, parser);
+ mKeys.add(key);
+ if (key.codes[0] == KEYCODE_SHIFT) {
+ // Find available shift key slot and put this shift key in it
+ for (int i = 0; i < mShiftKeys.length; i++) {
+ if (mShiftKeys[i] == null) {
+ mShiftKeys[i] = key;
+ mShiftKeyIndices[i] = mKeys.size()-1;
+ break;
+ }
+ }
+ mModifierKeys.add(key);
+ } else if (key.codes[0] == KEYCODE_ALT) {
+ mModifierKeys.add(key);
+ }
+ currentRow.mKeys.add(key);
+ } else if (TAG_KEYBOARD.equals(tag)) {
+ parseKeyboardAttributes(res, parser);
+ }
+ } else if (event == XmlResourceParser.END_TAG) {
+ if (inKey) {
+ inKey = false;
+ x += key.gap + key.width;
+ if (x > mTotalWidth) {
+ mTotalWidth = x;
+ }
+ } else if (inRow) {
+ inRow = false;
+ y += currentRow.verticalGap;
+ y += currentRow.defaultHeight;
+ row++;
+ } else {
+ // TODO: error or extend?
+ }
+ }
+ }
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+ mTotalHeight = y - mDefaultVerticalGap;
+ }
+
+ private void skipToEndOfRow(XmlResourceParser parser)
+ throws XmlPullParserException, IOException {
+ int event;
+ while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) {
+ if (event == XmlResourceParser.END_TAG
+ && parser.getName().equals(TAG_ROW)) {
+ break;
+ }
+ }
+ }
+
+ private void parseKeyboardAttributes(Resources res, XmlResourceParser parser) {
+ TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser),
+ R.styleable.My_Keyboard_view);
+
+ mDefaultWidth = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_keyWidth,
+ mDisplayWidth, mDisplayWidth / 10);
+ mDefaultHeight = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_keyHeight,
+ mDisplayHeight, 50);
+ mDefaultHorizontalGap = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_horizontalGap,
+ mDisplayWidth, 0);
+ mDefaultVerticalGap = getDimensionOrFraction(a,
+ R.styleable.My_Keyboard_view_android_verticalGap,
+ mDisplayHeight, 0);
+ mProximityThreshold = (int) (mDefaultWidth * SEARCH_DISTANCE);
+ mProximityThreshold = mProximityThreshold * mProximityThreshold; // Square it for comparison
+ a.recycle();
+ }
+
+ static int getDimensionOrFraction(TypedArray a, int index, int base, int defValue) {
+ TypedValue value = a.peekValue(index);
+ if (value == null) return defValue;
+ if (value.type == TypedValue.TYPE_DIMENSION) {
+ return a.getDimensionPixelOffset(index, defValue);
+ } else if (value.type == TypedValue.TYPE_FRACTION) {
+ // Round it to avoid values like 47.9999 from getting truncated
+ return Math.round(a.getFraction(index, base, base, defValue));
+ }
+ return defValue;
+ }
+}
+
diff --git a/app/src/main/java/com/app/brush/guitar/ink/fjord/DecipherView.java b/app/src/main/java/com/app/brush/guitar/ink/fjord/DecipherView.java
new file mode 100644
index 0000000..abba0d5
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/fjord/DecipherView.java
@@ -0,0 +1,1386 @@
+package com.app.brush.guitar.ink.fjord;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.Rect;
+import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
+import android.media.AudioManager;
+import android.os.Handler;
+import android.os.Message;
+import android.util.AttributeSet;
+import android.util.TypedValue;
+import android.view.GestureDetector;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.ViewGroup;
+import android.widget.PopupWindow;
+import android.widget.TextView;
+
+import com.app.brush.guitar.ink.R;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DecipherView extends View implements View.OnClickListener {
+
+ /**
+ * Listener for virtual keyboard events.
+ */
+ public interface OnKeyboardActionListener {
+
+
+ void onPress(int primaryCode);
+
+ /**
+ * Called when the user releases a key. This is sent after the {@link #onKey} is called.
+ * For keys that repeat, this is only called once.
+ * @param primaryCode the code of the key that was released
+ */
+ void onRelease(int primaryCode);
+
+ void onKey(int primaryCode, int[] keyCodes);
+
+ /**
+ * Sends a sequence of characters to the listener.
+ * @param text the sequence of characters to be displayed.
+ */
+ void onText(CharSequence text);
+
+ /**
+ * Called when the user quickly moves the finger from right to left.
+ */
+ void swipeLeft();
+
+ /**
+ * Called when the user quickly moves the finger from left to right.
+ */
+ void swipeRight();
+
+ /**
+ * Called when the user quickly moves the finger from up to down.
+ */
+ void swipeDown();
+
+ /**
+ * Called when the user quickly moves the finger from down to up.
+ */
+ void swipeUp();
+ }
+
+ private static final boolean DEBUG = false;
+ private static final int NOT_A_KEY = -1;
+ private static final int[] KEY_DELETE = { Comprehend.KEYCODE_DELETE };
+ private static final int[] LONG_PRESSABLE_STATE_SET = { R.styleable.IM_KeyboardViewPreviewState_android_state_long_pressable };
+
+ private Context mContext;
+ private Comprehend mKeyboard;
+ private int mCurrentKeyIndex = NOT_A_KEY;
+
+ private int mLabelTextSize;
+ private int mKeyTextSize;
+ private int mKeyTextColor;
+ private float mShadowRadius;
+ private int mShadowColor;
+ private float mBackgroundDimAmount;
+
+ private TextView mPreviewText;
+ private PopupWindow mPreviewPopup;
+ private int mPreviewTextSizeLarge;
+ private int mPreviewOffset;
+ private int mPreviewHeight;
+ // Working variable
+ private final int[] mCoordinates = new int[2];
+
+ private PopupWindow mPopupKeyboard;
+ private View mMiniKeyboardContainer;
+ private DecipherView mMiniKeyboard;
+ private boolean mMiniKeyboardOnScreen;
+ private View mPopupParent;
+ private int mMiniKeyboardOffsetX;
+ private int mMiniKeyboardOffsetY;
+ private Map mMiniKeyboardCache;
+ private Comprehend.Key[] mKeys;
+
+
+ private DecipherView.OnKeyboardActionListener mKeyboardActionListener;
+
+ private static final int MSG_SHOW_PREVIEW = 1;
+ private static final int MSG_REMOVE_PREVIEW = 2;
+ private static final int MSG_REPEAT = 3;
+ private static final int MSG_LONGPRESS = 4;
+
+ private static final int DELAY_BEFORE_PREVIEW = 0;
+ private static final int DELAY_AFTER_PREVIEW = 70;
+ private static final int DEBOUNCE_TIME = 70;
+
+ private int mVerticalCorrection;
+ private int mProximityThreshold;
+
+ private boolean mPreviewCentered = false;
+ private boolean mShowPreview = true;
+ private boolean mShowTouchPoints = true;
+ private int mPopupPreviewX;
+ private int mPopupPreviewY;
+
+ private int mLastX;
+ private int mLastY;
+ private int mStartX;
+ private int mStartY;
+
+ private boolean mProximityCorrectOn;
+
+ private Paint mPaint;
+ private Rect mPadding;
+
+ private long mDownTime;
+ private long mLastMoveTime;
+ private int mLastKey;
+ private int mLastCodeX;
+ private int mLastCodeY;
+ private int mCurrentKey = NOT_A_KEY;
+ private int mDownKey = NOT_A_KEY;
+ private long mLastKeyTime;
+ private long mCurrentKeyTime;
+ private int[] mKeyIndices = new int[12];
+ private GestureDetector mGestureDetector;
+ private int mPopupX;
+ private int mPopupY;
+ private int mRepeatKeyIndex = NOT_A_KEY;
+ private int mPopupLayout;
+ private boolean mAbortKey;
+ private Comprehend.Key mInvalidatedKey;
+ private Rect mClipRegion = new Rect(0, 0, 0, 0);
+ private boolean mPossiblePoly;
+ private SwipeTracker mSwipeTracker = new SwipeTracker();
+ private int mSwipeThreshold;
+ private boolean mDisambiguateSwipe;
+
+ // Variables for dealing with multiple pointers
+ private int mOldPointerCount = 1;
+ private float mOldPointerX;
+ private float mOldPointerY;
+
+ private Drawable mKeyBackground;
+
+ private static final int REPEAT_INTERVAL = 50; // ~20 keys per second
+ private static final int REPEAT_START_DELAY = 300;
+ private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout();
+
+ private static int MAX_NEARBY_KEYS = 12;
+ private int[] mDistances = new int[MAX_NEARBY_KEYS];
+
+ // For multi-tap
+ private int mLastSentIndex;
+ private int mTapCount;
+ private long mLastTapTime;
+ private boolean mInMultiTap;
+ private static final int MULTITAP_INTERVAL = 600; // milliseconds
+ private StringBuilder mPreviewLabel = new StringBuilder(1);
+
+ /** Whether the keyboard bitmap needs to be redrawn before it's blitted. **/
+ private boolean mDrawPending;
+ /** The dirty region in the keyboard bitmap */
+ private Rect mDirtyRect = new Rect();
+ /** The keyboard bitmap for faster updates */
+ private Bitmap mBuffer;
+ /** Notes if the keyboard just changed, so that we could possibly reallocate the mBuffer. */
+ private boolean mKeyboardChanged;
+ /** The canvas for the above mutable keyboard bitmap */
+ private Canvas mCanvas;
+ /** The accessibility manager for accessibility support */
+// private AccessibilityManager mAccessibilityManager;
+ /** The audio manager for accessibility support */
+ private AudioManager mAudioManager;
+ /** Whether the requirement of a headset to hear passwords if accessibility is enabled is announced. */
+ private boolean mHeadsetRequiredToHearPasswordsAnnounced;
+
+ Handler mHandler;
+
+ public DecipherView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public DecipherView(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, 0);
+ }
+
+ public DecipherView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ mContext = context;
+ TypedArray a = context.obtainStyledAttributes(
+ attrs, R.styleable.My_KeyboardView, defStyleAttr, defStyleRes);
+
+ LayoutInflater inflate =
+ (LayoutInflater) context
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+ int previewLayout = 0;
+ int keyTextSize = 0;
+
+ int n = a.getIndexCount();
+
+ for (int i = 0; i < n; i++) {
+ int attr = a.getIndex(i);
+
+ if (attr == R.styleable.My_KeyboardView_android_keyBackground) {
+ mKeyBackground = a.getDrawable(attr);
+ } else if (attr == R.styleable.My_KeyboardView_android_verticalCorrection) {
+ mVerticalCorrection = a.getDimensionPixelOffset(attr, 0);
+ } else if (attr == R.styleable.My_KeyboardView_android_keyPreviewLayout) {
+ previewLayout = a.getResourceId(attr, 0);
+ } else if (attr == R.styleable.My_KeyboardView_android_keyPreviewOffset) {
+ mPreviewOffset = a.getDimensionPixelOffset(attr, 0);
+ } else if (attr == R.styleable.My_KeyboardView_android_keyPreviewHeight) {
+ mPreviewHeight = a.getDimensionPixelSize(attr, 80);
+ } else if (attr == R.styleable.My_KeyboardView_android_keyTextSize) {
+ mKeyTextSize = a.getDimensionPixelSize(attr, 18);
+ } else if (attr == R.styleable.My_KeyboardView_android_keyTextColor) {
+ mKeyTextColor = a.getColor(attr, 0xFF333333);
+ } else if (attr == R.styleable.My_KeyboardView_android_labelTextSize) {
+ mLabelTextSize = a.getDimensionPixelSize(attr, 14);
+ } else if (attr == R.styleable.My_KeyboardView_android_popupLayout) {
+ mPopupLayout = a.getResourceId(attr, 0);
+ } else if (attr == R.styleable.My_KeyboardView_android_shadowColor) {
+ mShadowColor = a.getColor(attr, 0);
+ } else if (attr == R.styleable.My_KeyboardView_android_shadowRadius) {
+ mShadowRadius = a.getFloat(attr, 0f);
+ }
+ }
+
+ mPreviewPopup = new PopupWindow(context);
+ if (previewLayout != 0) {
+ mPreviewText = (TextView) inflate.inflate(previewLayout, null);
+ mPreviewTextSizeLarge = (int) mPreviewText.getTextSize();
+ mPreviewPopup.setContentView(mPreviewText);
+ mPreviewPopup.setBackgroundDrawable(null);
+ } else {
+ mShowPreview = false;
+ }
+
+ mPreviewPopup.setTouchable(false);
+
+ mPopupKeyboard = new PopupWindow(context);
+ mPopupKeyboard.setBackgroundDrawable(null);
+ //mPopupKeyboard.setClippingEnabled(false);
+
+ mPopupParent = this;
+ //mPredicting = true;
+
+ mPaint = new Paint();
+ mPaint.setAntiAlias(true);
+ mPaint.setTextSize(keyTextSize);
+ mPaint.setTextAlign(Paint.Align.CENTER);
+ mPaint.setAlpha(255);
+
+ mPadding = new Rect(0, 0, 0, 0);
+ mMiniKeyboardCache = new HashMap();
+ mKeyBackground.getPadding(mPadding);
+
+ mSwipeThreshold = (int) (500 * getResources().getDisplayMetrics().density);
+// mDisambiguateSwipe = getResources().getBoolean(
+// R.bool.config_swipeDisambiguation);
+
+ mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+
+ resetMultiTap();
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ initGestureDetector();
+ if (mHandler == null) {
+ mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_SHOW_PREVIEW:
+ showKey(msg.arg1);
+ break;
+ case MSG_REMOVE_PREVIEW:
+ mPreviewText.setVisibility(INVISIBLE);
+ break;
+ case MSG_REPEAT:
+ if (repeatKey()) {
+ Message repeat = Message.obtain(this, MSG_REPEAT);
+ sendMessageDelayed(repeat, REPEAT_INTERVAL);
+ }
+ break;
+ case MSG_LONGPRESS:
+ openPopupIfRequired((MotionEvent) msg.obj);
+ break;
+ }
+ }
+ };
+ }
+ }
+
+ private void initGestureDetector() {
+ if (mGestureDetector == null) {
+ mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
+ @Override
+ public boolean onFling(MotionEvent me1, MotionEvent me2,
+ float velocityX, float velocityY) {
+ if (mPossiblePoly) return false;
+ final float absX = Math.abs(velocityX);
+ final float absY = Math.abs(velocityY);
+ float deltaX = me2.getX() - me1.getX();
+ float deltaY = me2.getY() - me1.getY();
+ int travelX = getWidth() / 2; // Half the keyboard width
+ int travelY = getHeight() / 2; // Half the keyboard height
+ mSwipeTracker.computeCurrentVelocity(1000);
+ final float endingVelocityX = mSwipeTracker.getXVelocity();
+ final float endingVelocityY = mSwipeTracker.getYVelocity();
+ boolean sendDownKey = false;
+ if (velocityX > mSwipeThreshold && absY < absX && deltaX > travelX) {
+ if (mDisambiguateSwipe && endingVelocityX < velocityX / 4) {
+ sendDownKey = true;
+ } else {
+ swipeRight();
+ return true;
+ }
+ } else if (velocityX < -mSwipeThreshold && absY < absX && deltaX < -travelX) {
+ if (mDisambiguateSwipe && endingVelocityX > velocityX / 4) {
+ sendDownKey = true;
+ } else {
+ swipeLeft();
+ return true;
+ }
+ } else if (velocityY < -mSwipeThreshold && absX < absY && deltaY < -travelY) {
+ if (mDisambiguateSwipe && endingVelocityY > velocityY / 4) {
+ sendDownKey = true;
+ } else {
+ swipeUp();
+ return true;
+ }
+ } else if (velocityY > mSwipeThreshold && absX < absY / 2 && deltaY > travelY) {
+ if (mDisambiguateSwipe && endingVelocityY < velocityY / 4) {
+ sendDownKey = true;
+ } else {
+ swipeDown();
+ return true;
+ }
+ }
+
+ if (sendDownKey) {
+ detectAndSendKey(mDownKey, mStartX, mStartY, me1.getEventTime());
+ }
+ return false;
+ }
+ });
+
+ mGestureDetector.setIsLongpressEnabled(false);
+ }
+ }
+
+ public void setOnKeyboardActionListener(OnKeyboardActionListener listener) {
+ mKeyboardActionListener = listener;
+ }
+
+ protected OnKeyboardActionListener getOnKeyboardActionListener() {
+ return mKeyboardActionListener;
+ }
+
+
+ public void setKeyboard(Comprehend keyboard) {
+ if (mKeyboard != null) {
+ showPreview(NOT_A_KEY);
+ }
+ // Remove any pending messages
+ removeMessages();
+ mKeyboard = keyboard;
+ List keys = mKeyboard.getKeys();
+ mKeys = keys.toArray(new Comprehend.Key[keys.size()]);
+ requestLayout();
+ // Hint to reallocate the buffer if the size changed
+ mKeyboardChanged = true;
+ invalidateAllKeys();
+ computeProximityThreshold(keyboard);
+ mMiniKeyboardCache.clear(); // Not really necessary to do every time, but will free up views
+ // Switching to a different keyboard should abort any pending keys so that the key up
+ // doesn't get delivered to the old or new keyboard
+ mAbortKey = true; // Until the next ACTION_DOWN
+ }
+
+
+ public Comprehend getKeyboard() {
+ return mKeyboard;
+ }
+
+
+ public boolean setShifted(boolean shifted) {
+ if (mKeyboard != null) {
+ if (mKeyboard.setShifted(shifted)) {
+ // The whole keyboard probably needs to be redrawn
+ invalidateAllKeys();
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public boolean isShifted() {
+ if (mKeyboard != null) {
+ return mKeyboard.isShifted();
+ }
+ return false;
+ }
+
+
+ public void setPreviewEnabled(boolean previewEnabled) {
+ mShowPreview = previewEnabled;
+ }
+
+ /**
+ * Returns the enabled state of the key feedback popup.
+ * @return whether or not the key feedback popup is enabled
+ * @see #setPreviewEnabled(boolean)
+ */
+ public boolean isPreviewEnabled() {
+ return mShowPreview;
+ }
+
+ public void setVerticalCorrection(int verticalOffset) {
+
+ }
+ public void setPopupParent(View v) {
+ mPopupParent = v;
+ }
+
+ public void setPopupOffset(int x, int y) {
+ mMiniKeyboardOffsetX = x;
+ mMiniKeyboardOffsetY = y;
+ if (mPreviewPopup.isShowing()) {
+ mPreviewPopup.dismiss();
+ }
+ }
+
+ public void setProximityCorrectionEnabled(boolean enabled) {
+ mProximityCorrectOn = enabled;
+ }
+
+ /**
+ * Returns true if proximity correction is enabled.
+ */
+ public boolean isProximityCorrectionEnabled() {
+ return mProximityCorrectOn;
+ }
+
+ /**
+ * Popup keyboard close button clicked.
+ * @hide
+ */
+ public void onClick(View v) {
+ dismissPopupKeyboard();
+ }
+
+ private CharSequence adjustCase(CharSequence label) {
+ if (mKeyboard.isShifted() && label != null && label.length() < 3
+ && Character.isLowerCase(label.charAt(0))) {
+ label = label.toString().toUpperCase();
+ }
+ return label;
+ }
+
+ @Override
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // Round up a little
+ if (mKeyboard == null) {
+ setMeasuredDimension(getPaddingLeft() + getPaddingRight(), getPaddingTop() + getPaddingBottom());
+ } else {
+ int width = mKeyboard.getMinWidth() + getPaddingLeft() + getPaddingRight();
+ if (MeasureSpec.getSize(widthMeasureSpec) < width + 10) {
+ width = MeasureSpec.getSize(widthMeasureSpec);
+ }
+ setMeasuredDimension(width, mKeyboard.getHeight() + getPaddingTop() + getPaddingBottom());
+ }
+ }
+
+ /**
+ * Compute the average distance between adjacent keys (horizontally and vertically)
+ * and square it to get the proximity threshold. We use a square here and in computing
+ * the touch distance from a key's center to avoid taking a square root.
+ * @param keyboard
+ */
+ private void computeProximityThreshold(Comprehend keyboard) {
+ if (keyboard == null) return;
+ final Comprehend.Key[] keys = mKeys;
+ if (keys == null) return;
+ int length = keys.length;
+ int dimensionSum = 0;
+ for (int i = 0; i < length; i++) {
+ Comprehend.Key key = keys[i];
+ dimensionSum += Math.min(key.width, key.height) + key.gap;
+ }
+ if (dimensionSum < 0 || length == 0) return;
+ mProximityThreshold = (int) (dimensionSum * 1.4f / length);
+ mProximityThreshold *= mProximityThreshold; // Square it
+ }
+
+ @Override
+ public void onSizeChanged(int w, int h, int oldw, int 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
+ mBuffer = null;
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+// if (mDrawPending || mBuffer == null || mKeyboardChanged) {
+// onBufferDraw();
+// }
+// canvas.drawBitmap(mBuffer, 0, 0, null);
+ }
+
+ private void onBufferDraw() {
+ if (mBuffer == null || mKeyboardChanged) {
+ if (mBuffer == null || mKeyboardChanged &&
+ (mBuffer.getWidth() != getWidth() || mBuffer.getHeight() != getHeight())) {
+ // Make sure our bitmap is at least 1x1
+ final int width = Math.max(1, getWidth());
+ final int height = Math.max(1, getHeight());
+ mBuffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ mCanvas = new Canvas(mBuffer);
+ }
+ invalidateAllKeys();
+ mKeyboardChanged = false;
+ }
+
+ if (mKeyboard == null) return;
+
+ mCanvas.save();
+ final Canvas canvas = mCanvas;
+ canvas.clipRect(mDirtyRect);
+
+ final Paint paint = mPaint;
+ final Drawable keyBackground = mKeyBackground;
+ final Rect clipRegion = mClipRegion;
+ final Rect padding = mPadding;
+ final int kbdPaddingLeft = getPaddingLeft();
+ final int kbdPaddingTop = getPaddingTop();
+ final Comprehend.Key[] keys = mKeys;
+ final Comprehend.Key invalidKey = mInvalidatedKey;
+
+ paint.setColor(mKeyTextColor);
+ boolean drawSingleKey = false;
+ if (invalidKey != null && canvas.getClipBounds(clipRegion)) {
+ // Is clipRegion completely contained within the invalidated key?
+ if (invalidKey.x + kbdPaddingLeft - 1 <= clipRegion.left &&
+ invalidKey.y + kbdPaddingTop - 1 <= clipRegion.top &&
+ invalidKey.x + invalidKey.width + kbdPaddingLeft + 1 >= clipRegion.right &&
+ invalidKey.y + invalidKey.height + kbdPaddingTop + 1 >= clipRegion.bottom) {
+ drawSingleKey = true;
+ }
+ }
+ canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR);
+ final int keyCount = keys.length;
+ for (int i = 0; i < keyCount; i++) {
+ final Comprehend.Key key = keys[i];
+ if (drawSingleKey && invalidKey != key) {
+ continue;
+ }
+ int[] drawableState = key.getCurrentDrawableState();
+ keyBackground.setState(drawableState);
+
+ // Switch the character to uppercase if shift is pressed
+ String label = key.label == null? null : adjustCase(key.label).toString();
+
+ final Rect bounds = keyBackground.getBounds();
+ if (key.width != bounds.right ||
+ key.height != bounds.bottom) {
+ keyBackground.setBounds(0, 0, key.width, key.height);
+ }
+ canvas.translate(key.x + kbdPaddingLeft, key.y + kbdPaddingTop);
+ keyBackground.draw(canvas);
+
+ if (label != null) {
+ // For characters, use large font. For labels like "Done", use small font.
+ if (label.length() > 1 && key.codes.length < 2) {
+ paint.setTextSize(mLabelTextSize);
+ paint.setTypeface(Typeface.DEFAULT_BOLD);
+ } else {
+ paint.setTextSize(mKeyTextSize);
+ paint.setTypeface(Typeface.DEFAULT);
+ }
+ // Draw a drop shadow for the text
+ paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
+ // Draw the text
+ canvas.drawText(label,
+ (key.width - padding.left - padding.right) / 2
+ + padding.left,
+ (key.height - padding.top - padding.bottom) / 2
+ + (paint.getTextSize() - paint.descent()) / 2 + padding.top,
+ paint);
+ // Turn off drop shadow
+ paint.setShadowLayer(0, 0, 0, 0);
+ } else if (key.icon != null) {
+ final int drawableX = (key.width - padding.left - padding.right
+ - key.icon.getIntrinsicWidth()) / 2 + padding.left;
+ final int drawableY = (key.height - padding.top - padding.bottom
+ - key.icon.getIntrinsicHeight()) / 2 + padding.top;
+ canvas.translate(drawableX, drawableY);
+ key.icon.setBounds(0, 0,
+ key.icon.getIntrinsicWidth(), key.icon.getIntrinsicHeight());
+ key.icon.draw(canvas);
+ canvas.translate(-drawableX, -drawableY);
+ }
+ canvas.translate(-key.x - kbdPaddingLeft, -key.y - kbdPaddingTop);
+ }
+ mInvalidatedKey = null;
+ // Overlay a dark rectangle to dim the keyboard
+ if (mMiniKeyboardOnScreen) {
+// paint.setColor((int) (mBackgroundDimAmount * 0xFF) << 24);
+ canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
+ }
+
+ if (DEBUG && mShowTouchPoints) {
+ paint.setAlpha(128);
+ paint.setColor(0xFFFF0000);
+ canvas.drawCircle(mStartX, mStartY, 3, paint);
+ canvas.drawLine(mStartX, mStartY, mLastX, mLastY, paint);
+ paint.setColor(0xFF0000FF);
+ canvas.drawCircle(mLastX, mLastY, 3, paint);
+ paint.setColor(0xFF00FF00);
+ canvas.drawCircle((mStartX + mLastX) / 2, (mStartY + mLastY) / 2, 2, paint);
+ }
+ mCanvas.restore();
+ mDrawPending = false;
+ mDirtyRect.setEmpty();
+ }
+
+ private int getKeyIndices(int x, int y, int[] allKeys) {
+ final Comprehend.Key[] keys = mKeys;
+ int primaryIndex = NOT_A_KEY;
+ int closestKey = NOT_A_KEY;
+ int closestKeyDist = mProximityThreshold + 1;
+ java.util.Arrays.fill(mDistances, Integer.MAX_VALUE);
+ int [] nearestKeyIndices = mKeyboard.getNearestKeys(x, y);
+ final int keyCount = nearestKeyIndices.length;
+ for (int i = 0; i < keyCount; i++) {
+ final Comprehend.Key key = keys[nearestKeyIndices[i]];
+ int dist = 0;
+ boolean isInside = key.isInside(x,y);
+ if (isInside) {
+ primaryIndex = nearestKeyIndices[i];
+ }
+
+ if (((mProximityCorrectOn
+ && (dist = key.squaredDistanceFrom(x, y)) < mProximityThreshold)
+ || isInside)
+ && key.codes[0] > 32) {
+ // Find insertion point
+ final int nCodes = key.codes.length;
+ if (dist < closestKeyDist) {
+ closestKeyDist = dist;
+ closestKey = nearestKeyIndices[i];
+ }
+
+ if (allKeys == null) continue;
+
+ for (int j = 0; j < mDistances.length; j++) {
+ if (mDistances[j] > dist) {
+ // Make space for nCodes codes
+ System.arraycopy(mDistances, j, mDistances, j + nCodes,
+ mDistances.length - j - nCodes);
+ System.arraycopy(allKeys, j, allKeys, j + nCodes,
+ allKeys.length - j - nCodes);
+ for (int c = 0; c < nCodes; c++) {
+ allKeys[j + c] = key.codes[c];
+ mDistances[j + c] = dist;
+ }
+ break;
+ }
+ }
+ }
+ }
+ if (primaryIndex == NOT_A_KEY) {
+ primaryIndex = closestKey;
+ }
+ return primaryIndex;
+ }
+
+ private void detectAndSendKey(int index, int x, int y, long eventTime) {
+ if (index != NOT_A_KEY && index < mKeys.length) {
+ final Comprehend.Key key = mKeys[index];
+ if (key.text != null) {
+ mKeyboardActionListener.onText(key.text);
+ mKeyboardActionListener.onRelease(NOT_A_KEY);
+ } else {
+ int code = key.codes[0];
+ //TextEntryState.keyPressedAt(key, x, y);
+ int[] codes = new int[MAX_NEARBY_KEYS];
+ Arrays.fill(codes, NOT_A_KEY);
+ getKeyIndices(x, y, codes);
+ // Multi-tap
+ if (mInMultiTap) {
+ if (mTapCount != -1) {
+ mKeyboardActionListener.onKey(Comprehend.KEYCODE_DELETE, KEY_DELETE);
+ } else {
+ mTapCount = 0;
+ }
+ code = key.codes[mTapCount];
+ }
+ mKeyboardActionListener.onKey(code, codes);
+ mKeyboardActionListener.onRelease(code);
+ }
+ mLastSentIndex = index;
+ mLastTapTime = eventTime;
+ }
+ }
+
+ /**
+ * Handle multi-tap keys by producing the key label for the current multi-tap state.
+ */
+ private CharSequence getPreviewText(Comprehend.Key key) {
+ if (mInMultiTap) {
+ // Multi-tap
+ mPreviewLabel.setLength(0);
+ mPreviewLabel.append((char) key.codes[mTapCount < 0 ? 0 : mTapCount]);
+ return adjustCase(mPreviewLabel);
+ } else {
+ return adjustCase(key.label);
+ }
+ }
+
+ private void showPreview(int keyIndex) {
+ int oldKeyIndex = mCurrentKeyIndex;
+ final PopupWindow previewPopup = mPreviewPopup;
+
+ mCurrentKeyIndex = keyIndex;
+ // Release the old key and press the new key
+ final Comprehend.Key[] keys = mKeys;
+ if (oldKeyIndex != mCurrentKeyIndex) {
+ if (oldKeyIndex != NOT_A_KEY && keys.length > oldKeyIndex) {
+ Comprehend.Key oldKey = keys[oldKeyIndex];
+ oldKey.onReleased(mCurrentKeyIndex == NOT_A_KEY);
+ invalidateKey(oldKeyIndex);
+ final int keyCode = oldKey.codes[0];
+ }
+ if (mCurrentKeyIndex != NOT_A_KEY && keys.length > mCurrentKeyIndex) {
+ Comprehend.Key newKey = keys[mCurrentKeyIndex];
+ newKey.onPressed();
+ invalidateKey(mCurrentKeyIndex);
+ final int keyCode = newKey.codes[0];
+ }
+ }
+ // If key changed and preview is on ...
+ if (oldKeyIndex != mCurrentKeyIndex && mShowPreview) {
+ mHandler.removeMessages(MSG_SHOW_PREVIEW);
+ if (previewPopup.isShowing()) {
+ if (keyIndex == NOT_A_KEY) {
+ mHandler.sendMessageDelayed(mHandler
+ .obtainMessage(MSG_REMOVE_PREVIEW),
+ DELAY_AFTER_PREVIEW);
+ }
+ }
+ if (keyIndex != NOT_A_KEY) {
+ if (previewPopup.isShowing() && mPreviewText.getVisibility() == VISIBLE) {
+ // Show right away, if it's already visible and finger is moving around
+ showKey(keyIndex);
+ } else {
+ mHandler.sendMessageDelayed(
+ mHandler.obtainMessage(MSG_SHOW_PREVIEW, keyIndex, 0),
+ DELAY_BEFORE_PREVIEW);
+ }
+ }
+ }
+ }
+
+ private void showKey(final int keyIndex) {
+ final PopupWindow previewPopup = mPreviewPopup;
+ final Comprehend.Key[] keys = mKeys;
+ if (keyIndex < 0 || keyIndex >= mKeys.length) return;
+ Comprehend.Key key = keys[keyIndex];
+ if (key.icon != null) {
+ mPreviewText.setCompoundDrawables(null, null, null,
+ key.iconPreview != null ? key.iconPreview : key.icon);
+ mPreviewText.setText(null);
+ } else {
+ mPreviewText.setCompoundDrawables(null, null, null, null);
+ mPreviewText.setText(getPreviewText(key));
+ if (key.label!=null && key.label.length() > 1 && key.codes.length < 2) {
+ mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize);
+ mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
+ } else {
+ mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
+ mPreviewText.setTypeface(Typeface.DEFAULT);
+ }
+ }
+ mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
+ MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
+ int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), key.width
+ + mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
+ final int popupHeight = mPreviewHeight;
+ ViewGroup.LayoutParams lp = mPreviewText.getLayoutParams();
+ if (lp != null) {
+ lp.width = popupWidth;
+ lp.height = popupHeight;
+ }
+ if (!mPreviewCentered) {
+ mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + getPaddingLeft();
+ mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
+ } else {
+ // TODO: Fix this if centering is brought back
+ mPopupPreviewX = 160 - mPreviewText.getMeasuredWidth() / 2;
+ mPopupPreviewY = - mPreviewText.getMeasuredHeight();
+ }
+ mHandler.removeMessages(MSG_REMOVE_PREVIEW);
+ getLocationInWindow(mCoordinates);
+ mCoordinates[0] += mMiniKeyboardOffsetX; // Offset may be zero
+ mCoordinates[1] += mMiniKeyboardOffsetY; // Offset may be zero
+
+ // Set the preview background state
+ mPreviewText.getBackground().setState(
+ key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
+ mPopupPreviewX += mCoordinates[0];
+ mPopupPreviewY += mCoordinates[1];
+
+ // If the popup cannot be shown above the key, put it on the side
+ getLocationOnScreen(mCoordinates);
+ if (mPopupPreviewY + mCoordinates[1] < 0) {
+ // If the key you're pressing is on the left side of the keyboard, show the popup on
+ // the right, offset by enough to see at least one key to the left/right.
+ if (key.x + key.width <= getWidth() / 2) {
+ mPopupPreviewX += (int) (key.width * 2.5);
+ } else {
+ mPopupPreviewX -= (int) (key.width * 2.5);
+ }
+ mPopupPreviewY += popupHeight;
+ }
+
+ if (previewPopup.isShowing()) {
+ previewPopup.update(mPopupPreviewX, mPopupPreviewY,
+ popupWidth, popupHeight);
+ } else {
+ previewPopup.setWidth(popupWidth);
+ previewPopup.setHeight(popupHeight);
+ previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY,
+ mPopupPreviewX, mPopupPreviewY);
+ }
+ mPreviewText.setVisibility(VISIBLE);
+ }
+
+
+ public void invalidateAllKeys() {
+ mDirtyRect.union(0, 0, getWidth(), getHeight());
+ mDrawPending = true;
+ invalidate();
+ }
+
+
+ public void invalidateKey(int keyIndex) {
+ if (mKeys == null) return;
+ if (keyIndex < 0 || keyIndex >= mKeys.length) {
+ return;
+ }
+ final Comprehend.Key key = mKeys[keyIndex];
+ mInvalidatedKey = key;
+ mDirtyRect.union(key.x + getPaddingLeft(), key.y + getPaddingTop(),
+ key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
+ onBufferDraw();
+ invalidate(key.x + getPaddingLeft(), key.y + getPaddingTop(),
+ key.x + key.width + getPaddingLeft(), key.y + key.height + getPaddingTop());
+ }
+
+ private boolean openPopupIfRequired(MotionEvent me) {
+ // Check if we have a popup layout specified first.
+ if (mPopupLayout == 0) {
+ return false;
+ }
+ if (mCurrentKey < 0 || mCurrentKey >= mKeys.length) {
+ return false;
+ }
+
+ Comprehend.Key popupKey = mKeys[mCurrentKey];
+ boolean result = onLongPress(popupKey);
+ if (result) {
+ mAbortKey = true;
+ showPreview(NOT_A_KEY);
+ }
+ return result;
+ }
+
+ protected boolean onLongPress(Comprehend.Key popupKey) {
+ int popupKeyboardId = popupKey.popupResId;
+
+ if (popupKeyboardId != 0) {
+ mMiniKeyboardContainer = mMiniKeyboardCache.get(popupKey);
+ if (mMiniKeyboardContainer == null) {
+ LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ mMiniKeyboardContainer = inflater.inflate(mPopupLayout, null);
+ mMiniKeyboard = mMiniKeyboardContainer.findViewById(
+ R.id.custom_input_view);
+// View closeButton = mMiniKeyboardContainer.findViewById(
+// R.id.closeButton);
+// if (closeButton != null) closeButton.setOnClickListener(this);
+ mMiniKeyboard.setOnKeyboardActionListener(new OnKeyboardActionListener() {
+ public void onKey(int primaryCode, int[] keyCodes) {
+ mKeyboardActionListener.onKey(primaryCode, keyCodes);
+ dismissPopupKeyboard();
+ }
+
+ public void onText(CharSequence text) {
+ mKeyboardActionListener.onText(text);
+ dismissPopupKeyboard();
+ }
+
+ public void swipeLeft() { }
+ public void swipeRight() { }
+ public void swipeUp() { }
+ public void swipeDown() { }
+ public void onPress(int primaryCode) {
+ mKeyboardActionListener.onPress(primaryCode);
+ }
+ public void onRelease(int primaryCode) {
+ mKeyboardActionListener.onRelease(primaryCode);
+ }
+ });
+ //mInputView.setSuggest(mSuggest);
+ Comprehend keyboard;
+ if (popupKey.popupCharacters != null) {
+ keyboard = new Comprehend(getContext(), popupKeyboardId,
+ popupKey.popupCharacters, -1, getPaddingLeft() + getPaddingRight());
+ } else {
+ keyboard = new Comprehend(getContext(), popupKeyboardId);
+ }
+ mMiniKeyboard.setKeyboard(keyboard);
+ mMiniKeyboard.setPopupParent(this);
+ mMiniKeyboardContainer.measure(
+ MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
+ MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST));
+
+ mMiniKeyboardCache.put(popupKey, mMiniKeyboardContainer);
+ } else {
+ mMiniKeyboard = mMiniKeyboardContainer.findViewById(
+ R.id.custom_input_view);
+ }
+ getLocationInWindow(mCoordinates);
+ mPopupX = popupKey.x + getPaddingLeft();
+ mPopupY = popupKey.y + getPaddingTop();
+ mPopupX = mPopupX + popupKey.width - mMiniKeyboardContainer.getMeasuredWidth();
+ mPopupY = mPopupY - mMiniKeyboardContainer.getMeasuredHeight();
+ final int x = mPopupX + mMiniKeyboardContainer.getPaddingRight() + mCoordinates[0];
+ final int y = mPopupY + mMiniKeyboardContainer.getPaddingBottom() + mCoordinates[1];
+ mMiniKeyboard.setPopupOffset(x < 0 ? 0 : x, y);
+ mMiniKeyboard.setShifted(isShifted());
+ mPopupKeyboard.setContentView(mMiniKeyboardContainer);
+ mPopupKeyboard.setWidth(mMiniKeyboardContainer.getMeasuredWidth());
+ mPopupKeyboard.setHeight(mMiniKeyboardContainer.getMeasuredHeight());
+ mPopupKeyboard.showAtLocation(this, Gravity.NO_GRAVITY, x, y);
+ mMiniKeyboardOnScreen = true;
+ //mMiniKeyboard.onTouchEvent(getTranslatedEvent(me));
+ invalidateAllKeys();
+ return true;
+ }
+ return false;
+ }
+
+
+
+ @Override
+ public boolean onTouchEvent(MotionEvent me) {
+ // Convert multi-pointer up/down events to single up/down events to
+ // deal with the typical multi-pointer behavior of two-thumb typing
+ final int pointerCount = me.getPointerCount();
+ final int action = me.getAction();
+ boolean result = false;
+ final long now = me.getEventTime();
+
+ if (pointerCount != mOldPointerCount) {
+ if (pointerCount == 1) {
+ // Send a down event for the latest pointer
+ MotionEvent down = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN,
+ me.getX(), me.getY(), me.getMetaState());
+ result = onModifiedTouchEvent(down, false);
+ down.recycle();
+ // If it's an up action, then deliver the up as well.
+ if (action == MotionEvent.ACTION_UP) {
+ result = onModifiedTouchEvent(me, true);
+ }
+ } else {
+ // Send an up event for the last pointer
+ MotionEvent up = MotionEvent.obtain(now, now, MotionEvent.ACTION_UP,
+ mOldPointerX, mOldPointerY, me.getMetaState());
+ result = onModifiedTouchEvent(up, true);
+ up.recycle();
+ }
+ } else {
+ if (pointerCount == 1) {
+ result = onModifiedTouchEvent(me, false);
+ mOldPointerX = me.getX();
+ mOldPointerY = me.getY();
+ } else {
+ // Don't do anything when 2 pointers are down and moving.
+ result = true;
+ }
+ }
+ mOldPointerCount = pointerCount;
+
+
+ return result;
+ }
+
+ private boolean onModifiedTouchEvent(MotionEvent me, boolean possiblePoly) {
+ int touchX = (int) me.getX() - getPaddingLeft();
+ int touchY = (int) me.getY() - getPaddingTop();
+ if (touchY >= -mVerticalCorrection)
+ touchY += mVerticalCorrection;
+ final int action = me.getAction();
+ final long eventTime = me.getEventTime();
+ int keyIndex = getKeyIndices(touchX, touchY, null);
+ mPossiblePoly = possiblePoly;
+
+ // Track the last few movements to look for spurious swipes.
+ if (action == MotionEvent.ACTION_DOWN) mSwipeTracker.clear();
+ mSwipeTracker.addMovement(me);
+
+ // Ignore all motion events until a DOWN.
+ if (mAbortKey
+ && action != MotionEvent.ACTION_DOWN && action != MotionEvent.ACTION_CANCEL) {
+ mRepeatKeyIndex = NOT_A_KEY;
+ return true;
+ }
+
+ if (mGestureDetector.onTouchEvent(me)) {
+ showPreview(NOT_A_KEY);
+ mHandler.removeMessages(MSG_REPEAT);
+ mHandler.removeMessages(MSG_LONGPRESS);
+ return true;
+ }
+
+ // Needs to be called after the gesture detector gets a turn, as it may have
+ // displayed the mini keyboard
+ if (mMiniKeyboardOnScreen && action != MotionEvent.ACTION_CANCEL) {
+ mRepeatKeyIndex = NOT_A_KEY;
+ return true;
+ }
+
+ switch (action) {
+ case MotionEvent.ACTION_DOWN:
+ mAbortKey = false;
+ mStartX = touchX;
+ mStartY = touchY;
+ mLastCodeX = touchX;
+ mLastCodeY = touchY;
+ mLastKeyTime = 0;
+ mCurrentKeyTime = 0;
+ mLastKey = NOT_A_KEY;
+ mCurrentKey = keyIndex;
+ mDownKey = keyIndex;
+ mDownTime = me.getEventTime();
+ mLastMoveTime = mDownTime;
+ checkMultiTap(eventTime, keyIndex);
+ mKeyboardActionListener.onPress(keyIndex != NOT_A_KEY ?
+ mKeys[keyIndex].codes[0] : 0);
+ if (mCurrentKey >= 0 && mKeys[mCurrentKey].repeatable) {
+ mRepeatKeyIndex = mCurrentKey;
+ Message msg = mHandler.obtainMessage(MSG_REPEAT);
+ mHandler.sendMessageDelayed(msg, REPEAT_START_DELAY);
+ repeatKey();
+ // Delivering the key could have caused an abort
+ if (mAbortKey) {
+ mRepeatKeyIndex = NOT_A_KEY;
+ break;
+ }
+ }
+ if (mCurrentKey != NOT_A_KEY) {
+ Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me);
+ mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT);
+ }
+ showPreview(keyIndex);
+ break;
+
+ case MotionEvent.ACTION_MOVE:
+ boolean continueLongPress = false;
+ if (keyIndex != NOT_A_KEY) {
+ if (mCurrentKey == NOT_A_KEY) {
+ mCurrentKey = keyIndex;
+ mCurrentKeyTime = eventTime - mDownTime;
+ } else {
+ if (keyIndex == mCurrentKey) {
+ mCurrentKeyTime += eventTime - mLastMoveTime;
+ continueLongPress = true;
+ } else if (mRepeatKeyIndex == NOT_A_KEY) {
+ resetMultiTap();
+ mLastKey = mCurrentKey;
+ mLastCodeX = mLastX;
+ mLastCodeY = mLastY;
+ mLastKeyTime =
+ mCurrentKeyTime + eventTime - mLastMoveTime;
+ mCurrentKey = keyIndex;
+ mCurrentKeyTime = 0;
+ }
+ }
+ }
+ if (!continueLongPress) {
+ // Cancel old longpress
+ mHandler.removeMessages(MSG_LONGPRESS);
+ // Start new longpress if key has changed
+ if (keyIndex != NOT_A_KEY) {
+ Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me);
+ mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT);
+ }
+ }
+ showPreview(mCurrentKey);
+ mLastMoveTime = eventTime;
+ break;
+
+ case MotionEvent.ACTION_UP:
+ removeMessages();
+ if (keyIndex == mCurrentKey) {
+ mCurrentKeyTime += eventTime - mLastMoveTime;
+ } else {
+ resetMultiTap();
+ mLastKey = mCurrentKey;
+ mLastKeyTime = mCurrentKeyTime + eventTime - mLastMoveTime;
+ mCurrentKey = keyIndex;
+ mCurrentKeyTime = 0;
+ }
+ if (mCurrentKeyTime < mLastKeyTime && mCurrentKeyTime < DEBOUNCE_TIME
+ && mLastKey != NOT_A_KEY) {
+ mCurrentKey = mLastKey;
+ touchX = mLastCodeX;
+ touchY = mLastCodeY;
+ }
+ showPreview(NOT_A_KEY);
+ Arrays.fill(mKeyIndices, NOT_A_KEY);
+ // If we're not on a repeating key (which sends on a DOWN event)
+ if (mRepeatKeyIndex == NOT_A_KEY && !mMiniKeyboardOnScreen && !mAbortKey) {
+ detectAndSendKey(mCurrentKey, touchX, touchY, eventTime);
+ }
+ invalidateKey(keyIndex);
+ mRepeatKeyIndex = NOT_A_KEY;
+ break;
+ case MotionEvent.ACTION_CANCEL:
+ removeMessages();
+ dismissPopupKeyboard();
+ mAbortKey = true;
+ showPreview(NOT_A_KEY);
+ invalidateKey(mCurrentKey);
+ break;
+ }
+ mLastX = touchX;
+ mLastY = touchY;
+ return true;
+ }
+
+ private boolean repeatKey() {
+ if(mRepeatKeyIndex != NOT_A_KEY){
+ Comprehend.Key key = mKeys[mRepeatKeyIndex];
+ detectAndSendKey(mCurrentKey, key.x, key.y, mLastTapTime);
+ return true;
+ }
+ return false;
+ }
+
+ protected void swipeRight() {
+ mKeyboardActionListener.swipeRight();
+ }
+
+ protected void swipeLeft() {
+ mKeyboardActionListener.swipeLeft();
+ }
+
+ protected void swipeUp() {
+ mKeyboardActionListener.swipeUp();
+ }
+
+ protected void swipeDown() {
+ mKeyboardActionListener.swipeDown();
+ }
+
+ public void closing() {
+ if (mPreviewPopup.isShowing()) {
+ mPreviewPopup.dismiss();
+ }
+ removeMessages();
+
+ dismissPopupKeyboard();
+ mBuffer = null;
+ mCanvas = null;
+ mMiniKeyboardCache.clear();
+ }
+
+ private void removeMessages() {
+ if (mHandler != null) {
+ mHandler.removeMessages(MSG_REPEAT);
+ mHandler.removeMessages(MSG_LONGPRESS);
+ mHandler.removeMessages(MSG_SHOW_PREVIEW);
+ }
+ }
+
+ @Override
+ public void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ closing();
+ }
+
+ private void dismissPopupKeyboard() {
+ if (mPopupKeyboard.isShowing()) {
+ mPopupKeyboard.dismiss();
+ mMiniKeyboardOnScreen = false;
+ invalidateAllKeys();
+ }
+ }
+
+ public boolean handleBack() {
+ if (mPopupKeyboard.isShowing()) {
+ dismissPopupKeyboard();
+ return true;
+ }
+ return false;
+ }
+
+ private void resetMultiTap() {
+ mLastSentIndex = NOT_A_KEY;
+ mTapCount = 0;
+ mLastTapTime = -1;
+ mInMultiTap = false;
+ }
+
+ private void checkMultiTap(long eventTime, int keyIndex) {
+ if (keyIndex == NOT_A_KEY) return;
+ Comprehend.Key key = mKeys[keyIndex];
+ if (key.codes.length > 1) {
+ mInMultiTap = true;
+ if (eventTime < mLastTapTime + MULTITAP_INTERVAL
+ && keyIndex == mLastSentIndex) {
+ mTapCount = (mTapCount + 1) % key.codes.length;
+ return;
+ } else {
+ mTapCount = -1;
+ return;
+ }
+ }
+ if (eventTime > mLastTapTime + MULTITAP_INTERVAL || keyIndex != mLastSentIndex) {
+ resetMultiTap();
+ }
+ }
+
+ private static class SwipeTracker {
+
+ static final int NUM_PAST = 4;
+ static final int LONGEST_PAST_TIME = 200;
+
+ final float mPastX[] = new float[NUM_PAST];
+ final float mPastY[] = new float[NUM_PAST];
+ final long mPastTime[] = new long[NUM_PAST];
+
+ float mYVelocity;
+ float mXVelocity;
+
+ public void clear() {
+ mPastTime[0] = 0;
+ }
+
+ public void addMovement(MotionEvent ev) {
+ long time = ev.getEventTime();
+ final int N = ev.getHistorySize();
+ for (int i=0; i= 0) {
+ final int start = drop+1;
+ final int count = NUM_PAST-drop-1;
+ System.arraycopy(pastX, start, pastX, 0, count);
+ System.arraycopy(pastY, start, pastY, 0, count);
+ System.arraycopy(pastTime, start, pastTime, 0, count);
+ i -= (drop+1);
+ }
+ pastX[i] = x;
+ pastY[i] = y;
+ pastTime[i] = time;
+ i++;
+ if (i < NUM_PAST) {
+ pastTime[i] = 0;
+ }
+ }
+
+ public void computeCurrentVelocity(int units) {
+ computeCurrentVelocity(units, Float.MAX_VALUE);
+ }
+
+ public void computeCurrentVelocity(int units, float maxVelocity) {
+ final float[] pastX = mPastX;
+ final float[] pastY = mPastY;
+ final long[] pastTime = mPastTime;
+
+ final float oldestX = pastX[0];
+ final float oldestY = pastY[0];
+ final long oldestTime = pastTime[0];
+ float accumX = 0;
+ float accumY = 0;
+ int N=0;
+ while (N < NUM_PAST) {
+ if (pastTime[N] == 0) {
+ break;
+ }
+ N++;
+ }
+
+ for (int i=1; i < N; i++) {
+ final int dur = (int)(pastTime[i] - oldestTime);
+ if (dur == 0) continue;
+ float dist = pastX[i] - oldestX;
+ float vel = (dist/dur) * units; // pixels/frame.
+ if (accumX == 0) accumX = vel;
+ else accumX = (accumX + vel) * .5f;
+
+ dist = pastY[i] - oldestY;
+ vel = (dist/dur) * units; // pixels/frame.
+ if (accumY == 0) accumY = vel;
+ else accumY = (accumY + vel) * .5f;
+ }
+ mXVelocity = accumX < 0.0f ? Math.max(accumX, -maxVelocity)
+ : Math.min(accumX, maxVelocity);
+ mYVelocity = accumY < 0.0f ? Math.max(accumY, -maxVelocity)
+ : Math.min(accumY, maxVelocity);
+ }
+
+ public float getXVelocity() {
+ return mXVelocity;
+ }
+
+ public float getYVelocity() {
+ return mYVelocity;
+ }
+ }
+}
+
diff --git a/app/src/main/java/com/app/brush/guitar/ink/gallery/FavoriteElucidate.java b/app/src/main/java/com/app/brush/guitar/ink/gallery/FavoriteElucidate.java
new file mode 100644
index 0000000..d2def77
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/gallery/FavoriteElucidate.java
@@ -0,0 +1,126 @@
+package com.app.brush.guitar.ink.gallery;
+
+
+import android.content.Context;
+import android.content.Intent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+
+import androidx.annotation.NonNull;
+import androidx.cardview.widget.CardView;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.bumptech.glide.Glide;
+import com.app.brush.guitar.ink.R;
+import com.app.brush.guitar.ink.drama.DichotomyDetails;
+import com.app.brush.guitar.ink.iguana.UbiquitousSerene;
+import com.app.brush.guitar.ink.canvas.JubilantDeleteFavorite;
+import com.app.brush.guitar.ink.eraser.SetKeyboardAmplify;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class FavoriteElucidate extends RecyclerView.Adapter {
+
+ private Context mContext;
+ private List mList = new ArrayList<>();
+
+ private JubilantDeleteFavorite mCallBack;
+
+ public FavoriteElucidate(Context context) {
+ mContext = context;
+ }
+
+ public void setForYouList(List list) {
+ this.mList = list;
+ notifyDataSetChanged();
+ }
+
+
+ public void setRemoveLike(JubilantDeleteFavorite callback) {
+ mCallBack = callback;
+ }
+
+ @NonNull
+ @Override
+ public ForYouViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+
+ View view = LayoutInflater.from(mContext).inflate(R.layout.quick_adapter_favorite_item, parent, false);
+ return new ForYouViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull ForYouViewHolder holder, int position) {
+ DichotomyDetails beanDetails = mList.get(position);
+ String thumbGif = beanDetails.getThumbGif();
+ String thumb = beanDetails.getThumbUrl();
+ if (!thumbGif.isEmpty()) {
+ UbiquitousSerene.INSTANCE.loadWepJif(mContext, thumbGif, holder.itemImg);
+ } else {
+ Glide.with(mContext)
+ .load(thumb).error(R.drawable.place_holder)
+ .placeholder(R.drawable.place_holder).into(holder.itemImg);
+ }
+ holder.itemFavorite.setSelected(true);
+ holder.layoutFavorite.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ holder.itemFavorite.setSelected(false);
+ int adapterPosition = holder.getAdapterPosition();
+ notifyItemRemoved(adapterPosition);
+ if (mCallBack != null) {
+ mCallBack.OnRemoveLike(beanDetails);
+ }
+ }
+ });
+ holder.cardView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intentApply = new Intent(mContext, SetKeyboardAmplify.class);
+ intentApply.putExtra(SetKeyboardAmplify.SOURCE_KEY, beanDetails);
+ intentApply.putExtra(SetKeyboardAmplify.DISPLAY_URL_KEY, beanDetails.getImgPath());
+ intentApply.putExtra(SetKeyboardAmplify.ZIP_URL_KEY, beanDetails.getZipPath());
+ intentApply.putExtra(SetKeyboardAmplify.NAME_KEY, beanDetails.getTitleName());
+ intentApply.putExtra(SetKeyboardAmplify.GIF_KEY, beanDetails.getImgGif());
+ String intent_thumb;
+ if (!thumbGif.isEmpty()) {
+ intent_thumb = thumbGif;
+ } else {
+ intent_thumb = thumb;
+ }
+ intentApply.putExtra(SetKeyboardAmplify.THUMB_KEY, intent_thumb);
+ mContext.startActivity(intentApply);
+
+
+ }
+ });
+
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return mList.size();
+ }
+
+ public static class ForYouViewHolder extends RecyclerView.ViewHolder {
+
+ private CardView cardView;
+ private FrameLayout layoutFavorite;
+ private ImageView itemImg, itemFavorite;
+
+ public ForYouViewHolder(@NonNull View itemView) {
+ super(itemView);
+ cardView = itemView.findViewById(R.id.card_view);
+ layoutFavorite = itemView.findViewById(R.id.layout_favorite);
+ itemImg = itemView.findViewById(R.id.im);
+ itemFavorite = itemView.findViewById(R.id.im_favorite);
+
+ }
+
+ }
+
+}
diff --git a/app/src/main/java/com/app/brush/guitar/ink/gallery/HomeChildGalvanize.java b/app/src/main/java/com/app/brush/guitar/ink/gallery/HomeChildGalvanize.java
new file mode 100644
index 0000000..e970ec5
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/gallery/HomeChildGalvanize.java
@@ -0,0 +1,104 @@
+package com.app.brush.guitar.ink.gallery;
+
+
+import android.content.Context;
+import android.content.Intent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.app.brush.guitar.ink.R;
+import com.app.brush.guitar.ink.drama.DichotomyDetails;
+import com.app.brush.guitar.ink.databinding.RichAdapterChildHomeBinding;
+import com.app.brush.guitar.ink.eraser.SetKeyboardAmplify;
+import com.app.brush.guitar.ink.iguana.UbiquitousSerene;
+import com.bumptech.glide.Glide;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HomeChildGalvanize extends RecyclerView.Adapter {
+
+ private Context mContext;
+ private List mList = new ArrayList<>();
+
+
+ public HomeChildGalvanize(Context context, List list) {
+ mContext = context;
+ this.mList = list;
+ }
+
+
+ @NonNull
+ @Override
+ public ChildViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ RichAdapterChildHomeBinding inflate = RichAdapterChildHomeBinding.inflate(LayoutInflater.from(parent.getContext()));
+
+
+ return new ChildViewHolder(inflate);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull ChildViewHolder holder, int position) {
+ DichotomyDetails beanDetails = mList.get(position);
+
+
+ String thumbGif = beanDetails.getThumbGif();
+ String thumb = beanDetails.getThumbUrl();
+ if (thumbGif != null && !thumbGif.isEmpty()) {
+ UbiquitousSerene.INSTANCE.loadWepJif(mContext, thumbGif, holder.binding.imageView);
+ } else {
+ Glide.with(mContext).load(thumb)
+ .error(R.drawable.place_holder)
+ .placeholder(R.drawable.place_holder)
+ .into(holder.binding.imageView);
+ }
+
+ holder.binding.fragme.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intentApply = new Intent(mContext, SetKeyboardAmplify.class);
+ intentApply.putExtra(SetKeyboardAmplify.SOURCE_KEY, beanDetails);
+ intentApply.putExtra(SetKeyboardAmplify.DISPLAY_URL_KEY, beanDetails.getImgPath());
+ intentApply.putExtra(SetKeyboardAmplify.ZIP_URL_KEY, beanDetails.getZipPath());
+ intentApply.putExtra(SetKeyboardAmplify.NAME_KEY, beanDetails.getTitleName());
+ intentApply.putExtra(SetKeyboardAmplify.GIF_KEY, beanDetails.getImgGif());
+ String intent_thumb;
+ if (!thumbGif.isEmpty()) {
+ intent_thumb = thumbGif;
+ } else {
+ intent_thumb = thumb;
+ }
+ intentApply.putExtra(SetKeyboardAmplify.THUMB_KEY, intent_thumb);
+ mContext.startActivity(intentApply);
+
+
+ }
+ });
+
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return mList.size();
+ }
+
+ public static class ChildViewHolder extends RecyclerView.ViewHolder {
+
+ private RichAdapterChildHomeBinding binding;
+
+
+ public ChildViewHolder(@NonNull RichAdapterChildHomeBinding itemView) {
+ super(itemView.getRoot());
+ binding = itemView;
+
+
+ }
+
+ }
+
+}
diff --git a/app/src/main/java/com/app/brush/guitar/ink/gallery/HomeFluctuate.java b/app/src/main/java/com/app/brush/guitar/ink/gallery/HomeFluctuate.java
new file mode 100644
index 0000000..60d46b2
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/gallery/HomeFluctuate.java
@@ -0,0 +1,210 @@
+package com.app.brush.guitar.ink.gallery;
+
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.app.brush.guitar.ink.R;
+import com.app.brush.guitar.ink.drama.EphemeralWrapper;
+import com.app.brush.guitar.ink.canvas.CacophonyViewAll;
+import com.app.brush.guitar.ink.databinding.NiceAdapterMainHomeBinding;
+import com.app.brush.guitar.ink.databinding.ThinAdapterRecommendedHomeBinding;
+import com.app.brush.guitar.ink.drama.DichotomyDetails;
+import com.app.brush.guitar.ink.iguana.ListDecorationFossil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HomeFluctuate extends RecyclerView.Adapter {
+ private static final int TYPE_RECOMMENDED = 0;
+ private static final int TYPE_CATEGORY = 1;
+
+ private Context mContext;
+ private List mList = new ArrayList<>();
+ private CacophonyViewAll mCallBack;
+
+ public HomeFluctuate(Context context, List list) {
+ mContext = context;
+ this.mList = list;
+ }
+
+ public void setClickAction(CacophonyViewAll callback) {
+ mCallBack = callback;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ // 第一个是推荐模块
+ return position == 0 ? TYPE_RECOMMENDED : TYPE_CATEGORY;
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ if (viewType == TYPE_RECOMMENDED) {
+ ThinAdapterRecommendedHomeBinding binding = ThinAdapterRecommendedHomeBinding.inflate(
+ LayoutInflater.from(parent.getContext()), parent, false);
+ return new RecommendedViewHolder(binding);
+ } else {
+ NiceAdapterMainHomeBinding binding = NiceAdapterMainHomeBinding.inflate(
+ LayoutInflater.from(parent.getContext()), parent, false);
+ return new CategoryViewHolder(binding);
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+ if (holder instanceof RecommendedViewHolder) {
+ bindRecommendedViewHolder((RecommendedViewHolder) holder);
+ } else if (holder instanceof CategoryViewHolder) {
+ // 推荐模块占第一个位置,所以分类从 position-1 开始
+ int categoryIndex = position - 1;
+ if (categoryIndex >= 0 && categoryIndex < mList.size()) {
+ bindCategoryViewHolder((CategoryViewHolder) holder, mList.get(categoryIndex));
+ }
+ }
+ }
+
+ private void bindRecommendedViewHolder(RecommendedViewHolder holder) {
+ // 获取所有分类的键盘,合并作为推荐内容
+ List recommendedList = new ArrayList<>();
+ for (EphemeralWrapper wrapper : mList) {
+ if (wrapper.getKeyboardList() != null && !wrapper.getKeyboardList().isEmpty()) {
+ int count = Math.min(2, wrapper.getKeyboardList().size());
+ for (int i = 0; i < count; i++) {
+ recommendedList.add(wrapper.getKeyboardList().get(i));
+ }
+ }
+ }
+
+ RecommendedCardNurture adapter = new RecommendedCardNurture(mContext, recommendedList);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
+ holder.binding.recyclerRecommended.setLayoutManager(layoutManager);
+ holder.binding.recyclerRecommended.setAdapter(adapter);
+
+ // 添加横向间距装饰
+ if (holder.binding.recyclerRecommended.getItemDecorationCount() <= 0) {
+ // 为横向列表添加间距
+ holder.binding.recyclerRecommended.addItemDecoration(new RecyclerView.ItemDecoration() {
+ @Override
+ public void getItemOffsets(@NonNull android.graphics.Rect outRect, @NonNull View view,
+ @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
+ int position = parent.getChildAdapterPosition(view);
+ int itemCount = parent.getAdapter() != null ? parent.getAdapter().getItemCount() : 0;
+ if (position == 0) {
+ outRect.left = 0;
+ } else {
+ outRect.left = (int) ListDecorationFossil.dpToPx(14);
+ }
+ // 最后一个卡片添加右边距
+ if (position == itemCount - 1) {
+ outRect.right = (int) ListDecorationFossil.dpToPx(20);
+ } else {
+ outRect.right = 0;
+ }
+ }
+ });
+ }
+
+ }
+
+ private void bindCategoryViewHolder(CategoryViewHolder holder, EphemeralWrapper beanWrapper) {
+ String parentName = beanWrapper.getParentName();
+ holder.binding.className.setText(parentName);
+
+ setCategoryIconAndSubtitle(holder, parentName);
+ List keyboardList = beanWrapper.getKeyboardList();
+ if (keyboardList == null || keyboardList.isEmpty()) {
+ holder.binding.childRecycler.setAdapter(null);
+ return;
+ }
+
+ ListDecorationFossil listDecoration = new ListDecorationFossil(7, 14, 0);
+ int itemCount = Math.min(4, keyboardList.size());
+ List displayList = keyboardList.subList(0, itemCount);
+ HomeChildGalvanize homeChildAdapter = new HomeChildGalvanize(mContext, displayList);
+
+ GridLayoutManager layoutManager = new GridLayoutManager(mContext, 2);
+ holder.binding.childRecycler.setLayoutManager(layoutManager);
+ holder.binding.childRecycler.setAdapter(homeChildAdapter);
+
+ if (holder.binding.childRecycler.getItemDecorationCount() <= 0) {
+ holder.binding.childRecycler.addItemDecoration(listDecoration);
+ }
+
+ holder.binding.ivArrow.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mCallBack != null) {
+ mCallBack.OnClickSeeAll(parentName);
+ }
+ }
+ });
+ }
+
+ private void setCategoryIconAndSubtitle(CategoryViewHolder holder, String categoryName) {
+ int iconRes = R.mipmap.aesthetic;
+ String subtitle = "Soft · Romantic · Popular";
+ String lowerName = categoryName.toLowerCase();
+
+ if (lowerName.contains("recommend")) {
+ iconRes = R.mipmap.recommend;
+ } else if (lowerName.contains("aesthetic") || lowerName.contains("美学")) {
+ iconRes = R.mipmap.aesthetic;
+ } else if (lowerName.contains("cool") || lowerName.contains("酷")) {
+ iconRes = R.mipmap.zcool;
+ subtitle = "Modern · Bold · Trendy";
+ } else if (lowerName.contains("cute") || lowerName.contains("可爱")) {
+ iconRes = R.mipmap.cute;
+ subtitle = "Sweet · Lovely · Charming";
+ } else if (lowerName.contains("festival")) {
+ iconRes = R.mipmap.festival;
+ } else if (lowerName.contains("live")) {
+ iconRes = R.mipmap.live;
+ } else if (lowerName.contains("love")) {
+ iconRes = R.mipmap.glove;
+ } else if (lowerName.contains("neon")) {
+ iconRes = R.mipmap.neon;
+ } else if (lowerName.contains("gravity")) {
+ iconRes = R.mipmap.beautiful;
+ } else if (lowerName.contains("super") && lowerName.contains("theme")) {
+ iconRes = R.mipmap.su;
+ }
+
+ holder.binding.ivCategoryIcon.setImageResource(iconRes);
+ holder.binding.tvCategorySubtitle.setText(subtitle);
+ }
+
+ @Override
+ public int getItemCount() {
+ // 推荐模块 + 分类数量
+ return 1 + mList.size();
+ }
+
+ // 推荐模块ViewHolder
+ public static class RecommendedViewHolder extends RecyclerView.ViewHolder {
+ private ThinAdapterRecommendedHomeBinding binding;
+
+ public RecommendedViewHolder(@NonNull ThinAdapterRecommendedHomeBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ }
+ }
+
+ // 分类ViewHolder
+ public static class CategoryViewHolder extends RecyclerView.ViewHolder {
+ private NiceAdapterMainHomeBinding binding;
+
+ public CategoryViewHolder(@NonNull NiceAdapterMainHomeBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ }
+ }
+}
diff --git a/app/src/main/java/com/app/brush/guitar/ink/gallery/RecommendedCardNurture.java b/app/src/main/java/com/app/brush/guitar/ink/gallery/RecommendedCardNurture.java
new file mode 100644
index 0000000..fe8363b
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/gallery/RecommendedCardNurture.java
@@ -0,0 +1,105 @@
+package com.app.brush.guitar.ink.gallery;
+
+import android.content.Context;
+import android.content.Intent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.app.brush.guitar.ink.R;
+import com.app.brush.guitar.ink.drama.DichotomyDetails;
+import com.app.brush.guitar.ink.databinding.WideItemCardRecommendedBinding;
+import com.app.brush.guitar.ink.eraser.SetKeyboardAmplify;
+import com.app.brush.guitar.ink.iguana.UbiquitousSerene;
+import com.bumptech.glide.Glide;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RecommendedCardNurture extends RecyclerView.Adapter {
+
+ private Context mContext;
+ private List mList = new ArrayList<>();
+
+ public RecommendedCardNurture(Context context, List list) {
+ mContext = context;
+ this.mList = list;
+ }
+
+ @NonNull
+ @Override
+ public RecommendedCardViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ WideItemCardRecommendedBinding binding = WideItemCardRecommendedBinding.inflate(
+ LayoutInflater.from(parent.getContext()), parent, false);
+ return new RecommendedCardViewHolder(binding);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecommendedCardViewHolder holder, int position) {
+ DichotomyDetails beanDetails = mList.get(position);
+
+ String thumbGif = beanDetails.getThumbGif();
+ String thumb = beanDetails.getThumbUrl();
+
+ // 加载图片
+ if (thumbGif != null && !thumbGif.isEmpty()) {
+ UbiquitousSerene.INSTANCE.loadWepJif(mContext, thumbGif, holder.binding.imageView);
+ } else {
+ Glide.with(mContext).load(thumb)
+ .error(R.drawable.place_holder)
+ .placeholder(R.drawable.place_holder)
+ .into(holder.binding.imageView);
+ }
+
+ // 设置标签(可以根据需要动态设置)
+ String tag = "HOT";
+ if (position == 0) {
+ tag = "HOT";
+ } else if (position == 1) {
+ tag = "Editor's Pick";
+ } else {
+ tag = "Popular Today";
+ }
+ holder.binding.tvTag.setText(tag);
+ holder.binding.layoutTag.setVisibility(View.VISIBLE);
+
+ // 点击事件
+ holder.binding.cardRecommended.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intentApply = new Intent(mContext, SetKeyboardAmplify.class);
+ intentApply.putExtra(SetKeyboardAmplify.SOURCE_KEY, beanDetails);
+ intentApply.putExtra(SetKeyboardAmplify.DISPLAY_URL_KEY, beanDetails.getImgPath());
+ intentApply.putExtra(SetKeyboardAmplify.ZIP_URL_KEY, beanDetails.getZipPath());
+ intentApply.putExtra(SetKeyboardAmplify.NAME_KEY, beanDetails.getTitleName());
+ intentApply.putExtra(SetKeyboardAmplify.GIF_KEY, beanDetails.getImgGif());
+ String intent_thumb;
+ if (thumbGif != null && !thumbGif.isEmpty()) {
+ intent_thumb = thumbGif;
+ } else {
+ intent_thumb = thumb;
+ }
+ intentApply.putExtra(SetKeyboardAmplify.THUMB_KEY, intent_thumb);
+ mContext.startActivity(intentApply);
+ }
+ });
+ }
+
+ @Override
+ public int getItemCount() {
+ return mList.size();
+ }
+
+ public static class RecommendedCardViewHolder extends RecyclerView.ViewHolder {
+ private WideItemCardRecommendedBinding binding;
+
+ public RecommendedCardViewHolder(@NonNull WideItemCardRecommendedBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ }
+ }
+}
+
diff --git a/app/src/main/java/com/app/brush/guitar/ink/gallery/SetKeyboardMoreNebulous.java b/app/src/main/java/com/app/brush/guitar/ink/gallery/SetKeyboardMoreNebulous.java
new file mode 100644
index 0000000..0eee8d2
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/gallery/SetKeyboardMoreNebulous.java
@@ -0,0 +1,108 @@
+package com.app.brush.guitar.ink.gallery;
+
+
+import android.content.Context;
+import android.content.Intent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+
+import androidx.annotation.NonNull;
+import androidx.cardview.widget.CardView;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.app.brush.guitar.ink.R;
+import com.app.brush.guitar.ink.drama.DichotomyDetails;
+import com.app.brush.guitar.ink.canvas.AcquiesceOnItemClick;
+import com.app.brush.guitar.ink.eraser.SetKeyboardAmplify;
+import com.bumptech.glide.Glide;
+import com.app.brush.guitar.ink.iguana.UbiquitousSerene;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SetKeyboardMoreNebulous extends RecyclerView.Adapter {
+
+ private Context mContext;
+ private List mList = new ArrayList<>();
+
+ private AcquiesceOnItemClick mCallBack;
+
+ public SetKeyboardMoreNebulous(Context context) {
+ mContext = context;
+ }
+
+ public void setForYouList(List list) {
+ this.mList = list;
+ notifyDataSetChanged();
+ }
+ public void setClickAction(AcquiesceOnItemClick callback) {
+ mCallBack = callback;
+ }
+
+ @NonNull
+ @Override
+ public ForYouViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+
+ View view = LayoutInflater.from(mContext).inflate(R.layout.deep_adapter_more_keyboard_set, parent, false);
+ return new ForYouViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull ForYouViewHolder holder, int position) {
+ DichotomyDetails beanDetails = mList.get(position);
+ String thumbGif = beanDetails.getThumbGif();
+ String thumb = beanDetails.getThumbUrl();
+ if (!thumbGif.isEmpty()) {
+ UbiquitousSerene.INSTANCE.loadWepJif(mContext, thumbGif, holder.itemImg);
+ } else {
+ Glide.with(mContext).load(thumb).into(holder.itemImg);
+ }
+
+ holder.cardView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intentApply = new Intent(mContext, SetKeyboardAmplify.class);
+ intentApply.putExtra(SetKeyboardAmplify.SOURCE_KEY, beanDetails);
+ intentApply.putExtra(SetKeyboardAmplify.DISPLAY_URL_KEY, beanDetails.getImgPath());
+ intentApply.putExtra(SetKeyboardAmplify.ZIP_URL_KEY, beanDetails.getZipPath());
+ intentApply.putExtra(SetKeyboardAmplify.NAME_KEY, beanDetails.getTitleName());
+ intentApply.putExtra(SetKeyboardAmplify.GIF_KEY, beanDetails.getImgGif());
+ String intent_thumb;
+ if (!thumbGif.isEmpty()) {
+ intent_thumb = thumbGif;
+ } else {
+ intent_thumb = thumb;
+ }
+ intentApply.putExtra(SetKeyboardAmplify.THUMB_KEY, intent_thumb);
+ mContext.startActivity(intentApply);
+ if (mCallBack != null) {
+ mCallBack.OnItemClickListener();
+ }
+
+ }
+ });
+
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return mList.size();
+ }
+
+ public static class ForYouViewHolder extends RecyclerView.ViewHolder {
+
+ private CardView cardView;
+ private ImageView itemImg;
+
+ public ForYouViewHolder(@NonNull View itemView) {
+ super(itemView);
+ cardView = itemView.findViewById(R.id.card_view);
+ itemImg = itemView.findViewById(R.id.imPreview);
+
+ }
+
+ }
+}
diff --git a/app/src/main/java/com/app/brush/guitar/ink/icicle/DialogEnableObstinate.kt b/app/src/main/java/com/app/brush/guitar/ink/icicle/DialogEnableObstinate.kt
new file mode 100644
index 0000000..e84154f
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/icicle/DialogEnableObstinate.kt
@@ -0,0 +1,181 @@
+package com.app.brush.guitar.ink.icicle
+
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import android.content.IntentFilter
+import android.graphics.Color
+import android.graphics.drawable.ColorDrawable
+import android.os.Bundle
+import android.provider.Settings
+import android.view.Gravity
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.view.WindowManager
+import android.view.inputmethod.InputMethodManager
+import android.widget.ImageView
+import android.widget.LinearLayout
+import android.widget.TextView
+import androidx.appcompat.app.AppCompatActivity
+import androidx.core.content.ContextCompat
+import androidx.core.view.isVisible
+import androidx.fragment.app.DialogFragment
+import com.app.brush.guitar.ink.App
+import com.app.brush.guitar.ink.R
+import com.app.brush.guitar.ink.databinding.WarmDialogKeyboardEnableBinding
+import com.app.brush.guitar.ink.iguana.UbiquitousSerene
+
+
+class DialogEnableObstinate : DialogFragment() {
+
+ private lateinit var vb: WarmDialogKeyboardEnableBinding
+
+ private lateinit var layoutStepOne: LinearLayout
+ private lateinit var layoutStepTwo: LinearLayout
+ private lateinit var imgStepOkOne: ImageView
+ private lateinit var imgStepOkTwo: ImageView
+ private lateinit var intentFilter: IntentFilter
+ private var myreceiver: BroadcastReceiver? = null
+
+ private lateinit var stepOne: TextView
+ private lateinit var stepTwo: TextView
+
+ private lateinit var context: Context
+
+ private var clickAction: (() -> Unit )? = null
+
+
+
+ companion object {
+ fun newInstance(): DialogEnableObstinate {
+ val fragment = DialogEnableObstinate()
+ return fragment
+ }
+ }
+
+
+ fun setClickListener(action:() -> Unit){
+ clickAction = action
+ }
+
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
+ vb = WarmDialogKeyboardEnableBinding.inflate(layoutInflater)
+ context = App.Companion.appInstance
+
+
+ findViewId()
+ onViewStep()
+ getReceiver()
+ return vb.root
+ }
+
+ override fun onStart() {
+ super.onStart()
+ dialog?.run {
+ setCanceledOnTouchOutside(true)
+ window?.run {
+ setGravity(Gravity.BOTTOM)
+ setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
+
+ attributes = attributes.apply {
+ width = WindowManager.LayoutParams.MATCH_PARENT
+ height = WindowManager.LayoutParams.WRAP_CONTENT
+ }
+ }
+
+ }
+ }
+
+ private fun findViewId() {
+
+ layoutStepOne = vb.linearStepOne
+ layoutStepTwo = vb.linearStepTwo
+ imgStepOkOne = vb.okOne
+ imgStepOkTwo = vb.okTwo
+ stepOne = vb.textStepOne
+ stepTwo = vb.textStepTwo
+ }
+
+ private fun onViewStep() {
+
+ layoutStepOne.setOnClickListener {
+ startActivity(Intent(Settings.ACTION_INPUT_METHOD_SETTINGS))
+ }
+ layoutStepTwo.setOnClickListener {
+ val inputMethodManager =
+ context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+ inputMethodManager.showInputMethodPicker()
+ }
+ vb.imClose.setOnClickListener {
+ dismiss()
+ }
+ }
+
+ override fun onResume() {
+ super.onResume()
+ updateUI()
+ }
+
+ private fun getReceiver() {
+ myreceiver = object : BroadcastReceiver() {
+ override fun onReceive(context: Context?, intent: Intent?) {
+ updateUI()
+ }
+ }
+ intentFilter = IntentFilter(Intent.ACTION_INPUT_METHOD_CHANGED)
+
+ context.registerReceiver(myreceiver, intentFilter)
+ }
+
+ private fun updateUI() {
+
+ val checkEnable = UbiquitousSerene.checkEnable(App.Companion.appInstance)
+ val checkSetDefault = UbiquitousSerene.checkSetDefault(App.Companion.appInstance)
+ if (checkEnable && checkSetDefault) {
+ clickAction?.invoke()
+ dismiss()
+ return
+ }
+ if (checkEnable) {
+ layoutStepOne.isEnabled = false
+ layoutStepOne.isSelected = true
+ imgStepOkOne.isVisible = true
+ stepOne.setTextColor(ContextCompat.getColor(context, R.color.step_true))
+ } else {
+ layoutStepOne.isEnabled = true
+ layoutStepOne.isSelected = false
+ imgStepOkOne.isVisible = false
+ stepOne.setTextColor(ContextCompat.getColor(context, R.color.white))
+ }
+
+ if (checkSetDefault) {
+ layoutStepTwo.isEnabled = false
+ layoutStepTwo.isSelected = true
+ imgStepOkTwo.isVisible = true
+ stepTwo.setTextColor(ContextCompat.getColor(context, R.color.step_true))
+ } else {
+ layoutStepTwo.isEnabled = true
+ layoutStepTwo.isSelected = false
+ imgStepOkTwo.isVisible = false
+ stepTwo.setTextColor(ContextCompat.getColor(context, R.color.white))
+ }
+
+
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ if (myreceiver != null) {
+ context.unregisterReceiver(myreceiver)
+ }
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/app/brush/guitar/ink/icicle/PragmaticFavoriteKeyboard.kt b/app/src/main/java/com/app/brush/guitar/ink/icicle/PragmaticFavoriteKeyboard.kt
new file mode 100644
index 0000000..646bc8b
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/icicle/PragmaticFavoriteKeyboard.kt
@@ -0,0 +1,76 @@
+package com.app.brush.guitar.ink.icicle
+
+import android.os.Bundle
+import android.util.Log
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.core.view.isVisible
+import androidx.fragment.app.Fragment
+import androidx.lifecycle.lifecycleScope
+import androidx.recyclerview.widget.GridLayoutManager
+import com.app.brush.guitar.ink.App
+import com.app.brush.guitar.ink.drama.DichotomyDetails
+import com.app.brush.guitar.ink.databinding.PureFragmentKeyboardFavoriteBinding
+import com.app.brush.guitar.ink.ballad.Brilliant
+import com.app.brush.guitar.ink.ballad.Gratitude
+import com.app.brush.guitar.ink.canvas.JubilantDeleteFavorite
+import com.app.brush.guitar.ink.gallery.FavoriteElucidate
+import kotlinx.coroutines.launch
+
+class PragmaticFavoriteKeyboard : Fragment() {
+ private lateinit var vb: PureFragmentKeyboardFavoriteBinding
+ companion object {
+
+ @JvmStatic
+ fun newInstance() =
+ PragmaticFavoriteKeyboard()
+ }
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ vb = PureFragmentKeyboardFavoriteBinding.inflate(layoutInflater)
+ return vb.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ init()
+ }
+
+ private fun init() {
+ val mainAdapter = FavoriteElucidate(
+ requireContext()
+ ).apply {
+ setRemoveLike(object : JubilantDeleteFavorite {
+ override fun OnRemoveLike(data: DichotomyDetails) {
+ lifecycleScope.launch {
+ Gratitude.removeLike(data)
+ }
+ }
+
+ })
+ }
+ vb.likeRecycler.run {
+ adapter = mainAdapter
+ layoutManager = GridLayoutManager(requireContext(), 2)
+ }
+
+ Brilliant.Companion.baseDataBase.ThemesDao().queryAllLike().observe(viewLifecycleOwner) {
+ Log.d(App.Companion.TAG, "---------it=${it?.size}")
+ if(it.isNullOrEmpty()){
+ vb.likeRecycler.isVisible = false
+ vb.emptyTitle.isVisible = true
+ }else{
+ vb.likeRecycler.isVisible = true
+ vb.emptyTitle.isVisible = false
+ mainAdapter.setForYouList(it)
+ }
+
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/app/brush/guitar/ink/icicle/QuixoticHome.kt b/app/src/main/java/com/app/brush/guitar/ink/icicle/QuixoticHome.kt
new file mode 100644
index 0000000..b41000d
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/icicle/QuixoticHome.kt
@@ -0,0 +1,86 @@
+package com.app.brush.guitar.ink.icicle
+
+import android.content.Intent
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.Fragment
+import androidx.recyclerview.widget.LinearLayoutManager
+import com.app.brush.guitar.ink.App
+import com.app.brush.guitar.ink.drama.EphemeralWrapper
+import com.app.brush.guitar.ink.databinding.DarkFragmentMainHomeBinding
+import com.app.brush.guitar.ink.canvas.CacophonyViewAll
+import com.app.brush.guitar.ink.gallery.HomeFluctuate
+import com.app.brush.guitar.ink.eraser.CategoryListResonance
+
+class QuixoticHome : Fragment() {
+
+
+ private lateinit var vb: DarkFragmentMainHomeBinding
+
+
+
+ lateinit var viewAllList: MutableList
+ private lateinit var adapterParent: HomeFluctuate
+
+
+
+ companion object {
+
+ @JvmStatic
+ fun newInstance() =
+ QuixoticHome()
+ }
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ vb = DarkFragmentMainHomeBinding.inflate(layoutInflater)
+ return vb.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ setTabRecycler()
+ setupSearchIcon()
+ }
+
+ private fun setupSearchIcon() {
+ vb.ivSearch.setOnClickListener {
+ startActivity(Intent(requireContext(), com.app.brush.guitar.ink.eraser.SearchTrajectory::class.java))
+ }
+ }
+
+
+ private fun setTabRecycler() {
+ viewAllList = try {
+ App.Companion.list
+ } catch (e: kotlin.UninitializedPropertyAccessException) {
+ mutableListOf()
+ }
+ adapterParent = HomeFluctuate(
+ requireContext(), viewAllList
+ ).apply {
+ setClickAction(object : CacophonyViewAll {
+ override fun OnClickSeeAll(name: String) {
+ startActivity(Intent(requireContext(),
+ CategoryListResonance::class.java).apply {
+ putExtra(CategoryListResonance.KEY_NAME,name)
+ })
+
+ }
+
+ })
+ }
+ vb.tabRecycler.run {
+ adapter = adapterParent
+ layoutManager = LinearLayoutManager(requireContext())
+ }
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/app/brush/guitar/ink/icicle/ResilientSetting.kt b/app/src/main/java/com/app/brush/guitar/ink/icicle/ResilientSetting.kt
new file mode 100644
index 0000000..e0a1a12
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/icicle/ResilientSetting.kt
@@ -0,0 +1,134 @@
+package com.app.brush.guitar.ink.icicle
+
+import android.app.Dialog
+import android.content.pm.PackageManager
+import android.graphics.Color
+import android.graphics.drawable.ColorDrawable
+import android.os.Bundle
+import android.view.Gravity
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.view.WindowManager
+import android.widget.Toast
+import androidx.fragment.app.Fragment
+import com.app.brush.guitar.ink.BuildConfig
+import com.app.brush.guitar.ink.R
+import com.app.brush.guitar.ink.databinding.BoldDialogRateUserBinding
+import com.app.brush.guitar.ink.databinding.SlimFragmentSettingsPageBinding
+
+class ResilientSetting : Fragment() {
+
+ private lateinit var vb: SlimFragmentSettingsPageBinding
+ private var currentRating = 0
+
+ companion object {
+ @JvmStatic
+ fun newInstance() =
+ ResilientSetting()
+ }
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ vb = SlimFragmentSettingsPageBinding.inflate(layoutInflater)
+ return vb.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ setupVersion()
+ setupRateUs()
+ }
+
+ private fun setupRateUs() {
+ vb.layoutRateUs.setOnClickListener {
+ showRateDialog()
+ }
+ }
+
+ private fun showRateDialog() {
+ val dialog = Dialog(requireContext())
+ val dialogBinding = BoldDialogRateUserBinding.inflate(LayoutInflater.from(requireContext()))
+ dialog.setContentView(dialogBinding.root)
+
+ dialog.window?.apply {
+ val displayMetrics = requireContext().resources.displayMetrics
+ val width = (displayMetrics.widthPixels * 0.9).toInt() // 宽度为屏幕的90%
+
+ setLayout(width, WindowManager.LayoutParams.WRAP_CONTENT)
+ setGravity(Gravity.CENTER)
+ setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
+ }
+
+ dialog.setCanceledOnTouchOutside(true)
+
+ currentRating = 0
+ val stars = listOf(
+ dialogBinding.star1,
+ dialogBinding.star2,
+ dialogBinding.star3,
+ dialogBinding.star4,
+ dialogBinding.star5
+ )
+
+ fun updateStars(rating: Int) {
+ currentRating = rating
+ stars.forEachIndexed { index, star ->
+ if (index < rating) {
+ star.setImageResource(R.drawable.empty_ic_filled_star)
+ } else {
+ star.setImageResource(R.drawable.full_ic_empty_star)
+ }
+ }
+ dialogBinding.tvSubmit.visibility = if (rating > 0) View.VISIBLE else View.GONE
+ }
+
+ stars.forEachIndexed { index, star ->
+ star.setOnClickListener {
+ updateStars(index + 1)
+ }
+ }
+
+ dialogBinding.imClose.setOnClickListener {
+ dialog.dismiss()
+ }
+
+ dialogBinding.tvSubmit.setOnClickListener {
+ dialog.dismiss()
+ // 显示评分完成的提示
+ showRatingSubmittedToast()
+ }
+
+ dialog.show()
+ }
+
+ private fun showRatingSubmittedToast() {
+ Toast.makeText(
+ requireContext(),
+ getString(R.string.rating_submitted),
+ Toast.LENGTH_SHORT
+ ).show()
+ }
+
+ private fun setupVersion() {
+ try {
+ val versionName = BuildConfig.VERSION_NAME
+ vb.tvVersionValue.text = versionName
+ } catch (e: Exception) {
+ // Fallback to PackageManager if BuildConfig is not available
+ try {
+ val packageInfo = requireContext().packageManager.getPackageInfo(
+ requireContext().packageName,
+ 0
+ )
+ vb.tvVersionValue.text = packageInfo.versionName ?: "Unknown"
+ } catch (e2: PackageManager.NameNotFoundException) {
+ vb.tvVersionValue.text = "Unknown"
+ }
+ }
+ }
+
+}
+
diff --git a/app/src/main/java/com/app/brush/guitar/ink/iguana/DiodeEclipse.kt b/app/src/main/java/com/app/brush/guitar/ink/iguana/DiodeEclipse.kt
new file mode 100644
index 0000000..b5db154
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/iguana/DiodeEclipse.kt
@@ -0,0 +1,60 @@
+package com.app.brush.guitar.ink.iguana
+
+object DiodeEclipse {
+
+
+
+ const val KEY_CODE_DELETE = -5
+
+
+ //同一个按键
+ const val KEY_CODE_SHIFT = -1
+ const val KEY_CODE_NUMBER_SHIFT = -103
+ const val KEY_CODE_SYMBOL_SHIFT = -101
+
+ //同一个按键
+ const val KEY_CODE_CHANGE_NUMBER = -2
+ const val KEY_CODE_BACK = -102
+
+
+ const val KEY_CODE_COMPLETE = -4
+ const val KEY_CODE_CANCEL = -3
+
+ const val KEY_CODE_SPACE = 32
+
+
+ const val functionNormalName = "btn_keyboard_key_functional_normal.9.png"
+ const val functionPressName = "btn_keyboard_key_functional_pressed.9.png"
+
+ const val normalName = "btn_keyboard_key_normal_normal.9.png"
+ const val pressName = "btn_keyboard_key_normal_pressed.9.png"
+
+ const val toNormalName="btn_keyboard_key_toggle_normal_on.9.png"
+ const val toPressName="btn_keyboard_key_toggle_pressed_on.9.png"
+
+ const val spaceNormalName = "btn_keyboard_spacekey_normal_normal.9.png"
+ const val spacePressName = "btn_keyboard_spacekey_normal_pressed.9.png"
+
+ const val imeSwitchName ="ic_ime_switcher.png"
+
+ const val deleteNormalName = "sym_keyboard_delete_normal.png"
+ const val deletePressName = "sym_keyboard_delete_pressed.png"
+
+ const val backName ="sym_keyboard_return_normal.png"
+
+ const val searchName ="sym_keyboard_search.png"
+
+ const val shiftNormalName ="sym_keyboard_shift.png"
+ const val shiftLockName ="sym_keyboard_shift_locked.png"
+
+ const val keyTextColorName ="key_text_color_normal"
+ const val keyTextColorFunctionName ="key_text_color_functional"
+
+ const val videoName ="keyboard_background_video.mp4"
+ const val bgName ="keyboard_background.jpg"
+ const val bgName_png ="keyboard_background.png"
+
+ const val previewBg="keyboard_preview_screenshot.jpg"
+
+ const val video ="keyboard_background_video.gif"
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/app/brush/guitar/ink/iguana/IsotopeTextView.java b/app/src/main/java/com/app/brush/guitar/ink/iguana/IsotopeTextView.java
new file mode 100644
index 0000000..20154e7
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/iguana/IsotopeTextView.java
@@ -0,0 +1,37 @@
+package com.app.brush.guitar.ink.iguana;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.widget.TextView;
+
+import androidx.annotation.Nullable;
+
+import com.app.brush.guitar.ink.App;
+import com.app.brush.guitar.ink.R;
+
+
+public class IsotopeTextView extends androidx.appcompat.widget.AppCompatTextView {
+
+
+ public IsotopeTextView(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ initAttrs(context,attrs);
+ }
+
+
+ private void initAttrs(Context context, AttributeSet attrs){
+ TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MyTV);
+ boolean aBoolean = typedArray.getBoolean(R.styleable.MyTV_apply_font,false);
+ if(aBoolean){
+ initFont(this);
+ }
+
+ typedArray.recycle();
+ }
+
+ public static void initFont(TextView tv) {
+ tv.setTypeface(App.Companion.getDefaultFont());
+ }
+
+}
diff --git a/app/src/main/java/com/app/brush/guitar/ink/iguana/ListDecorationFossil.java b/app/src/main/java/com/app/brush/guitar/ink/iguana/ListDecorationFossil.java
new file mode 100644
index 0000000..4ae9732
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/iguana/ListDecorationFossil.java
@@ -0,0 +1,76 @@
+package com.app.brush.guitar.ink.iguana;
+
+import android.graphics.Rect;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.StaggeredGridLayoutManager;
+
+import com.app.brush.guitar.ink.App;
+
+
+public class ListDecorationFossil extends RecyclerView.ItemDecoration {
+
+ private int v, h, ex;
+
+ public ListDecorationFossil(int v, int h, int ex) {
+ this.v = Math.round(dpToPx(v));
+ this.h = Math.round(dpToPx(h));
+ this.ex = Math.round(dpToPx(ex));
+ }
+
+ @Override
+ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
+ super.getItemOffsets(outRect, view, parent, state);
+ int spanCount = 1;
+ int spanSize = 1;
+ int spanIndex = 0;
+
+ int childAdapterPosition = parent.getChildAdapterPosition(view);
+ RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
+ if (layoutManager instanceof StaggeredGridLayoutManager) {
+ StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
+ StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
+ spanCount = staggeredGridLayoutManager.getSpanCount();
+ if (layoutParams.isFullSpan()) {
+ spanSize = spanCount;
+ }
+ spanIndex = layoutParams.getSpanIndex();
+ } else if (layoutManager instanceof GridLayoutManager) {
+ GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
+ GridLayoutManager.LayoutParams layoutParams = (GridLayoutManager.LayoutParams) view.getLayoutParams();
+ spanCount = gridLayoutManager.getSpanCount();
+ spanSize = gridLayoutManager.getSpanSizeLookup().getSpanSize(childAdapterPosition);
+ spanIndex = layoutParams.getSpanIndex();
+ } else if (layoutManager instanceof LinearLayoutManager) {
+ outRect.left = v;
+ outRect.right = v;
+ outRect.bottom = h;
+ }
+
+ if (spanSize == spanCount) {
+ outRect.left = v + ex;
+ outRect.right = v + ex;
+ outRect.bottom = h;
+
+ } else {
+ int itemAllSpacing = (v * (spanCount + 1) + ex * 2) / spanCount;
+ int left = v * (spanIndex + 1) - itemAllSpacing * spanIndex + ex;
+ int right = itemAllSpacing - left;
+ outRect.left = left;
+ outRect.right = right;
+ outRect.bottom = h;
+
+ }
+
+ }
+
+
+ public static float dpToPx(float dpValue) {
+ float density = App.appInstance.getResources().getDisplayMetrics().density;
+ return density * dpValue + 0.5f;
+ }
+}
diff --git a/app/src/main/java/com/app/brush/guitar/ink/iguana/SaveGeyserTheme.kt b/app/src/main/java/com/app/brush/guitar/ink/iguana/SaveGeyserTheme.kt
new file mode 100644
index 0000000..9e7fbf0
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/iguana/SaveGeyserTheme.kt
@@ -0,0 +1,19 @@
+package com.app.brush.guitar.ink.iguana
+
+import android.content.Context
+import com.app.brush.guitar.ink.App
+
+object SaveGeyserTheme {
+
+ val SP_NAME = "keyboard_skin"
+ val SKIN_PATH = "skin_path"
+ val spSkin = App.Companion.appInstance.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE)
+
+ fun updateSkinPath(skinPath:String){
+ spSkin.edit().putString(SKIN_PATH,skinPath).apply()
+ }
+
+ fun getSkinPath( ):String?{
+ return spSkin.getString(SKIN_PATH,null)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/app/brush/guitar/ink/iguana/ThemesManagerKinetic.kt b/app/src/main/java/com/app/brush/guitar/ink/iguana/ThemesManagerKinetic.kt
new file mode 100644
index 0000000..502760e
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/iguana/ThemesManagerKinetic.kt
@@ -0,0 +1,181 @@
+package com.app.brush.guitar.ink.iguana
+
+import android.content.Context
+import android.graphics.BitmapFactory
+import android.graphics.Color
+import android.graphics.drawable.BitmapDrawable
+import android.graphics.drawable.Drawable
+import android.graphics.drawable.StateListDrawable
+import android.util.Xml
+import androidx.core.content.ContextCompat
+import com.app.brush.guitar.ink.App
+import com.app.brush.guitar.ink.encore.NucleusConfig
+import com.app.brush.guitar.ink.R
+import org.xmlpull.v1.XmlPullParser
+import java.io.File
+import java.io.StringReader
+import kotlin.collections.iterator
+
+class ThemesManagerKinetic(var context: Context) {
+
+
+ private var textSize = 13f
+
+ var functionDraw: Drawable =
+ getDefaultDrawList(R.drawable.default_normal_key, R.drawable.default_pressed_key)
+ var generalDraw: Drawable =
+ getDefaultDrawList(R.drawable.default_normal_key, R.drawable.default_pressed_key)
+
+ var toDraw: Drawable = getDefaultDrawList(R.drawable.default_normal_key, R.drawable.default_pressed_key)
+ var spaceDraw: Drawable = getDefaultDrawList(R.drawable.default_normal_key, R.drawable.default_pressed_key)
+
+ var switchDraw: Drawable? = null
+ var deleteDraw: Drawable? = null
+ var backDraw: Drawable? = null
+ var searchDraw: Drawable? = null
+
+ var shiftDraw: Drawable? = null
+ var shiftLockDraw: Drawable? = null
+
+ var keyTextColor: Int = ContextCompat.getColor(context, R.color.black)
+ var keyTextColorFunction: Int = ContextCompat.getColor(context, R.color.black)
+
+
+
+
+ fun getConfig(): NucleusConfig? {
+ val skinPath = SaveGeyserTheme.getSkinPath()
+ val configFilePath = skinPath + "assets/keyboard.conf"
+ val file = File(configFilePath)
+ return if (file.exists()) {
+ VoraciousConfFile.initConfig(configFilePath)
+ } else {
+ null
+ }
+ }
+
+ fun getConfigBg(name: String): Drawable? {
+ SaveGeyserTheme.getSkinPath()?.let { resPath ->
+ val pPath = "${resPath}res/drawable-xhdpi-v4/"
+
+ return getDrawList(
+ pPath + name,
+ pPath + name
+ )
+ }
+ return null
+ }
+
+ fun updateSkinConfig() {
+ SaveGeyserTheme.getSkinPath()?.let { resPath ->
+ val pPath = "${resPath}res/drawable-xhdpi-v4/"
+ pPath.let {
+ readColors(resPath) {
+ for ((name, value) in it) {
+ if (name == DiodeEclipse.keyTextColorName) {
+ keyTextColor = value
+ }
+ if (name == DiodeEclipse.keyTextColorFunctionName) {
+ keyTextColorFunction = value
+ }
+ }
+
+ }
+ functionDraw = getDrawList(
+ it + DiodeEclipse.functionNormalName,
+ it + DiodeEclipse.functionPressName
+ )
+ generalDraw = getDrawList(it + DiodeEclipse.normalName, it + DiodeEclipse.pressName)
+ toDraw = getDrawList(it + DiodeEclipse.toNormalName, it + DiodeEclipse.toPressName)
+ spaceDraw =
+ getDrawList(it + DiodeEclipse.spaceNormalName, it + DiodeEclipse.spacePressName)
+ switchDraw =
+ getDrawList(it + DiodeEclipse.imeSwitchName, it + DiodeEclipse.imeSwitchName)
+ deleteDraw = getDrawList(
+ it + DiodeEclipse.deleteNormalName,
+ it + DiodeEclipse.deletePressName
+ )
+ backDraw = getDrawList(it + DiodeEclipse.backName, it + DiodeEclipse.backName)
+ searchDraw = getDrawList(it + DiodeEclipse.searchName, it + DiodeEclipse.searchName)
+ shiftDraw = getDrawList(
+ it + DiodeEclipse.shiftNormalName,
+ it + DiodeEclipse.shiftNormalName
+ )
+ shiftLockDraw =
+ getDrawList(it + DiodeEclipse.shiftLockName, it + DiodeEclipse.shiftLockName)
+ }
+
+ }
+ }
+
+
+ private fun getDefaultDrawList(normalDrawId: Int, pressDrawId: Int): StateListDrawable {
+ val normalDraw = ContextCompat.getDrawable(App.Companion.appInstance, normalDrawId)
+ val pressDraw = ContextCompat.getDrawable(App.Companion.appInstance, pressDrawId)
+ val stateListDrawable = StateListDrawable().apply {
+ addState(
+ intArrayOf(android.R.attr.state_pressed),
+ pressDraw
+ )
+ addState(intArrayOf(), normalDraw)
+ }
+
+ return stateListDrawable
+
+
+ }
+
+
+ private fun getDrawList(normalPath: String, pressPath: String): StateListDrawable {
+ val pressDraw = BitmapFactory.decodeFile(pressPath)
+ val normalDraw = BitmapFactory.decodeFile(normalPath)
+ val stateListDrawable = StateListDrawable().apply {
+ addState(
+ intArrayOf(android.R.attr.state_pressed),
+ BitmapDrawable(context.resources, pressDraw)
+ )
+ addState(intArrayOf(), BitmapDrawable(context.resources, normalDraw))
+ }
+
+ return stateListDrawable
+
+
+ }
+
+ private fun readColors(resPath: String, callBack: (Map) -> Unit) {
+ val resMaps = mutableMapOf()
+
+ val pPath = "${resPath}res/colors.xml"
+ val file = File(pPath)
+ if (file.exists()) {
+ val xmlPullParser = Xml.newPullParser().apply {
+ setInput(StringReader(file.readText()))
+ setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false)
+
+ }
+ var curType = xmlPullParser.eventType
+ while (curType != XmlPullParser.END_DOCUMENT) {
+ val b = curType == XmlPullParser.START_TAG
+ val b1 = xmlPullParser.name == "color"
+ val b2 = xmlPullParser.name == "item"
+ if (b && (b1 || b2)) {
+ val attributeName = xmlPullParser.getAttributeValue(null, "name")
+ val nextTextValue = xmlPullParser.nextText()
+ val b3 = attributeName == DiodeEclipse.keyTextColorName
+ val b4 = attributeName == DiodeEclipse.keyTextColorFunctionName
+ if (b3 || b4) {
+ resMaps[attributeName] = Color.parseColor(nextTextValue)
+ }
+ }
+ curType = xmlPullParser.next()
+ }
+
+ }
+
+ callBack.invoke(resMaps)
+
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/app/brush/guitar/ink/iguana/UbiquitousSerene.kt b/app/src/main/java/com/app/brush/guitar/ink/iguana/UbiquitousSerene.kt
new file mode 100644
index 0000000..7d47afa
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/iguana/UbiquitousSerene.kt
@@ -0,0 +1,115 @@
+package com.app.brush.guitar.ink.iguana
+
+import android.app.Activity
+import android.content.Context
+import android.graphics.BitmapFactory
+import android.graphics.drawable.BitmapDrawable
+import android.graphics.drawable.Drawable
+import android.provider.Settings
+import android.view.View
+import android.view.WindowManager
+import android.view.inputmethod.EditorInfo
+import android.view.inputmethod.InputMethodManager
+import android.widget.ImageView
+import com.app.brush.guitar.ink.App
+import com.bumptech.glide.Glide
+import com.bumptech.glide.integration.webp.decoder.WebpDrawable
+import com.bumptech.glide.load.DataSource
+import com.bumptech.glide.load.engine.GlideException
+import com.bumptech.glide.load.resource.bitmap.CenterCrop
+import com.bumptech.glide.load.resource.bitmap.RoundedCorners
+import com.bumptech.glide.request.RequestListener
+import com.bumptech.glide.request.RequestOptions
+import com.bumptech.glide.request.target.Target
+import java.io.File
+
+object UbiquitousSerene {
+
+ val transform = RequestOptions().transform(CenterCrop(), RoundedCorners(dpToPx(8f)))
+ fun initFullScreen(activity: Activity, dark: Boolean? = true) {
+ val window = activity.window
+ val decorView = window.decorView
+ val rootView = decorView.rootView
+//
+ if (dark == null) return
+
+ if (dark) {
+ decorView.setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
+ )
+ } else {
+ decorView.setSystemUiVisibility(
+ (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
+ )
+ }
+ window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
+ }
+
+
+ fun loadWepJif(mContext: Context, webpGifUrl: String, view: ImageView) {
+ Glide.with(mContext)
+ .load(webpGifUrl)
+// .apply(transform)
+ .addListener(object : RequestListener {
+ override fun onLoadFailed(
+ e: GlideException?,
+ model: Any?,
+ target: Target,
+ isFirstResource: Boolean
+ ): Boolean {
+ return false
+ }
+
+ override fun onResourceReady(
+ resource: Drawable,
+ model: Any,
+ target: Target,
+ dataSource: DataSource,
+ isFirstResource: Boolean
+ ): Boolean {
+ if (resource is WebpDrawable) {
+ resource.loopCount = WebpDrawable.LOOP_FOREVER
+ }
+ return false
+ }
+ }).into(view)
+ }
+
+
+ fun getBgDrawable(con: Context, filePath: String): Drawable? {
+ if (!File(filePath).exists()) {
+ return null
+ }
+ return BitmapDrawable(con.resources, BitmapFactory.decodeFile(filePath))
+ }
+
+
+ private val systemService =
+ App.Companion.appInstance.getSystemService(Context.INPUT_METHOD_SERVICE)
+ private val inputMethodManager = systemService as InputMethodManager
+ fun checkSetDefault(con: Context): Boolean {
+ val defaultId =
+ Settings.Secure.getString(con.contentResolver, Settings.Secure.DEFAULT_INPUT_METHOD)
+ return defaultId != null && defaultId.startsWith(con.packageName)
+ }
+
+ fun checkEnable(con: Context): Boolean {
+ for (methodInfo in inputMethodManager.enabledInputMethodList) {
+ if (methodInfo.id.startsWith(con.packageName)) {
+ return true
+ }
+ }
+ return false
+ }
+
+ fun getTextForImeAction(imeOptions: Int): Int {
+ return imeOptions and EditorInfo.IME_MASK_ACTION
+ }
+
+ fun dpToPx(dpValue: Float): Int {
+ val scale = App.Companion.appInstance.resources.displayMetrics.density
+ return (dpValue * scale + 0.5f).toInt()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/app/brush/guitar/ink/iguana/VoraciousConfFile.java b/app/src/main/java/com/app/brush/guitar/ink/iguana/VoraciousConfFile.java
new file mode 100644
index 0000000..09cc311
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/iguana/VoraciousConfFile.java
@@ -0,0 +1,106 @@
+package com.app.brush.guitar.ink.iguana;
+
+import com.app.brush.guitar.ink.encore.ModelHarbinger;
+import com.app.brush.guitar.ink.encore.NucleusConfig;
+import com.app.brush.guitar.ink.encore.OasisLayout;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class VoraciousConfFile {
+
+ public static NucleusConfig initConfig(String path) {
+ String filePath = "keyboard.conf"; // 文件路径
+ NucleusConfig config = parseConfig(path);
+ return config;
+ }
+
+ public static NucleusConfig parseConfig(String filePath) {
+// InputStream open = App.appInstance.getAssets().open(filePath);
+ NucleusConfig config = new NucleusConfig();
+ try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
+ String line;
+ OasisLayout currentLayout = null;
+ while ((line = br.readLine()) != null) {
+ line = line.trim();
+ if (line.isEmpty()) {
+ continue; // 跳过空行
+ }
+ if (line.startsWith("Version:")) {
+ config.setVersion(line.split(":")[1].trim());
+ } else if (line.startsWith("SupportLayouts:")) {
+ config.setSupportLayouts(line.split(":")[1].trim());
+ } else if (line.startsWith("HideHint:")) {
+ config.setHideHint(Integer.parseInt(line.split(":")[1].trim()));
+ } else if (line.startsWith("LayoutStyle:")) {
+ config.setLayoutStyle(line.split(":")[1].trim());
+ } else if (line.equals("KeyDefault") || line.equals("KeyMarkDefault") || line.equals("KeyFuncDefault")) {
+ LinkedHashMap maps = config.getMaps();
+ maps.put(line, "");
+ } else if (line.contains(":") && currentLayout == null) {
+ String[] parts = line.split(":");
+ String keyName = parts[0].trim();
+ String keyValue = parts[1].trim();
+
+ String latestKey = null;
+ LinkedHashMap maps = config.getMaps();
+ for (Map.Entry entry : maps.entrySet()) {
+ latestKey = entry.getKey();
+ }
+ if (latestKey != null) {
+ maps.put(latestKey, keyValue);
+ }
+ } else if (line.startsWith("Row")) {
+ currentLayout = new OasisLayout(line.split(":")[0].trim());
+ config.addLayout(currentLayout);
+ } else if (currentLayout != null) {
+ if (line.equals("Key")) {
+ String[] parts = line.split(":");
+ String keyName = parts[0].trim();
+ ModelHarbinger keyModel = new ModelHarbinger(keyName);
+ currentLayout.addKey(keyModel);
+ } else if (line.contains(":") && currentLayout.getLastKey().getBackground() == null) {
+ // 解析按键的其他属性(如 Label)
+ String[] parts = line.split(":");
+ String keyName = parts[0].trim();
+ String keyValue = parts[1].trim();
+ ModelHarbinger keyModel = currentLayout.getLastKey();
+ if (keyName.equals("Label")) {
+ keyModel.setLabel(keyValue);
+ }
+ if (keyName.equals("Background")) {
+ keyModel.setBackground(keyValue);
+ }
+ } else {
+ if (line.equals("KeyShift") || line.equals("KeyDelete") || line.equals("KeyAlphaSymbol") || line.equals("KeyEmoji")
+ || line.equals("KeyMark")
+ || line.equals("KeySpace")
+ || line.equals("KeyEnter")) {
+ ModelHarbinger funcationKeyModel = new ModelHarbinger(line);
+ config.addKey(funcationKeyModel);
+ } else if (line.contains(":")) {
+ String[] parts = line.split(":");
+ String keyName = parts[0].trim();
+ String keyValue = parts[1].trim();
+ ModelHarbinger lastKeyModel = config.getLastKeyList();
+ if (keyName.equals("Label")) {
+ lastKeyModel.setLabel(keyValue);
+ }
+ if (keyName.equals("Background")) {
+ lastKeyModel.setBackground(keyValue);
+ }
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return config;
+ }
+}
+
+
diff --git a/app/src/main/java/com/app/brush/guitar/ink/iguana/WhimsicalZipFile.java b/app/src/main/java/com/app/brush/guitar/ink/iguana/WhimsicalZipFile.java
new file mode 100644
index 0000000..6f7f032
--- /dev/null
+++ b/app/src/main/java/com/app/brush/guitar/ink/iguana/WhimsicalZipFile.java
@@ -0,0 +1,238 @@
+package com.app.brush.guitar.ink.iguana;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.util.Log;
+
+import com.app.brush.guitar.ink.App;
+import com.app.brush.guitar.ink.canvas.BellicoseSetKeyboard;
+
+import net.sf.sevenzipjbinding.ArchiveFormat;
+import net.sf.sevenzipjbinding.IArchiveOpenCallback;
+import net.sf.sevenzipjbinding.IInArchive;
+import net.sf.sevenzipjbinding.SevenZip;
+import net.sf.sevenzipjbinding.SevenZipException;
+import net.sf.sevenzipjbinding.impl.RandomAccessFileInStream;
+import net.sf.sevenzipjbinding.impl.RandomAccessFileOutStream;
+import net.sf.sevenzipjbinding.simple.ISimpleInArchive;
+import net.sf.sevenzipjbinding.simple.ISimpleInArchiveItem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+
+public class WhimsicalZipFile {
+
+ public static void startDownloadZip(String zipPath, BellicoseSetKeyboard callback) {
+ OkHttpClient clientZip = new OkHttpClient().newBuilder().
+ connectTimeout(20, TimeUnit.SECONDS)
+ .writeTimeout(10, TimeUnit.SECONDS)
+ .readTimeout(10, TimeUnit.SECONDS).build();
+ Request.Builder builder = new Request.Builder();
+ Request request = builder.get().url(zipPath).build();
+
+ clientZip.newCall(request).enqueue(new Callback() {
+ @Override
+ public void onFailure(Call call, IOException e) {
+ callback.OnApplySkinListener(null);
+ }
+
+ @Override
+ public void onResponse(Call call, Response response) {
+
+ InputStream inputStream = response.body().byteStream();
+ long l = response.body().contentLength();
+ MediaType mediaType = response.body().contentType();
+
+ saveZipFile(inputStream, getServiceZipName(zipPath), callback);
+
+ }
+ });
+ }
+
+
+ public static String getServiceZipName(String zipPath) {
+ String pointStr = "/";
+ int lastIndexOf = zipPath.lastIndexOf(pointStr);
+ String zipName = zipPath.substring(lastIndexOf + pointStr.length());
+
+
+ return zipName;
+ }
+
+ private static String getunZipFolderName(String zipPath) {
+ String pointStr = ".";
+ int lastIndexOf = zipPath.lastIndexOf(pointStr);
+ String zipName = zipPath.substring(0, lastIndexOf);
+
+
+ return zipName;
+ }
+
+ private static void saveZipFile(InputStream inputStream, String zipFileName, BellicoseSetKeyboard callback) {
+ File zipfFile = new File(App.appInstance.getFilesDir(), zipFileName);
+
+ Log.d("-------------------","-------zipFileName="+zipFileName);
+ byte[] bytes = new byte[4096];
+ int readLength = 0;
+ InputStream is = inputStream;
+ FileOutputStream fileOs = null;
+ try {
+ fileOs = new FileOutputStream(zipfFile);
+
+ while ((readLength = is.read(bytes)) != -1) {
+ fileOs.write(bytes, 0, readLength);
+ }
+ fileOs.flush();
+
+ } catch (Exception exception) {
+
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ if (fileOs != null) {
+ fileOs.close();
+ }
+ } catch (IOException ioException) {
+
+ }
+ un7ZZipFile(zipfFile, callback);
+ }
+
+ }
+
+ public static String getUnzipPath(String zipName){
+ String folderName = getunZipFolderName(zipName);
+ String replace = folderName.replace(".", "");
+ return App.appInstance.getFilesDir().getPath() + "/" + replace;
+ }
+
+ private static void un7ZZipFile(File saveZipFile, BellicoseSetKeyboard callback) {
+ List fileList = new ArrayList<>();
+
+ String unzipFolderPath = getUnzipPath(saveZipFile.getName());
+
+ try {
+ RandomAccessFileInStream inStream = new RandomAccessFileInStream(new RandomAccessFile(saveZipFile, "r"));
+ IInArchive open = SevenZip.openInArchive(ArchiveFormat.SEVEN_ZIP, inStream, new IArchiveOpenCallback() {
+ @Override
+ public void setTotal(Long files, Long bytes) {
+
+ }
+
+ @Override
+ public void setCompleted(Long files, Long bytes) {
+
+ }
+ });
+
+
+ ISimpleInArchive simple = open.getSimpleInterface();
+ for (ISimpleInArchiveItem archiveItem : simple.getArchiveItems()) {
+ RandomAccessFileOutStream outStream = null;
+ try {
+ File itemFile;
+ if (archiveItem.isFolder()) {
+ File itemFolder = new File(unzipFolderPath, archiveItem.getPath());
+ boolean mkdirs = itemFolder.mkdirs();
+ continue;
+ } else {
+ itemFile = new File(unzipFolderPath, archiveItem.getPath());
+ if (!itemFile.getParentFile().exists()) {
+ boolean mkdirs = itemFile.getParentFile().mkdirs();
+ }
+ }
+ outStream = new RandomAccessFileOutStream(new RandomAccessFile(itemFile, "rw"));
+ archiveItem.extractSlow(outStream);
+ fileList.add(itemFile);
+ } finally {
+ if (outStream != null) {
+ outStream.close();
+ }
+ }
+ }
+
+
+ inStream.close();
+ open.close();
+
+ } catch (FileNotFoundException | SevenZipException exception) {
+
+ } catch (IOException ioException) {
+
+ } finally {
+ if (saveZipFile.exists()) {
+
+ saveZipFile.delete();
+
+ }
+ callback.OnApplySkinListener(fileList);
+ }
+ }
+
+ public static File findFirstDirectory(File dir) {
+ if (dir.isDirectory()) {
+ File[] files = dir.listFiles();
+ if (files != null) {
+ for (File file : files) {
+ if (file.isDirectory()) {
+ return file; // 返回第一个文件目录
+ }
+ }
+ }
+ }
+ return null; // 如果没有找到文件目录,则返回null
+ }
+
+
+ private static Bitmap drawableToBitmap(Drawable drawable) {
+ if (drawable instanceof BitmapDrawable) {
+ return ((BitmapDrawable) drawable).getBitmap();
+ }
+
+ // 如果不是 BitmapDrawable,则创建一个空的 Bitmap 对象
+ Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
+ drawable.getIntrinsicHeight(),
+ Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+ drawable.draw(canvas);
+ return bitmap;
+ }
+
+ // 将 Bitmap 保存到文件
+ private static void saveBitmapToFile(Bitmap bitmap, File file) throws IOException {
+ if(!file.exists()){
+ file.createNewFile();
+ }
+ FileOutputStream out = new FileOutputStream(file);
+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); // 保存为 PNG 格式
+ out.flush();
+ out.close();
+ }
+
+ // 示例:将 Drawable 写入文件
+ public static void saveDrawableToFile(Drawable drawable, File file) throws IOException {
+ Bitmap bitmap = drawableToBitmap(drawable);
+ saveBitmapToFile(bitmap, file);
+ }
+
+
+}
diff --git a/app/src/main/res/color/selector_color_tab.xml b/app/src/main/res/color/selector_color_tab.xml
new file mode 100644
index 0000000..09a7c75
--- /dev/null
+++ b/app/src/main/res/color/selector_color_tab.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/back_ffffff.png b/app/src/main/res/drawable/back_ffffff.png
new file mode 100644
index 0000000..86d9c4e
Binary files /dev/null and b/app/src/main/res/drawable/back_ffffff.png differ
diff --git a/app/src/main/res/drawable/big_selector_home_tab.xml b/app/src/main/res/drawable/big_selector_home_tab.xml
new file mode 100644
index 0000000..e15594d
--- /dev/null
+++ b/app/src/main/res/drawable/big_selector_home_tab.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/blue_dialog_enable_bg1.xml b/app/src/main/res/drawable/blue_dialog_enable_bg1.xml
new file mode 100644
index 0000000..f797c0d
--- /dev/null
+++ b/app/src/main/res/drawable/blue_dialog_enable_bg1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/bold_tab_normal_setting.xml b/app/src/main/res/drawable/bold_tab_normal_setting.xml
new file mode 100644
index 0000000..97b5b10
--- /dev/null
+++ b/app/src/main/res/drawable/bold_tab_normal_setting.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/close_dialog_rate_background.xml b/app/src/main/res/drawable/close_dialog_rate_background.xml
new file mode 100644
index 0000000..a2b9330
--- /dev/null
+++ b/app/src/main/res/drawable/close_dialog_rate_background.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/cool_tab_normal_home.xml b/app/src/main/res/drawable/cool_tab_normal_home.xml
new file mode 100644
index 0000000..b9f13a1
--- /dev/null
+++ b/app/src/main/res/drawable/cool_tab_normal_home.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/dark_tab_selected_setting.xml b/app/src/main/res/drawable/dark_tab_selected_setting.xml
new file mode 100644
index 0000000..0294fa8
--- /dev/null
+++ b/app/src/main/res/drawable/dark_tab_selected_setting.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/deep_dialog_background_unenable.xml b/app/src/main/res/drawable/deep_dialog_background_unenable.xml
new file mode 100644
index 0000000..0631d5e
--- /dev/null
+++ b/app/src/main/res/drawable/deep_dialog_background_unenable.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/default_normal_key.png b/app/src/main/res/drawable/default_normal_key.png
new file mode 100644
index 0000000..423191b
Binary files /dev/null and b/app/src/main/res/drawable/default_normal_key.png differ
diff --git a/app/src/main/res/drawable/default_pressed_key.png b/app/src/main/res/drawable/default_pressed_key.png
new file mode 100644
index 0000000..156ea42
Binary files /dev/null and b/app/src/main/res/drawable/default_pressed_key.png differ
diff --git a/app/src/main/res/drawable/empty_ic_filled_star.xml b/app/src/main/res/drawable/empty_ic_filled_star.xml
new file mode 100644
index 0000000..872126b
--- /dev/null
+++ b/app/src/main/res/drawable/empty_ic_filled_star.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/fast_ic_search_icon.xml b/app/src/main/res/drawable/fast_ic_search_icon.xml
new file mode 100644
index 0000000..f519b05
--- /dev/null
+++ b/app/src/main/res/drawable/fast_ic_search_icon.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/fine_tab_selected_favorite.xml b/app/src/main/res/drawable/fine_tab_selected_favorite.xml
new file mode 100644
index 0000000..05421fc
--- /dev/null
+++ b/app/src/main/res/drawable/fine_tab_selected_favorite.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/flat_shape_button_set_bg.xml b/app/src/main/res/drawable/flat_shape_button_set_bg.xml
new file mode 100644
index 0000000..4a6d65e
--- /dev/null
+++ b/app/src/main/res/drawable/flat_shape_button_set_bg.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/full_ic_empty_star.xml b/app/src/main/res/drawable/full_ic_empty_star.xml
new file mode 100644
index 0000000..b8ce07e
--- /dev/null
+++ b/app/src/main/res/drawable/full_ic_empty_star.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/goody_tab_selected_home.xml b/app/src/main/res/drawable/goody_tab_selected_home.xml
new file mode 100644
index 0000000..07d989b
--- /dev/null
+++ b/app/src/main/res/drawable/goody_tab_selected_home.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/high_selector_enable_button.xml b/app/src/main/res/drawable/high_selector_enable_button.xml
new file mode 100644
index 0000000..23c521a
--- /dev/null
+++ b/app/src/main/res/drawable/high_selector_enable_button.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/icon_already_enable.png b/app/src/main/res/drawable/icon_already_enable.png
new file mode 100644
index 0000000..4e1e7c1
Binary files /dev/null and b/app/src/main/res/drawable/icon_already_enable.png differ
diff --git a/app/src/main/res/drawable/icon_set_white.png b/app/src/main/res/drawable/icon_set_white.png
new file mode 100644
index 0000000..6b72a74
Binary files /dev/null and b/app/src/main/res/drawable/icon_set_white.png differ
diff --git a/app/src/main/res/drawable/long_ic_right_arrow.xml b/app/src/main/res/drawable/long_ic_right_arrow.xml
new file mode 100644
index 0000000..a1543d0
--- /dev/null
+++ b/app/src/main/res/drawable/long_ic_right_arrow.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/lowp_selector_favorite_icon.xml b/app/src/main/res/drawable/lowp_selector_favorite_icon.xml
new file mode 100644
index 0000000..50cfc07
--- /dev/null
+++ b/app/src/main/res/drawable/lowp_selector_favorite_icon.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/new_selector_setting_tab.xml b/app/src/main/res/drawable/new_selector_setting_tab.xml
new file mode 100644
index 0000000..1f364a3
--- /dev/null
+++ b/app/src/main/res/drawable/new_selector_setting_tab.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/nice_shape_selected_favorite.xml b/app/src/main/res/drawable/nice_shape_selected_favorite.xml
new file mode 100644
index 0000000..d82414d
--- /dev/null
+++ b/app/src/main/res/drawable/nice_shape_selected_favorite.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/open_ic_clear_button.xml b/app/src/main/res/drawable/open_ic_clear_button.xml
new file mode 100644
index 0000000..314c5a2
--- /dev/null
+++ b/app/src/main/res/drawable/open_ic_clear_button.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/place_holder.png b/app/src/main/res/drawable/place_holder.png
new file mode 100644
index 0000000..b5b8283
Binary files /dev/null and b/app/src/main/res/drawable/place_holder.png differ
diff --git a/app/src/main/res/drawable/pure_bg_white_oval.xml b/app/src/main/res/drawable/pure_bg_white_oval.xml
new file mode 100644
index 0000000..f44588b
--- /dev/null
+++ b/app/src/main/res/drawable/pure_bg_white_oval.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/quick_launcher_drawable_pb.xml b/app/src/main/res/drawable/quick_launcher_drawable_pb.xml
new file mode 100644
index 0000000..3a5581f
--- /dev/null
+++ b/app/src/main/res/drawable/quick_launcher_drawable_pb.xml
@@ -0,0 +1,21 @@
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/red_selector_item_key_white.xml b/app/src/main/res/drawable/red_selector_item_key_white.xml
new file mode 100644
index 0000000..57321c0
--- /dev/null
+++ b/app/src/main/res/drawable/red_selector_item_key_white.xml
@@ -0,0 +1,19 @@
+
+
+-
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/rich_selector_favorite_tab.xml b/app/src/main/res/drawable/rich_selector_favorite_tab.xml
new file mode 100644
index 0000000..5ede4a1
--- /dev/null
+++ b/app/src/main/res/drawable/rich_selector_favorite_tab.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/slim_back_arrow_svg.xml b/app/src/main/res/drawable/slim_back_arrow_svg.xml
new file mode 100644
index 0000000..71da016
--- /dev/null
+++ b/app/src/main/res/drawable/slim_back_arrow_svg.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/small_bg_box_search.xml b/app/src/main/res/drawable/small_bg_box_search.xml
new file mode 100644
index 0000000..efe484c
--- /dev/null
+++ b/app/src/main/res/drawable/small_bg_box_search.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/soft_bg_gradient_light_blue_purple.xml b/app/src/main/res/drawable/soft_bg_gradient_light_blue_purple.xml
new file mode 100644
index 0000000..7266477
--- /dev/null
+++ b/app/src/main/res/drawable/soft_bg_gradient_light_blue_purple.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/soft_shape_normal_favorite.xml b/app/src/main/res/drawable/soft_shape_normal_favorite.xml
new file mode 100644
index 0000000..c72d421
--- /dev/null
+++ b/app/src/main/res/drawable/soft_shape_normal_favorite.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/thin_bg_tag_item.xml b/app/src/main/res/drawable/thin_bg_tag_item.xml
new file mode 100644
index 0000000..394d3e9
--- /dev/null
+++ b/app/src/main/res/drawable/thin_bg_tag_item.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/tiny_ic_close_dialog.xml b/app/src/main/res/drawable/tiny_ic_close_dialog.xml
new file mode 100644
index 0000000..266c148
--- /dev/null
+++ b/app/src/main/res/drawable/tiny_ic_close_dialog.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/warm_tab_normal_favorite.xml b/app/src/main/res/drawable/warm_tab_normal_favorite.xml
new file mode 100644
index 0000000..a3d0c31
--- /dev/null
+++ b/app/src/main/res/drawable/warm_tab_normal_favorite.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/wide_bg_edittext_success_preview.xml b/app/src/main/res/drawable/wide_bg_edittext_success_preview.xml
new file mode 100644
index 0000000..12f86f2
--- /dev/null
+++ b/app/src/main/res/drawable/wide_bg_edittext_success_preview.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/big_activity_preview_success.xml b/app/src/main/res/layout/big_activity_preview_success.xml
new file mode 100644
index 0000000..e1fde59
--- /dev/null
+++ b/app/src/main/res/layout/big_activity_preview_success.xml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/bold_dialog_rate_user.xml b/app/src/main/res/layout/bold_dialog_rate_user.xml
new file mode 100644
index 0000000..50ed070
--- /dev/null
+++ b/app/src/main/res/layout/bold_dialog_rate_user.xml
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/cool_activity_search_keyboard.xml b/app/src/main/res/layout/cool_activity_search_keyboard.xml
new file mode 100644
index 0000000..b5a7920
--- /dev/null
+++ b/app/src/main/res/layout/cool_activity_search_keyboard.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/dark_fragment_main_home.xml b/app/src/main/res/layout/dark_fragment_main_home.xml
new file mode 100644
index 0000000..f32339e
--- /dev/null
+++ b/app/src/main/res/layout/dark_fragment_main_home.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/deep_adapter_more_keyboard_set.xml b/app/src/main/res/layout/deep_adapter_more_keyboard_set.xml
new file mode 100644
index 0000000..522b37a
--- /dev/null
+++ b/app/src/main/res/layout/deep_adapter_more_keyboard_set.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/fast_activity_keyboard_setting.xml b/app/src/main/res/layout/fast_activity_keyboard_setting.xml
new file mode 100644
index 0000000..6cc4fd5
--- /dev/null
+++ b/app/src/main/res/layout/fast_activity_keyboard_setting.xml
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/fine_default_input_keyboard_view.xml b/app/src/main/res/layout/fine_default_input_keyboard_view.xml
new file mode 100644
index 0000000..8f929e5
--- /dev/null
+++ b/app/src/main/res/layout/fine_default_input_keyboard_view.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/flat_activity_category_main.xml b/app/src/main/res/layout/flat_activity_category_main.xml
new file mode 100644
index 0000000..074ba89
--- /dev/null
+++ b/app/src/main/res/layout/flat_activity_category_main.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/long_custom_tab_view.xml b/app/src/main/res/layout/long_custom_tab_view.xml
new file mode 100644
index 0000000..b60cd7c
--- /dev/null
+++ b/app/src/main/res/layout/long_custom_tab_view.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/nice_adapter_main_home.xml b/app/src/main/res/layout/nice_adapter_main_home.xml
new file mode 100644
index 0000000..9826bcf
--- /dev/null
+++ b/app/src/main/res/layout/nice_adapter_main_home.xml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/pure_fragment_keyboard_favorite.xml b/app/src/main/res/layout/pure_fragment_keyboard_favorite.xml
new file mode 100644
index 0000000..dd1eb57
--- /dev/null
+++ b/app/src/main/res/layout/pure_fragment_keyboard_favorite.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/quick_adapter_favorite_item.xml b/app/src/main/res/layout/quick_adapter_favorite_item.xml
new file mode 100644
index 0000000..dce5966
--- /dev/null
+++ b/app/src/main/res/layout/quick_adapter_favorite_item.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/rich_adapter_child_home.xml b/app/src/main/res/layout/rich_adapter_child_home.xml
new file mode 100644
index 0000000..1a39dbd
--- /dev/null
+++ b/app/src/main/res/layout/rich_adapter_child_home.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/slim_fragment_settings_page.xml b/app/src/main/res/layout/slim_fragment_settings_page.xml
new file mode 100644
index 0000000..a36802d
--- /dev/null
+++ b/app/src/main/res/layout/slim_fragment_settings_page.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/small_activity_list_category.xml b/app/src/main/res/layout/small_activity_list_category.xml
new file mode 100644
index 0000000..ba3abe4
--- /dev/null
+++ b/app/src/main/res/layout/small_activity_list_category.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/thin_adapter_recommended_home.xml b/app/src/main/res/layout/thin_adapter_recommended_home.xml
new file mode 100644
index 0000000..7cd56b5
--- /dev/null
+++ b/app/src/main/res/layout/thin_adapter_recommended_home.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/tiny_activity_launch_screen.xml b/app/src/main/res/layout/tiny_activity_launch_screen.xml
new file mode 100644
index 0000000..87f31c5
--- /dev/null
+++ b/app/src/main/res/layout/tiny_activity_launch_screen.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/warm_dialog_keyboard_enable.xml b/app/src/main/res/layout/warm_dialog_keyboard_enable.xml
new file mode 100644
index 0000000..0fc88cb
--- /dev/null
+++ b/app/src/main/res/layout/warm_dialog_keyboard_enable.xml
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/wide_item_card_recommended.xml b/app/src/main/res/layout/wide_item_card_recommended.xml
new file mode 100644
index 0000000..3e14299
--- /dev/null
+++ b/app/src/main/res/layout/wide_item_card_recommended.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/mipmap-xxxhdpi/aesthetic.png b/app/src/main/res/mipmap-xxxhdpi/aesthetic.png
new file mode 100644
index 0000000..45fbb6a
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/aesthetic.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/beautiful.png b/app/src/main/res/mipmap-xxxhdpi/beautiful.png
new file mode 100644
index 0000000..c506359
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/beautiful.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/cute.png b/app/src/main/res/mipmap-xxxhdpi/cute.png
new file mode 100644
index 0000000..4641595
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/cute.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/festival.png b/app/src/main/res/mipmap-xxxhdpi/festival.png
new file mode 100644
index 0000000..be9bd22
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/festival.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/fire_fill.png b/app/src/main/res/mipmap-xxxhdpi/fire_fill.png
new file mode 100644
index 0000000..c18ecd5
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/fire_fill.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/glove.png b/app/src/main/res/mipmap-xxxhdpi/glove.png
new file mode 100644
index 0000000..9691e12
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/glove.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/live.png b/app/src/main/res/mipmap-xxxhdpi/live.png
new file mode 100644
index 0000000..f5f74d8
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/live.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/logo.png b/app/src/main/res/mipmap-xxxhdpi/logo.png
new file mode 100644
index 0000000..1b77e32
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/logo.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/neon.png b/app/src/main/res/mipmap-xxxhdpi/neon.png
new file mode 100644
index 0000000..87f360a
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/neon.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/recommend.png b/app/src/main/res/mipmap-xxxhdpi/recommend.png
new file mode 100644
index 0000000..eef0a70
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/recommend.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/su.png b/app/src/main/res/mipmap-xxxhdpi/su.png
new file mode 100644
index 0000000..3f0a1da
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/su.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/zcool.png b/app/src/main/res/mipmap-xxxhdpi/zcool.png
new file mode 100644
index 0000000..3515f47
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/zcool.png differ
diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml
new file mode 100644
index 0000000..2e6440b
--- /dev/null
+++ b/app/src/main/res/values-night/themes.xml
@@ -0,0 +1,16 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..7f4917d
--- /dev/null
+++ b/app/src/main/res/values/attrs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..0bdc23a
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,25 @@
+
+
+
+ #FFD4B3E8
+ #FFB895D4
+ #FF9D7BC2
+ #FF87CEEB
+ #FF74CBFF
+ #FF000000
+ #FFFFFFFF
+ #1A000000
+ #ffbbbbbb
+ #666666
+ #00000000
+ #80000000
+ #F44336
+ #858484
+ #74CBFF
+ #FFB895D4
+ #FFB895D4
+ #FFD4B3E8
+
+ #FFB895D4
+ #7B7E7E
+
\ No newline at end of file
diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml
new file mode 100644
index 0000000..2b678d7
--- /dev/null
+++ b/app/src/main/res/values/dimen.xml
@@ -0,0 +1,7 @@
+
+
+
+ 15sp
+ 48dp
+ 5dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..3cfc2b4
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,22 @@
+
+ RandomKeyboard
+ Download & Apply
+ Apply
+ recommend
+ recommendation
+ Activate RandomKeyboard to enable more functions!
+ Step 1:Select
+ Step 2:Enable
+ Theme application successful
+ Download failed, please try again
+ Type a Message
+ Favorite
+ Home
+ Setting
+ Rate us
+ Rate Us
+ Submit
+ Thank you for your rating!
+ See All
+ You haven not added any favorite skins yet
+
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
new file mode 100644
index 0000000..4f8805f
--- /dev/null
+++ b/app/src/main/res/values/themes.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/value.xml b/app/src/main/res/values/value.xml
new file mode 100644
index 0000000..ec81e28
--- /dev/null
+++ b/app/src/main/res/values/value.xml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/keyborad_xml.xml b/app/src/main/res/xml/keyborad_xml.xml
new file mode 100644
index 0000000..34453bb
--- /dev/null
+++ b/app/src/main/res/xml/keyborad_xml.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/xml_one.xml b/app/src/main/res/xml/xml_one.xml
new file mode 100644
index 0000000..a4789dd
--- /dev/null
+++ b/app/src/main/res/xml/xml_one.xml
@@ -0,0 +1,142 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/xml_three.xml b/app/src/main/res/xml/xml_three.xml
new file mode 100644
index 0000000..7173668
--- /dev/null
+++ b/app/src/main/res/xml/xml_three.xml
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/xml_two.xml b/app/src/main/res/xml/xml_two.xml
new file mode 100644
index 0000000..af71a77
--- /dev/null
+++ b/app/src/main/res/xml/xml_two.xml
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/test/java/com/keyboard/bubble/skin/keyboard/ExampleUnitTest.kt b/app/src/test/java/com/keyboard/bubble/skin/keyboard/ExampleUnitTest.kt
new file mode 100644
index 0000000..4063f0a
--- /dev/null
+++ b/app/src/test/java/com/keyboard/bubble/skin/keyboard/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package com.keyboard.skinning.cool
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 0000000..d4e8229
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,6 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+plugins {
+ id("com.android.application") version "8.11.1" apply false
+ id("org.jetbrains.kotlin.android") version "2.2.21" apply false
+ kotlin("kapt") version "2.0.0"
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..dae8329
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,23 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Kotlin code style for this project: "official" or "obsolete":
+kotlin.code.style=official
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..d64cd49
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d4081da
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..1aa94a4
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,249 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..6689b85
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,92 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/keystore.properties b/keystore.properties
new file mode 100644
index 0000000..2032d84
--- /dev/null
+++ b/keystore.properties
@@ -0,0 +1,6 @@
+app_name=RandomKeyboard
+package_name=com.app.brush.guitar.ink
+keystoreFile=app/RandomKeyboard.jks
+key_alias=key0
+key_store_password=123456
+key_password=123456
diff --git a/settings.gradle.kts b/settings.gradle.kts
new file mode 100644
index 0000000..654ecad
--- /dev/null
+++ b/settings.gradle.kts
@@ -0,0 +1,21 @@
+pluginManagement {
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ maven("https://jitpack.io")
+
+ }
+}
+
+rootProject.name = "RandomKeyboard"
+include(":app")
+
\ No newline at end of file