debug mode extension

make it available on all build variants
show multilingual typing confidences on space bar
This commit is contained in:
Helium314 2023-11-22 21:51:48 +01:00
parent 9ef79821f4
commit e1a89c811c
23 changed files with 150 additions and 110 deletions

View file

@ -40,7 +40,6 @@
android:protectionLevel="signature" />
<application android:label="@string/english_ime_name"
android:name="org.dslul.openboard.inputmethod.latin.App"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"

View file

@ -575,4 +575,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
public void switchToSubtype(InputMethodSubtype subtype) {
mLatinIME.switchToSubtype(subtype);
}
// used for debug
public String getLocaleAndConfidenceInfo() {
return mLatinIME.getLocaleAndConfidenceInfo();
}
}

View file

@ -49,6 +49,7 @@ import org.dslul.openboard.inputmethod.latin.SuggestedWords;
import org.dslul.openboard.inputmethod.latin.common.Colors;
import org.dslul.openboard.inputmethod.latin.common.Constants;
import org.dslul.openboard.inputmethod.latin.common.CoordinateUtils;
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.utils.DeviceProtectedUtils;
@ -865,7 +866,13 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
paint.setTextAlign(Align.CENTER);
paint.setTypeface(Typeface.DEFAULT);
paint.setTextSize(mLanguageOnSpacebarTextSize);
final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
final String languageText;
if (DebugFlags.DEBUG_ENABLED) {
final String l = KeyboardSwitcher.getInstance().getLocaleAndConfidenceInfo();
languageText = l != null ? l : layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
}
else
languageText = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
// Draw language text with shadow
final float descent = paint.descent();
final float textHeight = -paint.ascent() + descent;
@ -878,7 +885,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
}
paint.setColor(mLanguageOnSpacebarTextColor);
paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
canvas.drawText(language, width / 2f, baseline - descent, paint);
canvas.drawText(languageText, width / 2f, baseline - descent, paint);
paint.clearShadowLayer();
paint.setTextScaleX(1.0f);
}

View file

@ -17,7 +17,6 @@ import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
// This hack is applied to certain classes of tablets.
public final class BogusMoveEventDetector {
private static final String TAG = BogusMoveEventDetector.class.getSimpleName();
private static final boolean DEBUG_MODE = DebugFlags.DEBUG_ENABLED;
// Move these thresholds to resource.
// These thresholds' unit is a diagonal length of a key.
@ -38,7 +37,7 @@ public final class BogusMoveEventDetector {
final int densityDpi = res.getDisplayMetrics().densityDpi;
final boolean hasLowDensityScreen = (densityDpi < DisplayMetrics.DENSITY_HIGH);
final boolean needsTheHack = isLargeTablet || (isSmallTablet && hasLowDensityScreen);
if (DEBUG_MODE) {
if (DebugFlags.DEBUG_ENABLED) {
final int sw = res.getConfiguration().smallestScreenWidthDp;
Log.d(TAG, "needsProximateBogusDownMoveUpEventHack=" + needsTheHack
+ " smallestScreenWidthDp=" + sw + " densityDpi=" + densityDpi

View file

@ -1,59 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
package org.dslul.openboard.inputmethod.latin
import android.app.Application
import android.content.Context
import android.os.Build
import java.io.File
import java.io.IOException
import java.io.PrintWriter
import java.io.StringWriter
import java.util.*
class App : Application() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
CrashReportExceptionHandler(applicationContext).install()
}
}
}
// basically copied from StreetComplete
private class CrashReportExceptionHandler(val appContext: Context) : Thread.UncaughtExceptionHandler {
private var defaultUncaughtExceptionHandler: Thread.UncaughtExceptionHandler? = null
fun install(): Boolean {
val ueh = Thread.getDefaultUncaughtExceptionHandler()
if (ueh is CrashReportExceptionHandler)
return false
defaultUncaughtExceptionHandler = ueh
Thread.setDefaultUncaughtExceptionHandler(this)
return true
}
override fun uncaughtException(t: Thread, e: Throwable) {
val stackTrace = StringWriter()
e.printStackTrace(PrintWriter(stackTrace))
writeCrashReportToFile("""
Thread: ${t.name}
App version: ${BuildConfig.VERSION_NAME}
Device: ${Build.BRAND} ${Build.DEVICE}, Android ${Build.VERSION.RELEASE}
Locale: ${Locale.getDefault()}
Stack trace:
$stackTrace
""")
defaultUncaughtExceptionHandler!!.uncaughtException(t, e)
}
private fun writeCrashReportToFile(text: String) {
try {
val dir = appContext.getExternalFilesDir(null) ?: return
val crashReportFile = File(dir, "crash_report_${System.currentTimeMillis()}.txt")
crashReportFile.writeText(text)
} catch (ignored: IOException) {
}
}
}

View file

@ -167,6 +167,8 @@ public interface DictionaryFacilitator {
String dump(final Context context);
String localesAndConfidences();
void dumpDictionaryForDebug(final String dictName);
@NonNull List<DictionaryStats> getDictionaryStats(final Context context);

View file

@ -1080,6 +1080,18 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
return clearSubDictionary(Dictionary.TYPE_USER_HISTORY);
}
@Override
public String localesAndConfidences() {
if (mDictionaryGroups.size() < 2) return null;
final StringBuilder sb = new StringBuilder();
for (final DictionaryGroup dictGroup : mDictionaryGroups) {
if (sb.length() > 0)
sb.append(", ");
sb.append(dictGroup.mLocale).append(" ").append(dictGroup.mConfidence);
}
return sb.toString();
}
@Override
public void dumpDictionaryForDebug(final String dictName) {
final ExpandableBinaryDictionary dictToDump = mDictionaryGroups.get(0).getSubDict(dictName);

View file

@ -596,13 +596,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void onCreate() {
Settings.init(this);
DebugFlags.init(DeviceProtectedUtils.getSharedPreferences(this));
DebugFlags.init(this);
SubtypeSettingsKt.init(this);
RichInputMethodManager.init(this);
mRichImm = RichInputMethodManager.getInstance();
AudioAndHapticFeedbackManager.init(this);
AccessibilityUtils.init(this);
mStatsUtilsManager.onCreate(this /* context */, mDictionaryFacilitator);
mStatsUtilsManager.onCreate(this, mDictionaryFacilitator);
mDisplayContext = getDisplayContext();
KeyboardSwitcher.init(this);
super.onCreate();
@ -740,6 +740,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
this /* DictionaryInitializationListener */);
}
// used for debug
public String getLocaleAndConfidenceInfo() {
return mDictionaryFacilitator.localesAndConfidences();
}
@Override
public void onDestroy() {
mClipboardHistoryManager.onDestroy();

View file

@ -49,7 +49,6 @@ public final class Suggest {
// Close to -2**31
private static final int SUPPRESS_SUGGEST_THRESHOLD = -2000000000;
private static final boolean DBG = DebugFlags.DEBUG_ENABLED;
private final DictionaryFacilitator mDictionaryFacilitator;
private static final int MAXIMUM_AUTO_CORRECT_LENGTH_FOR_GERMAN = 12;
@ -212,7 +211,7 @@ public final class Suggest {
}
final ArrayList<SuggestedWordInfo> suggestionsList;
if (DBG && !suggestionsContainer.isEmpty()) {
if (DebugFlags.DEBUG_ENABLED && !suggestionsContainer.isEmpty()) {
suggestionsList = getSuggestionsInfoListWithDebugInfo(typedWordString,
suggestionsContainer);
} else {

View file

@ -30,7 +30,6 @@ import java.util.Collections;
*/
public final class WordComposer {
private static final int MAX_WORD_LENGTH = DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH;
private static final boolean DBG = DebugFlags.DEBUG_ENABLED;
public static final int CAPS_MODE_OFF = 0;
// 1 is shift bit, 2 is caps bit, 4 is auto bit but this is just a convention as these bits
@ -221,7 +220,7 @@ public final class WordComposer {
}
public boolean isCursorFrontOrMiddleOfComposingWord() {
if (DBG && mCursorPositionWithinWord > mCodePointSize) {
if (DebugFlags.DEBUG_ENABLED && mCursorPositionWithinWord > mCodePointSize) {
throw new RuntimeException("Wrong cursor position : " + mCursorPositionWithinWord
+ "in a word of size " + mCodePointSize);
}

View file

@ -6,16 +6,64 @@
package org.dslul.openboard.inputmethod.latin.define
import android.content.SharedPreferences
import android.content.Context
import android.os.Build
import org.dslul.openboard.inputmethod.latin.BuildConfig
import org.dslul.openboard.inputmethod.latin.settings.DebugSettings
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils
import java.io.File
import java.io.IOException
import java.io.PrintWriter
import java.io.StringWriter
import java.util.Locale
object DebugFlags {
@JvmField
var DEBUG_ENABLED = false
@JvmStatic
fun init(prefs: SharedPreferences) {
DEBUG_ENABLED = BuildConfig.DEBUG && prefs.getBoolean(DebugSettings.PREF_DEBUG_MODE, false)
fun init(context: Context) {
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
DEBUG_ENABLED = prefs.getBoolean(DebugSettings.PREF_DEBUG_MODE, false)
if (DEBUG_ENABLED || BuildConfig.DEBUG)
CrashReportExceptionHandler(context.applicationContext).install()
}
}
// basically copied from StreetComplete
private class CrashReportExceptionHandler(val appContext: Context) : Thread.UncaughtExceptionHandler {
private var defaultUncaughtExceptionHandler: Thread.UncaughtExceptionHandler? = null
fun install(): Boolean {
val ueh = Thread.getDefaultUncaughtExceptionHandler()
if (ueh is CrashReportExceptionHandler)
return false
defaultUncaughtExceptionHandler = ueh
Thread.setDefaultUncaughtExceptionHandler(this)
return true
}
override fun uncaughtException(t: Thread, e: Throwable) {
val stackTrace = StringWriter()
e.printStackTrace(PrintWriter(stackTrace))
writeCrashReportToFile("""
Thread: ${t.name}
App version: ${BuildConfig.VERSION_NAME}
Device: ${Build.BRAND} ${Build.DEVICE}, Android ${Build.VERSION.RELEASE}
Locale: ${Locale.getDefault()}
Stack trace:
$stackTrace
""")
defaultUncaughtExceptionHandler!!.uncaughtException(t, e)
}
private fun writeCrashReportToFile(text: String) {
try {
val dir = appContext.getExternalFilesDir(null) ?: return
val crashReportFile = File(dir, "crash_report_${System.currentTimeMillis()}.txt")
crashReportFile.writeText(text)
} catch (ignored: IOException) {
}
}
}

View file

@ -13,6 +13,7 @@ import android.os.Bundle;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.core.graphics.drawable.DrawableCompat;
@ -41,24 +42,42 @@ public final class AboutFragment extends SubScreenFragment {
}
}
Preference versionPreference = findPreference("pref_key_version");
versionPreference.setSummary(BuildConfig.VERSION_NAME);
setupHiddenFeatures();
setupVersionPref();
}
private void setupHiddenFeatures() {
Preference hiddenFeaturesPreference = findPreference("hidden_features");
hiddenFeaturesPreference.setOnPreferenceClickListener(preference -> {
final String link = "<a href=\"https://developer.android.com/reference/android/content/Context#createDeviceProtectedStorageContext()\">"
+ getString(R.string.hidden_features_text) + "</a>";
final String message = getContext().getString(R.string.hidden_features_message, link);
final String message = requireContext().getString(R.string.hidden_features_message, link);
final Spanned dialogMessage = SpannableStringUtils.fromHtml(message);
final AlertDialog builder = new AlertDialog.Builder(getContext())
final AlertDialog builder = new AlertDialog.Builder(requireContext())
.setIcon(R.drawable.ic_settings_about_hidden_features)
.setTitle(R.string.hidden_features_title)
.setMessage(dialogMessage)
.setPositiveButton(R.string.dialog_close, null)
.create();
builder.show();
((TextView)builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView) builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
return true;
});
}
private void setupVersionPref() {
Preference versionPreference = findPreference("pref_key_version");
versionPreference.setSummary(BuildConfig.VERSION_NAME);
if (BuildConfig.DEBUG) return;
int[] count = new int[] {0};
versionPreference.setOnPreferenceClickListener((pref) -> {
if (getSharedPreferences().getBoolean(DebugSettings.PREF_SHOW_DEBUG_SETTINGS, false))
return true;
count[0]++;
if (count[0] < 5) return true;
getSharedPreferences().edit().putBoolean(DebugSettings.PREF_SHOW_DEBUG_SETTINGS, true).apply();
Toast.makeText(requireContext(), R.string.prefs_debug_settings_enabled, Toast.LENGTH_LONG).show();
return true;
});
}

View file

@ -25,6 +25,7 @@ import org.dslul.openboard.inputmethod.latin.BuildConfig
import org.dslul.openboard.inputmethod.latin.R
import org.dslul.openboard.inputmethod.latin.SystemBroadcastReceiver
import org.dslul.openboard.inputmethod.latin.common.FileUtils
import org.dslul.openboard.inputmethod.latin.define.DebugFlags
import org.dslul.openboard.inputmethod.latin.define.JniLibName
import org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference.ValueProxy
import java.io.File
@ -85,9 +86,6 @@ class AdvancedSettingsFragment : SubScreenFragment() {
// singleton and utility classes may not have been initialized. We have to call
// initialization method of these classes here. See {@link LatinIME#onCreate()}.
AudioAndHapticFeedbackManager.init(context)
if (!BuildConfig.DEBUG) {
removePreference(Settings.SCREEN_DEBUG)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
removePreference(Settings.PREF_SHOW_SETUP_WIZARD_ICON)
}
@ -96,6 +94,13 @@ class AdvancedSettingsFragment : SubScreenFragment() {
findPreference<Preference>("pref_backup_restore")?.setOnPreferenceClickListener { showBackupRestoreDialog() }
}
override fun onStart() {
super.onStart()
if (!BuildConfig.DEBUG && !sharedPreferences.getBoolean(DebugSettings.PREF_SHOW_DEBUG_SETTINGS, false)) {
removePreference(Settings.SCREEN_DEBUG)
}
}
private fun onClickLoadLibrary(): Boolean {
// get architecture for telling user which file to use
val abi = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

View file

@ -17,9 +17,9 @@ package org.dslul.openboard.inputmethod.latin.settings;
public final class DebugSettings {
public static final String PREF_DEBUG_MODE = "debug_mode";
public static final String PREF_FORCE_NON_DISTINCT_MULTITOUCH = "force_non_distinct_multitouch";
public static final String PREF_SHOULD_SHOW_LXX_SUGGESTION_UI =
"pref_should_show_lxx_suggestion_ui";
public static final String PREF_SHOULD_SHOW_LXX_SUGGESTION_UI = "pref_should_show_lxx_suggestion_ui";
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";
private DebugSettings() {
// This class is not publicly instantiable.

View file

@ -16,6 +16,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
import androidx.preference.TwoStatePreference;
import org.dslul.openboard.inputmethod.latin.BuildConfig;
import org.dslul.openboard.inputmethod.latin.DictionaryDumpBroadcastReceiver;
import org.dslul.openboard.inputmethod.latin.DictionaryFacilitatorImpl;
import org.dslul.openboard.inputmethod.latin.R;
@ -49,6 +50,8 @@ public final class DebugSettingsFragment extends SubScreenFragment
pref.setOnPreferenceClickListener(this);
dictDumpPreferenceGroup.addPreference(pref);
}
if (BuildConfig.DEBUG)
removePreference(DebugSettings.PREF_SHOW_DEBUG_SETTINGS);
mServiceNeedsRestart = false;
mDebugMode = findPreference(DebugSettings.PREF_DEBUG_MODE);
@ -92,7 +95,6 @@ public final class DebugSettingsFragment extends SubScreenFragment
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
if (key.equals(DebugSettings.PREF_DEBUG_MODE) && mDebugMode != null) {
mDebugMode.setChecked(prefs.getBoolean(DebugSettings.PREF_DEBUG_MODE, false));
updateDebugMode();
mServiceNeedsRestart = true;
} else if (key.equals(DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH)) {
mServiceNeedsRestart = true;
@ -100,16 +102,8 @@ public final class DebugSettingsFragment extends SubScreenFragment
}
private void updateDebugMode() {
boolean isDebugMode = mDebugMode.isChecked();
final String version = getString(
R.string.version_text, ApplicationUtils.getVersionName(getActivity()));
if (!isDebugMode) {
mDebugMode.setTitle(version);
mDebugMode.setSummary(null);
} else {
mDebugMode.setTitle(getString(R.string.prefs_debug_mode));
final String version = getString(R.string.version_text, ApplicationUtils.getVersionName(getActivity()));
mDebugMode.setSummary(version);
}
}
}

View file

@ -31,6 +31,7 @@ import androidx.preference.PreferenceScreen;
import org.dslul.openboard.inputmethod.latin.BuildConfig;
import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.common.FileUtils;
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
import org.dslul.openboard.inputmethod.latin.utils.ApplicationUtils;
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
import org.dslul.openboard.inputmethod.latin.utils.DictionaryUtilsKt;
@ -95,7 +96,7 @@ public final class SettingsFragment extends PreferenceFragmentCompat {
SubtypeSettingsKt.init(getActivity());
findPreference("screen_languages").setSummary(getEnabledSubtypesLabel());
if (BuildConfig.DEBUG)
if (BuildConfig.DEBUG || DebugFlags.DEBUG_ENABLED)
askAboutCrashReports();
}

View file

@ -14,6 +14,7 @@ import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
import org.dslul.openboard.inputmethod.latin.BuildConfig
import org.dslul.openboard.inputmethod.latin.R
import org.dslul.openboard.inputmethod.latin.RichInputMethodManager
import org.dslul.openboard.inputmethod.latin.define.DebugFlags
import org.dslul.openboard.inputmethod.latin.utils.AdditionalSubtypeUtils
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils
import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils
@ -235,7 +236,7 @@ private fun loadEnabledSubtypes(context: Context) {
for (localeAndLayout in subtypeStrings) {
require(localeAndLayout.size == 2)
val subtypesForLocale = resourceSubtypesByLocale[localeAndLayout.first()]
if (BuildConfig.DEBUG) // should not happen, but should not crash for normal user
if (DebugFlags.DEBUG_ENABLED) // should not happen, but should not crash for normal user
require(subtypesForLocale != null)
else if (subtypesForLocale == null)
continue
@ -243,7 +244,7 @@ private fun loadEnabledSubtypes(context: Context) {
val subtype = subtypesForLocale.firstOrNull { SubtypeLocaleUtils.getKeyboardLayoutSetName(it) == localeAndLayout.last() }
?: additionalSubtypes.firstOrNull { it.locale() == localeAndLayout.first() && SubtypeLocaleUtils.getKeyboardLayoutSetName(it) == localeAndLayout.last() }
if (subtype == null) {
if (BuildConfig.DEBUG)
if (DebugFlags.DEBUG_ENABLED)
Toast.makeText(context, "subtype $localeAndLayout could not be loaded", Toast.LENGTH_LONG).show()
continue
}

View file

@ -364,7 +364,7 @@ final class SuggestionStripLayoutHelper {
layoutWord(context, mCenterPositionInStrip, stripWidth - mPadding);
stripView.addView(centerWordView);
setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT);
if (SuggestionStripView.DBG) {
if (SuggestionStripView.DEBUG) {
layoutDebugInfo(mCenterPositionInStrip, placerView, stripWidth);
}
final Integer lastIndex = (Integer)centerWordView.getTag();
@ -390,7 +390,7 @@ final class SuggestionStripLayoutHelper {
ViewGroup.LayoutParams.MATCH_PARENT);
x += wordView.getMeasuredWidth();
if (SuggestionStripView.DBG) {
if (SuggestionStripView.DEBUG) {
layoutDebugInfo(positionInStrip, placerView, x);
}
}
@ -484,7 +484,7 @@ final class SuggestionStripLayoutHelper {
wordView.setText(null);
wordView.setTag(null);
// Make this inactive for touches in {@link #layoutWord(int,int)}.
if (SuggestionStripView.DBG) {
if (SuggestionStripView.DEBUG) {
mDebugInfoViews.get(positionInStrip).setText(null);
}
}
@ -503,7 +503,7 @@ final class SuggestionStripLayoutHelper {
wordView.setTag(indexInSuggestedWords);
wordView.setText(getStyledSuggestedWord(suggestedWords, indexInSuggestedWords));
wordView.setTextColor(getSuggestionTextColor(suggestedWords, indexInSuggestedWords));
if (SuggestionStripView.DBG) {
if (SuggestionStripView.DEBUG) {
mDebugInfoViews.get(positionInStrip).setText(
suggestedWords.getDebugString(indexInSuggestedWords));
}

View file

@ -70,7 +70,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
CharSequence getSelection();
}
static final boolean DBG = DebugFlags.DEBUG_ENABLED;
static final boolean DEBUG = DebugFlags.DEBUG_ENABLED;
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";
@ -405,7 +405,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
}
return false;
});
if (BuildConfig.DEBUG && (isShowingMoreSuggestionPanel() || !showMoreSuggestions())) {
if (DEBUG && (isShowingMoreSuggestionPanel() || !showMoreSuggestions())) {
showSourceDict(wordView);
return true;
} else return showMoreSuggestions();

View file

@ -14,7 +14,6 @@ import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import org.dslul.openboard.inputmethod.latin.define.DebugFlags;
public final class AutoCorrectionUtils {
private static final boolean DBG = DebugFlags.DEBUG_ENABLED;
private static final String TAG = AutoCorrectionUtils.class.getSimpleName();
private AutoCorrectionUtils() {
@ -37,13 +36,13 @@ public final class AutoCorrectionUtils {
// the normalized score of the second suggestion, behave less aggressive.
final float normalizedScore = BinaryDictionaryUtils.calcNormalizedScore(
consideredWord, suggestion.mWord, autoCorrectionSuggestionScore);
if (DBG) {
if (DebugFlags.DEBUG_ENABLED) {
Log.d(TAG, "Normalized " + consideredWord + "," + suggestion + ","
+ autoCorrectionSuggestionScore + ", " + normalizedScore
+ "(" + threshold + ")");
}
if (normalizedScore >= threshold) {
if (DBG) {
if (DebugFlags.DEBUG_ENABLED) {
Log.d(TAG, "Exceeds threshold.");
}
return true;

View file

@ -6,7 +6,9 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Title for Android keyboard debug settings activity / dialog -->
<string name="english_ime_debug_settings" translatable="false">Android Keyboard Debug settings</string>
<string name="debug_settings_title" translatable="false">Debug settings</string>
<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_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>

View file

@ -72,7 +72,7 @@
<PreferenceScreen
android:fragment="org.dslul.openboard.inputmethod.latin.settings.DebugSettingsFragment"
android:key="screen_debug"
android:title="Debug settings"
android:title="@string/debug_settings_title"
android:defaultValue="false"
android:persistent="true" />

View file

@ -6,10 +6,13 @@
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:latin="http://schemas.android.com/apk/res-auto"
android:title="@string/prefs_debug_mode"
android:title="@string/debug_settings_title"
android:key="english_ime_debug_settings"
>
<SwitchPreferenceCompat
android:key="pref_show_debug_settings"
android:title="@string/prefs_show_debug_settings"
android:persistent="true" />
<SwitchPreferenceCompat
android:key="debug_mode"
android:title="@string/prefs_debug_mode"