diff --git a/app/build.gradle b/app/build.gradle
index 8fcf67c8c..dd0260879 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -114,4 +114,5 @@ dependencies {
// Icon pack, classic for all, material for libre and pro
implementation project(path: ':icon-pack-classic')
implementation project(path: ':icon-pack-material')
+ implementation project(path: ':magikeyboard')
}
diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/NestedSettingsFragment.java b/app/src/main/java/com/kunzisoft/keepass/settings/NestedSettingsFragment.java
index bf4357c82..e8fbd0f4c 100644
--- a/app/src/main/java/com/kunzisoft/keepass/settings/NestedSettingsFragment.java
+++ b/app/src/main/java/com/kunzisoft/keepass/settings/NestedSettingsFragment.java
@@ -39,6 +39,7 @@ import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.util.Log;
import android.view.autofill.AutofillManager;
+import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
import com.kunzisoft.keepass.BuildConfig;
@@ -60,6 +61,8 @@ import com.kunzisoft.keepass.settings.preferenceDialogFragment.ParallelismPrefer
import com.kunzisoft.keepass.settings.preferenceDialogFragment.RoundsPreferenceDialogFragmentCompat;
import com.kunzisoft.keepass.stylish.Stylish;
+import static android.content.Context.INPUT_METHOD_SERVICE;
+
public class NestedSettingsFragment extends PreferenceFragmentCompat
implements Preference.OnPreferenceClickListener {
@@ -277,8 +280,16 @@ public class NestedSettingsFragment extends PreferenceFragmentCompat
});
}
+ // TODO define the checkbox by verifying
SwitchPreference keyboardPreference = (SwitchPreference) findPreference(getString(R.string.magic_keyboard_key));
- preferenceInDevelopment(keyboardPreference);
+ keyboardPreference.setOnPreferenceClickListener(preference -> {
+ if (getContext() != null) {
+ InputMethodManager imeManager = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
+ if (imeManager != null)
+ imeManager.showInputMethodPicker();
+ }
+ return false;
+ });
break;
diff --git a/magikeyboard/.gitignore b/magikeyboard/.gitignore
new file mode 100644
index 000000000..796b96d1c
--- /dev/null
+++ b/magikeyboard/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/magikeyboard/build.gradle b/magikeyboard/build.gradle
new file mode 100644
index 000000000..79f502b08
--- /dev/null
+++ b/magikeyboard/build.gradle
@@ -0,0 +1,28 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 27
+
+ defaultConfig {
+ minSdkVersion 14
+ targetSdkVersion 27
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'com.android.support:appcompat-v7:27.1.1'
+}
diff --git a/magikeyboard/proguard-rules.pro b/magikeyboard/proguard-rules.pro
new file mode 100644
index 000000000..f1b424510
--- /dev/null
+++ b/magikeyboard/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/magikeyboard/src/main/AndroidManifest.xml b/magikeyboard/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..2b2d4f271
--- /dev/null
+++ b/magikeyboard/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/java/com/kunzisoft/magikeyboard/MagikIME.java b/magikeyboard/src/main/java/com/kunzisoft/magikeyboard/MagikIME.java
new file mode 100644
index 000000000..80fae420b
--- /dev/null
+++ b/magikeyboard/src/main/java/com/kunzisoft/magikeyboard/MagikIME.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2018 Jeremy Jamet / Kunzisoft.
+ *
+ * This file is part of KeePass DX.
+ *
+ * KeePass DX is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * KeePass DX is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with KeePass DX. If not, see .
+ *
+ */
+package com.kunzisoft.magikeyboard;
+
+import android.inputmethodservice.InputMethodService;
+import android.inputmethodservice.Keyboard;
+import android.inputmethodservice.KeyboardView;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.InputConnection;
+import android.view.inputmethod.InputMethodManager;
+
+public class MagikIME extends InputMethodService
+ implements KeyboardView.OnKeyboardActionListener {
+ private static final String TAG = MagikIME.class.getName();
+
+ private static final int KEY_CHANGE_KEYBOARD = 600;
+ private static final int KEY_LOCK = 610;
+ private static final int KEY_ENTRY = 620;
+ private static final int KEY_USERNAME = 500;
+ private static final int KEY_PASSWORD = 510;
+ private static final int KEY_URL = 520;
+ private static final int KEY_FIELDS = 530;
+
+ private KeyboardView keyboardView;
+ private Keyboard keyboard;
+
+ @Override
+ public View onCreateInputView() {
+ keyboardView = (KeyboardView) getLayoutInflater().inflate(R.layout.keyboard, null);
+ keyboard = new Keyboard(this, R.xml.password_keys);
+ keyboardView.setKeyboard(keyboard);
+ keyboardView.setOnKeyboardActionListener(this);
+ keyboardView.setPreviewEnabled(false);
+ return keyboardView;
+ }
+
+ @Override
+ public void onKey(int primaryCode, int[] keyCodes) {
+ InputConnection ic = getCurrentInputConnection();
+ switch(primaryCode){
+ case KEY_CHANGE_KEYBOARD:
+ InputMethodManager imeManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
+ if (imeManager != null)
+ imeManager.showInputMethodPicker();
+ break;
+ case KEY_LOCK:
+ break;
+ case KEY_ENTRY:
+ break;
+ case KEY_USERNAME:
+ break;
+ case KEY_PASSWORD:
+ break;
+ case KEY_URL:
+ break;
+ case KEY_FIELDS:
+ break;
+ case Keyboard.KEYCODE_DELETE :
+ ic.deleteSurroundingText(1, 0);
+ break;
+ case Keyboard.KEYCODE_DONE:
+ ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
+ break;
+ default:
+ }
+ }
+
+
+ @Override
+ public void onPress(int primaryCode) {
+ }
+
+ @Override
+ public void onRelease(int primaryCode) {
+ }
+
+ @Override
+ public void onText(CharSequence text) {
+ }
+
+ @Override
+ public void swipeDown() {
+ }
+
+ @Override
+ public void swipeLeft() {
+ }
+
+ @Override
+ public void swipeRight() {
+ }
+
+ @Override
+ public void swipeUp() {
+ }
+}
\ No newline at end of file
diff --git a/magikeyboard/src/main/java/com/kunzisoft/magikeyboard/MagikIMESettings.java b/magikeyboard/src/main/java/com/kunzisoft/magikeyboard/MagikIMESettings.java
new file mode 100644
index 000000000..adba94da5
--- /dev/null
+++ b/magikeyboard/src/main/java/com/kunzisoft/magikeyboard/MagikIMESettings.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2018 Jeremy Jamet / Kunzisoft.
+ *
+ * This file is part of KeePass DX.
+ *
+ * KeePass DX is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * KeePass DX is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with KeePass DX. If not, see .
+ *
+ */
+package com.kunzisoft.magikeyboard;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+
+public class MagikIMESettings extends PreferenceActivity {
+ @Override
+ public Intent getIntent() {
+ final Intent modIntent = new Intent(super.getIntent());
+ modIntent.putExtra(EXTRA_SHOW_FRAGMENT, Settings.class.getName());
+ modIntent.putExtra(EXTRA_NO_HEADERS, true);
+ return modIntent;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // We overwrite the title of the activity, as the default one is "Voice Search".
+ setTitle(R.string.keyboard_name);
+ }
+
+ @Override
+ protected boolean isValidFragment(final String fragmentName) {
+ return Settings.class.getName().equals(fragmentName);
+ }
+
+ public static class Settings extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Load the preferences from an XML resource
+ addPreferencesFromResource(R.xml.ime_preferences);
+ }
+ }
+}
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/drawable-v21/key_background_normal.xml b/magikeyboard/src/main/res/drawable-v21/key_background_normal.xml
new file mode 100644
index 000000000..efff84f2e
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable-v21/key_background_normal.xml
@@ -0,0 +1,37 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/drawable/ic_backspace_white_24dp.xml b/magikeyboard/src/main/res/drawable/ic_backspace_white_24dp.xml
new file mode 100644
index 000000000..d480b8bec
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/ic_backspace_white_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/magikeyboard/src/main/res/drawable/ic_comment_white_24dp.xml b/magikeyboard/src/main/res/drawable/ic_comment_white_24dp.xml
new file mode 100644
index 000000000..779c38973
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/ic_comment_white_24dp.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/magikeyboard/src/main/res/drawable/ic_keyboard_return_white_24dp.xml b/magikeyboard/src/main/res/drawable/ic_keyboard_return_white_24dp.xml
new file mode 100644
index 000000000..f848f9eec
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/ic_keyboard_return_white_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/magikeyboard/src/main/res/drawable/ic_keyboard_white_24dp.xml b/magikeyboard/src/main/res/drawable/ic_keyboard_white_24dp.xml
new file mode 100644
index 000000000..0515c9b9e
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/ic_keyboard_white_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/magikeyboard/src/main/res/drawable/ic_link_black_24dp.xml b/magikeyboard/src/main/res/drawable/ic_link_black_24dp.xml
new file mode 100644
index 000000000..d9f3fe38b
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/ic_link_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/magikeyboard/src/main/res/drawable/ic_list_white_24dp.xml b/magikeyboard/src/main/res/drawable/ic_list_white_24dp.xml
new file mode 100644
index 000000000..7f5d99c3b
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/ic_list_white_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/magikeyboard/src/main/res/drawable/ic_lock_white_24dp.xml b/magikeyboard/src/main/res/drawable/ic_lock_white_24dp.xml
new file mode 100644
index 000000000..27a2aa1dc
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/ic_lock_white_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/magikeyboard/src/main/res/drawable/ic_password_white_24dp.xml b/magikeyboard/src/main/res/drawable/ic_password_white_24dp.xml
new file mode 100644
index 000000000..3b23b78f6
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/ic_password_white_24dp.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/drawable/ic_person_white_24dp.xml b/magikeyboard/src/main/res/drawable/ic_person_white_24dp.xml
new file mode 100644
index 000000000..29620f4a5
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/ic_person_white_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/magikeyboard/src/main/res/drawable/key_background.xml b/magikeyboard/src/main/res/drawable/key_background.xml
new file mode 100644
index 000000000..c51ec5a8a
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/key_background.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/drawable/key_background_normal.xml b/magikeyboard/src/main/res/drawable/key_background_normal.xml
new file mode 100644
index 000000000..efff84f2e
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/key_background_normal.xml
@@ -0,0 +1,37 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/drawable/key_background_pressed.xml b/magikeyboard/src/main/res/drawable/key_background_pressed.xml
new file mode 100644
index 000000000..27093297c
--- /dev/null
+++ b/magikeyboard/src/main/res/drawable/key_background_pressed.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/layout/key_preview.xml b/magikeyboard/src/main/res/layout/key_preview.xml
new file mode 100644
index 000000000..465238093
--- /dev/null
+++ b/magikeyboard/src/main/res/layout/key_preview.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/layout/keyboard.xml b/magikeyboard/src/main/res/layout/keyboard.xml
new file mode 100644
index 000000000..9113800a6
--- /dev/null
+++ b/magikeyboard/src/main/res/layout/keyboard.xml
@@ -0,0 +1,32 @@
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/values/colors.xml b/magikeyboard/src/main/res/values/colors.xml
new file mode 100644
index 000000000..371742953
--- /dev/null
+++ b/magikeyboard/src/main/res/values/colors.xml
@@ -0,0 +1,25 @@
+
+
+
+ #263238
+
+ #263238
+ #263238
+
diff --git a/magikeyboard/src/main/res/values/strings.xml b/magikeyboard/src/main/res/values/strings.xml
new file mode 100644
index 000000000..e17888795
--- /dev/null
+++ b/magikeyboard/src/main/res/values/strings.xml
@@ -0,0 +1,21 @@
+
+
+ Magikeyboard
+
diff --git a/magikeyboard/src/main/res/xml/ime_preferences.xml b/magikeyboard/src/main/res/xml/ime_preferences.xml
new file mode 100644
index 000000000..892816c40
--- /dev/null
+++ b/magikeyboard/src/main/res/xml/ime_preferences.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/xml/method.xml b/magikeyboard/src/main/res/xml/method.xml
new file mode 100644
index 000000000..ebb7ab7bb
--- /dev/null
+++ b/magikeyboard/src/main/res/xml/method.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/magikeyboard/src/main/res/xml/password_keys.xml b/magikeyboard/src/main/res/xml/password_keys.xml
new file mode 100644
index 000000000..28121054d
--- /dev/null
+++ b/magikeyboard/src/main/res/xml/password_keys.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 48a1ac76b..b1cd735c6 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':icon-pack-classic', ':icon-pack-material'
+include ':app', ':icon-pack-classic', ':icon-pack-material', ':magikeyboard'