mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-22 15:19:10 +00:00
improve suggestion infos and make them optional
This commit is contained in:
parent
48e0b05d26
commit
dc0490a0e1
7 changed files with 36 additions and 24 deletions
|
@ -16,9 +16,9 @@ import org.dslul.openboard.inputmethod.latin.common.ComposedData;
|
|||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
import org.dslul.openboard.inputmethod.latin.common.InputPointers;
|
||||
import org.dslul.openboard.inputmethod.latin.common.StringUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||
import org.dslul.openboard.inputmethod.latin.suggestions.SuggestionStripView;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.AutoCorrectionUtils;
|
||||
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.SuggestionResults;
|
||||
|
@ -211,9 +211,8 @@ public final class Suggest {
|
|||
}
|
||||
|
||||
final ArrayList<SuggestedWordInfo> suggestionsList;
|
||||
if (DebugFlags.DEBUG_ENABLED && !suggestionsContainer.isEmpty()) {
|
||||
suggestionsList = getSuggestionsInfoListWithDebugInfo(typedWordString,
|
||||
suggestionsContainer);
|
||||
if (SuggestionStripView.DEBUG_SUGGESTIONS && !suggestionsContainer.isEmpty()) {
|
||||
suggestionsList = getSuggestionsInfoListWithDebugInfo(typedWordString, suggestionsContainer);
|
||||
} else {
|
||||
suggestionsList = suggestionsContainer;
|
||||
}
|
||||
|
@ -461,7 +460,14 @@ public final class Suggest {
|
|||
final SuggestedWordInfo pseudoTypedWordInfo = suggestionsContainer.isEmpty() ? null
|
||||
: suggestionsContainer.get(0);
|
||||
|
||||
callback.onGetSuggestedWords(new SuggestedWords(suggestionsContainer,
|
||||
final ArrayList<SuggestedWordInfo> suggestionsList;
|
||||
if (SuggestionStripView.DEBUG_SUGGESTIONS && !suggestionsContainer.isEmpty()) {
|
||||
suggestionsList = getSuggestionsInfoListWithDebugInfo(suggestionResults.first().mWord, suggestionsContainer);
|
||||
} else {
|
||||
suggestionsList = suggestionsContainer;
|
||||
}
|
||||
|
||||
callback.onGetSuggestedWords(new SuggestedWords(suggestionsList,
|
||||
suggestionResults.mRawSuggestions,
|
||||
pseudoTypedWordInfo,
|
||||
true /* typedWordValid */,
|
||||
|
@ -487,7 +493,7 @@ public final class Suggest {
|
|||
if (normalizedScore > 0) {
|
||||
scoreInfoString = String.format(
|
||||
Locale.ROOT, "%d (%4.2f), %s", cur.mScore, normalizedScore,
|
||||
cur.mSourceDict.mDictType);
|
||||
cur.mSourceDict.mDictType + ":" + cur.mSourceDict.mLocale);
|
||||
} else {
|
||||
scoreInfoString = Integer.toString(cur.mScore);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public final class DebugSettings {
|
|||
public static final String PREF_SLIDING_KEY_INPUT_PREVIEW = "pref_sliding_key_input_preview";
|
||||
public static final String PREF_SHOW_DEBUG_SETTINGS = "pref_show_debug_settings";
|
||||
|
||||
public static final String PREF_SHOW_SUGGESTION_INFOS = "pref_show_suggestion_infos";
|
||||
private DebugSettings() {
|
||||
// This class is not publicly instantiable.
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import androidx.preference.Preference;
|
|||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher;
|
||||
import org.dslul.openboard.inputmethod.latin.BuildConfig;
|
||||
import org.dslul.openboard.inputmethod.latin.DictionaryDumpBroadcastReceiver;
|
||||
import org.dslul.openboard.inputmethod.latin.DictionaryFacilitatorImpl;
|
||||
|
@ -98,6 +99,8 @@ public final class DebugSettingsFragment extends SubScreenFragment
|
|||
mServiceNeedsRestart = true;
|
||||
} else if (key.equals(DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH)) {
|
||||
mServiceNeedsRestart = true;
|
||||
} else if (key.equals(DebugSettings.PREF_SHOW_SUGGESTION_INFOS)) {
|
||||
KeyboardSwitcher.getInstance().forceUpdateKeyboardTheme(requireContext());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -171,8 +171,7 @@ final class SuggestionStripLayoutHelper {
|
|||
/ mMoreSuggestionsRowHeight;
|
||||
}
|
||||
|
||||
private static Drawable getMoreSuggestionsHint(final Resources res, final float textSize,
|
||||
final int color) {
|
||||
private static Drawable getMoreSuggestionsHint(final Resources res, final float textSize, final int color) {
|
||||
final Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
paint.setTextAlign(Align.CENTER);
|
||||
|
@ -364,7 +363,7 @@ final class SuggestionStripLayoutHelper {
|
|||
layoutWord(context, mCenterPositionInStrip, stripWidth - mPadding);
|
||||
stripView.addView(centerWordView);
|
||||
setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
if (SuggestionStripView.DEBUG) {
|
||||
if (SuggestionStripView.DEBUG_SUGGESTIONS) {
|
||||
layoutDebugInfo(mCenterPositionInStrip, placerView, stripWidth);
|
||||
}
|
||||
final Integer lastIndex = (Integer)centerWordView.getTag();
|
||||
|
@ -390,7 +389,7 @@ final class SuggestionStripLayoutHelper {
|
|||
ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
x += wordView.getMeasuredWidth();
|
||||
|
||||
if (SuggestionStripView.DEBUG) {
|
||||
if (SuggestionStripView.DEBUG_SUGGESTIONS) {
|
||||
layoutDebugInfo(positionInStrip, placerView, x);
|
||||
}
|
||||
}
|
||||
|
@ -453,8 +452,7 @@ final class SuggestionStripLayoutHelper {
|
|||
return;
|
||||
}
|
||||
placerView.addView(debugInfoView);
|
||||
debugInfoView.measure(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
debugInfoView.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
final int infoWidth = debugInfoView.getMeasuredWidth();
|
||||
final int y = debugInfoView.getMeasuredHeight();
|
||||
ViewLayoutUtils.placeViewAt(
|
||||
|
@ -484,7 +482,7 @@ final class SuggestionStripLayoutHelper {
|
|||
wordView.setText(null);
|
||||
wordView.setTag(null);
|
||||
// Make this inactive for touches in {@link #layoutWord(int,int)}.
|
||||
if (SuggestionStripView.DEBUG) {
|
||||
if (SuggestionStripView.DEBUG_SUGGESTIONS) {
|
||||
mDebugInfoViews.get(positionInStrip).setText(null);
|
||||
}
|
||||
}
|
||||
|
@ -503,9 +501,8 @@ final class SuggestionStripLayoutHelper {
|
|||
wordView.setTag(indexInSuggestedWords);
|
||||
wordView.setText(getStyledSuggestedWord(suggestedWords, indexInSuggestedWords));
|
||||
wordView.setTextColor(getSuggestionTextColor(suggestedWords, indexInSuggestedWords));
|
||||
if (SuggestionStripView.DEBUG) {
|
||||
mDebugInfoViews.get(positionInStrip).setText(
|
||||
suggestedWords.getDebugString(indexInSuggestedWords));
|
||||
if (SuggestionStripView.DEBUG_SUGGESTIONS) {
|
||||
mDebugInfoViews.get(positionInStrip).setText(suggestedWords.getDebugString(indexInSuggestedWords));
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.dslul.openboard.inputmethod.keyboard.Keyboard;
|
|||
import org.dslul.openboard.inputmethod.keyboard.MainKeyboardView;
|
||||
import org.dslul.openboard.inputmethod.keyboard.MoreKeysPanel;
|
||||
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||
import org.dslul.openboard.inputmethod.latin.BuildConfig;
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.SuggestedWords;
|
||||
import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||
|
@ -48,6 +47,7 @@ import org.dslul.openboard.inputmethod.latin.common.BackgroundType;
|
|||
import org.dslul.openboard.inputmethod.latin.common.Colors;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.DebugSettings;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.Settings;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.SettingsValues;
|
||||
import org.dslul.openboard.inputmethod.latin.suggestions.MoreSuggestionsView.MoreSuggestionsListener;
|
||||
|
@ -70,7 +70,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
CharSequence getSelection();
|
||||
}
|
||||
|
||||
static final boolean DEBUG = DebugFlags.DEBUG_ENABLED;
|
||||
public static boolean DEBUG_SUGGESTIONS;
|
||||
private static final float DEBUG_INFO_TEXT_SIZE_IN_DIP = 6.0f;
|
||||
private static final String VOICE_KEY_TAG = "voice_key";
|
||||
private static final String CLIPBOARD_KEY_TAG = "clipboard_key";
|
||||
|
@ -144,6 +144,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||
DEBUG_SUGGESTIONS = DeviceProtectedUtils.getSharedPreferences(context).getBoolean(DebugSettings.PREF_SHOW_SUGGESTION_INFOS, false);
|
||||
|
||||
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||
inflater.inflate(R.layout.suggestions_strip, this);
|
||||
|
@ -174,17 +175,15 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
final View divider = inflater.inflate(R.layout.suggestion_divider, null);
|
||||
mDividerViews.add(divider);
|
||||
final TextView info = new TextView(context, null, R.attr.suggestionWordStyle);
|
||||
info.setTextColor(Color.WHITE);
|
||||
info.setTextColor(colors.getKeyText());
|
||||
info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP);
|
||||
mDebugInfoViews.add(info);
|
||||
}
|
||||
|
||||
mLayoutHelper = new SuggestionStripLayoutHelper(
|
||||
context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews);
|
||||
mLayoutHelper = new SuggestionStripLayoutHelper(context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews);
|
||||
|
||||
mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null);
|
||||
mMoreSuggestionsView = mMoreSuggestionsContainer
|
||||
.findViewById(R.id.more_suggestions_view);
|
||||
mMoreSuggestionsView = mMoreSuggestionsContainer.findViewById(R.id.more_suggestions_view);
|
||||
mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView);
|
||||
|
||||
final Resources res = context.getResources();
|
||||
|
@ -405,7 +404,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
}
|
||||
return false;
|
||||
});
|
||||
if (DEBUG && (isShowingMoreSuggestionPanel() || !showMoreSuggestions())) {
|
||||
if (DebugFlags.DEBUG_ENABLED && (isShowingMoreSuggestionPanel() || !showMoreSuggestions())) {
|
||||
showSourceDict(wordView);
|
||||
return true;
|
||||
} else return showMoreSuggestions();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<string name="prefs_show_debug_settings" translatable="false">Enable debug settings</string>
|
||||
<string name="prefs_debug_settings_enabled" translatable="false">Debug settings enabled. Find them in advanced settings.</string>
|
||||
<string name="prefs_debug_mode" translatable="false">Debug Mode</string>
|
||||
<string name="prefs_show_suggestion_infos" translatable="false">Show suggestion infos</string>
|
||||
<string name="prefs_force_non_distinct_multitouch" translatable="false">Force non-distinct multitouch</string>
|
||||
<string name="prefs_should_show_lxx_suggestion_ui" translatable="false">Show LXX suggestion UI</string>
|
||||
<!-- Option to enable sliding key input indicator. The user can see a rubber band-like effect during sliding key input. [CHAR LIMIT=30]-->
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
android:title="@string/prefs_debug_mode"
|
||||
android:defaultValue="false"
|
||||
android:persistent="true" />
|
||||
<SwitchPreferenceCompat
|
||||
android:key="pref_show_suggestion_infos"
|
||||
android:title="@string/prefs_show_suggestion_infos"
|
||||
android:defaultValue="false"
|
||||
android:persistent="true" />
|
||||
<SwitchPreferenceCompat
|
||||
android:key="force_non_distinct_multitouch"
|
||||
android:title="@string/prefs_force_non_distinct_multitouch"
|
||||
|
|
Loading…
Add table
Reference in a new issue