Skip to content

Commit

Permalink
Total engine refactoring (#44)
Browse files Browse the repository at this point in the history
* totally refactored the Languages, the Database and the IME module. New and more clear folder/package structure

* CharMap and LangHelper are no more

* removed many unused icons, translations and other resources

* deleted the old keymap samples

* Update user-manual.md

* Preferences are stored in Preferences, not in the database.

* removed some unclear and unused settings from the Preferences screen and the code.

* fixed issues with displaying the UI

* removed all non-English words and words with foreign spelling from the English dictionary

* 0 now works as it should in all modes.

* a more clear newline character in suggestions view

* last used input mode is now preserved and restored the next time

* removed the smiley and symbol dialogs

* capsMode -> textCase

* language names are no longer translated

* updated build instructions

* better use of threads for DB operations

* current text candidate is as long as the sequence, to make it more intuitive

* single characters are added to the end of the suggestion, when there are no more in the database

* Added ѝ to Bulgarian character map

* disabled adding words in a user-friendly manner

* when adding a new word is not possible, a toast message appears, for better user experience

* an error is logged when there are duplicate language IDs

* settings -> settings_legacy

* custom Logger class for easier debugging and no logcat flood in the Release version

* removed unnecessary single letters and invalid words from the dictionaries

* more translations cleanup; also corrected some weird translations

* upgraded gradle
  • Loading branch information
sspanak authored Oct 3, 2022
1 parent af172b7 commit 78b6681
Show file tree
Hide file tree
Showing 225 changed files with 2,718 additions and 4,981 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
bin/
gen/

# Gradle files
# Gradle/build files
.gradle/
build/
release/

# Local configuration file (sdk path, etc)
local.properties
Expand Down
75 changes: 30 additions & 45 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,53 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.github.sspanak.tt9"
android:versionCode="4"
android:versionName="git" >
<manifest
android:versionCode="5"
android:versionName="git"
package="io.github.sspanak.tt9"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-configuration
android:reqFiveWayNav="true"
android:reqHardKeyboard="true"
android:reqKeyboardType="qwerty"
/>
<uses-configuration
android:reqFiveWayNav="true"
android:reqKeyboardType="twelvekey"
android:reqHardKeyboard="true"
/>
<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/ime_name"
android:theme="@style/AppTheme" >
<service
android:name="io.github.sspanak.tt9.TraditionalT9"
android:permission="android.permission.BIND_INPUT_METHOD" >
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<uses-configuration android:reqFiveWayNav="true" android:reqHardKeyboard="true" android:reqKeyboardType="qwerty"/>
<uses-configuration android:reqFiveWayNav="true" android:reqHardKeyboard="true" android:reqKeyboardType="twelvekey"/>

<meta-data
android:name="android.view.im"
android:resource="@xml/method" />
</service>
<application
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">

<service android:name=".DBUpdateService" />
<service android:name="io.github.sspanak.tt9.ime.TraditionalT9" 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"/>
</service>

<activity
android:name="io.github.sspanak.tt9.TraditionalT9Settings"
android:label="@string/traditionalt9_settings" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:theme="@android:style/Theme.Dialog"
android:name="io.github.sspanak.tt9.AddWordAct"
android:label="@string/title_activity_add_word"
android:excludeFromRecents="true" >
</activity>
</application>
<activity android:label="@string/app_settings" android:name="io.github.sspanak.tt9.ui.TraditionalT9Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>

<activity
android:excludeFromRecents="true"
android:label="@string/add_word_title"
android:name="io.github.sspanak.tt9.ui.AddWordAct"
android:theme="@android:style/Theme.Dialog"/>
</application>
</manifest>
45 changes: 24 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,37 @@ That's it! Now you should be able to deploy and debug the app on your device.
You can find more info in this [Github issue](https://github.com/android/input-samples/issues/18).

### Building a Release .apk
The project is configured to build an unsigned release variant by default. You just need to select the "release" variant from Android Studio options, then `Build -> Rebuild Project`. After that, just ignore all warnings until you get to the end of the process. You will find the `.apk` in the generated 'build/' folder.
The project is configured to build an unsigned release variant by default.

- Select the "release" variant from Android Studio options (`Build` -> `Select Build Variant...`)
- `Build` -> `Rebuild Project`. After that, just ignore all warnings until you get to the end of the process.
- Find the `.apk` in the generated 'build/' folder.

_Note that it may not be possible to install an unsigned `.apk` on newer versions of Android. You must either manually sign it or build a signed one instead._

### Building a Signed .apk
- Make sure you have a signing key. If you don't have one, follow the [official manual](https://developer.android.com/studio/publish/app-signing#sign-apk).
- In `build.gradle` find the `signingConfigs` and `buildTypes` sections and uncomment them.
- Set properly the environment variables listed in `signingConfigs.release` _(You may need to restart Android Studio after that)_. Alternatively, you may simply type the actual key path, alias and passwords there. **Just make sure not to commit them!**
- Build the project normally. Android Studio should show you where it has generated the signed `.apk` file. If not, look for it in the `build/` folder.
Make sure you have a signing key. If you don't have one, follow the [official manual](https://developer.android.com/studio/publish/app-signing#sign-apk).

- Select `Build` -> `Generate Signed Bundle / APK...`.
- Select `APK` and proceed to the next screen.
- Enter your key details (or create a new one) and continue to the next screen.
- Choose the "Release" variant, then click `Finish` to start building.
- Android Studio will tell you where the `.apk` is, but if it does not, try looking for it in the `release/` folder.

## Adding a new language
To support a new language one needs to:

- Modify CharMap.java
- New Map needs to be created with the characters to be encountered in addWord or in the user dictionary when loaded.
- New character array needs to be added for characters that are to cycle on each number press.
- New array needs to be made to tell where the capital letters start in that array.
- modify LangHelper.java
- Add status icons
- Create proper icons for each mode (e.g. "Ab", "En", "12") and each screen size. The font must be Roboto Lt at an adequate size to fit the icon square with minimum padding. Text must be white and the background must be transparent as per the [official Android guide](https://android-doc.github.io/guide/practices/ui_guidelines/icon_design_status_bar.html). To simplify the process, you could use Android Studio. It has a built-in icon generator accessible by right-cicking on "drawable" folder -> New -> Image Asset. Then choose "Icon Type": "Notification Icons", "Asset Type": Text, "Trim": No, "Padding": 0%.
- Add new entry in ICONMAP
- Add new LANGUAGE enum entry e.g. FR(3,5) (index, id) Where index is index in arrays like LOCALES, and id is the identifier used in the database and such. The latter should never change unless database update is done.
- Make sure new id matches const.xml
- Add the LOCALE of the language in the LOCALES Locale array
- Add translations for arrays.xml and strings.xml in to new files in the appropriate locale folder (e.g. res/values-de/arrays.xml.) AndroidStudio has a cute/nice Translation Editor which might be handy.
- Edit the base arrays.xml file to add the new language. (pref_lang_titles, pref_lang_values)
- Exclude translatable="false" items from the new locale arrays.xml file.
- Find a suitable dictionary and add it to assets

That should be it? I hope.
- Create a proper icon for each screen size. The icon needs to contain the abbreviation of the language. (e.g. "En" for "English").
- The font must be Roboto Lt at an adequate size to fit the icon square with minimum padding.
- The text must be white and the background must be transparent as per the [official Android guide](https://android-doc.github.io/guide/practices/ui_guidelines/icon_design_status_bar.html).
- To simplify the process, you could use Android Studio. It has a built-in icon generator accessible by right-cicking on "drawable" folder -> New -> Image Asset. Then choose "Icon Type": "Notification Icons", "Asset Type": Text, "Trim": No, "Padding": 0%.
- Find a suitable dictionary and add it to `assets` folder.
- Create a new language class in `languages/definitions/`. Make sure to set all properties. The ID must be the next available one. Currently, the range is limited between 1 and 31, so there can be 31 languages in total.
- Add the new language to the list in `LanguageCollection.java`. You only need to add it in one place, in the constructor. Please, be nice and maintain the alphabetical order.
- Add a new entry in `res/values/const.xml`. Make sure the new ID matches the one in the language class.
- Add new entries in `res/values/arrays.xml`.
- Add translations in `res/values/strings-your-lang`. The Android Studio translation editor is very handy.

## Using the app
See the [user manual](docs/user-manual.md).
Expand Down
19 changes: 3 additions & 16 deletions assets/de-utf8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5954,7 +5954,6 @@ Andorra
Andrang
Andranges
andre
André
Andrea
Andreas
andrehen
Expand Down Expand Up @@ -10441,8 +10440,6 @@ Atomzeitalter
Atomzertrümmerung
ATP
ATS
Attaché
Attachés
Attacke
Attacken
attackieren
Expand Down Expand Up @@ -24205,7 +24202,7 @@ Bogenmaßes
Bogens
Bogenstück
Bogenstücke
Bogotá
Bogota
bogst
Bohle
Bohlen
Expand Down Expand Up @@ -25901,7 +25898,6 @@ Cabaret
Cabrio
Cabriolet
CAD
Café
Cafeteria
Calamares
Callgirl
Expand Down Expand Up @@ -26094,7 +26090,7 @@ chartern
charterten
Charts
Chassis
Château
Chateau
Chauffeur
Chauffeure
Chauffeuren
Expand Down Expand Up @@ -26267,7 +26263,6 @@ Cineast
cineastisch
circa
City
Cività
Clan
Claude
Claudia
Expand Down Expand Up @@ -26340,7 +26335,6 @@ Computerstimme
Computertechnik
Computerviren
Concorde
Conférencier
const
Container
cool
Expand All @@ -26360,7 +26354,6 @@ Couleur
Count-down
Coup
Coupe
Coupé
Coupon
Coupons
Coups
Expand Down Expand Up @@ -77418,7 +77411,7 @@ Militärarzt
Militärärzte
Militärärzten
Militärarztes
Militärattachés
Militärattaches
Militärbündnis
Militärdienstes
Militärdiktatur
Expand Down Expand Up @@ -80903,7 +80896,6 @@ negierter
negiertes
negiertest
negiertet
Negligé
Negligee
nehme
nehmen
Expand Down Expand Up @@ -101437,7 +101429,6 @@ Sortimentsbuchhändlern
SOS
Soße
Soßen
Soufflé
Soufflee
Souffleur
Souffleuren
Expand Down Expand Up @@ -121119,12 +121110,8 @@ Variationsbreite
Variationsrechnung
Varietät
Varietäten
Varieté
Varietee
Varietees
Varietés
Varietétheatern
Varietétheaters
variierbare
variiere
variieren
Expand Down
Loading

0 comments on commit 78b6681

Please sign in to comment.