An attempt to run fcitx5 on Android

Overview

fcitx5-android-poc

An attempt to run fcitx5 on Android.

Project status

It can build, run, and print to stdout.

Build

Dependencies

  • Android SDK Platform & Build-Tools 30
  • Android NDK (Side by side) 23 & cmake 3.18.1 . Note: you may need to install Android Studio Beta for Android NDK 23. NDK 21 & 22 are comfirmed not working with this project.
  • KDE/extra-cmake-modules

Patch CMakeLists.txt

If cmake complaint about "cannot find ...", just comment out those lines. Believe me, it will build. See my patchs here: https://gist.github.com/rocka/f25d29bc6ceb31033543fd95eba09bf9

libime data

I don't know why cmake won't download and generate those data. Just install libime, and copy /usr/{lib,share}/libime/* to app/src/main/assets/fcitx5/libime/.

fcitx5-chinese-addons dict

Make it read dict path from environment variable, we need to specify that path at runtime.

diff --git a/im/pinyin/pinyin.cpp b/im/pinyin/pinyin.cpp
index 2f98f7f..1cceb7e 100644
--- a/im/pinyin/pinyin.cpp
+++ b/im/pinyin/pinyin.cpp
@@ -607,7 +607,7 @@ PinyinEngine::PinyinEngine(Instance *instance)
             libime::DefaultLanguageModelResolver::instance()
                 .languageModelFileForLanguage("zh_CN")));
     ime_->dict()->load(libime::PinyinDictionary::SystemDict,
-                       LIBIME_INSTALL_PKGDATADIR "/sc.dict",
+                       stringutils::joinPath(getenv("LIBIME_INSTALL_PKGDATADIR"), "sc.dict").c_str(),
                        libime::PinyinDictFormat::Binary);
     prediction_.setUserLanguageModel(ime_->model());

PoC

Logcat
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.301125 instance.cpp
D/fcitx5: :
D/fcitx5: 1371]
D/fcitx5: Override Enabled Addons: {
D/fcitx5: unicode,
D/fcitx5: punctuation,
D/fcitx5: androidfrontend, pinyin
D/fcitx5: }
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.301305 instance.cpp:
D/fcitx5: 1372]
D/fcitx5: Override Disabled Addons: {all
D/fcitx5: }
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.339251
D/fcitx5: addonmanager.cpp:
D/fcitx5: 189]
D/fcitx5: Loaded addon unicode
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.339849 addonmanager.cpp
D/fcitx5: :189]
D/fcitx5: Loaded addon androidfrontend
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.342312 inputmethodmanager.cpp
D/fcitx5: :117
D/fcitx5: ] No valid input method group in configuration.
D/fcitx5: Building a default one
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.343421
D/fcitx5:  instance.cpp
D/fcitx5: :
D/fcitx5: 730]
D/fcitx5: Items in Default
D/fcitx5: : [
D/fcitx5: InputMethodGroupItem(
D/fcitx5: keyboard-us,layout=
D/fcitx5: )]
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.343485 instance.cpp
D/fcitx5: :735]
D/fcitx5: Generated groups: [
D/fcitx5: Default]
D/fcitx5: E
D/fcitx5: 2021-06-10 21:14:01.343650 instance.cpp
D/fcitx5: :1381]
D/fcitx5: Couldn't find keyboard-us
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.346341 addonmanager.cpp:189] Loaded addon punctuation
D/fcitx5: E
D/fcitx5: 2021-06-10 21:14:01.636885
D/fcitx5:
D/fcitx5: pinyin.cpp
D/fcitx5: :
D/fcitx5: 647
D/fcitx5: ]
D/fcitx5: Failed to load pinyin history:
D/fcitx5: io fail: unspecified iostream_category error
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.706428
D/fcitx5:
D/fcitx5: addonmanager.cpp
D/fcitx5: :
D/fcitx5: 189
D/fcitx5: ]
D/fcitx5: Loaded addon
D/fcitx5: pinyin
W/ocka.fcitx5test: type=1400 audit(0.0:26994): avc: denied { read } for name="uuid" dev="proc" ino=15533979 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0
W/ocka.fcitx5test: type=1400 audit(0.0:26995): avc: denied { read } for name="uuid" dev="proc" ino=15533979 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.735381
D/fcitx5:
D/fcitx5: androidfrontend.cpp
D/fcitx5: :
D/fcitx5: 71
D/fcitx5: ]
D/fcitx5: KeyEvent key:
D/fcitx5: n
D/fcitx5:  isRelease:
D/fcitx5: 0
D/fcitx5:  accepted:
D/fcitx5: 1
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.742409
D/fcitx5:
D/fcitx5: androidfrontend.cpp
D/fcitx5: :
D/fcitx5: 71
D/fcitx5: ]
D/fcitx5: KeyEvent key:
D/fcitx5: i
D/fcitx5:  isRelease:
D/fcitx5: 0
D/fcitx5:  accepted:
D/fcitx5: 1
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.771056
D/fcitx5:
D/fcitx5: androidfrontend.cpp
D/fcitx5: :
D/fcitx5: 71
D/fcitx5: ]
D/fcitx5: KeyEvent key:
D/fcitx5: h
D/fcitx5:  isRelease:
D/fcitx5: 0
D/fcitx5:  accepted:
D/fcitx5: 1
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.776967
D/fcitx5:
D/fcitx5: androidfrontend.cpp
D/fcitx5: :
D/fcitx5: 71
D/fcitx5: ]
D/fcitx5: KeyEvent key:
D/fcitx5: a
D/fcitx5:  isRelease:
D/fcitx5: 0
D/fcitx5:  accepted:
D/fcitx5: 1
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.790069
D/fcitx5:
D/fcitx5: androidfrontend.cpp
D/fcitx5: :
D/fcitx5: 71
D/fcitx5: ]
D/fcitx5: KeyEvent key:
D/fcitx5: o
D/fcitx5:  isRelease:
D/fcitx5: 0
D/fcitx5:  accepted:
D/fcitx5: 1
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.790626
D/fcitx5:
D/fcitx5: androidfrontend.cpp
D/fcitx5: :
D/fcitx5: 29
D/fcitx5: ]
D/fcitx5: Commit:
D/fcitx5: 你好
D/fcitx5: I
D/fcitx5: 2021-06-10 21:14:01.791372
D/fcitx5:
D/fcitx5: androidfrontend.cpp
D/fcitx5: :
D/fcitx5: 71
D/fcitx5: ]
D/fcitx5: KeyEvent key:
D/fcitx5: 1
D/fcitx5:  isRelease:
D/fcitx5: 0
D/fcitx5:  accepted:
D/fcitx5: 1
Comments
  • Adding support for fcitx5-unikey

    Adding support for fcitx5-unikey

    Hi, I just come across this new project and I am very interested to see the fcitx5 input method ported to Android. So far I tried the English keyboard and it's a pretty decent keyboard (it's lacking the characters change to normal/CAPS when I press the switch). However since I am a Vietnamese I wonder if the team have any plan to port fcitx5-unikey to the app ?

    opened by hmtheboy154 4
  • Cleanup cmake build scripts

    Cleanup cmake build scripts

    We should avoid modifying submodules if possible — that is to say we have to make sure find_package work in submodules.

    1. For third-party libraries, we could use prebuilt static binaries. In this case, we could obtain configuration files (XXXConfig.cmake) from the build result, so find_package should work.
      • [ ] ~~curl with openssl~~
      • [x] boost
      • [x] libevent
      • [x] libintl-lite
      • [x] fmt
    2. For fcitx related libraries (fcitx5 and fcitx5-chinese-addons), the difference between third-party libraries is that these two libraries are interdependent, so it's not clear yet how to accomplish that. One possible way could be dropping their cmake files, delegating them to our top-level cmake file. However, this would require us to duplicate existing works, which might be tedious. The alternative could be using prebuilt version, but compiling them independently might be a non-trivial work.
    opened by berberman 4
  • Roadmap

    Roadmap

    Outdated, see more on our Trello: https://trello.com/b/gftk6ZdV/kanban

    Original, outdated Roadmap

    Short Term

    • [x] chinese-addons user dictionary manager UI
    • [ ] chinese-addons custom 双拼 profile editor ( https://github.com/fcitx/libime/blob/1.0.11/test/testshuangpinprofile.cpp )
    • [x] map Android EditorInfo (and InputType) to fcitx5 CapabilityFlag #23
    • [ ] share input state per program (maybe create an input context for each application)
    • [ ] surrounding text support in androidkeyboard (Android: InputConnection#getSurroundingText; fcitx5: fcitx::SurroundingText)
    • [x] invokeAction support in androidkeyboard (reference: PinyinEngine::invokeActionImpl) https://github.com/rocka/fcitx5-android-poc/commit/e2ffe7e950262ac692ecc5730e01f4e055809cdc
    • [ ] new fcitx API to now whether next "Return" KeyEvent would be captrued

    Mid Term

    Long Term

    • [ ] fully customizable keyboard layout
    • [ ] fcitx5-mozc

    Nice to have

    • [ ] Support Direct Boot mode (https://developer.android.com/training/articles/direct-boot)
    discussion 
    opened by berberman 4
  • [bug] QQ 聊天无法删除回复

    [bug] QQ 聊天无法删除回复

    描述

    一旦在QQ聊天中选择回复某一段文字,被选择的文字无法删除(可以选择回复另一段文字,但是不能不回复) 就图里面的那段文字无法删除,可以替换成回复别的消息。

    补充

    注: gboard 正常, 0.0.2-197-g4af305f-release 版本正常

    0.0.2-204-g5a4e391-release 不正常 0.0.2-210-g0eb401b-release 不正常

    附图

    security_Screenshot_20220914-112828-469

    bug component: IME service 
    opened by sukanka 3
  • 每次开机后会崩溃一次

    每次开机后会崩溃一次

    --------- Build Info Build Time: 2022-05-13T17:07:57Z Build Git Hash: b2a5f3b Build Version Name: 0.0.2-2-gb2a5f3b-release --------- Device Info App Package Name: org.fcitx.fcitx5.android App Version Name: 0.0.2-2-gb2a5f3b App Version Code: 2 OS Name: RQ3A.211001.001 OS Version: 4.19.217-Arrow-g60e77b7089e0 (12510) OS API Level: 30 Device: apollo Model (product): M2007J3SC (arrow_apollo) Manufacturer: Xiaomi Tags: release-keys Screen Size: 1080 x 2310 Screen Density: 2.75 Screen orientation: Portrait --------- beginning of main W/InputConnectionWrapper( 4481): requestUpdateCursorAnchorInfo() didn't respond in 2000 msec. Returning default: 0 E/CustomActivityOnCrash( 4481): App has crashed, executing CustomActivityOnCrash's UncaughtExceptionHandler E/CustomActivityOnCrash( 4481): java.lang.RuntimeException: Alive checking failed! The job didn't get run after 8000 ms! E/CustomActivityOnCrash( 4481): at org.fcitx.fcitx5.android.core.FcitxDispatcher$AliveChecker$install$1.invokeSuspend(FcitxDispatcher.kt:73) E/CustomActivityOnCrash( 4481): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) E/CustomActivityOnCrash( 4481): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) E/CustomActivityOnCrash( 4481): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/CustomActivityOnCrash( 4481): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/CustomActivityOnCrash( 4481): at java.lang.Thread.run(Thread.java:923) I/Process ( 4481): Sending signal. PID: 4481 SIG: 9

    倒是不影响什么 而且只有开机时会这样

    opened by lisansas 3
  • will cause

    will cause "Keyboard cursor control" in lineage unable to use / 会导致 lineage 的音量键控制光标无法使用

    in lineage os, there is a feature called "Keyboard cursor control". can use Volume up/down keys to move cursor left/right. but after using this ime. that feature not working anymore. 这个输入法好像会导致 lineage 的“音量键当左右键用”的功能用不了

    opened by rhjdvsgsgks 2
  • symbol keyboard & themes from google pinyin ime / 使用来自谷歌拼音输入法的符号键盘与主题

    symbol keyboard & themes from google pinyin ime / 使用来自谷歌拼音输入法的符号键盘与主题

    google pinyin ime have a wider symbol keyboard. which provided much more symbol than usual gboard. it would be great if possible to used this symbol keyboard replace gboard one. 谷歌拼音有个挺大的符号键盘,提供了比 gboard 多很多的的符号,希望能用这个换掉目前的符号键盘 pic 谷歌拼音还有个几个 gboard 没有的配色,希望能一并加进来

    enhancement component: keyboard 
    opened by rhjdvsgsgks 2
  • F-Droid inclusion

    F-Droid inclusion

    Hello,

    Since this is an open-source app, would you approve to have it included to F-Droid? It's a strong community (actually almost the unique) focusing on distributing open-source Android apps, and you can find some other CJK IMEs like Trime, Guileless, Mozc, etc. already listed there.

    You can find documentation here.

    If you're interested, feel free to contact @ linsui (who speaks Chinese) or @ Poussinou for further details.

    Thanks for your attention and it wouldn't take too much time since their team would help you.

    PS: Apps on F-Droid are signed by F-Droid by default, but you can ask for the case of reproducible build, then they just verify if your builds are reproducible and simply distribute the builds signed by you, in that way there would be no problem of distributing packages with different signatures.

    PPS: just a suggestion, no matter if you agree to add the app to F-Droid, please regularly tag your releases so that others can easily know if there is any new version. Many thanks

    question discussion 
    opened by momobobe 2
  • reworked symbol presets

    reworked symbol presets

    Removed a lot of rarely-used symbols and reordered them. Added first two blocks of IPA symbols (I don't know whether combining characters work though).

    opened by lilydjwg 1
  • Set LUA_PATH envvar for fcitx5-lua

    Set LUA_PATH envvar for fcitx5-lua

    设置好LUA_PATHLUA_CPATH后就可以引入模块了

    • $FCITX_DATA_HOME/lua,为非root用户提供模块放置的位置
    • $XDG_DATA_DIRS/lua/5.4,和电脑上的lua位置是一样的,为那种反编译再重新打包来集成资源的人提供(放置在assets/usr/share/lua/5.4)
    • 保留了预置的/usr/local/share/lua/5.4,但是对非root用户来说显然没有任何意义

    当然这是我自己定的,或者你看放置在哪里好一点

    下面两例测试通过

    例子一:

    1. json_example.lua,文件内容如下:
    local json = require ("dkjson")
    
    local tbl = {
      animals = { "dog", "cat", "aardvark" },
      instruments = { "violin", "trombone", "theremin" },
      bugs = json.null,
      trees = nil
    }
    
    function output()
      return {
        json.encode (tbl, { indent = true })
      }
    end
    
    ime.register_command("bm", "output", "", "none")
    
    1. dkjson.lua在此下载
    2. 编译并安装fcitx5,dkjson.lua放置在存储/Android/data/org.fcitx.fcitx5.android/files/data/lua/json_example.json放置在存储/Android/data/org.fcitx.fcitx5.android/files/data/lua/imeapi/extensions/,重启fcitx5
    3. 进入 QuickPhrase 模式并输入 bm,能够正常输出json。在以前日志会提示找不到模块

    例子二:

    1. 解包一个fcitx5的安装包
    2. 上述dkjson.lua,放置在app/src/main/assets/usr/share/lua/5.4/,~并修改那个清单json文件~(gradle 构建时会自动生成)
    3. 签名,安装这个改过的包
    4. json_example.lua还是放在上述位置,重启配置
    5. 进入 QuickPhrase 模式并输入 bm
    opened by TheInterestingSoul 1
  • [Bug]Cannot write in capital letters if completion in English is turned off

    [Bug]Cannot write in capital letters if completion in English is turned off

    Hello. First of all thanks for amazing app! In current nightly app i've downloaded from i cannot write in capital letters if completion in English is turned off, it works again if i re-enable completion

    Steps to reproduce: 1- Open the app click into "Input Methods" 2- Click the cog on English input method 3- Disable "completion". 4- Now open any application and try typing capital letters while English input was selected.

    Thank you!

    status: fixed in master 
    opened by Gurbuzguven 1
  • 键盘位置调节

    键盘位置调节

    Keyboard position adjustment 希望可以调节键盘的高度

    比如这样 https://user-images.githubusercontent.com/80346269/189528526-1ab4beaf-538a-456f-8ba2-ce2044a775a5.mp4

    可以为屏幕下方预留空间

    部分手机屏幕是圆角的,键盘总会有部分会被挡住,操作也会有影响 Under the rounded screen, some keys are always covered or affect the use.

    mmexport1662895796541.jpg

    比如下滑不了句号这个键,因为下方屏幕太小了。 不过不是什么大问题。

    作者考虑一下加这个,谢谢了

    enhancement component: keyboard 
    opened by MesPent 0
  • Help wanted to build on Windows!

    Help wanted to build on Windows!

    Hi,

    I need some help from devs how to configure and build this keyboard app on Android Studio i have done all required step but the app can't build on android studio on the first step it doesn't sync with gradle i got this error!

    cancelled
    :prepareKotlinBuildScriptModel
    settings.gradle.kts
    Build configuration failed, run 'gradle tasks' for more information
    build.gradle.kts
    org.gradle.internal.exceptions.LocationAwareException: Build file 'C:\Users\GoRaN\Desktop\KBoard\build.gradle.kts' line: 22
    Build configuration failed, run 'gradle tasks' for more information
    This script caused build configuration to fail, run 'gradle tasks' for more information
    java.lang.IllegalArgumentException: [email protected]09f59d2 must be locked before it can be used to compute a classpath!
    java.lang.IllegalArgumentException: project.classLoaderScope must be locked before querying the project schema
    build.gradle.kts
    org.gradle.internal.exceptions.LocationAwareException: Build file 'C:\Users\GoRaN\Desktop\KBoard\app\build.gradle.kts' line: 22
    Build configuration failed, run 'gradle tasks' for more information
    This script caused build configuration to fail, run 'gradle tasks' for more information
    java.lang.IllegalArgumentException: [email protected]09f59d2 must be locked before it can be used to compute a classpath!
    java.lang.IllegalArgumentException: project.classLoaderScope must be locked before querying the project schema
    java.lang.IllegalArgumentException: [email protected]2fbcca8 must be locked before it can be used to compute a classpath!
    java.lang.IllegalArgumentException: project.classLoaderScope must be locked before querying the project schema
    
    question build 
    opened by GoRaN909 6
Owner
TypoError: Cannot read property 'null' of undefined
null
My humble attempt at getting tensorflow and the ESP32-CAM to cooperate

ESP32-Object-Recognition My humble attempt at getting tensorflow and the ESP32-CAM to cooperate (among other things) Notes: "Webcam_detection.py" isn'

null 13 Jun 21, 2022
My attempt at comparing the 5455 XDK kernel against an older build, NOT COMPILABLE CODE (Mainly psudocode with sections filled in)

xboxkrnl.exe build 5445 XDK CHK My attempt at comparing the 5455 XDK kernel an older build, NOT COMPILABLE CODE (Mainly psudocode with sections filled

null 2 Dec 4, 2021
Historical Bell Labs ratfor code. Plus an attempt to modernize it.

RATFOR --- Rational Fortran This repository tracks the history of the original C version of the Bell Labs ratfor translator written by Brian Kernighan

Arnold Robbins 9 May 5, 2022
My attempt at writing an Operating System from scratch

Operating System Trying to write my own operating system from scratch Current Status: Compiles ✔️ Directory Structure (Will be updated as changes happ

Nofil Qasim 11 Jan 9, 2022
CAAR is an attempt at writing a modern Lisp machine.

CAAR - The modern lisp machine CAAR is an attempt at writing a modern Lisp machine. The goal of this project is to be able to run a somewhat functiona

Abbix 10 Jun 19, 2022
Unity project with an example on how to run the depthai library in Android.

depthai-android-unity-example Unity project (built with Unity 2020.3.25f1) with an example on how to run the depthai library in Android. Important Thi

Ibai Gorordo 18 Mar 13, 2022
A customized LGL Android mod menu, containing ESP only for PUBG Mobile 1.3.0 for Android

PUBG Mobile ESP Mod Menu A customized LGL mod menu, containing ESP only for PUBG Mobile 1.3.0 for Android. Everything are fixed so it works with both

null 42 Mar 19, 2022
First open source android modding library for Geometry Dash Based on Hooking-and-Patching-android-template

Android-ML First open source android modding library for Geometry Dash Based on Hooking-and-Patching-android-template Installation Download this githu

BlackTea ML 21 Jul 17, 2022
A simple library that helps Android developers to execute JavaScript code from Android native side easily without using Webview.

AndroidJSModule A simple library that helps Android developers to execute JavaScript code from Android native side easily without using Webview. Insta

Hung Nguyen 5 May 24, 2022
A repository for experimenting with elf loading and in-place patching of android native libraries on non-android operating systems.

droidports: A repository for experimenting with elf loading and in-place patching of android native libraries on non-android operating systems. Discla

João Henrique 23 Aug 5, 2022
Android NDK samples with Android Studio

NDK Samples This repository contains Android NDK samples with Android Studio C++ integration. These samples use the new CMake Android plugin with C++

Android 9.1k Oct 5, 2022
Combining Sealighter with unpatched exploits to run the Threat-Intelligence ETW Provider

Sealighter-TI Combining Sealighter with unpatched exploits and PPLDump to run the Microsoft-Windows-Threat-Intelligence ETW Provider without a signed

pat_h/to/file 50 Sep 27, 2022
Run-time program generator embedded in C++

Run-time program generator embedded in C++

Z Guan 25 Aug 5, 2022
anthemtotheego 366 Sep 29, 2022
Run Linux programs on DOS

A WSL alternative for users who prefer an MS-DOS environment. DOS Subsystem for Linux integrates a real Linux environment into MS-DOS systems, allowing users to make use of both DOS and Linux applications from the DOS command prompt.

Hailey Somerville 1.3k Sep 25, 2022
Project #1: Run-length Encoding (Computer Architecture, Fall 2021)

4190.308 Computer Architecture (Fall 2021) Project #1: Run-length Encoding Due: 11:59PM, September 26 (Sunday) Introduction In this project, you need

SNU Systems Software & Architecture Laboratory 7 Sep 19, 2022
Realtime Micro Kernel -- Event-driven Run-to-Completion RTOS with Active Objects, Timed Events, Memory Pools, and Message Queues

Realtime Micro Kernel Features Active Objects Message queues Variable sized, custom messages Periodic and single timed events Memory pools Supported P

null 2 Feb 25, 2022
Phan Sang 10 Sep 29, 2022
A python library to run metal compute kernels on MacOS

metalcompute for Python A python library to run metal compute kernels on MacOS Usage Example execution from M1-based Mac running MacOS 12.0: > ./build

Andrew Baldwin 15 Sep 18, 2022