From c038249298e61a84f68970c3ae2be7413b063636 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sat, 12 Apr 2025 11:11:01 +0200 Subject: [PATCH 01/37] Clickable button --- java/res/drawable/ic_ime_switch.xml | 15 +++++ java/res/layout/main_keyboard_frame.xml | 60 ++++++++++++------- java/res/values/strings.xml | 3 + .../android/inputmethod/latin/LatinIME.java | 12 ++++ 4 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 java/res/drawable/ic_ime_switch.xml diff --git a/java/res/drawable/ic_ime_switch.xml b/java/res/drawable/ic_ime_switch.xml new file mode 100644 index 0000000000..e484a69816 --- /dev/null +++ b/java/res/drawable/ic_ime_switch.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index ebf746679c..269cf98f82 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -18,28 +18,48 @@ */ --> - + android:layout_gravity="bottom"> - - + - - - + + + + + + + + + + diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index d32ee3c294..70995630f9 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -579,4 +579,7 @@ Tip: You can download and remove dictionaries by going to <b>Languages & This resource is copied from packages/apps/Settings/res/values/strings.xml --> \u0020ABCDEFGHIJKLMNOPQRSTUVWXYZ + + + STT diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d01bdd4dc8..cbc6e71105 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -57,6 +57,7 @@ import android.view.WindowManager; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodSubtype; +import android.widget.ImageButton; import androidx.annotation.NonNull; @@ -868,6 +869,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (hasSuggestionStripView()) { mSuggestionStripView.setListener(this, view); } + + ImageButton floatingButton = view.findViewById(R.id.floating_button); + if (floatingButton != null) { + floatingButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Log.d(TAG, "Clicked"); + //launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA); + } + }); + } } @Override -- GitLab From 8798afaccafe34ddc902a5d6135b113972505a32 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sat, 12 Apr 2025 16:06:33 +0200 Subject: [PATCH 02/37] Fix background --- java/res/layout/main_keyboard_frame.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index 269cf98f82..2d1e71622d 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -56,7 +56,7 @@ android:layout_gravity="top|end" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" - android:background="?attr/selectableItemBackgroundBorderless" + android:background="@android:color/transparent" android:src="@drawable/ic_ime_switch" android:contentDescription="@string/ime_switch_button" android:focusable="true" -- GitLab From fd3d80d7b0c9ad011f6442ae84762b787e94bb69 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sat, 12 Apr 2025 20:23:12 +0200 Subject: [PATCH 03/37] Center button --- java/res/layout/main_keyboard_frame.xml | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index 2d1e71622d..27f8c496cf 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -49,17 +49,21 @@ android:layout_height="wrap_content" /> - + + + + + -- GitLab From 239c38a053c16f33cdc0af7712872092024e42fd Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sat, 12 Apr 2025 20:23:12 +0200 Subject: [PATCH 04/37] Center button --- java/res/layout/main_keyboard_frame.xml | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index 2d1e71622d..abccd48d30 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -49,17 +49,21 @@ android:layout_height="wrap_content" /> - + + + + + -- GitLab From 63928bbf0a0f2d8c7522f29e05c4c24d1e264e85 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 13 Apr 2025 13:21:32 +0200 Subject: [PATCH 05/37] Revert "Fix background" This reverts commit 8798afaccafe34ddc902a5d6135b113972505a32. --- java/res/layout/main_keyboard_frame.xml | 30 ++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index d42fe18fcd..269cf98f82 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -49,23 +49,17 @@ android:layout_height="wrap_content" /> - - - - - + -- GitLab From aa872933a0b0cd820261a45ded2aca0e4d679fc7 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 13 Apr 2025 13:23:41 +0200 Subject: [PATCH 06/37] Fix center --- java/res/layout/main_keyboard_frame.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index 269cf98f82..b1cfc45625 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -54,9 +54,9 @@ android:layout_width="48dp" android:layout_height="48dp" android:layout_gravity="top|end" - android:layout_marginTop="8dp" - android:layout_marginEnd="8dp" - android:background="?attr/selectableItemBackgroundBorderless" + android:layout_marginTop="16dp" + android:layout_marginEnd="16dp" + android:background="@android:color/transparent" android:src="@drawable/ic_ime_switch" android:contentDescription="@string/ime_switch_button" android:focusable="true" -- GitLab From 23d6bea269c47eadab1c31876a65e5a316031ef8 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 13 Apr 2025 13:43:27 +0200 Subject: [PATCH 07/37] Get SetupWizard status --- .../android/inputmethod/latin/LatinIME.java | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index cbc6e71105..317a74884a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -105,6 +105,8 @@ import com.android.inputmethod.latin.utils.StatsUtils; import com.android.inputmethod.latin.utils.StatsUtilsManager; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.ViewLayoutUtils; +import android.provider.Settings; +import android.content.ContentResolver; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -870,18 +872,33 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mSuggestionStripView.setListener(this, view); } - ImageButton floatingButton = view.findViewById(R.id.floating_button); - if (floatingButton != null) { - floatingButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Log.d(TAG, "Clicked"); - //launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA); - } - }); + if (isSetupWizardFinished()) { + ImageButton floatingButton = view.findViewById(R.id.floating_button); + if (floatingButton != null) { + floatingButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Log.d(TAG, "Clicked"); + //launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA); + } + }); + } } } + private boolean isSetupWizardFinished() { + Log.d(TAG, "isSetupWizardFinished"); + ContentResolver contentResolver = mDisplayContext.getContentResolver(); + Log.d(TAG, "isSetupWizardFinished 2"); + boolean isDeviceProvisioned = Settings.Global.getInt(contentResolver, + Settings.Global.DEVICE_PROVISIONED, 0) == 1; + boolean isUserSetupComplete = Settings.Secure.getInt(contentResolver, + Settings.Secure.USER_SETUP_COMPLETE, 0) == 1; + Log.d(TAG, "isSetupWizardFinished " + isDeviceProvisioned + " " + isUserSetupComplete); + + return isDeviceProvisioned && isUserSetupComplete; + } + @Override public void setCandidatesView(final View view) { // To ensure that CandidatesView will never be set. -- GitLab From 17a97d7d797b1561b12e71ad3f2238780a57052b Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 13 Apr 2025 14:47:19 +0200 Subject: [PATCH 08/37] reference to Settings is ambiguous --- java/src/com/android/inputmethod/latin/LatinIME.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 317a74884a..57c78a9144 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -105,7 +105,7 @@ import com.android.inputmethod.latin.utils.StatsUtils; import com.android.inputmethod.latin.utils.StatsUtilsManager; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.ViewLayoutUtils; -import android.provider.Settings; + import android.content.ContentResolver; import java.io.FileDescriptor; @@ -890,10 +890,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen Log.d(TAG, "isSetupWizardFinished"); ContentResolver contentResolver = mDisplayContext.getContentResolver(); Log.d(TAG, "isSetupWizardFinished 2"); - boolean isDeviceProvisioned = Settings.Global.getInt(contentResolver, - Settings.Global.DEVICE_PROVISIONED, 0) == 1; - boolean isUserSetupComplete = Settings.Secure.getInt(contentResolver, - Settings.Secure.USER_SETUP_COMPLETE, 0) == 1; + boolean isDeviceProvisioned = android.provider.Settings.Global.getInt(contentResolver, + android.provider.Settings.Global.DEVICE_PROVISIONED, 0) == 1; + boolean isUserSetupComplete = android.provider.Settings.Secure.getInt(contentResolver, + android.provider.Settings.Secure.USER_SETUP_COMPLETE, 0) == 1; Log.d(TAG, "isSetupWizardFinished " + isDeviceProvisioned + " " + isUserSetupComplete); return isDeviceProvisioned && isUserSetupComplete; -- GitLab From b2ac56ef74df0c9e82f390a916234fd8e2896883 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 13 Apr 2025 15:39:04 +0200 Subject: [PATCH 09/37] Remove --- java/src/com/android/inputmethod/latin/LatinIME.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 57c78a9144..f53c5cb8f8 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -892,11 +892,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen Log.d(TAG, "isSetupWizardFinished 2"); boolean isDeviceProvisioned = android.provider.Settings.Global.getInt(contentResolver, android.provider.Settings.Global.DEVICE_PROVISIONED, 0) == 1; - boolean isUserSetupComplete = android.provider.Settings.Secure.getInt(contentResolver, - android.provider.Settings.Secure.USER_SETUP_COMPLETE, 0) == 1; - Log.d(TAG, "isSetupWizardFinished " + isDeviceProvisioned + " " + isUserSetupComplete); + //boolean isUserSetupComplete = android.provider.Settings.Secure.getInt(contentResolver, + // android.provider.Settings.Secure.USER_SETUP_COMPLETE, 0) == 1; + Log.d(TAG, "isSetupWizardFinished " + isDeviceProvisioned ); - return isDeviceProvisioned && isUserSetupComplete; + return isDeviceProvisioned;// && isUserSetupComplete; } @Override -- GitLab From c9d5e7a01e6b00fa7f63a83c63755ff859429222 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 13 Apr 2025 21:36:18 +0200 Subject: [PATCH 10/37] Better position & click --- java/res/layout/main_keyboard_frame.xml | 7 +++---- java/src/com/android/inputmethod/latin/LatinIME.java | 9 ++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index b1cfc45625..a9af600c57 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -20,12 +20,11 @@ + android:layout_width="match_parent" + android:layout_height="wrap_content"> diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index f53c5cb8f8..e828d2bb66 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -872,9 +872,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mSuggestionStripView.setListener(this, view); } - if (isSetupWizardFinished()) { - ImageButton floatingButton = view.findViewById(R.id.floating_button); - if (floatingButton != null) { + ImageButton floatingButton = view.findViewById(R.id.floating_button); + if (floatingButton != null) { + if (isSetupWizardFinished()) { + floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -882,6 +883,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen //launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA); } }); + } else { + floatingButton.setVisibility(View.GONE); } } } -- GitLab From 947ce509aa30e57b1dc8109f3656a75b9692c864 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 14 Apr 2025 09:52:54 +0200 Subject: [PATCH 11/37] Try center --- java/res/layout/main_keyboard_frame.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index a9af600c57..c5928bcbef 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -20,8 +20,9 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom"> Date: Mon, 14 Apr 2025 12:03:20 +0200 Subject: [PATCH 12/37] Better center --- java/res/layout/main_keyboard_frame.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index c5928bcbef..bc618462c4 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -54,8 +54,8 @@ android:layout_width="48dp" android:layout_height="48dp" android:layout_gravity="top|end" - android:layout_marginTop="-16dp" - android:layout_marginEnd="16dp" + android:layout_marginTop="-8dp" + android:layout_marginEnd="8dp" android:background="@android:color/transparent" android:src="@drawable/ic_ime_switch" android:contentDescription="@string/ime_switch_button" -- GitLab From 96e89ab1e1d5cd201bf91a65721cf9b98969461c Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 14 Apr 2025 18:18:33 +0200 Subject: [PATCH 13/37] Update icon --- java/res/drawable/ic_ime_switch.xml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/java/res/drawable/ic_ime_switch.xml b/java/res/drawable/ic_ime_switch.xml index e484a69816..2302161c1c 100644 --- a/java/res/drawable/ic_ime_switch.xml +++ b/java/res/drawable/ic_ime_switch.xml @@ -1,15 +1,9 @@ - - - - + - + android:pathData="M11.48 19.69c2.72 0 4.91 -2.2 4.91 -4.92l0.02 -9.84c0 -2.72 -2.2 -4.92 -4.92 -4.92s-4.92 2.2 -4.92 4.92v9.84c0 2.72 2.2 4.92 4.92 4.92ZM20.18 14.77c0 4.92 -4.17 8.37 -8.7 8.37S2.79 19.69 2.79 14.77H0c0 5.59 4.46 10.22 9.84 11.03v5.38h3.28v-5.38c5.38 -0.79 9.84 -5.41 9.84 -11.03h-2.79Z" + android:fillColor="#DEADB5B9" /> + \ No newline at end of file -- GitLab From 92bdeb810097a2c6a22d5bcccc52c2f54ce6891e Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 14 Apr 2025 18:18:43 +0200 Subject: [PATCH 14/37] Center --- java/res/layout/main_keyboard_frame.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index bc618462c4..89e0f3a96a 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -54,8 +54,8 @@ android:layout_width="48dp" android:layout_height="48dp" android:layout_gravity="top|end" - android:layout_marginTop="-8dp" - android:layout_marginEnd="8dp" + android:layout_marginTop="-4dp" + android:layout_marginEnd="4dp" android:background="@android:color/transparent" android:src="@drawable/ic_ime_switch" android:contentDescription="@string/ime_switch_button" -- GitLab From e36c1ed3e46e346f57df2c8e97c8a6224bfcaf1b Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 13 Apr 2025 13:21:32 +0200 Subject: [PATCH 15/37] Revert "Fix background" This reverts commit 8798afaccafe34ddc902a5d6135b113972505a32. --- java/res/drawable/ic_ime_switch.xml | 22 +++++------- java/res/layout/main_keyboard_frame.xml | 32 +++++++---------- .../android/inputmethod/latin/LatinIME.java | 34 +++++++++++++++---- 3 files changed, 48 insertions(+), 40 deletions(-) diff --git a/java/res/drawable/ic_ime_switch.xml b/java/res/drawable/ic_ime_switch.xml index e484a69816..2302161c1c 100644 --- a/java/res/drawable/ic_ime_switch.xml +++ b/java/res/drawable/ic_ime_switch.xml @@ -1,15 +1,9 @@ - - - - + - + android:pathData="M11.48 19.69c2.72 0 4.91 -2.2 4.91 -4.92l0.02 -9.84c0 -2.72 -2.2 -4.92 -4.92 -4.92s-4.92 2.2 -4.92 4.92v9.84c0 2.72 2.2 4.92 4.92 4.92ZM20.18 14.77c0 4.92 -4.17 8.37 -8.7 8.37S2.79 19.69 2.79 14.77H0c0 5.59 4.46 10.22 9.84 11.03v5.38h3.28v-5.38c5.38 -0.79 9.84 -5.41 9.84 -11.03h-2.79Z" + android:fillColor="#DEADB5B9" /> + \ No newline at end of file diff --git a/java/res/layout/main_keyboard_frame.xml b/java/res/layout/main_keyboard_frame.xml index d42fe18fcd..89e0f3a96a 100644 --- a/java/res/layout/main_keyboard_frame.xml +++ b/java/res/layout/main_keyboard_frame.xml @@ -25,7 +25,7 @@ android:layout_gravity="bottom"> @@ -49,23 +49,17 @@ android:layout_height="wrap_content" /> - - - - - + diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index cbc6e71105..e828d2bb66 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -106,6 +106,8 @@ import com.android.inputmethod.latin.utils.StatsUtilsManager; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.ViewLayoutUtils; +import android.content.ContentResolver; + import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; @@ -872,16 +874,34 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - floatingButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Log.d(TAG, "Clicked"); - //launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA); - } - }); + if (isSetupWizardFinished()) { + floatingButton.setVisibility(View.VISIBLE); + floatingButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Log.d(TAG, "Clicked"); + //launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA); + } + }); + } else { + floatingButton.setVisibility(View.GONE); + } } } + private boolean isSetupWizardFinished() { + Log.d(TAG, "isSetupWizardFinished"); + ContentResolver contentResolver = mDisplayContext.getContentResolver(); + Log.d(TAG, "isSetupWizardFinished 2"); + boolean isDeviceProvisioned = android.provider.Settings.Global.getInt(contentResolver, + android.provider.Settings.Global.DEVICE_PROVISIONED, 0) == 1; + //boolean isUserSetupComplete = android.provider.Settings.Secure.getInt(contentResolver, + // android.provider.Settings.Secure.USER_SETUP_COMPLETE, 0) == 1; + Log.d(TAG, "isSetupWizardFinished " + isDeviceProvisioned ); + + return isDeviceProvisioned;// && isUserSetupComplete; + } + @Override public void setCandidatesView(final View view) { // To ensure that CandidatesView will never be set. -- GitLab From 525d62e66b610cc5c83307e045701ad0726ceed5 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Thu, 17 Apr 2025 16:06:49 +0200 Subject: [PATCH 16/37] switchToNextInputMethod --- .../android/inputmethod/latin/LatinIME.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e828d2bb66..cd754e4384 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -108,6 +108,11 @@ import com.android.inputmethod.latin.utils.ViewLayoutUtils; import android.content.ContentResolver; +import android.view.inputmethod.InputMethodManager; +import android.view.inputmethod.InputMethodSubtype; + +import android.os.IBinder; + import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; @@ -118,6 +123,9 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; + + + /** * Input method implementation for Qwerty'ish keyboard. */ @@ -880,7 +888,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public void onClick(View v) { Log.d(TAG, "Clicked"); - //launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA); + switchToNextInputMethod(); } }); } else { @@ -889,6 +897,19 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } } + private void switchToNextInputMethod() { + Log.d(TAG, "switchToNextInputMethod"); + final IBinder token = getWindow().getWindow().getAttributes().token; + Log.d(TAG, "switchToNextInputMethod 2"); + InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); + Log.d(TAG, "switchToNextInputMethod 3"); + if (imm != null) { + Log.d(TAG, "switchToNextInputMethod 4"); + imm.switchToNextInputMethod(token, false /* onlyCurrentIme */); + Log.d(TAG, "switchToNextInputMethod 5"); + } + } + private boolean isSetupWizardFinished() { Log.d(TAG, "isSetupWizardFinished"); ContentResolver contentResolver = mDisplayContext.getContentResolver(); -- GitLab From 3fac720a57b9fe9d09b71e96c3211e2244028e28 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Wed, 23 Apr 2025 10:34:06 +0200 Subject: [PATCH 17/37] Do not display switch button if button user is not premium REF: https://gitlab.e.foundation/e/os/backlog/-/issues/3066 --- .../android/inputmethod/latin/LatinIME.java | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index cd754e4384..d116ff4c63 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -23,6 +23,8 @@ import static com.android.inputmethod.latin.common.Constants.ImeOption.NO_MICROP import static com.android.inputmethod.latin.common.Constants.ImeOption.NO_MICROPHONE_COMPAT; import android.Manifest.permission; +import android.accounts.Account; +import android.accounts.AccountManager; import android.app.ActivityOptions; import android.app.AlertDialog; import android.content.BroadcastReceiver; @@ -56,6 +58,7 @@ import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; import android.widget.ImageButton; @@ -108,10 +111,6 @@ import com.android.inputmethod.latin.utils.ViewLayoutUtils; import android.content.ContentResolver; -import android.view.inputmethod.InputMethodManager; -import android.view.inputmethod.InputMethodSubtype; - -import android.os.IBinder; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -882,7 +881,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - if (isSetupWizardFinished()) { + if (isSetupWizardFinished() && accountIsPremium()) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override @@ -898,29 +897,36 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } private void switchToNextInputMethod() { - Log.d(TAG, "switchToNextInputMethod"); - final IBinder token = getWindow().getWindow().getAttributes().token; - Log.d(TAG, "switchToNextInputMethod 2"); - InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); - Log.d(TAG, "switchToNextInputMethod 3"); - if (imm != null) { - Log.d(TAG, "switchToNextInputMethod 4"); - imm.switchToNextInputMethod(token, false /* onlyCurrentIme */); - Log.d(TAG, "switchToNextInputMethod 5"); - } + final IBinder token = getWindow().getAttributes().token; + InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); + if (imm != null) { + imm.switchToNextInputMethod(token, false); + } } private boolean isSetupWizardFinished() { - Log.d(TAG, "isSetupWizardFinished"); ContentResolver contentResolver = mDisplayContext.getContentResolver(); - Log.d(TAG, "isSetupWizardFinished 2"); boolean isDeviceProvisioned = android.provider.Settings.Global.getInt(contentResolver, android.provider.Settings.Global.DEVICE_PROVISIONED, 0) == 1; - //boolean isUserSetupComplete = android.provider.Settings.Secure.getInt(contentResolver, - // android.provider.Settings.Secure.USER_SETUP_COMPLETE, 0) == 1; - Log.d(TAG, "isSetupWizardFinished " + isDeviceProvisioned ); + return isDeviceProvisioned; + } + + private boolean accountIsPremium() { + AccountManager accountManager = AccountManager.get(mDisplayContext); + Account[] accountList = accountManager.getAccountsByType("e.foundation.webdav.eelo"); + boolean accountIsPremium = false; + + if (accountList != null) { + for (Account account : accountList) { + String groupData = accountManager.getUserData(account, "group"); + if ("premium".equals(groupData)) { + accountIsPremium = true; + break; + } + } + } - return isDeviceProvisioned;// && isUserSetupComplete; + return accountIsPremium; } @Override -- GitLab From 8fe072f18f742a51abb6c1ab4873d1adec8a98c6 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Wed, 23 Apr 2025 13:47:16 +0200 Subject: [PATCH 18/37] Remove extra lines --- java/src/com/android/inputmethod/latin/LatinIME.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d116ff4c63..17e83015bb 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -111,7 +111,6 @@ import com.android.inputmethod.latin.utils.ViewLayoutUtils; import android.content.ContentResolver; - import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; @@ -122,9 +121,6 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; - - - /** * Input method implementation for Qwerty'ish keyboard. */ -- GitLab From bd67df356861e78465a4fa007f005b37dafc5dc7 Mon Sep 17 00:00:00 2001 From: Frank Preel Date: Wed, 23 Apr 2025 11:47:25 +0000 Subject: [PATCH 19/37] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Jonathan Klee --- java/src/com/android/inputmethod/latin/LatinIME.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d116ff4c63..843441dbe5 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -898,7 +898,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void switchToNextInputMethod() { final IBinder token = getWindow().getAttributes().token; - InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); + InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); if (imm != null) { imm.switchToNextInputMethod(token, false); } -- GitLab From cc147e5a4064879cf460c6d28817c580d224a9e2 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Wed, 23 Apr 2025 14:06:11 +0200 Subject: [PATCH 20/37] Remove debug --- java/src/com/android/inputmethod/latin/LatinIME.java | 1 - 1 file changed, 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index cc0ebeea10..a621104656 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -882,7 +882,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Log.d(TAG, "Clicked"); switchToNextInputMethod(); } }); -- GitLab From ecb562d8e6d704835dc643139432a3acca3a1de7 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Wed, 23 Apr 2025 16:11:34 +0200 Subject: [PATCH 21/37] Rename --- java/src/com/android/inputmethod/latin/LatinIME.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index a621104656..ce3b080db4 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -894,8 +894,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void switchToNextInputMethod() { final IBinder token = getWindow().getAttributes().token; InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); - if (imm != null) { - imm.switchToNextInputMethod(token, false); + if (inputMethodManager != null) { + inputMethodManager.switchToNextInputMethod(token, false); } } -- GitLab From ff9468bc777ddf900ecdadbb24e7453186ce1c59 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Wed, 23 Apr 2025 16:29:27 +0200 Subject: [PATCH 22/37] As for token like other --- java/src/com/android/inputmethod/latin/LatinIME.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index ce3b080db4..17a1d3f9dd 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -892,7 +892,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } private void switchToNextInputMethod() { - final IBinder token = getWindow().getAttributes().token; + final IBinder token = getWindow().getWindow().getAttributes().token; InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); if (inputMethodManager != null) { inputMethodManager.switchToNextInputMethod(token, false); -- GitLab From f9f30cc594de106d017df7e69423ad87c709871c Mon Sep 17 00:00:00 2001 From: frankpreel Date: Fri, 25 Apr 2025 16:32:14 +0200 Subject: [PATCH 23/37] add debug --- java/src/com/android/inputmethod/latin/LatinIME.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 17a1d3f9dd..c6a1433a1f 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -903,6 +903,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ContentResolver contentResolver = mDisplayContext.getContentResolver(); boolean isDeviceProvisioned = android.provider.Settings.Global.getInt(contentResolver, android.provider.Settings.Global.DEVICE_PROVISIONED, 0) == 1; + Log.d(TAG, ">>>isDeviceProvisioned=" + isDeviceProvisioned); return isDeviceProvisioned; } @@ -911,16 +912,19 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen Account[] accountList = accountManager.getAccountsByType("e.foundation.webdav.eelo"); boolean accountIsPremium = false; + Log.d(TAG, ">>>" + accountList); if (accountList != null) { for (Account account : accountList) { String groupData = accountManager.getUserData(account, "group"); + Log.d(TAG, ">>>" + groupData); if ("premium".equals(groupData)) { + Log.d(TAG, ">>> OK"); accountIsPremium = true; break; } } } - + Log.d(TAG, ">>>>>>" + accountIsPremium); return accountIsPremium; } -- GitLab From c4546117ce0a5d86f255df57c2dccfdad40626a1 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Fri, 25 Apr 2025 21:05:46 +0200 Subject: [PATCH 24/37] Debug --- java/src/com/android/inputmethod/latin/LatinIME.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index c6a1433a1f..bacfaca01a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -909,12 +909,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private boolean accountIsPremium() { AccountManager accountManager = AccountManager.get(mDisplayContext); + Log.d(TAG, ">>>" + accountManager); Account[] accountList = accountManager.getAccountsByType("e.foundation.webdav.eelo"); boolean accountIsPremium = false; - Log.d(TAG, ">>>" + accountList); + Log.d(TAG, ">>>" + accountList.length); if (accountList != null) { + Log.d(TAG, ">>>accountList is not null"); for (Account account : accountList) { + Log.d(TAG, ">>>accountList iterate..."); String groupData = accountManager.getUserData(account, "group"); Log.d(TAG, ">>>" + groupData); if ("premium".equals(groupData)) { @@ -923,6 +926,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen break; } } + } else { + Log.d(TAG, ">>>accountList is null"); } Log.d(TAG, ">>>>>>" + accountIsPremium); return accountIsPremium; -- GitLab From 7018874df777674dc05aab593aadcb53c5728f0a Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sat, 26 Apr 2025 10:09:32 +0200 Subject: [PATCH 25/37] Debug --- .../android/inputmethod/latin/LatinIME.java | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index bacfaca01a..f35f8dbbd4 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -25,6 +25,8 @@ import static com.android.inputmethod.latin.common.Constants.ImeOption.NO_MICROP import android.Manifest.permission; import android.accounts.Account; import android.accounts.AccountManager; +import android.content.pm.PackageManager; +import androidx.core.content.ContextCompat; import android.app.ActivityOptions; import android.app.AlertDialog; import android.content.BroadcastReceiver; @@ -877,7 +879,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - if (isSetupWizardFinished() && accountIsPremium()) { + if (isSetupWizardFinished() && accountIsPremium(this)) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override @@ -907,30 +909,30 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return isDeviceProvisioned; } - private boolean accountIsPremium() { - AccountManager accountManager = AccountManager.get(mDisplayContext); - Log.d(TAG, ">>>" + accountManager); + private boolean accountIsPremium(Context context) { + if(ContextCompat.checkSelfPermission(context, android.Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) { + Log.e(TAG, "Missing permission"); + return false; + } + + AccountManager accountManager = AccountManager.get(context); + Log.d(TAG, "AccountManager: " + accountManager); + Account[] accountList = accountManager.getAccountsByType("e.foundation.webdav.eelo"); - boolean accountIsPremium = false; - - Log.d(TAG, ">>>" + accountList.length); - if (accountList != null) { - Log.d(TAG, ">>>accountList is not null"); - for (Account account : accountList) { - Log.d(TAG, ">>>accountList iterate..."); - String groupData = accountManager.getUserData(account, "group"); - Log.d(TAG, ">>>" + groupData); - if ("premium".equals(groupData)) { - Log.d(TAG, ">>> OK"); - accountIsPremium = true; - break; - } + Log.d(TAG, "Nb: " + accountList.length); + + for (Account account : accountList) { + Log.d(TAG, "Account: " + account.name); + String groupData = accountManager.getUserData(account, "group"); + Log.d(TAG, "Group: " + groupData); + if ("premium".equals(groupData)) { + Log.d(TAG, "Premium"); + return true; } - } else { - Log.d(TAG, ">>>accountList is null"); } - Log.d(TAG, ">>>>>>" + accountIsPremium); - return accountIsPremium; + + Log.d(TAG, "No premium user"); + return false; } @Override -- GitLab From 7a14d259df154c769cbd621f6bdf9741921babc5 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 27 Apr 2025 09:59:30 +0200 Subject: [PATCH 26/37] Test several context --- java/src/com/android/inputmethod/latin/LatinIME.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index f35f8dbbd4..e7fee2f795 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -877,9 +877,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mSuggestionStripView.setListener(this, view); } + Context secureContext = createPackageContext( + "com.android.inputmethod.latin", + Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY + ); + ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - if (isSetupWizardFinished() && accountIsPremium(this)) { + if (isSetupWizardFinished() && ( accountIsPremium(getApplicationContext() || accountIsPremium(secureContext)) ) ) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override @@ -932,6 +937,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } Log.d(TAG, "No premium user"); + return false; } -- GitLab From 07abdb3a08fc3bf3056fe5e8834f042e6297744a Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 27 Apr 2025 14:18:16 +0200 Subject: [PATCH 27/37] Test several context --- java/src/com/android/inputmethod/latin/LatinIME.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e7fee2f795..033549c967 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -884,7 +884,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - if (isSetupWizardFinished() && ( accountIsPremium(getApplicationContext() || accountIsPremium(secureContext)) ) ) { + if (isSetupWizardFinished() && ( accountIsPremium(getApplicationContext()) || accountIsPremium(secureContext) ) ) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override -- GitLab From ad8c8c04846955e2e63a9b0003fd29cd3d1b7998 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Sun, 27 Apr 2025 14:18:16 +0200 Subject: [PATCH 28/37] Test several context --- java/src/com/android/inputmethod/latin/LatinIME.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e7fee2f795..0dd6f700e2 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -884,7 +884,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - if (isSetupWizardFinished() && ( accountIsPremium(getApplicationContext() || accountIsPremium(secureContext)) ) ) { + if (isSetupWizardFinished() && (accountIsPremium(getApplicationContext()) || accountIsPremium(secureContext))) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override -- GitLab From f36da27bb0bae6f0e08705cc82c40701902dec17 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 28 Apr 2025 09:58:56 +0200 Subject: [PATCH 29/37] Try to find if user is premium in several ways --- java/src/com/android/inputmethod/latin/LatinIME.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index fc16e9deb0..32afaa7366 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -915,12 +915,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen "com.android.inputmethod.latin", Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY ); - Log.d(TAG, "Contexte sécurisé créé avec succès: " + secureContext); + Log.d(TAG, "Secur context: " + secureContext); return accountIsPremium(secureContext); } catch (PackageManager.NameNotFoundException e) { - // Cas gravissime, impossible réellement en théorie dans ton cas précis - Log.wtf(TAG, "Erreur CRITIQUE: Le package LatinIME n'est pas trouvé par createPackageContext()", e); - // Logique de secours absolue: repli sur contexte initial même si restreint, mieux que rien + Log.wtf(TAG, "Error createPackageContext()", e); return accountIsPremium(this); } } -- GitLab From 6d1c9eddd7f610dbf9a05db3066c33a9ee151f15 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 28 Apr 2025 11:02:10 +0200 Subject: [PATCH 30/37] Try several contexts --- .../android/inputmethod/latin/LatinIME.java | 52 ++++++++++++++----- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 17a1d3f9dd..32afaa7366 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -25,6 +25,8 @@ import static com.android.inputmethod.latin.common.Constants.ImeOption.NO_MICROP import android.Manifest.permission; import android.accounts.Account; import android.accounts.AccountManager; +import android.content.pm.PackageManager; +import androidx.core.content.ContextCompat; import android.app.ActivityOptions; import android.app.AlertDialog; import android.content.BroadcastReceiver; @@ -877,7 +879,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - if (isSetupWizardFinished() && accountIsPremium()) { + if (isSetupWizardFinished() && (accountIsPremium(getApplicationContext()) || accountIsPremiumFromIME())) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override @@ -903,25 +905,49 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ContentResolver contentResolver = mDisplayContext.getContentResolver(); boolean isDeviceProvisioned = android.provider.Settings.Global.getInt(contentResolver, android.provider.Settings.Global.DEVICE_PROVISIONED, 0) == 1; + Log.d(TAG, ">>>isDeviceProvisioned=" + isDeviceProvisioned); return isDeviceProvisioned; } - private boolean accountIsPremium() { - AccountManager accountManager = AccountManager.get(mDisplayContext); - Account[] accountList = accountManager.getAccountsByType("e.foundation.webdav.eelo"); - boolean accountIsPremium = false; + private boolean accountIsPremiumFromIME() { + try { + final Context secureContext = createPackageContext( + "com.android.inputmethod.latin", + Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY + ); + Log.d(TAG, "Secur context: " + secureContext); + return accountIsPremium(secureContext); + } catch (PackageManager.NameNotFoundException e) { + Log.wtf(TAG, "Error createPackageContext()", e); + return accountIsPremium(this); + } + } - if (accountList != null) { - for (Account account : accountList) { - String groupData = accountManager.getUserData(account, "group"); - if ("premium".equals(groupData)) { - accountIsPremium = true; - break; - } + private boolean accountIsPremium(Context context) { + if(ContextCompat.checkSelfPermission(context, android.Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) { + Log.e(TAG, "Missing permission"); + return false; + } + + AccountManager accountManager = AccountManager.get(context); + Log.d(TAG, "AccountManager: " + accountManager); + + Account[] accountList = accountManager.getAccountsByType("e.foundation.webdav.eelo"); + Log.d(TAG, "Nb: " + accountList.length); + + for (Account account : accountList) { + Log.d(TAG, "Account: " + account.name); + String groupData = accountManager.getUserData(account, "group"); + Log.d(TAG, "Group: " + groupData); + if ("premium".equals(groupData)) { + Log.d(TAG, "Premium"); + return true; } } - return accountIsPremium; + Log.d(TAG, "No premium user"); + + return false; } @Override -- GitLab From 4aac6d6925dfa636d36c67878fb156a2d1d5f30d Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 28 Apr 2025 16:45:02 +0200 Subject: [PATCH 31/37] Try platform signed app --- java/Android.bp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/Android.bp b/java/Android.bp index 85f305977a..fc1ff3cf8f 100644 --- a/java/Android.bp +++ b/java/Android.bp @@ -36,7 +36,7 @@ android_app { srcs: ["src/**/*.java"], - certificate: "shared", + certificate: "platform", jni_libs: ["libjni_latinime"], -- GitLab From 0c79183f45482e9d9a91bc3082d3fc68ce3230f8 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 28 Apr 2025 20:28:24 +0200 Subject: [PATCH 32/37] Test for switching to precise keyboard --- java/src/com/android/inputmethod/latin/LatinIME.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 32afaa7366..60fee66c56 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -866,6 +866,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mIsHardwareAcceleratedDrawingEnabled); } + public void switchToSttIme() { + switchInputMethod("foundation.e.stt/.MurenaWhisperInputService:"); + } + @Override public void setInputView(final View view) { super.setInputView(view); @@ -879,12 +883,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - if (isSetupWizardFinished() && (accountIsPremium(getApplicationContext()) || accountIsPremiumFromIME())) { + //if (isSetupWizardFinished() && (accountIsPremium(getApplicationContext()) || accountIsPremiumFromIME())) { + if (true) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - switchToNextInputMethod(); + //switchToNextInputMethod(); + switchToSttIme(); } }); } else { -- GitLab From 63867d06973a974ca0929e3a433a0d5a23d151c5 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 28 Apr 2025 20:36:48 +0200 Subject: [PATCH 33/37] Test for switching to precise keyboard --- java/src/com/android/inputmethod/latin/LatinIME.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 32afaa7366..b62756a32f 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -866,6 +866,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mIsHardwareAcceleratedDrawingEnabled); } + public void switchToSttIme() { + switchInputMethod("foundation.e.stt/.MurenaWhisperInputService"); + } + @Override public void setInputView(final View view) { super.setInputView(view); @@ -879,12 +883,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - if (isSetupWizardFinished() && (accountIsPremium(getApplicationContext()) || accountIsPremiumFromIME())) { + //if (isSetupWizardFinished() && (accountIsPremium(getApplicationContext()) || accountIsPremiumFromIME())) { + if (true) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - switchToNextInputMethod(); + //switchToNextInputMethod(); + switchToSttIme(); } }); } else { -- GitLab From 00925d737dc6c3f76b5af9cda897dca9be26924c Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 28 Apr 2025 21:24:27 +0200 Subject: [PATCH 34/37] Test dynamic switch button display --- .../android/inputmethod/latin/LatinIME.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b62756a32f..7c3853f735 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -219,6 +219,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public final UIHandler mHandler = new UIHandler(this); + private ImageButton floatingButton; + public static final class UIHandler extends LeakGuardHandlerWrapper { private static final int MSG_UPDATE_SHIFT_STATE = 0; private static final int MSG_PENDING_IMS_CALLBACK = 1; @@ -881,10 +883,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mSuggestionStripView.setListener(this, view); } - ImageButton floatingButton = view.findViewById(R.id.floating_button); + floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { //if (isSetupWizardFinished() && (accountIsPremium(getApplicationContext()) || accountIsPremiumFromIME())) { - if (true) { + if (shouldShowFloatingButton()) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override @@ -899,6 +901,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } } + private boolean shouldShowFloatingButton() { + Log.d(TAG, ">>>shouldShowFloatingButton"); + return true; + } + private void switchToNextInputMethod() { final IBinder token = getWindow().getWindow().getAttributes().token; InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); @@ -970,6 +977,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void onStartInputView(final EditorInfo editorInfo, final boolean restarting) { mHandler.onStartInputView(editorInfo, restarting); mStatsUtilsManager.onStartInputView(); + + if (floatingButton != null) { + if (shouldShowFloatingButton()) { + floatingButton.setVisibility(View.VISIBLE); + } else { + floatingButton.setVisibility(View.GONE); + } + } } @Override -- GitLab From 5458c7bf43ff81e440f29fb45431b38c76e7212b Mon Sep 17 00:00:00 2001 From: frankpreel Date: Tue, 29 Apr 2025 10:55:45 +0200 Subject: [PATCH 35/37] Test isPremium several + Keyboard activated --- .../android/inputmethod/latin/LatinIME.java | 72 ++++++------------- 1 file changed, 21 insertions(+), 51 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 7c3853f735..ad669dbacd 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -60,6 +60,7 @@ import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; import android.widget.ImageButton; @@ -140,6 +141,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private static final int MAX_SPACESLIDE_CHARS = 32; + private static final String KEY_STT_KEYBOARD = "foundation.e.stt/.MurenaWhisperInputService"; + /** * A broadcast intent action to hide the software keyboard. */ @@ -868,8 +871,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mIsHardwareAcceleratedDrawingEnabled); } - public void switchToSttIme() { - switchInputMethod("foundation.e.stt/.MurenaWhisperInputService"); + private boolean isSttKeyboardActivated() { + InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + List enabledImeList = inputMethodManager.getEnabledInputMethodList(); + for (InputMethodInfo inputMethodInfo : enabledImeList) { + if (inputMethodInfo.getId().equals(KEY_STT_KEYBOARD)) { + return true; + } + } + Log.e(TAG, "The targeted keyboard is not activated : " + KEY_STT_KEYBOARD); + return false; + } + + private void switchToSttIme() { + if (isSttKeyboardActivated()) { + switchInputMethod(KEY_STT_KEYBOARD); + } } @Override @@ -885,13 +902,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { - //if (isSetupWizardFinished() && (accountIsPremium(getApplicationContext()) || accountIsPremiumFromIME())) { if (shouldShowFloatingButton()) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - //switchToNextInputMethod(); switchToSttIme(); } }); @@ -902,64 +917,19 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } private boolean shouldShowFloatingButton() { - Log.d(TAG, ">>>shouldShowFloatingButton"); - return true; - } - - private void switchToNextInputMethod() { - final IBinder token = getWindow().getWindow().getAttributes().token; - InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); - if (inputMethodManager != null) { - inputMethodManager.switchToNextInputMethod(token, false); - } - } - - private boolean isSetupWizardFinished() { - ContentResolver contentResolver = mDisplayContext.getContentResolver(); - boolean isDeviceProvisioned = android.provider.Settings.Global.getInt(contentResolver, - android.provider.Settings.Global.DEVICE_PROVISIONED, 0) == 1; - Log.d(TAG, ">>>isDeviceProvisioned=" + isDeviceProvisioned); - return isDeviceProvisioned; - } - - private boolean accountIsPremiumFromIME() { - try { - final Context secureContext = createPackageContext( - "com.android.inputmethod.latin", - Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY - ); - Log.d(TAG, "Secur context: " + secureContext); - return accountIsPremium(secureContext); - } catch (PackageManager.NameNotFoundException e) { - Log.wtf(TAG, "Error createPackageContext()", e); - return accountIsPremium(this); - } + return accountIsPremium(getApplicationContext()) && isSttKeyboardActivated(); } private boolean accountIsPremium(Context context) { - if(ContextCompat.checkSelfPermission(context, android.Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) { - Log.e(TAG, "Missing permission"); - return false; - } - AccountManager accountManager = AccountManager.get(context); - Log.d(TAG, "AccountManager: " + accountManager); - Account[] accountList = accountManager.getAccountsByType("e.foundation.webdav.eelo"); - Log.d(TAG, "Nb: " + accountList.length); for (Account account : accountList) { - Log.d(TAG, "Account: " + account.name); String groupData = accountManager.getUserData(account, "group"); - Log.d(TAG, "Group: " + groupData); - if ("premium".equals(groupData)) { - Log.d(TAG, "Premium"); + if (groupData != null && groupData.contains("premium")) { return true; } } - - Log.d(TAG, "No premium user"); - return false; } -- GitLab From 4348d4c8fbdf2d5566952c55fdccc5fba29fec34 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Tue, 29 Apr 2025 13:45:47 +0200 Subject: [PATCH 36/37] Test Keyboard does not works after adding account, needs to use globe first. --- java/src/com/android/inputmethod/latin/LatinIME.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index ad669dbacd..1e58bf4e7b 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -885,6 +885,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void switchToSttIme() { if (isSttKeyboardActivated()) { + Log.d(TAG, "Load keyboard"); switchInputMethod(KEY_STT_KEYBOARD); } } @@ -904,9 +905,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (floatingButton != null) { if (shouldShowFloatingButton()) { floatingButton.setVisibility(View.VISIBLE); + floatingButton.setClickable(true); + floatingButton.setFocusable(true); + floatingButton.setEnabled(true); + floatingButton.bringToFront(); + floatingButton.requestFocus(); floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + Log.d(TAG, "Clicked"); switchToSttIme(); } }); -- GitLab From 2dcbaf7a3cb5e5b93b8823a088c419097f274316 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Tue, 29 Apr 2025 17:33:27 +0200 Subject: [PATCH 37/37] remove debug --- java/src/com/android/inputmethod/latin/LatinIME.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 1e58bf4e7b..faadd60e4c 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -879,13 +879,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return true; } } - Log.e(TAG, "The targeted keyboard is not activated : " + KEY_STT_KEYBOARD); return false; } private void switchToSttIme() { if (isSttKeyboardActivated()) { - Log.d(TAG, "Load keyboard"); switchInputMethod(KEY_STT_KEYBOARD); } } @@ -913,7 +911,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Log.d(TAG, "Clicked"); switchToSttIme(); } }); -- GitLab