Loading java/res/drawable/ic_ime_switch.xml 0 → 100644 +9 −0 Original line number Diff line number Diff line <vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" android:viewportWidth="22.97" android:viewportHeight="31.17" android:width="22.97dp" android:height="31.17dp"> <path 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" /> </vector> No newline at end of file java/res/layout/main_keyboard_frame.xml +39 −19 Original line number Diff line number Diff line Loading @@ -18,10 +18,15 @@ */ --> <LinearLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:orientation="vertical"> Loading @@ -43,3 +48,18 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> <ImageButton android:id="@+id/floating_button" android:layout_width="48dp" android:layout_height="48dp" android:layout_gravity="top|end" 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" android:focusable="true" android:clickable="true" /> </FrameLayout> java/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -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 --> <!-- This resource is corresponding to msgid="5433275485499039199" --> <string name="user_dict_fast_scroll_alphabet">\u0020ABCDEFGHIJKLMNOPQRSTUVWXYZ</string> <!-- Speach to text --> <string name="ime_switch_button">STT</string> </resources> java/src/com/android/inputmethod/latin/LatinIME.java +54 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,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; Loading Loading @@ -54,7 +56,9 @@ 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; import androidx.annotation.NonNull; Loading Loading @@ -103,6 +107,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; Loading Loading @@ -849,6 +855,54 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (hasSuggestionStripView()) { mSuggestionStripView.setListener(this, view); } ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { if (isSetupWizardFinished() && accountIsPremium()) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switchToNextInputMethod(); } }); } else { floatingButton.setVisibility(View.GONE); } } } private void switchToNextInputMethod() { final IBinder token = getWindow().getAttributes().token; InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); if (imm != null) { imm.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; 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 accountIsPremium; } @Override Loading Loading
java/res/drawable/ic_ime_switch.xml 0 → 100644 +9 −0 Original line number Diff line number Diff line <vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" android:viewportWidth="22.97" android:viewportHeight="31.17" android:width="22.97dp" android:height="31.17dp"> <path 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" /> </vector> No newline at end of file
java/res/layout/main_keyboard_frame.xml +39 −19 Original line number Diff line number Diff line Loading @@ -18,10 +18,15 @@ */ --> <LinearLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:orientation="vertical"> Loading @@ -43,3 +48,18 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> <ImageButton android:id="@+id/floating_button" android:layout_width="48dp" android:layout_height="48dp" android:layout_gravity="top|end" 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" android:focusable="true" android:clickable="true" /> </FrameLayout>
java/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -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 --> <!-- This resource is corresponding to msgid="5433275485499039199" --> <string name="user_dict_fast_scroll_alphabet">\u0020ABCDEFGHIJKLMNOPQRSTUVWXYZ</string> <!-- Speach to text --> <string name="ime_switch_button">STT</string> </resources>
java/src/com/android/inputmethod/latin/LatinIME.java +54 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,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; Loading Loading @@ -54,7 +56,9 @@ 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; import androidx.annotation.NonNull; Loading Loading @@ -103,6 +107,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; Loading Loading @@ -849,6 +855,54 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (hasSuggestionStripView()) { mSuggestionStripView.setListener(this, view); } ImageButton floatingButton = view.findViewById(R.id.floating_button); if (floatingButton != null) { if (isSetupWizardFinished() && accountIsPremium()) { floatingButton.setVisibility(View.VISIBLE); floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switchToNextInputMethod(); } }); } else { floatingButton.setVisibility(View.GONE); } } } private void switchToNextInputMethod() { final IBinder token = getWindow().getAttributes().token; InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); if (imm != null) { imm.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; 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 accountIsPremium; } @Override Loading