Bugfixes and possibility to have multiple-character symbols.

This commit is contained in:
2024-10-23 23:24:18 +02:00
parent 640ad71198
commit 335cffe433
8 changed files with 30 additions and 76 deletions
@@ -35,7 +35,9 @@ import java.util.regex.Pattern;
// TODO: Mode without the bottom input view, in case the user does not care about completions.
// This will involve making a popup screen and a shortcut for changing languages.
/** @noinspection SizeReplaceableByIsEmpty*/
/**
* @noinspection SizeReplaceableByIsEmpty
*/
public class InputMethod extends InputMethodService {
public MetaKeyManager mMetaKeyManager;
public KeymapManager mKeymapManager;
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
@@ -74,11 +75,22 @@ public class InputView extends RelativeLayout {
view.setVisibility(GONE);
}
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
new ContextThemeWrapper(this.getContext(), R.style.InputViewSymbol), null);
if (symbols != null) {
for (int i = 0; i < Math.min(mSymbolsList.getChildCount(), symbols.size()); ++i) {
for (int i = 0; i < symbols.size(); ++i) {
TextView view = (TextView) mSymbolsList.getChildAt(i);
if (view == null) {
view = new TextView(new ContextThemeWrapper(this.getContext(),
R.style.InputViewSymbol), null, R.style.InputViewSymbol);
mSymbolsList.addView(view, lp);
}
view.setVisibility(VISIBLE);
view.setText(symbols.get(i));
if (i == index) {
view.setTextAppearance(getContext(), R.style.InputViewSymbolSelected);
} else {
@@ -59,7 +59,9 @@ public class SymbolCycler extends Handler {
public void cycle() {
if (!hasCycled) {
mInputMethod.mInputView.setSymbolsVisibility(true);
mConn.deleteSurroundingText(mSymbols.get(0).length(), 0);
// This works sort of like setComposingText. Good enough, and supports low APIs.
mConn.setSelection(mInputMethod.mCurrentCursorPosition - mSymbols.get(0).length(),
mInputMethod.mCurrentCursorPosition);
hasCycled = true;
}
+9 -2
View File
@@ -1,3 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
<path android:fillColor="@android:color/white" android:pathData="M80,160L80,80L880,80L880,160L80,160ZM420,800L420,240L540,240L540,800L420,800Z"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#000000"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#FFF"
android:pathData="M80,160L80,80L880,80L880,160L80,160ZM420,800L420,240L540,240L540,800L420,800Z" />
</vector>
-27
View File
@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ An input method for the Unihertz Titan/physical keyboard phones
~ Copyright (C) 2024 Emil Kosz
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
~
-->
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="45"
android:pivotX="100%"
android:pivotY="-50%">
<shape android:shape="rectangle">
<solid android:color="#333" />
</shape>
</rotate>
+1 -43
View File
@@ -11,49 +11,7 @@
android:layout_height="match_parent"
android:layout_alignTop="@id/input_state"
android:layout_alignBottom="@id/input_state"
android:orientation="horizontal">
<TextView
style="@style/InputViewSymbol"
android:layout_height="match_parent"
android:text="A" />
<TextView
style="@style/InputViewSymbol"
android:layout_height="match_parent"
android:text="A" />
<TextView
style="@style/InputViewSymbol"
android:layout_height="match_parent"
android:text="A" />
<TextView
style="@style/InputViewSymbol"
android:layout_height="match_parent"
android:text="A" />
<TextView
style="@style/InputViewSymbol"
android:layout_height="match_parent"
android:text="A" />
<TextView
style="@style/InputViewSymbol"
android:layout_height="match_parent"
android:text="A" />
<TextView
style="@style/InputViewSymbol"
android:layout_height="match_parent"
android:text="A" />
<TextView
style="@style/InputViewSymbol"
android:layout_height="match_parent"
android:text="A" />
</LinearLayout>
android:orientation="horizontal" />
<Button
android:id="@+id/input_state"
+1
View File
@@ -20,6 +20,7 @@
<item name="android:textColor">#BBB</item>
<item name="android:textSize">16sp</item>
<item name="android:layout_margin">8dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">32dp</item>
<item name="android:gravity">center</item>
</style>
-1
View File
@@ -806,7 +806,6 @@
<shift value="H" />
<shift value="Ή" />
<alt value="#" />
<alt value="₽" />
<alt value="€" />
<alt value="$" />
</key>