2 Commits
8 changed files with 64 additions and 49 deletions
+2 -2
View File
@@ -10,8 +10,8 @@ android {
applicationId 'eur.cfpifpsi.titanboard'
minSdk 3
targetSdk 35
versionCode 30
versionName '0.3'
versionCode 31
versionName '0.3.1'
}
buildTypes {
+1 -1
View File
@@ -33,7 +33,7 @@
android:shell="true"
tools:targetApi="q" />
<service
android:name=".InputMethod"
android:name=".TitanboardIME"
android:directBootAware="true"
android:exported="false"
android:label="@string/app_name"
@@ -28,16 +28,16 @@ import java.util.ArrayList;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class ClipManager implements ClipboardManager.OnPrimaryClipChangedListener {
private final InputMethod mInputMethod;
private final TitanboardIME mTitanboardIME;
private final ClipboardManager mClipboardManager;
private final ArrayList<ClipData.Item> mClips;
private long mLastCallbackTimestamp;
public ClipManager(Context context) {
mInputMethod = (InputMethod) context;
mClips = new ArrayList<>(mInputMethod.mPreferenceHolder.getClipboardSize());
mTitanboardIME = (TitanboardIME) context;
mClips = new ArrayList<>(mTitanboardIME.mPreferenceHolder.getClipboardSize());
mClipboardManager = (ClipboardManager)
mInputMethod.getSystemService(Context.CLIPBOARD_SERVICE);
mTitanboardIME.getSystemService(Context.CLIPBOARD_SERVICE);
mClipboardManager.addPrimaryClipChangedListener(this);
}
@@ -58,12 +58,12 @@ public class ClipManager implements ClipboardManager.OnPrimaryClipChangedListene
mClips.add(0, item);
}
if (mClips.size() > mInputMethod.mPreferenceHolder.getClipboardSize()) {
if (mClips.size() > mTitanboardIME.mPreferenceHolder.getClipboardSize()) {
mClips.remove(mClips.size() - 1);
}
}
mInputMethod.mInputView.setClips(mClips);
mTitanboardIME.mInputView.setClips(mClips);
}
}
}
@@ -43,7 +43,7 @@ import java.util.ArrayList;
public final class InputView extends RelativeLayout {
private final int[] buttonStateToggled = {R.attr.state_toggled};
private final InputMethod mInputMethod;
private final TitanboardIME mTitanboardIME;
private final LinearLayout.LayoutParams mSymbolLayout;
private final LinearLayout.LayoutParams mClipLayout;
public PopupWindow mClipboardPopup;
@@ -54,7 +54,7 @@ public final class InputView extends RelativeLayout {
public InputView(Context context, AttributeSet attrs) {
super(context, attrs, 0);
mInputMethod = (InputMethod) context;
mTitanboardIME = (TitanboardIME) context;
mSymbolLayout = new LinearLayout.LayoutParams(
getResources().getDimensionPixelSize(R.dimen.symbol_width),
ViewGroup.LayoutParams.MATCH_PARENT, 0);
@@ -77,12 +77,12 @@ public final class InputView extends RelativeLayout {
mClipboardPopup.setOnDismissListener(() -> mClipboardButton.setImageState(null, true));
mStateButton.setOnClickListener(button -> {
MetaKeyManager metaManager = mInputMethod.mMetaKeyManager;
MetaKeyManager metaManager = mTitanboardIME.mMetaKeyManager;
if (metaManager.getAlt().isActive()) {
metaManager.getAlt().resetState();
} else {
mInputMethod.mKeymapManager
.nextKeymap(mInputMethod.mPreferenceHolder.getSelectedKeymaps());
mTitanboardIME.mKeymapManager
.nextKeymap(mTitanboardIME.mPreferenceHolder.getSelectedKeymaps());
}
updateStateText();
});
@@ -103,10 +103,10 @@ public final class InputView extends RelativeLayout {
mClipboardButton.setOnLongClickListener(button -> {
// On a long click, we just send the latest clip (if any).
if (!mInputMethod.mClipManager.isEmpty()
if (!mTitanboardIME.mClipManager.isEmpty()
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mInputMethod.getCurrentInputConnection()
.commitText(mInputMethod.mClipManager.getItemAt(0).getText(), 1);
mTitanboardIME.getCurrentInputConnection()
.commitText(mTitanboardIME.mClipManager.getItemAt(0).getText(), 1);
}
return true;
@@ -117,8 +117,8 @@ public final class InputView extends RelativeLayout {
* @noinspection FeatureEnvy
*/
public void updateStateText() {
MetaKeyManager metaManager = mInputMethod.mMetaKeyManager;
KeymapManager keymapManager = mInputMethod.mKeymapManager;
MetaKeyManager metaManager = mTitanboardIME.mMetaKeyManager;
KeymapManager keymapManager = mTitanboardIME.mKeymapManager;
mStateButton.setPaintFlags(mStateButton.getPaintFlags() & ~(Paint.UNDERLINE_TEXT_FLAG));
@@ -165,13 +165,13 @@ public final class InputView extends RelativeLayout {
Button pasteButton = clipView.findViewById(R.id.paste_button);
pasteButton.setText(item.getText());
pasteButton.setOnClickListener(button -> mInputMethod.getCurrentInputConnection()
pasteButton.setOnClickListener(button -> mTitanboardIME.getCurrentInputConnection()
.commitText(item.getText(), 1));
LinearLayout finalClipView = clipView;
clipView.findViewById(R.id.button_delete).setOnClickListener(button -> {
mClipList.removeView(finalClipView);
mInputMethod.mClipManager.removeItem(item);
mTitanboardIME.mClipManager.removeItem(item);
});
}
}
@@ -32,25 +32,25 @@ public class MetaKeyManager {
mVibrator = vibrator;
}
public void updateMetaStateDown(int keyCode) {
public boolean updateMetaStateDown(int keyCode) {
switch (keyCode) {
case KeyEvent.KEYCODE_ALT_LEFT:
case KeyEvent.KEYCODE_ALT_RIGHT:
mAlt.onDown();
break;
return true;
case KeyEvent.KEYCODE_SHIFT_LEFT:
case KeyEvent.KEYCODE_SHIFT_RIGHT:
mShift.onDown();
break;
return true;
default:
break;
return false;
}
}
/**
* @noinspection FeatureEnvy
*/
public void updateMetaStateUp(int keyCode, KeyEvent event) {
public boolean updateMetaStateUp(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_ALT_LEFT:
case KeyEvent.KEYCODE_ALT_RIGHT:
@@ -58,16 +58,16 @@ public class MetaKeyManager {
if (mAlt.isLocked()) {
mVibrator.vibrate(TOGGLE_VIBRATION_TIME);
}
break;
return true;
case KeyEvent.KEYCODE_SHIFT_LEFT:
case KeyEvent.KEYCODE_SHIFT_RIGHT:
mShift.onUp(event);
if (mShift.isLocked()) {
mVibrator.vibrate(TOGGLE_VIBRATION_TIME);
}
break;
return true;
default:
break;
return false;
}
}
@@ -34,7 +34,7 @@ import java.util.ArrayList;
// TODO: Implement device recognition and a keymap picking based on it.
public class InputMethod extends InputMethodService {
public class TitanboardIME extends InputMethodService {
public MetaKeyManager mMetaKeyManager;
public KeymapManager mKeymapManager;
public PreferenceHolder mPreferenceHolder;
@@ -88,8 +88,10 @@ public class InputMethod extends InputMethodService {
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
mMetaKeyManager.updateMetaStateDown(keyCode);
mInputView.updateStateText();
if (mMetaKeyManager.updateMetaStateDown(keyCode)) {
mInputView.updateStateText();
return true;
}
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (isInputViewShown()) {
@@ -99,6 +101,11 @@ public class InputMethod extends InputMethodService {
return false;
}
// Workaround for default Android behaviour that pisses people off.
if (keyCode == KeyEvent.KEYCODE_DEL && (event.isAltPressed() || event.isShiftPressed())) {
return true;
}
if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_ENTER) {
mMetaKeyManager.adjustMetaStateAfterKeypress();
mInputView.updateStateText();
@@ -124,7 +131,8 @@ public class InputMethod extends InputMethodService {
if (mPreferenceHolder.isCycleManualOn()) {
boolean isCycling = mHandler.hasMessages(0);
if (isCycling && keyCode == mLastSymbolKeyCode && symbols.size() > 1) {
if (isCycling && keyCode == mLastSymbolKeyCode
&& mSymbolManualCycler.getList().size() > 1) {
mSymbolManualCycler.run();
} else {
mFinishCyclingRunnable.run();
@@ -155,8 +163,11 @@ public class InputMethod extends InputMethodService {
mFinishCyclingRunnable.run();
}
mMetaKeyManager.updateMetaStateUp(keyCode, event);
mInputView.updateStateText();
if (mMetaKeyManager.updateMetaStateUp(keyCode, event)) {
mInputView.updateStateText();
return true;
}
return false;
}
@@ -243,6 +254,8 @@ public class InputMethod extends InputMethodService {
if (conn != null) {
conn.setComposingText(getCurrentElement().toString(), 1);
}
mHandler.postDelayed(this, mPreferenceHolder.getCycleSpeed());
}
@SuppressWarnings("unchecked") //NON-NLS
+1
View File
@@ -60,6 +60,7 @@
android:layout_alignParentRight="true"
android:background="@drawable/button_state"
android:text="@string/state_button_default"
android:textAllCaps="false"
android:textColor="@color/background"
android:textSize="@dimen/default_text_size" />
+15 -14
View File
@@ -1465,6 +1465,7 @@
<base value="χ" />
<shift value="X" />
<alt value="?" />
<alt value=";" /> <!-- Greek question mark -->
</key>
<!-- Lots of diacritics -->
<key code="53"> <!-- Y -->
@@ -1505,6 +1506,9 @@
<base value="إ" />
<base value="ئ" />
<base value="آ" />
<shift value="َ" /> <!-- Fatha -->
<shift value="ً" /> <!-- Fathatan -->
<shift value="ٰ" /> <!-- Superscript alif -->
<alt value="@" />
</key>
<key code="30"> <!-- B -->
@@ -1526,10 +1530,8 @@
<alt value="»" />
</key>
<key code="33"> <!-- E -->
<!-- Space for diacritics -->
<!-- Space for something -->
<base value="ء" />
<base value="ْ" /> <!-- Sukun -->
<base value="ّ" /> <!-- Shadda -->
<alt value="_" />
<alt value="~" />
</key>
@@ -1554,7 +1556,8 @@
</key>
<key code="37"> <!-- I -->
<base value="ي" />
<base value="ِ" /> <!-- Kasrah -->
<shift value="ِ" /> <!-- Kasrah -->
<shift value="ٍ" /> <!-- Kasratan -->
<alt value="2" />
</key>
<key code="38"> <!-- J -->
@@ -1576,14 +1579,10 @@
</key>
<key code="42"> <!-- N -->
<base value="ن" />
<base value="ٍ" /> <!-- Kasratan -->
<base value="ً" /> <!-- Fathatan -->
<base value="ٍ" /> <!-- Dammatan -->
<alt value="8" />
</key>
<key code="43"> <!-- O -->
<!-- Space for diacritics -->
<base value="ٰ" /> <!-- Superscript alif -->
<!-- Space for something -->
<alt value="3" />
</key>
<key code="44"> <!-- P -->
@@ -1622,8 +1621,9 @@
<alt value="{" />
</key>
<key code="49"> <!-- U -->
<!-- Space for diacritics -->
<base value="ُ" /> <!-- Dammah -->
<!-- Space for something -->
<shift value="ُ" /> <!-- Dammah -->
<shift value="ٌ" /> <!-- Dammatan -->
<alt value="1" />
</key>
<key code="50"> <!-- V -->
@@ -1639,13 +1639,14 @@
<alt value="|" />
</key>
<key code="52"> <!-- X -->
<!-- Space for diacritics -->
<!-- Sukun removes a vowel, so it's under X -->
<base value="؟" />
<shift value="ْ" /> <!-- Sukun -->
<shift value="ّ" /> <!-- Shadda -->
<alt value="?" />
</key>
<key code="53"> <!-- Y -->
<!-- Space for diacritics -->
<base value="َ" /> <!-- Fatha -->
<!-- Space for something -->
<alt value=")" />
<alt value="&gt;" />
<alt value="]" />