Skip to content

Commit

Permalink
add character compose candidate string in hint
Browse files Browse the repository at this point in the history
  • Loading branch information
plateaukao committed Feb 18, 2022
1 parent 935a47c commit a14a5b5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 23 deletions.
4 changes: 2 additions & 2 deletions LimeStudio/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ android {

minSdkVersion 23
targetSdkVersion 30
versionCode 642
versionName '6.4.2'
versionCode 650
versionName '6.5.0'
}
buildTypes {
release {
Expand Down
44 changes: 34 additions & 10 deletions LimeStudio/app/src/main/java/net/toload/main/hd/LIMEService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1527,23 +1527,23 @@ private void commitTyped(InputConnection ic) {
* Candidate Hint Handlings -- Start
*/
private static final int HINT_COUNT = 5;
private static final int HIDE_HINT_INTERVAL = 1000 * 3;
private static final int HIDE_HINT_INTERVAL = 1000 * 5;
private Timer timer = null;
private String hint = "";
private void candidateHintAddWord(String word) {
candidateHintView.setVisibility(View.VISIBLE);
if (mCandidateView != null) {
candidateHintView.setTextColor(mCandidateView.mColorNormalText);
}

String newHint = (candidateHintView.getText() + word);
String newHint = hint + word;
if (newHint.length() > HINT_COUNT) {
candidateHintView.setText(newHint.substring(newHint.length()-HINT_COUNT));
} else {
candidateHintView.setText(newHint);
}
hint = candidateHintView.getText().toString();

if (timer != null) {
timer.cancel();
timer = null;
}
timer = new Timer();
timer.schedule(new TimerTask() {
Expand All @@ -1556,12 +1556,30 @@ public void run() {
}, HIDE_HINT_INTERVAL);
}

private void clearCandidateHint(){
candidateHintView.post(new Runnable() {
@Override
public void run() {
candidateHintView.setText("");
private void candidateHintAddComposing(String composingText) {
candidateHintView.post(() -> {
candidateHintView.setVisibility(View.VISIBLE);
candidateHintView.setText(hint + composingText);
if (timer != null) {
timer.cancel();
timer = null;
}
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
clearCandidateHint();
timer = null;
}

}, HIDE_HINT_INTERVAL);
});
}

private void clearCandidateHint(){
candidateHintView.post(() -> {
candidateHintView.setText("");
hint = "";
});
}

Expand Down Expand Up @@ -2342,6 +2360,9 @@ public void run() {
// Show composing window if keyToKeyname got different string. Revised by Jeremy '11,6,4
if (SearchSrv.getTablename() != null) {
String keynameString = SearchSrv.keyToKeyname(finalKeyString); //.toLowerCase(Locale.US)); moved to LimeDB
if (mLIMEPref.shouldShowTypedWord()) {
candidateHintAddComposing(keynameString);
}
if (mCandidateView != null
&& !keynameString.toUpperCase(Locale.US).equals(finalKeyString.toUpperCase(Locale.US))
&& !keynameString.trim().equals("")
Expand Down Expand Up @@ -2957,6 +2978,9 @@ private void initialViewAndSwitcher(boolean forceRecreate) {
mCandidateViewInInputView.setService(this);

candidateHintView = mCandidateInInputView.findViewById(R.id.candidate_hint);
if (mCandidateView != null) {
candidateHintView.setTextColor(mCandidateView.mColorNormalText);
}
}
if (mCandidateView != mCandidateViewInInputView)
mCandidateView = mCandidateViewInInputView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ public class LIMEBaseKeyboard {
/**
* Reserved space in the middle in unit of columns for separated keyboard in landscape mode.
*/
protected static int mReservedColumnsForSplitedKeyboard = 3;
protected static int mReservedColumnsForSplitedKeyboard = 2;

/**
* Key width reduction scale for separated keyboard in landscape mode.
*/
protected static float mSplitedKeyWidthScale = 0.8f;
protected static float mSplitedKeyWidthScale = 1.2f;

/**
* Key width for separated keyboard in landscape mode.
Expand Down
2 changes: 1 addition & 1 deletion LimeStudio/app/src/main/res/values-land/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
-->

<resources>
<integer name="reserved_columns_for_seperated_keyboard">3</integer>
<integer name="reserved_columns_for_seperated_keyboard">2</integer>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,11 @@
<item>2</item>
</string-array>
<string-array name="vibrate_level_values">
<item>5</item>
<item>10</item>
<item>15</item>
<item>20</item>
<item>30</item>
<item>40</item>
<item>50</item>
<item>60</item>
</string-array>

</resources>
10 changes: 5 additions & 5 deletions LimeStudio/app/src/main/res/values/strings_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -788,11 +788,11 @@
<item>2</item>
</string-array>
<string-array name="vibrate_level_values">
<item>20</item>
<item>30</item>
<item>40</item>
<item>50</item>
<item>60</item>
<item>1</item>
<item>3</item>
<item>5</item>
<item>10</item>
<item>15</item>
</string-array>

</resources>

0 comments on commit a14a5b5

Please sign in to comment.