Last active
November 10, 2020 22:20
-
-
Save matthewmorrone/7ef0ec2f066faa230b138c9783eeb673 to your computer and use it in GitHub Desktop.
stuff to reimplement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| android:orientation="vertical" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_margin="20dp" | |
| android:background="@color/white" | |
| android:padding="10dp" | |
| android:layout_gravity="center" | |
| tools:context=".CustomEditTextPreference"> | |
| <TextView | |
| android:id="@+id/editSpaceBar" | |
| android:text="@string/edit_space_bar" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_margin="10dp" | |
| android:layout_gravity="center" | |
| /> | |
| <TextView | |
| android:id="@+id/editTabKey" | |
| android:text="@string/edit_tab_key" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_margin="10dp" | |
| android:layout_gravity="center" | |
| /> | |
| <TextView | |
| android:id="@+id/editEnterKey" | |
| android:text="@string/edit_enter_key" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_margin="10dp" | |
| android:layout_gravity="center" | |
| /> | |
| <Button | |
| android:id="@+id/editForegroundColor" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_gravity="center" | |
| android:text="@string/foreground_color" | |
| /> | |
| <Button | |
| android:id="@+id/editBackgroundColor" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:layout_gravity="center" | |
| android:text="@string/background_color" | |
| /> | |
| </LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int layoutMin = -400; | |
| int layoutMax = -454; | |
| public void adjustLayoutPage() { | |
| if (!sharedPreferences.getBoolean("relayout", true)) { | |
| return; | |
| } | |
| List<Keyboard.Key> layoutKeys = new ArrayList<>(); | |
| for (Keyboard.Key key : getKeyboard("Layouts").getKeys()) { | |
| if (key.codes[0] <= layoutMin && key.codes[0] >= layoutMax) { | |
| layoutKeys.add(key); | |
| } | |
| } | |
| Bounds bounds = getBounds(layoutKeys); | |
| int rowHeight = layoutKeys.get(0).height; | |
| int colCount = 6; | |
| int startRowCount = 9; | |
| int layoutCount = Math.max(layouts.size() - 1, 1); | |
| double finalRowCount = Math.ceil((double)layoutCount / (double)colCount); | |
| // 1 row: double moveBy = 448; //bounds.dY / (finalRowCount); 448 - (56 * 0) / 1 | |
| // 2 rows: double moveBy = 196; //bounds.dY / (finalRowCount); 448 - (56 * 1) / 2 | |
| // 3 rows: double moveBy = 112; //bounds.dY / (finalRowCount); 448 - (56 * 2) / 3 | |
| double moveBy = (bounds.dY - (rowHeight * (finalRowCount - 1))) / finalRowCount; | |
| int row, index = 0; | |
| for (Keyboard.Key key : getKeyboard("Layouts").getKeys()) { | |
| if (key.codes[0] <= layoutMin && key.codes[0] >= layoutMax) { | |
| row = (index / colCount); | |
| if (row >= (startRowCount - (startRowCount - finalRowCount))) { | |
| key.y = bounds.maxY; | |
| key.height = 0; | |
| } | |
| else { | |
| key.y += (moveBy * row); | |
| key.height += moveBy; | |
| } | |
| index++; | |
| } | |
| } | |
| int layoutMod = (layoutCount % colCount); | |
| if (layoutMod > 0) { | |
| int hi = layoutMin - layoutCount; | |
| int lo = hi + layoutMod; | |
| hi = lo - colCount; | |
| layoutKeys = new ArrayList<>(); | |
| for (Keyboard.Key key : getKeyboard("Layouts").getKeys()) { | |
| if (key.codes[0] <= lo && key.codes[0] >= hi) { | |
| layoutKeys.add(key); | |
| } | |
| } | |
| bounds = getBounds(layoutKeys); | |
| int keyWidth = layoutKeys.get(0).width; | |
| int rowWidth = bounds.dX; | |
| int usedWidth = keyWidth * layoutMod; | |
| int freeWidth = rowWidth - usedWidth; | |
| moveBy = (int)Math.ceil(freeWidth / layoutMod) + (keyWidth / layoutMod); | |
| index = 0; | |
| for (Keyboard.Key key : getKeyboard("Layouts").getKeys()) { | |
| if (key.codes[0] <= lo && key.codes[0] >= hi) { | |
| if (index >= layoutMod) { | |
| key.x = bounds.maxX; | |
| key.width = 0; | |
| key.label = empty; | |
| } | |
| else { | |
| key.x += (moveBy * index); | |
| key.width += moveBy; | |
| } | |
| index++; | |
| } | |
| } | |
| } | |
| try { | |
| redraw(); | |
| } | |
| catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (key.codes[0] == 32) { | |
| key.text = sharedPreferences.getString(Constants.SPACEBARTEXT, " "); | |
| key.popupCharacters = sharedPreferences.getString(Constants.SPACEBARPOPUP, getContext().getString(R.string.popup_first)); | |
| iconId = sharedPreferences.getString(Constants.SPACEBARICON, "ic_space"); | |
| if (!iconId.isEmpty()) { | |
| imageId = getResources().getIdentifier(iconId, "drawable", getContext().getPackageName()); | |
| key.icon = ContextCompat.getDrawable(getContext(), imageId); | |
| } | |
| else { | |
| key.label = sharedPreferences.getString(Constants.SPACEBARLABEL, ""); // getContext().getString(R.string.popup_first) | |
| } | |
| } | |
| if (key.codes[0] == 7) { | |
| key.text = sharedPreferences.getString(Constants.TABKEYTEXT, "\t"); | |
| key.popupCharacters = sharedPreferences.getString(Constants.TABKEYPOPUP, getContext().getString(R.string.popup_second)); | |
| iconId = sharedPreferences.getString(Constants.TABKEYICON, "ic_tab"); | |
| if (!iconId.isEmpty()) { | |
| imageId = getResources().getIdentifier(iconId, "drawable", getContext().getPackageName()); | |
| key.icon = ContextCompat.getDrawable(getContext(), imageId); | |
| } | |
| else { | |
| key.label = sharedPreferences.getString(Constants.TABKEYLABEL, ""); // getContext().getString(R.string.popup_second) | |
| } | |
| } | |
| if (key.codes[0] == 10) { | |
| key.text = sharedPreferences.getString(Constants.ENTERKEYTEXT, "\n"); | |
| key.popupCharacters = sharedPreferences.getString(Constants.ENTERKEYPOPUP, getContext().getString(R.string.popup_third)); | |
| iconId = sharedPreferences.getString(Constants.ENTERKEYICON, "ic_enter"); | |
| if (!iconId.isEmpty()) { | |
| imageId = getResources().getIdentifier(iconId, "drawable", getContext().getPackageName()); | |
| key.icon = ContextCompat.getDrawable(getContext(), imageId); | |
| } | |
| else { | |
| key.label = sharedPreferences.getString(Constants.ENTERKEYLABEL, ""); // getContext().getString(R.string.popup_third) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case -51: performReplace(Util.convertNumberBase(getText(ic), 2, 10)); break; | |
| case -52: performReplace(Util.convertNumberBase(getText(ic), 10, 2)); break; | |
| case -53: performReplace(Util.convertNumberBase(getText(ic), 8, 10)); break; | |
| case -54: performReplace(Util.convertNumberBase(getText(ic), 10, 8)); break; | |
| case -55: performReplace(Util.convertNumberBase(getText(ic), 16, 10)); break; | |
| case -56: performReplace(Util.convertNumberBase(getText(ic), 10, 16)); break; | |
| case -58: performReplace(Util.camelToSnake(getText(ic))); break; | |
| case -59: performReplace(Util.snakeToCamel(getText(ic))); break; | |
| case -60: performReplace(Util.doubleCharacters(getText(ic))); break; | |
| case -61: performReplace(Util.increaseIndentation(getText(ic))); break; | |
| case -62: performReplace(Util.decreaseIndentation(getText(ic))); break; | |
| case -27: sendKey(KeyEvent.KEYCODE_SETTINGS); break; | |
| case -28: sendKey(KeyEvent.KEYCODE_APP_SWITCH); break; | |
| case -29: sendKey(KeyEvent.KEYCODE_LANGUAGE_SWITCH); break; | |
| case -30: sendKey(KeyEvent.KEYCODE_BRIGHTNESS_DOWN); break; | |
| case -31: sendKey(KeyEvent.KEYCODE_BRIGHTNESS_UP); break; | |
| case -32: sendKey(KeyEvent.KEYCODE_NAVIGATE_PREVIOUS); break; | |
| case -33: sendKey(KeyEvent.KEYCODE_NAVIGATE_NEXT); break; | |
| case -34: sendKey(KeyEvent.KEYCODE_CLEAR); break; | |
| case -48: sendKey(KeyEvent.KEYCODE_MANNER_MODE); break; | |
| case -49: sendKey(KeyEvent.KEYCODE_PICTSYMBOLS); break; | |
| case -63: sendKey(KeyEvent.KEYCODE_ESCAPE); break; | |
| case -64: sendKey(KeyEvent.KEYCODE_CALCULATOR); break; | |
| case -65: sendKey(KeyEvent.KEYCODE_CONTACTS); break; | |
| case -67: sendKey(KeyEvent.KEYCODE_CALENDAR); break; | |
| case -99: | |
| if (!isSelecting()) selectLine(); | |
| sendKey(KeyEvent.KEYCODE_DEL); | |
| break; | |
| case -139: performReplace(Util.trimEndingWhitespace(getText(ic))); break; | |
| case -140: performReplace(Util.trimTrailingWhitespace(getText(ic))); break; | |
| case -143: performReplace(Util.rot13(getText(ic))); break; | |
| case -150: performContextMenuAction(16908338); break; // undo | |
| case -151: performContextMenuAction(16908339); break; // redo | |
| case -152: performContextMenuAction(16908337); break; // pasteAsPlainText, | |
| case -153: performContextMenuAction(16908323); break; // copyUrl | |
| case -154: performContextMenuAction(16908355); break; // autofill | |
| case -155: performContextMenuAction(16908330); break; // addToDictionary | |
| case -156: performContextMenuAction(16908320); break; // cut | |
| case -157: performContextMenuAction(16908321); break; // copy | |
| case -158: performContextMenuAction(16908322); break; // paste | |
| case -159: performContextMenuAction(16908319); break; // selectAll | |
| case -160: performContextMenuAction(16908324); break; // switchInputMethod | |
| case -161: performContextMenuAction(16908328); break; // startSelectingText | |
| case -162: performContextMenuAction(16908329); break; // stopSelectingText | |
| case -163: performContextMenuAction(16908326); break; // keyboardView | |
| case -164: performContextMenuAction(16908333); break; // selectTextMode | |
| case -165: performContextMenuAction(16908327); break; // closeButton | |
| case -166: performContextMenuAction(16908316); break; // extractArea | |
| case -167: performContextMenuAction(16908317); break; // candidatesArea | |
| case -168: performReplace(Util.spaceReplace(getText(ic))); break; | |
| case -169: | |
| sendKey(KeyEvent.KEYCODE_MOVE_END); | |
| ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT)); | |
| sendKey(KeyEvent.KEYCODE_MOVE_HOME); | |
| ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)); | |
| sendKey(KeyEvent.KEYCODE_CUT); | |
| sendKey(KeyEvent.KEYCODE_FORWARD_DEL); | |
| sendKey(KeyEvent.KEYCODE_DPAD_UP); | |
| sendKey(KeyEvent.KEYCODE_ENTER); | |
| sendKey(KeyEvent.KEYCODE_DPAD_UP); | |
| sendKey(KeyEvent.KEYCODE_PASTE); | |
| break; | |
| case -170: | |
| sendKey(KeyEvent.KEYCODE_MOVE_END); | |
| ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT)); | |
| sendKey(KeyEvent.KEYCODE_MOVE_HOME); | |
| ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT)); | |
| sendKey(KeyEvent.KEYCODE_CUT); | |
| sendKey(KeyEvent.KEYCODE_FORWARD_DEL); | |
| sendKey(KeyEvent.KEYCODE_DPAD_DOWN); | |
| sendKey(KeyEvent.KEYCODE_ENTER); | |
| sendKey(KeyEvent.KEYCODE_DPAD_DOWN); | |
| sendKey(KeyEvent.KEYCODE_PASTE); | |
| break; | |
| case -172: | |
| String toFind = getText(ic); | |
| selectAll(); | |
| performReplace(Util.replaceZWSP(getText(ic), toFind)); | |
| break; | |
| case -173: performReplace(Util.removeZWSP(getText(ic))); break; | |
| case -174: toastIt(Util.unidata(getText(ic))); break; | |
| case -175: showActivity(Settings.ACTION_INPUT_METHOD_SETTINGS); break; | |
| case -176: showActivity(Settings.ACTION_HARD_KEYBOARD_SETTINGS); break; | |
| case -177: showActivity(Settings.ACTION_LOCALE_SETTINGS); break; | |
| case -178: showActivity(Settings.ACTION_SETTINGS); break; | |
| case -179: showActivity(Settings.ACTION_USER_DICTIONARY_SETTINGS); break; | |
| case -182: showClipboard(); break; | |
| case -184: showActivity(Settings.ACTION_WIFI_SETTINGS); break; | |
| case -185: showActivity(Settings.ACTION_WIRELESS_SETTINGS); break; | |
| case -186: showActivity(Settings.ACTION_VOICE_INPUT_SETTINGS); break; | |
| case -187: showActivity(Settings.ACTION_USAGE_ACCESS_SETTINGS); break; | |
| case -188: showActivity(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE); break; | |
| case -189: performReplace(Util.normalize(getText(ic))); break; | |
| case -190: performReplace(Util.slug(getText(ic))); break; | |
| case -191: performReplace(Util.toAlternatingCase(getText(ic))); break; | |
| case -203: showActivity(Settings.ACTION_HOME_SETTINGS); break; // 🏠⌂ | |
| case -204: showActivity(Settings.ACTION_ZEN_MODE_PRIORITY_SETTINGS); break; // 📳📴📵 | |
| case -205: showActivity(Settings.ACTION_AIRPLANE_MODE_SETTINGS); break; // ✈✈️ | |
| case -206: showActivity(Settings.ACTION_SOUND_SETTINGS); break; // 🔔🔕🎶🎵🎼📣📢🎹 | |
| case -207: showActivity(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); break; | |
| case -208: showActivity(Settings.ACTION_BLUETOOTH_SETTINGS); break; | |
| case -209: showActivity(Settings.ACTION_CAPTIONING_SETTINGS); break; | |
| case -210: showActivity(Settings.ACTION_DEVICE_INFO_SETTINGS); break; | |
| case -211: performReplace(Util.addLineNumbers(getText(ic))); break; | |
| case -212: performReplace(Util.removeLineNumbers(getText(ic))); break; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public String setClipboardEntry(String text) { | |
| try { | |
| ClipboardManager clipboardManager = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); | |
| ClipData clip = ClipData.newPlainText(empty, Util.toCharSequence(text)); | |
| clipboardManager.setPrimaryClip(clip); | |
| } | |
| catch (Exception e) { | |
| return empty; | |
| } | |
| return empty; | |
| } | |
| public String getClipboardEntry(int n) { | |
| try { | |
| ClipboardManager clipboardManager = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); | |
| ClipData clip = clipboardManager.getPrimaryClip(); | |
| ClipData.Item item = null; | |
| if (clip != null) { | |
| item = clip.getItemAt(n); | |
| } | |
| CharSequence text = null; | |
| if (item != null) { | |
| text = item.getText(); | |
| } | |
| if (text != null) { | |
| return text.toString(); | |
| } | |
| } | |
| catch (Exception e) { | |
| return empty; | |
| } | |
| return empty; | |
| } | |
| public void handleCut() { | |
| String record; | |
| boolean wasntSelecting = f; | |
| if (!isSelecting()) { | |
| selectLine(); | |
| wasntSelecting = t; | |
| } | |
| sendKey(KeyEvent.KEYCODE_CUT); | |
| toast.cancel(); | |
| if (wasntSelecting) { | |
| sendKey(KeyEvent.KEYCODE_DEL); | |
| sendKey(KeyEvent.KEYCODE_DPAD_DOWN); | |
| } | |
| record = getClipboardEntry(0); | |
| if (!record.equals(empty)) { | |
| clipboardHistory.add(record); | |
| } | |
| } | |
| public void handleCopy() { | |
| String record; | |
| if (!isSelecting()) { | |
| selectLine(); | |
| } | |
| sendKey(KeyEvent.KEYCODE_COPY); | |
| toast.cancel(); | |
| record = getClipboardEntry(0); | |
| if (!record.equals(empty)) { | |
| clipboardHistory.add(record); | |
| } | |
| } | |
| public void trimClipboard() { | |
| setClipboardEntry(trim(getClipboardEntry(0))); | |
| } | |
| public void handlePaste() { | |
| String paste = getClipboardEntry(0); | |
| if (sharedPreferences.getBoolean("spaces", true)) { | |
| paste = trim(paste); | |
| trimClipboard(); | |
| } | |
| sendKey(KeyEvent.KEYCODE_PASTE); | |
| if (mCandidateView != null) { | |
| mCandidateView.clear(); | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface Constants { | |
| public String SPACEBARLABEL = "Spacebar Label"; | |
| public String SPACEBARTEXT = " "; | |
| public String SPACEBARPOPUP = "popup_first"; | |
| public String SPACEBARICON = "ic_space"; | |
| public String TABKEYLABEL = "Tab Key Label"; | |
| public String TABKEYTEXT = "\t"; | |
| public String TABKEYPOPUP = "popup_second"; | |
| public String TABKEYICON = "ic_tab"; | |
| public String ENTERKEYLABEL = "Enter Key Label"; | |
| public String ENTERKEYTEXT = "\n"; | |
| public String ENTERKEYPOPUP = "popup_third"; | |
| public String ENTERKEYICON = "ic_enter"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.custom.keyboard; | |
| import android.content.SharedPreferences; | |
| import android.preference.PreferenceManager; | |
| // import androidx.appcompat.app.AppCompatActivity; | |
| import android.os.Bundle; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.view.View; | |
| import top.defaults.colorpicker.ColorPickerPopup; | |
| public class CustomEditTextPreference extends AppCompatActivity implements View.OnClickListener { | |
| SharedPreferences sharedPreferences; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_custom_edit_text_preference); | |
| findViewById(R.id.editSpaceBar).setOnClickListener(this); | |
| findViewById(R.id.editTabKey).setOnClickListener(this); | |
| findViewById(R.id.editEnterKey).setOnClickListener(this); | |
| findViewById(R.id.editForegroundColor).setOnClickListener(this); | |
| findViewById(R.id.editBackgroundColor).setOnClickListener(this); | |
| } | |
| @Override | |
| public void onClick(View view) { | |
| sharedPreferences = PreferenceManager.getDefaultSharedPreferences(view.getContext()); | |
| if (view.getId() == R.id.editSpaceBar) { | |
| new EditSpacebarPopup(this, "space").show(); | |
| } | |
| else if (view.getId() == R.id.editTabKey) { | |
| new EditSpacebarPopup(this, "tab").show(); | |
| } | |
| else if (view.getId() == R.id.editEnterKey) { | |
| new EditSpacebarPopup(this, "enter").show(); | |
| } | |
| else if (view.getId() == R.id.editForegroundColor) { | |
| new ColorPickerPopup.Builder(this) | |
| .initialColor(sharedPreferences.getInt("fg", -1677216)) // Set initial color | |
| .enableBrightness(true) // Enable brightness slider or not | |
| // .enableAlpha(true) // Enable alpha slider or not | |
| .okTitle("Choose") | |
| .cancelTitle("Cancel") | |
| .showIndicator(true) | |
| .showValue(true) | |
| .build() | |
| .show(view, new ColorPickerPopup.ColorPickerObserver() { | |
| @Override | |
| public void onColorPicked(int color) { | |
| SharedPreferences.Editor sharedPreferenceEditor = sharedPreferences.edit(); | |
| sharedPreferenceEditor.putInt("fg", color); | |
| sharedPreferenceEditor.apply(); | |
| } | |
| }); | |
| } | |
| else if (view.getId() == R.id.editBackgroundColor) { | |
| new ColorPickerPopup.Builder(this) | |
| .initialColor(sharedPreferences.getInt("bg", -1)) // Set initial color | |
| .enableBrightness(true) // Enable brightness slider or not | |
| // .enableAlpha(true) // Enable alpha slider or not | |
| .okTitle("Choose") | |
| .cancelTitle("Cancel") | |
| .showIndicator(true) | |
| .showValue(true) | |
| .build() | |
| .show(view, new ColorPickerPopup.ColorPickerObserver() { | |
| @Override | |
| public void onColorPicked(int color) { | |
| SharedPreferences.Editor sharedPreferenceEditor = sharedPreferences.edit(); | |
| sharedPreferenceEditor.putInt("bg", color); | |
| sharedPreferenceEditor.apply(); | |
| } | |
| }); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:orientation="vertical" | |
| android:layout_gravity="center" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content"> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_margin="20dp" | |
| android:background="@color/white" | |
| android:padding="10dp" | |
| android:orientation="vertical"> | |
| <TextView | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:gravity="center" | |
| android:textColor="@android:color/black" | |
| android:textSize="18sp" | |
| android:text="@string/edit_key" /> | |
| <EditText | |
| android:id="@+id/editLabel" | |
| android:hint="@string/what_the_key_shows" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" /> | |
| <EditText | |
| android:id="@+id/editText" | |
| android:hint="@string/what_the_key_sends" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" /> | |
| <EditText | |
| android:id="@+id/editPopup" | |
| android:hint="@string/what_the_key_has_on_long_press" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" /> | |
| <EditText | |
| android:id="@+id/editIcon" | |
| android:hint="@string/what_icon_shows_up" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" /> | |
| <LinearLayout | |
| android:orientation="horizontal" | |
| android:layout_gravity="center" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content"> | |
| <Button | |
| android:id="@+id/savePopup" | |
| android:text="@string/save" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" /> | |
| <Button | |
| android:id="@+id/exitPopup" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:text="@string/cancel" /> | |
| </LinearLayout> | |
| </LinearLayout> | |
| </LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.custom.keyboard; | |
| import android.app.Dialog; | |
| import android.content.Context; | |
| import android.content.SharedPreferences; | |
| import android.os.Bundle; | |
| import android.preference.PreferenceManager; | |
| import android.view.Gravity; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import android.view.Window; | |
| import android.widget.EditText; | |
| import android.widget.Toast; | |
| public class EditSpacebarPopup extends Dialog { | |
| SharedPreferences sharedPreferences; | |
| LayoutInflater layoutInflater; | |
| String type; | |
| EditText labelTextView; | |
| EditText textTextView; | |
| EditText popupTextView; | |
| EditText iconTextView; | |
| public EditSpacebarPopup(Context context, String type) { | |
| super(context); | |
| this.type = type; | |
| layoutInflater = LayoutInflater.from(context); | |
| } | |
| public void setValues(String type) { | |
| // @TODO: this isn't working to set the default values | |
| if (type.equals("space")) { | |
| labelTextView.setText(sharedPreferences.getString(Constants.SPACEBARLABEL, "")); | |
| textTextView.setText(sharedPreferences.getString(Constants.SPACEBARTEXT, " ")); | |
| popupTextView.setText(sharedPreferences.getString(Constants.SPACEBARPOPUP, getContext().getString(R.string.popup_first))); | |
| iconTextView.setText(sharedPreferences.getString(Constants.SPACEBARICON, "ic_space")); | |
| } | |
| if (type.equals("tab")) { | |
| labelTextView.setText(sharedPreferences.getString(Constants.TABKEYLABEL, "")); | |
| textTextView.setText(sharedPreferences.getString(Constants.TABKEYTEXT, "")); | |
| popupTextView.setText(sharedPreferences.getString(Constants.TABKEYPOPUP, getContext().getString(R.string.popup_second))); | |
| iconTextView.setText(sharedPreferences.getString(Constants.TABKEYICON, "ic_tab")); | |
| } | |
| if (type.equals("enter")) { | |
| labelTextView.setText(sharedPreferences.getString(Constants.ENTERKEYLABEL, "")); | |
| textTextView.setText(sharedPreferences.getString(Constants.ENTERKEYTEXT, "")); | |
| popupTextView.setText(sharedPreferences.getString(Constants.ENTERKEYPOPUP, getContext().getString(R.string.popup_third))); | |
| iconTextView.setText(sharedPreferences.getString(Constants.ENTERKEYICON, "ic_enter")); | |
| } | |
| } | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| requestWindowFeature(Window.FEATURE_NO_TITLE); | |
| View view = layoutInflater.inflate(R.layout.edit_key_popup, null, false); | |
| setContentView(view); | |
| getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); | |
| getWindow().setBackgroundDrawableResource(R.color.transparent); | |
| getWindow().setGravity(Gravity.CENTER); | |
| setCancelable(true); | |
| sharedPreferences = PreferenceManager.getDefaultSharedPreferences(view.getContext()); | |
| labelTextView = findViewById(R.id.editLabel); | |
| textTextView = findViewById(R.id.editText); | |
| popupTextView = findViewById(R.id.editPopup); | |
| iconTextView = findViewById(R.id.editIcon); | |
| findViewById(R.id.savePopup).setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View view) { | |
| SharedPreferences.Editor sharedPreferenceEditor = sharedPreferences.edit(); | |
| if (type.equals("space")) { | |
| sharedPreferenceEditor.putString(Constants.SPACEBARLABEL, labelTextView.getText().toString()); | |
| sharedPreferenceEditor.putString(Constants.SPACEBARTEXT, textTextView.getText().toString()); | |
| sharedPreferenceEditor.putString(Constants.SPACEBARPOPUP, popupTextView.getText().toString()); | |
| sharedPreferenceEditor.putString(Constants.SPACEBARICON, iconTextView.getText().toString()); | |
| } | |
| if (type.equals("tab")) { | |
| sharedPreferenceEditor.putString(Constants.TABKEYLABEL, labelTextView.getText().toString()); | |
| sharedPreferenceEditor.putString(Constants.TABKEYTEXT, textTextView.getText().toString()); | |
| sharedPreferenceEditor.putString(Constants.TABKEYPOPUP, popupTextView.getText().toString()); | |
| sharedPreferenceEditor.putString(Constants.TABKEYICON, iconTextView.getText().toString()); | |
| } | |
| if (type.equals("enter")) { | |
| sharedPreferenceEditor.putString(Constants.ENTERKEYLABEL, labelTextView.getText().toString()); | |
| sharedPreferenceEditor.putString(Constants.ENTERKEYTEXT, textTextView.getText().toString()); | |
| sharedPreferenceEditor.putString(Constants.ENTERKEYPOPUP, popupTextView.getText().toString()); | |
| sharedPreferenceEditor.putString(Constants.ENTERKEYICON, iconTextView.getText().toString()); | |
| } | |
| sharedPreferenceEditor.apply(); | |
| Toast.makeText(view.getContext(), "Values Saved", Toast.LENGTH_SHORT).show(); | |
| dismiss(); | |
| } | |
| }); | |
| findViewById(R.id.exitPopup).setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View view) { | |
| dismiss(); | |
| } | |
| }); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Generator { | |
| static String toKeyboard(String str) { | |
| String[] rows = str.split("_"); | |
| StringBuilder keyboard = new StringBuilder("<Keyboard xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + "android:keyWidth=\"10%p\"\n" + "android:keyHeight=\"7%p\"\n" + "android:layout_width=\"wrap_content\"\n" + "android:layout_height=\"wrap_content\">\n"); | |
| for (String row : rows) { | |
| String[] keys = row.split(" "); | |
| keyboard.append("<Row>\n"); | |
| for (String key : keys) { | |
| String popup = ""; | |
| if (key.length() > 1) { | |
| popup = key.substring(1); | |
| key = key.substring(0, 1); | |
| } | |
| if (!key.equals(" ") && !key.equals("")) { | |
| keyboard.append("<Key android:codes=\"").append(key).append("\" android:keyLabel=\"").append(key).append("\" "); | |
| if (!popup.equals("")) { | |
| keyboard.append("android:popupCharacters=\"").append(popup).append("\" android:popupKeyboard=\"@layout/popup_template\""); | |
| } | |
| keyboard.append(" />\n"); | |
| } | |
| } | |
| keyboard.append("</Row>\n"); | |
| } | |
| keyboard.append("</Keyboard>\n"); | |
| return keyboard.toString(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void handleEnter() { | |
| try { | |
| // if (noop == 0) return; | |
| EditorInfo curEditor = getCurrentInputEditorInfo(); | |
| // InputType | |
| switch (curEditor.imeOptions & EditorInfo.IME_MASK_ACTION) { | |
| case EditorInfo.IME_ACTION_GO: ic.performEditorAction(EditorInfo.IME_ACTION_GO);break; | |
| case EditorInfo.IME_ACTION_SEND: ic.performEditorAction(EditorInfo.IME_ACTION_SEND);break; | |
| case EditorInfo.IME_ACTION_DONE: ic.performEditorAction(EditorInfo.IME_ACTION_DONE);break; | |
| case EditorInfo.IME_ACTION_SEARCH: ic.performEditorAction(EditorInfo.IME_ACTION_SEARCH);break; | |
| default: sendKey(KeyEvent.KEYCODE_ENTER);break; | |
| } | |
| if (sharedPreferences.getBoolean("spaces", true)) { | |
| String indent = Util.getIndentation(getPrevLine()); | |
| if (indent.length() > 0) { | |
| commitText("\n" + indent); | |
| } | |
| } | |
| } | |
| catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Hexagram { | |
| static String buildDigram(String monograms) { | |
| switch (monograms) { | |
| case "⚊⚊": | |
| return "⚌"; | |
| case "⚋⚊": | |
| return "⚍"; | |
| case "⚊⚋": | |
| return "⚎"; | |
| case "⚋⚋": | |
| return "⚏"; | |
| default: | |
| return ""; | |
| } | |
| } | |
| static String buildTrigram(String monograms) { | |
| switch (monograms) { | |
| case "⚊⚌": | |
| case "⚌⚊": | |
| case "⚊⚊⚊": | |
| return "☰"; | |
| case "⚍⚊": | |
| case "⚋⚌": | |
| case "⚋⚊⚊": | |
| return "☱"; | |
| case "⚊⚍": | |
| case "⚎⚊": | |
| case "⚊⚋⚊": | |
| return "☲"; | |
| case "⚏⚊": | |
| case "⚋⚍": | |
| case "⚋⚋⚊": | |
| return "☳"; | |
| case "⚌⚋": | |
| case "⚊⚎": | |
| case "⚊⚊⚋": | |
| return "☴"; | |
| case "⚍⚋": | |
| case "⚋⚎": | |
| case "⚋⚊⚋": | |
| return "☵"; | |
| case "⚎⚋": | |
| case "⚊⚏": | |
| case "⚊⚋⚋": | |
| return "☶"; | |
| case "⚏⚋": | |
| case "⚋⚏": | |
| case "⚋⚋⚋": | |
| return "☷"; | |
| default: | |
| return ""; | |
| } | |
| } | |
| static String buildHexagram(String trigrams) { | |
| switch (trigrams) { | |
| case "☰☰": | |
| return "䷀"; | |
| case "☰☱": | |
| return "䷸"; | |
| case "☰☲": | |
| return "䷰"; | |
| case "☰☳": | |
| return "䷐"; | |
| case "☰☴": | |
| return "䷨"; | |
| case "☰☵": | |
| return "䷘"; | |
| case "☰☶": | |
| return "䷠"; | |
| case "☰☷": | |
| return "䷈"; | |
| case "☱☰": | |
| return "䷇"; | |
| case "☱☱": | |
| return "䷿"; | |
| case "☱☲": | |
| return "䷷"; | |
| case "☱☳": | |
| return "䷗"; | |
| case "☱☴": | |
| return "䷯"; | |
| case "☱☵": | |
| return "䷟"; | |
| case "☱☶": | |
| return "䷧"; | |
| case "☱☷": | |
| return "䷏"; | |
| case "☲☰": | |
| return "䷆"; | |
| case "☲☱": | |
| return "䷾"; | |
| case "☲☲": | |
| return "䷶"; | |
| case "☲☳": | |
| return "䷖"; | |
| case "☲☴": | |
| return "䷮"; | |
| case "☲☵": | |
| return "䷞"; | |
| case "☲☶": | |
| return "䷦"; | |
| case "☲☷": | |
| return "䷎"; | |
| case "☳☰": | |
| return "䷂"; | |
| case "☳☱": | |
| return "䷺"; | |
| case "☳☲": | |
| return "䷲"; | |
| case "☳☳": | |
| return "䷒"; | |
| case "☳☴": | |
| return "䷪"; | |
| case "☳☵": | |
| return "䷚"; | |
| case "☳☶": | |
| return "䷢"; | |
| case "☳☷": | |
| return "䷊"; | |
| case "☴☰": | |
| return "䷅"; | |
| case "☴☱": | |
| return "䷽"; | |
| case "☴☲": | |
| return "䷵"; | |
| case "☴☳": | |
| return "䷕"; | |
| case "☴☴": | |
| return "䷭"; | |
| case "☴☵": | |
| return "䷝"; | |
| case "☴☶": | |
| return "䷥"; | |
| case "☴☷": | |
| return "䷍"; | |
| case "☵☰": | |
| return "䷃"; | |
| case "☵☱": | |
| return "䷻"; | |
| case "☵☲": | |
| return "䷳"; | |
| case "☵☳": | |
| return "䷓"; | |
| case "☵☴": | |
| return "䷫"; | |
| case "☵☵": | |
| return "䷛"; | |
| case "☵☶": | |
| return "䷣"; | |
| case "☵☷": | |
| return "䷋"; | |
| case "☶☰": | |
| return "䷄"; | |
| case "☶☱": | |
| return "䷼"; | |
| case "☶☲": | |
| return "䷴"; | |
| case "☶☳": | |
| return "䷔"; | |
| case "☶☴": | |
| return "䷬"; | |
| case "☶☵": | |
| return "䷜"; | |
| case "☶☶": | |
| return "䷤"; | |
| case "☶☷": | |
| return "䷌"; | |
| case "☷☰": | |
| return "䷁"; | |
| case "☷☱": | |
| return "䷹"; | |
| case "☷☲": | |
| return "䷱"; | |
| case "☷☳": | |
| return "䷑"; | |
| case "☷☴": | |
| return "䷩"; | |
| case "☷☵": | |
| return "䷙"; | |
| case "☷☶": | |
| return "䷡"; | |
| case "☷☷": | |
| return "䷉"; | |
| default: | |
| return ""; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public String getLastMorse() { | |
| ic = getCurrentInputConnection(); | |
| return ic.getTextBeforeCursor(8, 0).toString().replaceAll("[^·-]", ""); | |
| } | |
| if(currentKeyboard.key.equals("enmorse")&&!Morse.fromChar(String.valueOf((char)primaryCode)).equals(empty)) { | |
| String res = Morse.fromChar(String.valueOf((char)primaryCode)); | |
| if (kv.isShifted()) { | |
| res = res.toUpperCase(); | |
| } | |
| getKey(32).label = (char)primaryCode + " " + res; | |
| commitText(res + " "); | |
| return; | |
| } | |
| if(currentKeyboard.key.equals("enmorse") && primaryCode == 32) { | |
| commitText(" "); | |
| return; | |
| } | |
| if(currentKeyboard.key.equals("demorse")&&"·- ".contains(String.valueOf((char)primaryCode))){ | |
| if (primaryCode == 32) { | |
| String res = getLastMorse(); | |
| if (kv.isShifted()) { | |
| res = res.toUpperCase(); | |
| } | |
| ic.deleteSurroundingText(res.length(), 0); | |
| commitText(Morse.toChar(res) + ""); | |
| getKey(32).label = " "; | |
| redraw(); | |
| return; | |
| } | |
| String res = String.valueOf((char)primaryCode); | |
| if (kv.isShifted()) { | |
| res = res.toUpperCase(); | |
| } | |
| commitText(res); | |
| getKey(32).label = getLastMorse() + " " + Morse.toChar(getLastMorse()); | |
| redraw(); | |
| return; | |
| } | |
| class Morse { | |
| static String toChar(String buffer) { | |
| switch (buffer) { | |
| case "-": return "t"; | |
| case "·": return "e"; | |
| case "--": return "m"; | |
| case "-·": return "n"; | |
| case "·-": return "a"; | |
| case "··": return "i"; | |
| case "---": return "o"; | |
| case "--·": return "g"; | |
| case "-·-": return "k"; | |
| case "-··": return "d"; | |
| case "·--": return "w"; | |
| case "·-·": return "r"; | |
| case "··-": return "u"; | |
| case "···": return "s"; | |
| case "--·-": return "q"; | |
| case "--··": return "z"; | |
| case "-·--": return "y"; | |
| case "-·-·": return "c"; | |
| case "-··-": return "x"; | |
| case "-···": return "b"; | |
| case "·---": return "j"; | |
| case "·--·": return "p"; | |
| case "·-··": return "l"; | |
| case "··-·": return "f"; | |
| case "···-": return "v"; | |
| case "····": return "h"; | |
| case "-----": return "0"; | |
| case "----·": return "9"; | |
| case "---··": return "8"; | |
| case "--···": return "7"; | |
| case "-····": return "6"; | |
| case "·----": return "1"; | |
| case "··---": return "2"; | |
| case "···--": return "3"; | |
| case "····-": return "4"; | |
| case "·····": return "5"; | |
| // case "----": return "ch"; | |
| // case "----": return "ĥ"; | |
| case "----": return "š"; | |
| case "---·": return "ø"; | |
| // case "---·": return "ó"; | |
| // case "---·": return "ö"; | |
| // case "·-·-": return "ä"; | |
| // case "·-·-": return "ą"; | |
| case "·-·-": return "æ"; | |
| case "··--": return "ü"; | |
| // case "··--": return "ŭ"; | |
| case "--·--": return "ñ"; | |
| // case "--·--": return "ń"; | |
| case "--·-·": return "ĝ"; | |
| case "--··-": return "ż"; | |
| case "-·--·": return "("; | |
| case "-·-··": return "ç"; | |
| // case "-·-··": return "ć"; | |
| // case "-·-··": return "ĉ"; | |
| case "-··-·": return "/"; | |
| case "-···-": return "="; | |
| case "·---·": return "ĵ"; | |
| case "·--·-": return "à"; | |
| // case "·--·-": return "å"; | |
| case "·--··": return "þ"; | |
| case "·-·-·": return "+"; | |
| // case "·-··-": return "è"; | |
| case "·-··-": return "ł"; | |
| case "·-···": return "&"; | |
| case "··--·": return "ð"; | |
| // case "··-··": return "đ"; | |
| case "··-··": return "é"; | |
| // case "··-··": return "ę"; | |
| case "···-·": return "ŝ"; | |
| case "---···": return ":"; | |
| case "--··--": return ","; | |
| case "--··-·": return "ź"; | |
| case "-·--·-": return ")"; | |
| case "-·-·--": return "!"; | |
| case "-·-·-·": return ";"; | |
| case "-····-": return "-"; | |
| case "·----·": return "'"; | |
| case "·--·-·": return "@"; | |
| case "·-·-·-": return "."; | |
| case "·-··-·": return "\""; | |
| case "··--·-": return "_"; | |
| case "··--··": return "?"; | |
| case "···-··-": return "$"; | |
| case "···-···": return "ś"; | |
| default: return ""; | |
| } | |
| } | |
| static String fromChar(String buffer) { | |
| switch (buffer) { | |
| case " ": return " "; | |
| case "e": return "·"; | |
| case "t": return "-"; | |
| case "a": return "·-"; | |
| case "i": return "··"; | |
| case "m": return "--"; | |
| case "n": return "-·"; | |
| case "d": return "-··"; | |
| case "g": return "--·"; | |
| case "k": return "-·-"; | |
| case "o": return "---"; | |
| case "r": return "·-·"; | |
| case "s": return "···"; | |
| case "u": return "··-"; | |
| case "w": return "·--"; | |
| case "b": return "-···"; | |
| case "c": return "-·-·"; | |
| case "f": return "··-·"; | |
| case "h": return "····"; | |
| case "j": return "·---"; | |
| case "l": return "·-··"; | |
| case "p": return "·--·"; | |
| case "q": return "--·-"; | |
| case "v": return "···-"; | |
| case "x": return "-··-"; | |
| case "y": return "-·--"; | |
| case "z": return "--··"; | |
| case "0": return "-----"; | |
| case "1": return "·----"; | |
| case "2": return "··---"; | |
| case "3": return "···--"; | |
| case "4": return "····-"; | |
| case "5": return "·····"; | |
| case "6": return "-····"; | |
| case "7": return "--···"; | |
| case "8": return "---··"; | |
| case "9": return "----·"; | |
| case "ä": return "·-·-"; | |
| case "ą": return "·-·-"; | |
| case "æ": return "·-·-"; | |
| case "ĥ": return "----"; | |
| case "ó": return "---·"; | |
| case "ö": return "---·"; | |
| case "ø": return "---·"; | |
| case "š": return "----"; | |
| case "ŭ": return "··--"; | |
| case "ü": return "··--"; | |
| case "(": return "-·--·"; | |
| case "/": return "-··-·"; | |
| case "&": return "·-···"; | |
| case "+": return "·-·-·"; | |
| case "=": return "-···-"; | |
| case "à": return "·--·-"; | |
| case "å": return "·--·-"; | |
| case "ć": return "-·-··"; | |
| case "ĉ": return "-·-··"; | |
| case "ç": return "-·-··"; | |
| case "ð": return "··--·"; | |
| case "đ": return "··-··"; | |
| case "è": return "·-··-"; | |
| case "é": return "··-··"; | |
| case "ę": return "··-··"; | |
| case "ĝ": return "--·-·"; | |
| case "ĵ": return "·---·"; | |
| case "ł": return "·-··-"; | |
| case "ń": return "--·--"; | |
| case "ñ": return "--·--"; | |
| case "ŝ": return "···-·"; | |
| case "ż": return "--··-"; | |
| case "þ": return "·--··"; | |
| case "-": return "-····-"; | |
| case ",": return "--··--"; | |
| case ";": return "-·-·-·"; | |
| case ":": return "---···"; | |
| case "!": return "-·-·--"; | |
| case "?": return "··--··"; | |
| case ".": return "·-·-·-"; | |
| case "'": return "·----·"; | |
| case ")": return "-·--·-"; | |
| case "@": return "·--·-·"; | |
| case "\"": return "·-··-·"; | |
| case "ź": return "--··-·"; | |
| case "$": return "···-··-"; | |
| case "ś": return "···-···"; | |
| default: return ""; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.custom.keyboard; | |
| import android.content.Context; | |
| import android.view.GestureDetector; | |
| import android.view.GestureDetector.SimpleOnGestureListener; | |
| import android.view.MotionEvent; | |
| import android.view.View; | |
| import android.view.View.OnTouchListener; | |
| public class OnSwipeTouchListener implements View.OnTouchListener { | |
| private final GestureDetector gestureDetector; | |
| public OnSwipeTouchListener(Context ctx) { | |
| gestureDetector = new GestureDetector(ctx, new GestureListener()); | |
| } | |
| @Override | |
| public boolean onTouch(View v, MotionEvent event) { | |
| return gestureDetector.onTouchEvent(event); | |
| } | |
| private final class GestureListener extends SimpleOnGestureListener { | |
| private static final int SWIPE_THRESHOLD = 100; | |
| private static final int SWIPE_VELOCITY_THRESHOLD = 100; | |
| @Override | |
| public boolean onDown(MotionEvent e) { | |
| return true; | |
| } | |
| @Override | |
| public boolean onSingleTapUp(MotionEvent e) { | |
| onClick(); | |
| return super.onSingleTapUp(e); | |
| } | |
| @Override | |
| public boolean onDoubleTap(MotionEvent e) { | |
| onDoubleClick(); | |
| return super.onDoubleTap(e); | |
| } | |
| @Override | |
| public void onLongPress(MotionEvent e) { | |
| onLongClick(); | |
| super.onLongPress(e); | |
| } | |
| @Override | |
| public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { | |
| boolean result = false; | |
| try { | |
| float diffY = e2.getY() - e1.getY(); | |
| float diffX = e2.getX() - e1.getX(); | |
| if (Math.abs(diffX) > Math.abs(diffY)) { | |
| if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) { | |
| if (diffX > 0) { | |
| onSwipeRight(); | |
| } | |
| else { | |
| onSwipeLeft(); | |
| } | |
| result = true; | |
| } | |
| } | |
| else if (Math.abs(diffY) > SWIPE_THRESHOLD && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) { | |
| if (diffY > 0) { | |
| onSwipeBottom(); | |
| } | |
| else { | |
| onSwipeTop(); | |
| } | |
| result = true; | |
| } | |
| } | |
| catch (Exception e) { | |
| // e.printStackTrace(); | |
| } | |
| return result; | |
| } | |
| } | |
| public void onSwipeRight() {} | |
| public void onSwipeLeft() {} | |
| public void onSwipeTop() {} | |
| public void onSwipeBottom() {} | |
| public void onClick() {} | |
| public void onDoubleClick() {} | |
| public void onLongClick() {} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void populateLayouts() { | |
| sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); | |
| layouts.clear(); | |
| layouts.add(new CustomKeyboard(this, R.layout.primary, "primary", "qwerty").setCategory(Category.Main)); | |
| if (sharedPreferences.getBoolean("accents", true)) { layouts.add(new CustomKeyboard(this, R.layout.accents, "accents", "◌̀◌́◌̂").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("armenian", false)) { layouts.add(new CustomKeyboard(this, R.layout.armenian, "armenian", "աբգդեզ").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("braille", false)) { layouts.add(new CustomKeyboard(this, R.layout.braille, "braille", "⠟⠺⠑⠗⠞⠽").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("caps", false)) { layouts.add(new CustomKeyboard(this, R.layout.caps, "caps", "ҩᴡᴇʀᴛʏ").setCategory(Category.Font)); } | |
| if (sharedPreferences.getBoolean("cherokee", false)) { layouts.add(new CustomKeyboard(this, R.layout.cherokee, "cherokee", "ꭰꭱꭲꭳꭴꭵ").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("coding", false)) { layouts.add(new CustomKeyboard(this, R.layout.coding, "coding", "∅⊤⊥").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("coptic", true)) { layouts.add(new CustomKeyboard(this, R.layout.coptic, "coptic", "ⲑϣⲉⲣⲧⲯ").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("cree", false)) { layouts.add(new CustomKeyboard(this, R.layout.cree, "cree", "ᐁᐯᑌᑫᒉᒣ").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("cyrillic", true)) { layouts.add(new CustomKeyboard(this, R.layout.cyrillic, "cyrillic", "йцукен").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("deseret", false)) { layouts.add(new CustomKeyboard(this, R.layout.deseret, "deseret", "𐐨𐐩𐐪𐐫𐐬𐐭").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("drawing", false)) { layouts.add(new CustomKeyboard(this, R.layout.drawing, "drawing", "├─┤").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("dvorak", false)) { layouts.add(new CustomKeyboard(this, R.layout.dvorak, "dvorak", "pyfgcr").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("emoji", true)) { layouts.add(new CustomKeyboard(this, R.layout.emoji, "emoji", "😀😁😂").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("etruscan", false)) { layouts.add(new CustomKeyboard(this, R.layout.etruscan, "etruscan", "𐌀𐌁𐌂𐌃𐌄𐌅").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("extra", false)) { layouts.add(new CustomKeyboard(this, R.layout.extra, "extra", "☳ツᰄ").setCategory(Category.Util).setOrder(-4)); } | |
| if (sharedPreferences.getBoolean("fancy", true)) { layouts.add(new CustomKeyboard(this, R.layout.fancy, "fancy", "ɋƿҽꝛþү").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("fonts", true)) { layouts.add(new CustomKeyboard(this, R.layout.fonts, "fonts", "🄰🅐🄐𝔸𝕬𝒜").setCategory(Category.Font)); } | |
| if (sharedPreferences.getBoolean("function", true)) { layouts.add(new CustomKeyboard(this, R.layout.function, "function", "ƒ(x)").setCategory(Category.Util).setOrder(-2)); } | |
| if (sharedPreferences.getBoolean("futhark", true)) { layouts.add(new CustomKeyboard(this, R.layout.futhark, "futhark", "ᚠᚢᚦᚨᚱᚲ").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("georgian", false)) { layouts.add(new CustomKeyboard(this, R.layout.georgian, "georgian", "აბგდევ").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("glagolitic", false)) { layouts.add(new CustomKeyboard(this, R.layout.glagolitic, "glagolitic", "ⰀⰁⰂⰃⰄⰅ").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("greek", true)) { layouts.add(new CustomKeyboard(this, R.layout.greek, "greek", "ςερτυθ").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("hex", true)) { layouts.add(new CustomKeyboard(this, R.layout.hex, "hex", "\\uabcd").setCategory(Category.Util)); } | |
| if (sharedPreferences.getBoolean("ipa", true)) { layouts.add(new CustomKeyboard(this, R.layout.ipa, "IPA", "ɋʍəɹʈɥ").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("kana", false)) { layouts.add(new CustomKeyboard(this, R.layout.hiragana, "kana", "あいうえお").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("lisu", false)) { layouts.add(new CustomKeyboard(this, R.layout.lisu, "lisu", "ⵚꓟꓱꓤꓕ⅄").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("macros", true)) { layouts.add(new CustomKeyboard(this, R.layout.macros, "macros", "✐").setCategory(Category.Util).setOrder(-4)); } | |
| if (sharedPreferences.getBoolean("math", true)) { layouts.add(new CustomKeyboard(this, R.layout.math, "math", "+−×÷=%").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("mirror", false)) { layouts.add(new CustomKeyboard(this, R.layout.mirror, "mirror", "ytrewq").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("morse", false)) { layouts.add(new CustomKeyboard(this, R.layout.enmorse, "morse", "·-·-").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("navigation", true)) { layouts.add(new CustomKeyboard(this, R.layout.navigation, "navigation", "→←↑↓").setCategory(Category.Util).setOrder(-1)); } | |
| if (sharedPreferences.getBoolean("numeric", false)) { layouts.add(new CustomKeyboard(this, R.layout.numeric, "numeric", "123456").setCategory(Category.Util)); } | |
| if (sharedPreferences.getBoolean("ogham", false)) { layouts.add(new CustomKeyboard(this, R.layout.ogham, "ogham", "᚛ᚁᚆᚋᚐ᚜").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("pinyin", false)) { layouts.add(new CustomKeyboard(this, R.layout.pinyin, "pinyin", "").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("rotated", false)) { layouts.add(new CustomKeyboard(this, R.layout.rotated, "rotated", "ʎʇɹəʍb").setCategory(Category.Font)); } | |
| if (sharedPreferences.getBoolean("shortcuts", false)) { layouts.add(new CustomKeyboard(this, R.layout.shortcuts, "shortcuts", "").setCategory(Category.Util)); } | |
| if (sharedPreferences.getBoolean("stealth", false)) { layouts.add(new CustomKeyboard(this, R.layout.stealth, "stealth", "ԛԝеrtу").setCategory(Category.Font)); } | |
| if (sharedPreferences.getBoolean("symbol", true)) { layouts.add(new CustomKeyboard(this, R.layout.symbol, "symbol", "!@#$%^").setCategory(Category.Misc)); } | |
| if (sharedPreferences.getBoolean("tifinagh", false)) { layouts.add(new CustomKeyboard(this, R.layout.tifinagh, "tifinagh", "ⴰⴱⴳⴷⴹⴻ").setCategory(Category.Lang)); } | |
| if (sharedPreferences.getBoolean("unicode", true)) { layouts.add(new CustomKeyboard(this, R.layout.unicode, "unicode", "\\uxxxx").setCategory(Category.Util)); } | |
| if (sharedPreferences.getBoolean("url", false)) { layouts.add(new CustomKeyboard(this, R.layout.url, "URL", "@/.com").setCategory(Category.Util)); } | |
| if (sharedPreferences.getBoolean("utility", true)) { layouts.add(new CustomKeyboard(this, R.layout.utility, "utility", "/**/").setCategory(Category.Util).setOrder(-3)); } | |
| if (sharedPreferences.getBoolean("zhuyin", false)) { | |
| layouts.add(new CustomKeyboard(this, R.layout.zhuyin, "zhuyin", "ㄅㄆㄇㄈ").setCategory(Category.Lang)); | |
| } | |
| int layoutLayout = R.layout.layouts; | |
| layouts.add(new CustomKeyboard(this, layoutLayout, "Layouts").setOrder(-1)); | |
| if (getKeyboard("Layouts") != null) { | |
| for (Keyboard.Key key : getKeyboard("Layouts").getKeys()) { | |
| if (key.codes[0] <= layoutMin && key.codes[0] >= layoutMax) { | |
| try { | |
| CustomKeyboard layout = layouts.get(-key.codes[0] + layoutMin); | |
| if (layout != null && !layout.title.equals("Layouts")) { | |
| if (sharedPreferences.getBoolean("names", true)) { key.label = layout.title; } | |
| else { key.label = layout.label; } | |
| } | |
| else { key.label = empty; } | |
| } | |
| catch (Exception e) { | |
| key.label = empty; | |
| } | |
| } | |
| } | |
| } | |
| adjustLayoutPage(); | |
| StringBuilder autoLabel; | |
| for (CustomKeyboard layout : layouts) { | |
| autoLabel = new StringBuilder(); | |
| for (Keyboard.Key key : layout.getKeys()) { | |
| if (key.label == null) { continue; } | |
| if (key.label == empty) { continue; } | |
| if (key.label.length() > 1) { continue; } | |
| if (Util.isNumeric(String.valueOf(key.label))) { continue; } | |
| if (",\";".contains(String.valueOf(key.label))) { continue; } | |
| autoLabel.append(key.label); | |
| if (autoLabel.length() > 2) { break; } | |
| } | |
| String label = autoLabel.toString().trim(); | |
| if (layout.label == null || layout.label.equals(empty)) { | |
| layout.label = label; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.custom.keyboard; | |
| import android.content.Context; | |
| import android.content.DialogInterface; | |
| import android.content.Intent; | |
| import android.content.SharedPreferences; | |
| import android.os.Bundle; | |
| import android.preference.CheckBoxPreference; | |
| import android.preference.EditTextPreference; | |
| import android.preference.ListPreference; | |
| import android.preference.PreferenceCategory; | |
| import android.preference.PreferenceManager; | |
| import android.preference.PreferenceScreen; | |
| import android.preference.Preference; | |
| public class PreferenceFragment extends android.preference.PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { | |
| Context baseContext; | |
| SharedPreferences sharedPreferences; | |
| ListPreference listTheme; | |
| ListPreference listDefaultLayout; | |
| EditTextPreference bg; | |
| EditTextPreference fg; | |
| EditTextPreference text_size; | |
| EditTextPreference seps; | |
| EditTextPreference popup_first; | |
| EditTextPreference popup_second; | |
| EditTextPreference popup_third; | |
| EditTextPreference name; | |
| EditTextPreference email; | |
| EditTextPreference phone; | |
| EditTextPreference address; | |
| EditTextPreference k1; | |
| EditTextPreference k2; | |
| EditTextPreference k3; | |
| EditTextPreference k4; | |
| EditTextPreference k5; | |
| EditTextPreference k6; | |
| EditTextPreference k7; | |
| EditTextPreference k8; | |
| @Override | |
| public void onCreate(Bundle s) { | |
| super.onCreate(s); | |
| baseContext = getActivity().getBaseContext(); | |
| sharedPreferences = PreferenceManager.getDefaultSharedPreferences(baseContext); | |
| try { | |
| addPreferencesFromResource(R.xml.preferences); | |
| PreferenceManager.setDefaultValues(baseContext, R.xml.preferences, true); | |
| } | |
| catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| listDefaultLayout = (ListPreference)findPreference("default_layout"); | |
| listDefaultLayout.setSummary(listDefaultLayout.getEntry()); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| listTheme = (ListPreference)findPreference("theme"); | |
| listTheme.setSummary(listTheme.getEntry()); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| bg = (EditTextPreference)findPreference("bg"); | |
| fg = (EditTextPreference)findPreference("fg"); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| text_size = (EditTextPreference)findPreference("text_size"); | |
| seps = (EditTextPreference)findPreference("seps"); | |
| popup_first = (EditTextPreference)findPreference("popup_first"); | |
| popup_second = (EditTextPreference)findPreference("popup_second"); | |
| popup_third = (EditTextPreference)findPreference("popup_third"); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| popup_first.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { | |
| @Override | |
| public boolean onPreferenceClick(Preference preference) { | |
| EditSpacebarPopup popup = new EditSpacebarPopup(getContext(),"space"); | |
| popup.show(); | |
| popup.setOnDismissListener(new DialogInterface.OnDismissListener() { | |
| @Override | |
| public void onDismiss(DialogInterface dialog) { | |
| popup_first.getDialog().dismiss(); | |
| } | |
| }); | |
| return false; | |
| } | |
| }); | |
| popup_second.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { | |
| @Override | |
| public boolean onPreferenceClick(Preference preference) { | |
| EditSpacebarPopup popup = new EditSpacebarPopup(getContext(),"tab"); | |
| popup.show(); | |
| popup.setOnDismissListener(new DialogInterface.OnDismissListener() { | |
| @Override | |
| public void onDismiss(DialogInterface dialog) { | |
| popup_second.getDialog().dismiss(); | |
| } | |
| }); | |
| return false; | |
| } | |
| }); | |
| try { | |
| k1 = (EditTextPreference)findPreference("k1"); | |
| k2 = (EditTextPreference)findPreference("k2"); | |
| k3 = (EditTextPreference)findPreference("k3"); | |
| k4 = (EditTextPreference)findPreference("k4"); | |
| k5 = (EditTextPreference)findPreference("k5"); | |
| k6 = (EditTextPreference)findPreference("k6"); | |
| k7 = (EditTextPreference)findPreference("k7"); | |
| k8 = (EditTextPreference)findPreference("k8"); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| name = (EditTextPreference)findPreference("name"); | |
| name.setSummary(sharedPreferences.getString("name", "")); | |
| email = (EditTextPreference)findPreference("email"); | |
| email.setSummary(sharedPreferences.getString("email", "")); | |
| phone = (EditTextPreference)findPreference("phone"); | |
| phone.setSummary(sharedPreferences.getString("phone", "")); | |
| address = (EditTextPreference)findPreference("address"); | |
| address.setSummary(sharedPreferences.getString("address", "")); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| bg.setSummary(sharedPreferences.getString("bg", "")); | |
| fg.setSummary(sharedPreferences.getString("fg", "")); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| text_size.setSummary(sharedPreferences.getString("text_size", "")); | |
| seps.setSummary(sharedPreferences.getString("seps", "")); | |
| popup_first.setSummary(sharedPreferences.getString("popup_first", "")); | |
| popup_second.setSummary(sharedPreferences.getString("popup_second", "")); | |
| popup_third.setSummary(sharedPreferences.getString("popup_third", "")); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| k1.setSummary(sharedPreferences.getString("k1", "")); | |
| k2.setSummary(sharedPreferences.getString("k2", "")); | |
| k3.setSummary(sharedPreferences.getString("k3", "")); | |
| k4.setSummary(sharedPreferences.getString("k4", "")); | |
| k5.setSummary(sharedPreferences.getString("k5", "")); | |
| k6.setSummary(sharedPreferences.getString("k6", "")); | |
| k7.setSummary(sharedPreferences.getString("k7", "")); | |
| k8.setSummary(sharedPreferences.getString("k8", "")); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| PreferenceScreen preferences = (PreferenceScreen)findPreference("layouts"); | |
| if (sharedPreferences.getBoolean("custom_order", false)) { | |
| for(int i = 0; i < CustomInputMethodService.layouts.size(); i++) { | |
| CustomKeyboard kv = CustomInputMethodService.layouts.get(i); | |
| CheckBoxPreference preference; | |
| preference = (CheckBoxPreference)(preferences.findPreference(kv.key)); | |
| preference.setOrder(preferences.getPreferenceCount()-kv.order); | |
| } | |
| } | |
| sharedPreferences.registerOnSharedPreferenceChangeListener(this); | |
| } | |
| @Override | |
| public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) { | |
| CheckBoxPreference preference; | |
| if (s.equals("all")) { | |
| boolean isChecked = ((CheckBoxPreference)findPreference("all")).isChecked(); | |
| try {((CheckBoxPreference)findPreference("primary")).setChecked(isChecked);} | |
| catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try {((CheckBoxPreference)findPreference("secondary")).setChecked(isChecked);} | |
| catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try {((CheckBoxPreference)findPreference("tertiary")).setChecked(isChecked);} | |
| catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try {((CheckBoxPreference)findPreference("forthary")).setChecked(isChecked);} | |
| catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| } | |
| if (s.equals("primary")) { | |
| PreferenceCategory preferences = (PreferenceCategory)findPreference("primary_category"); | |
| boolean isChecked = ((CheckBoxPreference)findPreference("primary")).isChecked(); | |
| for(int i = 0; i < preferences.getPreferenceCount(); i++) { | |
| try { | |
| preference = (CheckBoxPreference)(preferences.getPreference(i)); | |
| preference.setChecked(isChecked); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| } | |
| } | |
| if (s.equals("secondary")) { | |
| PreferenceCategory preferences = (PreferenceCategory)findPreference("secondary_category"); | |
| boolean isChecked = ((CheckBoxPreference)findPreference("secondary")).isChecked(); | |
| for(int i = 0; i < preferences.getPreferenceCount(); i++) { | |
| try { | |
| preference = (CheckBoxPreference)(preferences.getPreference(i)); | |
| preference.setChecked(isChecked); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| } | |
| } | |
| if (s.equals("tertiary")) { | |
| PreferenceCategory preferences = (PreferenceCategory)findPreference("tertiary_category"); | |
| boolean isChecked = ((CheckBoxPreference)findPreference("tertiary")).isChecked(); | |
| for(int i = 0; i < preferences.getPreferenceCount(); i++) { | |
| try { | |
| preference = (CheckBoxPreference)(preferences.getPreference(i)); | |
| preference.setChecked(isChecked); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| } | |
| } | |
| if (s.equals("forthary")) { | |
| PreferenceCategory preferences = (PreferenceCategory)findPreference("forthary_category"); | |
| boolean isChecked = ((CheckBoxPreference)findPreference("forthary")).isChecked(); | |
| for(int i = 0; i < preferences.getPreferenceCount(); i++) { | |
| try { | |
| preference = (CheckBoxPreference)(preferences.getPreference(i)); | |
| preference.setChecked(isChecked); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| } | |
| } | |
| try { | |
| Intent intent = new Intent("updateKeyboard"); | |
| getContext().sendBroadcast(intent); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| listDefaultLayout = (ListPreference)findPreference("default_layout"); | |
| listDefaultLayout.setSummary(listDefaultLayout.getEntry()); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| bg.setSummary(sharedPreferences.getString("bg", "")); | |
| fg.setSummary(sharedPreferences.getString("fg", "")); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| listTheme = (ListPreference)findPreference("theme"); | |
| listTheme.setSummary(listTheme.getEntry()); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| text_size.setSummary(sharedPreferences.getString("text_size", "")); | |
| seps.setSummary(sharedPreferences.getString("seps", "")); | |
| popup_first.setSummary(sharedPreferences.getString("popup_first", "")); | |
| popup_second.setSummary(sharedPreferences.getString("popup_second", "")); | |
| popup_third.setSummary(sharedPreferences.getString("popup_third", "")); | |
| name.setSummary(sharedPreferences.getString("title", "")); | |
| email.setSummary(sharedPreferences.getString("email", "")); | |
| phone.setSummary(sharedPreferences.getString("phone", "")); | |
| address.setSummary(sharedPreferences.getString("address", "")); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| try { | |
| k1.setSummary(sharedPreferences.getString("k1", "")); | |
| k2.setSummary(sharedPreferences.getString("k2", "")); | |
| k3.setSummary(sharedPreferences.getString("k3", "")); | |
| k4.setSummary(sharedPreferences.getString("k4", "")); | |
| k5.setSummary(sharedPreferences.getString("k5", "")); | |
| k6.setSummary(sharedPreferences.getString("k6", "")); | |
| k7.setSummary(sharedPreferences.getString("k7", "")); | |
| k8.setSummary(sharedPreferences.getString("k8", "")); | |
| } catch (Exception e) { | |
| System.out.println(e); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case -144: commitText(Util.pickALetter()); break; | |
| case -95: commitText(Util.flipACoin()); break; | |
| case -96: commitText(Util.rollADie()); break; | |
| case -103: | |
| commitText(Util.castALot()); | |
| String trigram; | |
| if (!Hexagram.buildTrigram(ic.getTextBeforeCursor(3, 0).toString()).equals(empty)) { | |
| trigram = Hexagram.buildTrigram(ic.getTextBeforeCursor(3, 0).toString()); | |
| ic.deleteSurroundingText(3, 0); | |
| commitText(trigram); | |
| } | |
| if (!Hexagram.buildTrigram(ic.getTextBeforeCursor(2, 0).toString()).equals(empty)) { | |
| trigram = Hexagram.buildTrigram(ic.getTextBeforeCursor(2, 0).toString()); | |
| ic.deleteSurroundingText(2, 0); | |
| commitText(trigram); | |
| } | |
| if (!Hexagram.buildDigram(ic.getTextBeforeCursor(2, 0).toString()).equals(empty)) { | |
| trigram = Hexagram.buildDigram(ic.getTextBeforeCursor(2, 0).toString()); | |
| ic.deleteSurroundingText(2, 0); | |
| commitText(trigram); | |
| } | |
| if (!Hexagram.buildHexagram(ic.getTextBeforeCursor(2, 0).toString()).equals(empty)) { | |
| trigram = Hexagram.buildHexagram(ic.getTextBeforeCursor(2, 0).toString()); | |
| ic.deleteSurroundingText(2, 0); | |
| commitText(trigram); | |
| } | |
| break; | |
| case -115: commitText(Util.generateRandomInt(1, 10) + " "); break; | |
| case -116: commitText(Util.nowAsLong() + " " + Util.nowAsInt()); break; | |
| case -180: commitText(Util.shake8Ball()); break; | |
| case -181: commitText(Util.pickACard()); break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Keyboard xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:keyWidth="12.5%p" | |
| android:keyHeight="7%p" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content"> | |
| <Row android:keyWidth="9.09%p"> | |
| <Key android:keyOutputText="ABCDEFGHIJKLMNOPQRSTUVWXYZ" android:keyLabel="ABC" android:keyWidth="10%p" /> | |
| <Key android:keyOutputText="ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ" android:keyLabel="ΑΒΓ" android:keyWidth="10%p" /> | |
| <Key android:keyOutputText="ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠϤⲢⲤⲦⲨⲪⲬⲮⲰⳀϢϦϨϪϬϮ" android:keyLabel="ⲀⲂⲄ" android:keyWidth="10%p" /> | |
| <Key android:keyOutputText="АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ" android:keyLabel="АБГ" android:keyWidth="10%p" /> | |
| <Key android:codes="\u200B" android:keyIcon="@drawable/ic_zwsp_plus" /> | |
| <Key android:codes="-172" android:keyIcon="@drawable/ic_zwsp_arrow" /> | |
| <Key android:codes="-173" android:keyIcon="@drawable/ic_zwsp_minus" /> | |
| </Row> | |
| <Row android:keyWidth="10%p"> | |
| <Key android:codes="9675" android:keyLabel="○" android:popupCharacters="●◉◎◐◑◒◓◯❍" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9633" android:keyLabel="□" android:popupCharacters="■▢▣▤▥▦▧▨▩❏❐❑❒⧠" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9671" android:keyLabel="◇" android:popupCharacters="◆◈⌂" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9661" android:keyLabel="▽" android:popupCharacters="▼◀▶" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9651" android:keyLabel="△" android:popupCharacters="▲◀▶" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9734" android:keyLabel="☆" android:popupCharacters="★✩✪✫✬✭✮✯✰⛤⛥⛦⛧" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9831" android:keyLabel="♧" android:popupCharacters="♣" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9828" android:keyLabel="♤" android:popupCharacters="♠" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9826" android:keyLabel="♢" android:popupCharacters="♦" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9825" android:keyLabel="♡" android:popupCharacters="❥♥❤❣" android:popupKeyboard="@layout/popup_template" /> | |
| </Row> | |
| <Row android:keyWidth="10%p"> | |
| <Key android:codes="7172" android:keyLabel="ᰄ" android:popupCharacters="ಱ" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="3846" android:keyLabel="༆" android:popupCharacters="༈" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="1421" android:keyLabel="֍" android:popupCharacters="֎꩜꥟᪤" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="10054" android:keyLabel="❆" android:popupCharacters="❄❅✻✼✽✾✿❀" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9991" android:keyLabel="✇" android:popupCharacters="⎈☣" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="1758" android:keyLabel="۞" android:popupCharacters="✱✲✵✶✷✸✹✺" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="42606" android:keyLabel="ꙮ" android:popupCharacters="᪣᪥" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="11801" android:keyLabel="⸙" android:popupCharacters="⸎᯾" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9998" android:keyLabel="✎" android:popupCharacters="✏✐✑✒" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="9004" android:keyLabel="⌬" android:popupCharacters="⌬⏣⬡⎔" android:popupKeyboard="@layout/popup_template" /> | |
| </Row> | |
| <Row android:keyWidth="10%p"> | |
| <Key android:codes="9988" android:keyLabel="✄" android:popupCharacters="✁✃✂" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="7165" android:keyLabel="᯽" android:popupCharacters="᯼" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="-115" android:keyIcon="@drawable/ic_random" /> | |
| <Key android:codes="-95" android:keyIcon="@drawable/ic_coin_flip" android:popupCharacters="ⒽⓉ" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="-96" android:keyIcon="@drawable/ic_dice_roll" android:keyLabel="🎲" android:popupCharacters="⚀⚁⚂⚃⚄⚅" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="-180" android:keyLabel="🎱" android:popupCharacters="🎱" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="-103" android:keyIcon="@drawable/ic_hexagram" android:popupCharacters="⚊⚋⚌⚍⚎⚏" android:popupKeyboard="@layout/popup_template" /> | |
| <Key android:codes="+8253" android:keyLabel="‽" /> | |
| <Key android:codes="10062" android:keyLabel="❎" /> | |
| <Key android:codes="+9989" android:keyLabel="✅" /> | |
| </Row> | |
| </Keyboard> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void setTheme() { | |
| sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); | |
| // int fg = sharedPreferences.getInt("fg", -1677216); | |
| // String foreground = Integer.toHexString(fg); | |
| String foreground = sharedPreferences.getString("fg", "#ffffff"); | |
| String fgA = foreground.substring(0, 2); | |
| String fgR = foreground.substring(2, 4); | |
| String fgG = foreground.substring(4, 6); | |
| String fgB = foreground.substring(6, 8); | |
| // int bg = sharedPreferences.getInt("bg", -1); | |
| // String background = Integer.toHexString(bg); | |
| String background = sharedPreferences.getString("bg", "#000000"); | |
| String bgA = background.substring(0, 2); | |
| String bgR = background.substring(2, 4); | |
| String bgG = background.substring(4, 6); | |
| String bgB = background.substring(6, 8); | |
| toastIt(fgA + " " + fgR + " " + fgG + " " + fgB + "\n" + bgA + " " + bgR + " " + bgG + " " + bgB); | |
| float[] sCustomColorArray = { | |
| 1.0f, 0, 0, 0, Long.parseLong(bgR, 16), // red | |
| 0, 1.0f, 0, 0, Long.parseLong(bgG, 16), // green | |
| 0, 0, 1.0f, 0, Long.parseLong(bgB, 16), // blue | |
| 0, 0, 0, 1.0f, Long.parseLong(bgA, 16) // alpha | |
| }; | |
| mDefaultFilter = sCustomColorArray; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment