Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text to be committed is the middle suggestion #672

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions app/src/main/java/helium314/keyboard/latin/Suggest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,16 @@ class Suggest(private val mDictionaryFacilitator: DictionaryFacilitator) {
inputStyleIfNotPrediction
}

if (hasAutoCorrection) {
// make sure typed word is shown, so user is able to override incoming autocorrection
// If there is an incoming autocorrection, make sure typed word is shown, so user is able to override it.
// Otherwise, if the relevant setting is enabled, show the typed word in the middle.
val typedIndex = if (hasAutoCorrection) 2 else 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typedIndex is a confusing name, please be more explicit (e.g. indexOfTypedWord)

if ((hasAutoCorrection || Settings.getInstance().current.mCenterSuggestionTextToCommit)
&& suggestionsList.size >= typedIndex && !TextUtils.isEmpty(typedWordString)) {
if (typedWordFirstOccurrenceWordInfo != null) {
if (SuggestionStripView.DEBUG_SUGGESTIONS) addDebugInfo(typedWordFirstOccurrenceWordInfo, typedWordString)
suggestionsList.add(2, typedWordFirstOccurrenceWordInfo)
suggestionsList.add(typedIndex, typedWordFirstOccurrenceWordInfo)
} else {
suggestionsList.add(2,
suggestionsList.add(typedIndex,
SuggestedWordInfo(typedWordString, "", 0, SuggestedWordInfo.KIND_TYPED,
Dictionary.DICTIONARY_USER_TYPED, SuggestedWordInfo.NOT_AN_INDEX, SuggestedWordInfo.NOT_A_CONFIDENCE)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private void refreshEnabledSettings() {
setPreferenceVisible(Settings.PREF_MORE_AUTO_CORRECTION, Settings.readAutoCorrectEnabled(getSharedPreferences()));
setPreferenceVisible(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, getSharedPreferences().getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true));
setPreferenceVisible(Settings.PREF_ALWAYS_SHOW_SUGGESTIONS, getSharedPreferences().getBoolean(Settings.PREF_SHOW_SUGGESTIONS, true));
setPreferenceVisible(Settings.PREF_CENTER_SUGGESTION_TEXT_TO_COMMIT, getSharedPreferences().getBoolean(Settings.PREF_SHOW_SUGGESTIONS, true));
turnOffLookupContactsIfNoPermission();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_AUTO_CORRECTION = "auto_correction";
public static final String PREF_MORE_AUTO_CORRECTION = "more_auto_correction";
public static final String PREF_AUTO_CORRECTION_CONFIDENCE = "auto_correction_confidence";
public static final String PREF_CENTER_SUGGESTION_TEXT_TO_COMMIT = "center_suggestion_text_to_commit";
public static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
public static final String PREF_ALWAYS_SHOW_SUGGESTIONS = "always_show_suggestions";
public static final String PREF_KEY_USE_PERSONALIZED_DICTS = "use_personalized_dicts";
Expand Down Expand Up @@ -287,6 +288,10 @@ public static String readAutoCorrectConfidence(final SharedPreferences prefs, fi
res.getString(R.string.auto_correction_threshold_mode_index_modest));
}

public static boolean readCenterSuggestionTextToCommit(final SharedPreferences prefs, final Resources res) {
return prefs.getBoolean(PREF_CENTER_SUGGESTION_TEXT_TO_COMMIT, res.getBoolean(R.bool.config_center_suggestion_text_to_commit));
}

public static boolean readBlockPotentiallyOffensive(final SharedPreferences prefs, final Resources res) {
return prefs.getBoolean(PREF_BLOCK_POTENTIALLY_OFFENSIVE,
res.getBoolean(R.bool.config_block_potentially_offensive));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class SettingsValues {
public final List<String> mPopupKeyLabelSources;
public final List<Locale> mSecondaryLocales;
public final boolean mBigramPredictionEnabled;// Use bigrams to predict the next word when there is no input for it yet
public final boolean mCenterSuggestionTextToCommit;
public final boolean mGestureInputEnabled;
public final boolean mGestureTrailEnabled;
public final boolean mGestureFloatingPreviewTextEnabled;
Expand Down Expand Up @@ -161,6 +162,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
mAutoCorrectEnabled = mAutoCorrectionEnabledPerUserSettings
&& (mInputAttributes.mInputTypeShouldAutoCorrect || Settings.readMoreAutoCorrectEnabled(prefs))
&& (mUrlDetectionEnabled || !InputTypeUtils.isUriOrEmailType(mInputAttributes.mInputType));
mCenterSuggestionTextToCommit = Settings.readCenterSuggestionTextToCommit(prefs, res);
mAutoCorrectionThreshold = mAutoCorrectEnabled
? readAutoCorrectionThreshold(res, prefs)
: AUTO_CORRECTION_DISABLED_THRESHOLD;
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/config-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
-->

<resources>
<!-- By default, the centered suggestion will not show the word that should be committed -->
<bool name="config_center_suggestion_text_to_commit">false</bool>
<bool name="config_block_potentially_offensive">true</bool>
<!-- Default value for next word prediction: after entering a word and a space only, should we
look at input history to suggest a hopefully helpful suggestions for the next word? -->
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
<string name="auto_correction_threshold_mode_aggressive">Aggressive</string>
<!-- Option to suggest auto correction suggestions very aggressively. Auto-corrects to a word which has even large edit distance from typed word. [CHAR LIMIT=20] -->
<string name="auto_correction_threshold_mode_very_aggressive">Very aggressive</string>
<!-- Option to show the text to be committed as the middle middle suggestion -->
<string name="center_suggestion_text_to_commit">Center text to commit</string>
<!-- Description for the center text to commit setting -->
<string name="center_suggestion_text_to_commit_summary">If enabled, the middle suggestion will show the text to be committed</string>
Comment on lines +127 to +130
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to avoid to avoid "commit" in the name and description (no one used it in the related issue).
Also it's somewhat confusing, as the context of where the text is centered is not clear.

I'm not good at finding short and clear titles and descriptions, not sure how much I can help here...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked in the issue, maybe someone has a good idea. If not we can still change it later (though it would mean unnecessary work for translators)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "middle suggestion always used"? Then for the description something like "If enabled, the middle suggestion will display the word selected for completion, whether the typed text was correct or not"? Add a bit more detail for what its doing. Obviously just some ideas

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Always use middle suggestion" sounds good to me, at least I think this is hardest do mis-interpret.
And as summary something like "On pressing space or punctuation, the middle suggestion will be used". Or maybe "typed" or "entered"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used or entered seem better, given no typing is taking place. Entered leaves less ambiguity, but used might be more clear. Your summary is much clearer than mine in fewer words lol

<!-- Option to enable using next word suggestions. After the user types a space, with this option on, the keyboard will try to predict the next word. -->
<string name="bigram_prediction">Next-word suggestions</string>
<!-- Description for "next word suggestion" option. This displays suggestions even when there is no input, based on the previous word. -->
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/prefs_screen_correction.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@
android:defaultValue="true"
android:persistent="true" />

<SwitchPreference
android:key="center_suggestion_text_to_commit"
android:title="@string/center_suggestion_text_to_commit"
android:summary="@string/center_suggestion_text_to_commit_summary"
android:defaultValue="@bool/config_center_suggestion_text_to_commit"
android:persistent="true" />

<SwitchPreference
android:key="use_contacts"
android:title="@string/use_contacts_dict"
Expand Down