diff --git a/java/Android.bp b/java/Android.bp
index 85f305977a19e5cc09ec523c476b9e5cb2626963..fc1ff3cf8f6dbb5abee83e006d2e2648797ad41e 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"],
diff --git a/java/res/drawable/ic_ime_switch.xml b/java/res/drawable/ic_ime_switch.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2302161c1c25ccb8a22cee698953551e94b27131
--- /dev/null
+++ b/java/res/drawable/ic_ime_switch.xml
@@ -0,0 +1,9 @@
+
+
+
\ 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 ebf746679c603d9899ed78f591c665bfcf1c806d..89e0f3a96a930fafddb98174e69fb29c1166bf24 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">
-
-
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:orientation="vertical">
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index d32ee3c2941d6f75a7b0c1e4e6cd67ea06c259e5..70995630f95f5e3ea1a05ae678869c9258555f49 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 d01bdd4dc82b2ab5eab9549a84267aac34868603..faadd60e4cd2709084a1ab84ec549957441b665a 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -23,6 +23,10 @@ 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.content.pm.PackageManager;
+import androidx.core.content.ContextCompat;
import android.app.ActivityOptions;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
@@ -56,7 +60,10 @@ 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;
import androidx.annotation.NonNull;
@@ -105,6 +112,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;
@@ -132,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.
*/
@@ -211,6 +222,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;
@@ -858,6 +871,23 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mIsHardwareAcceleratedDrawingEnabled);
}
+ 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;
+ }
+ }
+ return false;
+ }
+
+ private void switchToSttIme() {
+ if (isSttKeyboardActivated()) {
+ switchInputMethod(KEY_STT_KEYBOARD);
+ }
+ }
+
@Override
public void setInputView(final View view) {
super.setInputView(view);
@@ -868,6 +898,43 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (hasSuggestionStripView()) {
mSuggestionStripView.setListener(this, view);
}
+
+ floatingButton = view.findViewById(R.id.floating_button);
+ 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) {
+ switchToSttIme();
+ }
+ });
+ } else {
+ floatingButton.setVisibility(View.GONE);
+ }
+ }
+ }
+
+ private boolean shouldShowFloatingButton() {
+ return accountIsPremium(getApplicationContext()) && isSttKeyboardActivated();
+ }
+
+ private boolean accountIsPremium(Context context) {
+ AccountManager accountManager = AccountManager.get(context);
+ Account[] accountList = accountManager.getAccountsByType("e.foundation.webdav.eelo");
+
+ for (Account account : accountList) {
+ String groupData = accountManager.getUserData(account, "group");
+ if (groupData != null && groupData.contains("premium")) {
+ return true;
+ }
+ }
+ return false;
}
@Override
@@ -884,6 +951,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