Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Added separate keyboard selection for all languages #39

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 89 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,102 @@
android:exported="false" />

<service
android:name=".services.SimpleKeyboardIME"
android:exported="true"
android:label="@string/app_name"
android:name=".services.EnglishKeyboardIME"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method" />
android:resource="@xml/method_english" />
</service>

<service
android:exported="true"
android:name=".services.GermanKeyboardIME"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method_german" />
</service>

<service
android:exported="true"
android:name=".services.FrenchKeyboardIME"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method_french" />
</service>
<service
android:exported="true"
android:name=".services.ItalianKeyboardIME"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method_italian" />
</service>
<service
android:exported="true"
android:name=".services.PortugueseKeyboardIME"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method_portuguese" />
</service>
<service
android:exported="true"
android:name=".services.RussianKeyboardIME"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method_russian" />
</service>
<service
android:exported="true"
android:name=".services.SpanishKeyboardIME"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method_spanish" />
</service>
<service
android:exported="true"
android:name=".services.SwedishKeyboardIME"
android:label="Scribe"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method_swedish" />
</service>

<activity
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/kotlin/org/scribe/services/EnglishKeyboardIME.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scribe.services

import org.scribe.R

class EnglishKeyboardIME : SimpleKeyboardIME() {
override fun getKeyboardLayoutXML(): Int = R.xml.keys_letters_english
}
8 changes: 8 additions & 0 deletions app/src/main/kotlin/org/scribe/services/FrenchKeyboardIME.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.scribe.services

import org.scribe.R

class FrenchKeyboardIME : SimpleKeyboardIME() {
override fun getKeyboardLayoutXML(): Int = R.xml.keys_letters_french
}

7 changes: 7 additions & 0 deletions app/src/main/kotlin/org/scribe/services/GermanKeyboardIME.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scribe.services

import org.scribe.R

class GermanKeyboardIME : SimpleKeyboardIME() {
override fun getKeyboardLayoutXML(): Int = R.xml.keys_letters_german
}
8 changes: 8 additions & 0 deletions app/src/main/kotlin/org/scribe/services/ItalianKeyboardIME.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.scribe.services

import org.scribe.R

class ItalianKeyboardIME : SimpleKeyboardIME() {
override fun getKeyboardLayoutXML(): Int = R.xml.keys_letters_italian
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.scribe.services

import org.scribe.R

class PortugueseKeyboardIME : SimpleKeyboardIME() {
override fun getKeyboardLayoutXML(): Int = R.xml.keys_letters_portuguese
}

7 changes: 7 additions & 0 deletions app/src/main/kotlin/org/scribe/services/RussianKeyboardIME.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scribe.services

import org.scribe.R

class RussianKeyboardIME : SimpleKeyboardIME() {
override fun getKeyboardLayoutXML(): Int = R.xml.keys_letters_russian
}
17 changes: 4 additions & 13 deletions app/src/main/kotlin/org/scribe/services/SimpleKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import org.scribe.helpers.*
import org.scribe.views.MyKeyboardView

// based on https://www.androidauthority.com/lets-build-custom-keyboard-android-832362/
class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionListener {


abstract class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionListener {
abstract fun getKeyboardLayoutXML(): Int
private var SHIFT_PERM_TOGGLE_SPEED = 500 // how quickly do we have to doubletap shift to enable permanent caps lock
private val KEYBOARD_LETTERS = 0
private val KEYBOARD_SYMBOLS = 1
Expand Down Expand Up @@ -258,16 +261,4 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
}
}

private fun getKeyboardLayoutXML(): Int {
return when (baseContext.config.keyboardLanguage) {
LANGUAGE_FRENCH -> R.xml.keys_letters_french
LANGUAGE_GERMAN -> R.xml.keys_letters_german
LANGUAGE_ITALIAN -> R.xml.keys_letters_italian
LANGUAGE_PORTUGUESE -> R.xml.keys_letters_portuguese
LANGUAGE_RUSSIAN -> R.xml.keys_letters_russian
LANGUAGE_SPANISH -> R.xml.keys_letters_spanish
LANGUAGE_SWEDISH -> R.xml.keys_letters_swedish
else -> R.xml.keys_letters_english
}
}
}
7 changes: 7 additions & 0 deletions app/src/main/kotlin/org/scribe/services/SpanishKeyboardIME.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scribe.services

import org.scribe.R

class SpanishKeyboardIME : SimpleKeyboardIME() {
override fun getKeyboardLayoutXML(): Int = R.xml.keys_letters_spanish
}
7 changes: 7 additions & 0 deletions app/src/main/kotlin/org/scribe/services/SwedishKeyboardIME.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scribe.services

import org.scribe.R

class SwedishKeyboardIME : SimpleKeyboardIME() {
override fun getKeyboardLayoutXML(): Int = R.xml.keys_letters_spanish
}
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,14 @@

<!-- Message digest algorithms -->
<string name="md5">MD5</string>
<string name="english_keyboard">English(US)</string>
<string name="german_keyboard">German</string>
<string name="french">French</string>
<string name="italian">Italian</string>
<string name="portugu_s">Português</string>
<string name="russian">Russian</string>
<string name="spanish">spanish</string>
<string name="swedish">swedish</string>

<string-array name="months">
<item>@string/january</item>
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/xml/method_english.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="org.scribe.activities.SettingsActivity"
android:icon="@mipmap/ic_launcher" >
<subtype
android:icon="@mipmap/ic_launcher"
android:label="@string/english_keyboard"
android:imeSubtypeLocale="en_US"
android:imeSubtypeMode="keyboard" />
</input-method>
9 changes: 9 additions & 0 deletions app/src/main/res/xml/method_french.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="org.scribe.activities.SettingsActivity"
android:icon="@mipmap/ic_launcher" >
<subtype
android:icon="@mipmap/ic_launcher"
android:label="@string/french"
android:imeSubtypeLocale="fr"
android:imeSubtypeMode="keyboard" />
</input-method>
6 changes: 6 additions & 0 deletions app/src/main/res/xml/method_german.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<input-method xmlns:android="http://schemas.android.com/apk/res/android">
<subtype
android:label="@string/german_keyboard"
android:imeSubtypeLocale="ge"
android:imeSubtypeMode="keyboard" />
</input-method>
9 changes: 9 additions & 0 deletions app/src/main/res/xml/method_italian.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="org.scribe.activities.SettingsActivity"
android:icon="@mipmap/ic_launcher" >
<subtype
android:icon="@mipmap/ic_launcher"
android:label="@string/italian"
android:imeSubtypeLocale="it"
android:imeSubtypeMode="keyboard" />
</input-method>
9 changes: 9 additions & 0 deletions app/src/main/res/xml/method_portuguese.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="org.scribe.activities.SettingsActivity"
android:icon="@mipmap/ic_launcher" >
<subtype
android:icon="@mipmap/ic_launcher"
android:label="@string/portugu_s"
android:imeSubtypeLocale="po"
android:imeSubtypeMode="keyboard" />
</input-method>
9 changes: 9 additions & 0 deletions app/src/main/res/xml/method_russian.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="org.scribe.activities.SettingsActivity"
android:icon="@mipmap/ic_launcher" >
<subtype
android:icon="@mipmap/ic_launcher"
android:label="@string/russian"
android:imeSubtypeLocale="ru"
android:imeSubtypeMode="keyboard" />
</input-method>
9 changes: 9 additions & 0 deletions app/src/main/res/xml/method_spanish.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="org.scribe.activities.SettingsActivity"
android:icon="@mipmap/ic_launcher" >
<subtype
android:icon="@mipmap/ic_launcher"
android:label="@string/spanish"
android:imeSubtypeLocale="sp"
android:imeSubtypeMode="keyboard" />
</input-method>
9 changes: 9 additions & 0 deletions app/src/main/res/xml/method_swedish.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="org.scribe.activities.SettingsActivity"
android:icon="@mipmap/ic_launcher" >
<subtype
android:icon="@mipmap/ic_launcher"
android:label="@string/swedish"
android:imeSubtypeLocale="sw"
android:imeSubtypeMode="keyboard" />
</input-method>
Loading