A rather working version

This commit is contained in:
2024-10-23 22:43:31 +02:00
parent 7108e2beb9
commit 640ad71198
6 changed files with 94 additions and 27 deletions
@@ -35,6 +35,7 @@ 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*/
public class InputMethod extends InputMethodService {
public MetaKeyManager mMetaKeyManager;
public KeymapManager mKeymapManager;
@@ -61,6 +62,7 @@ public class InputMethod extends InputMethodService {
public void onInitializeInterface() {
mInputView = (InputView) getLayoutInflater().inflate(R.layout.input, null);
mInputView.updateStateText();
mInputView.setSymbolsVisibility(false);
}
@Override
@@ -24,11 +24,16 @@ import android.content.Intent;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.util.ArrayList;
public class InputView extends RelativeLayout {
private final InputMethod mInputMethod;
private Button mStateButton;
private LinearLayout mSymbolsList;
public InputView(Context context, AttributeSet attrs) {
super(context, attrs, 0);
@@ -39,6 +44,7 @@ public class InputView extends RelativeLayout {
protected void onFinishInflate() {
super.onFinishInflate();
mStateButton = findViewById(R.id.input_state);
mSymbolsList = findViewById(R.id.symbol_list);
mStateButton.setOnClickListener(button -> {
MetaKeyManager metaManager = mInputMethod.mMetaKeyManager;
@@ -58,6 +64,30 @@ public class InputView extends RelativeLayout {
});
}
public void setSymbolsVisibility(boolean state) {
mSymbolsList.setVisibility(state ? VISIBLE : GONE);
}
public void setSymbols(ArrayList<String> symbols, int index) {
for (int i = 0; i < mSymbolsList.getChildCount(); ++i) {
TextView view = (TextView) mSymbolsList.getChildAt(i);
view.setVisibility(GONE);
}
if (symbols != null) {
for (int i = 0; i < Math.min(mSymbolsList.getChildCount(), symbols.size()); ++i) {
TextView view = (TextView) mSymbolsList.getChildAt(i);
view.setVisibility(VISIBLE);
view.setText(symbols.get(i));
if (i == index) {
view.setTextAppearance(getContext(), R.style.InputViewSymbolSelected);
} else {
view.setTextAppearance(getContext(), R.style.InputViewSymbol);
}
}
}
}
public void updateStateText() {
MetaKeyManager metaManager = mInputMethod.mMetaKeyManager;
KeymapManager keymapManager = mInputMethod.mKeymapManager;
@@ -52,11 +52,13 @@ public class SymbolCycler extends Handler {
public void stopCycling() {
hasCycled = false;
mInputMethod.mInputView.setSymbolsVisibility(false);
removeCallbacks(mRunnable);
}
public void cycle() {
if (!hasCycled) {
mInputMethod.mInputView.setSymbolsVisibility(true);
mConn.deleteSurroundingText(mSymbols.get(0).length(), 0);
hasCycled = true;
}
@@ -68,6 +70,7 @@ public class SymbolCycler extends Handler {
}
mConn.setComposingText(mSymbols.get(mIndex), 1);
mInputMethod.mInputView.setSymbols(mSymbols, mIndex);
}
private class SymbolCyclerRunnable implements Runnable {
+3 -17
View File
@@ -1,17 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#000"
android:viewportWidth="98"
android:viewportHeight="200.67188">
<group
android:translateX="26.984758"
android:translateY="8.0268755">
<group android:translateY="158.69531">
<path
android:fillColor="#000000"
android:pathData="M95.765625,-88.8125Q90.5625,-88.8125,79.734375,-89.65625Q69.1875,-90.421875,63.703125,-90.359375L58.71875,-90.359375Q58.921875,-80.65625,60.609375,-58.859375Q62.15625,-38.53125,62.15625,-27.28125Q62.15625,-24.828125,62.640625,-19.828125Q63.140625,-14.84375,63.140625,-12.3125Q63.140625,-7.53125,61.59375,-4.078125Q59.625,0.5625,55.484375,0.5625Q52.671875,0.5625,50.421875,-1.40625Q48.171875,-3.375,48.171875,-6.46875Q48.171875,-7.53125,48.515625,-9.640625Q48.875,-11.75,48.875,-12.796875Q48.875,-16.25,48.40625,-23.140625Q47.953125,-30.03125,47.953125,-33.546875Q47.953125,-43.59375,46.34375,-61.8125Q44.65625,-81.5,44.4375,-90.078125L38.046875,-90Q22.640625,-90,13.859375,-92.25Q8.15625,-93.734375,8.15625,-99.21875Q8.15625,-102.09375,9.984375,-104.28125Q12.09375,-106.734375,15.40625,-106.53125Q17.859375,-106.390625,26.65625,-105.265625Q33.6875,-104.421875,38.046875,-104.421875Q42.265625,-104.421875,50.84375,-104.59375Q59.421875,-104.765625,63.640625,-104.765625Q69.046875,-104.765625,79.703125,-103.984375Q90.359375,-103.21875,95.765625,-103.21875Q98.796875,-103.21875,100.828125,-101.140625Q102.875,-99.078125,102.875,-95.984375Q102.875,-92.953125,100.828125,-90.875Q98.796875,-88.8125,95.765625,-88.8125Z" />
</group>
</group>
</vector>
<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>
+50 -1
View File
@@ -5,6 +5,56 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<LinearLayout
android:id="@+id/symbol_list"
android:layout_width="wrap_content"
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>
<Button
android:id="@+id/input_state"
style="@style/InputViewButton"
@@ -14,5 +64,4 @@
android:layout_marginLeft="8dp"
android:gravity="center"
android:text="@string/inputview_default_state" />
</cfpi_fpsi.eu.titanboard.InputView>
+6 -9
View File
@@ -16,19 +16,16 @@
<item name="android:clickable">true</item>
</style>
<style name="SymbolCyclerViewBackground">
<item name="android:background">#AA333333</item>
</style>
<style name="SymbolCyclerViewSymbol">
<item name="android:textColor">#FFF</item>
<style name="InputViewSymbol">
<item name="android:textColor">#BBB</item>
<item name="android:textSize">16sp</item>
<item name="android:layout_margin">8dp</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_width">32dp</item>
<item name="android:gravity">center</item>
</style>
<style name="SymbolCyclerViewSymbolSelected" parent="SymbolCyclerViewSymbol">
<style name="InputViewSymbolSelected" parent="InputViewSymbol">
<item name="android:textStyle">bold</item>
<item name="android:textColor">#FFF</item>
</style>
</resources>