1
0
Fork 0

fixed the debug log setting not being applied on startup

This commit is contained in:
sspanak 2023-08-23 21:26:33 +03:00 committed by Dimo Karaivanov
parent c7045b79af
commit 312a6734d5
7 changed files with 12 additions and 11 deletions

View file

@ -2,11 +2,13 @@
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto" app:orderingFromXml="true">
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_enable_debug_logs"
app:layout="@layout/pref_switch"
app:title="@string/pref_debug_logs" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_enable_system_logs"
app:layout="@layout/pref_switch"
app:title="@string/pref_system_logs" />

View file

@ -18,12 +18,14 @@
app:singleLineTitle="true">
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_alternative_suggestion_scrolling"
app:layout="@layout/pref_switch"
app:title="@string/pref_alternative_suggestion_scrolling"
app:summary="@string/pref_alternative_suggestion_scrolling_summary"/>
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_hack_fb_messenger"
app:layout="@layout/pref_switch"
app:title="@string/pref_hack_fb_messenger"

View file

@ -10,12 +10,8 @@ public class Logger {
return LEVEL == Log.DEBUG;
}
public static void setDebugLevel() {
LEVEL = Log.DEBUG;
}
public static void setDefaultLevel() {
LEVEL = Log.ERROR;
public static void enableDebugLevel(boolean yes) {
LEVEL = yes ? Log.DEBUG : Log.ERROR;
}
static public void v(String tag, String msg) {

View file

@ -214,6 +214,7 @@ public class TraditionalT9 extends KeyPadHandler {
initTyping();
initUi();
Logger.enableDebugLevel(settings.getDebugLogsEnabled());
isActive = true;
}

View file

@ -13,6 +13,7 @@ import androidx.fragment.app.FragmentTransaction;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import io.github.sspanak.tt9.Logger;
import io.github.sspanak.tt9.R;
import io.github.sspanak.tt9.db.DictionaryDb;
import io.github.sspanak.tt9.db.DictionaryLoader;
@ -38,6 +39,7 @@ public class PreferencesActivity extends AppCompatActivity implements Preference
globalKeyboardSettings = new GlobalKeyboardSettings(this, (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE));
settings = new SettingsStore(this);
applyTheme();
Logger.enableDebugLevel(settings.getDebugLogsEnabled());
DictionaryDb.init(this);
DictionaryDb.normalizeWordFrequencies(settings);

View file

@ -265,6 +265,8 @@ public class SettingsStore {
/************* internal settings *************/
public boolean getDebugLogsEnabled() { return prefs.getBoolean("pref_enable_debug_logs", Logger.isDebugLevel()); }
public int getDictionaryImportProgressUpdateInterval() { return 250; /* ms */ }
public int getDictionaryImportWordChunkSize() { return 1000; /* words */ }

View file

@ -41,11 +41,7 @@ public class DebugScreen extends BaseScreenFragment {
msgSwitch.setChecked(Logger.isDebugLevel());
msgSwitch.setOnPreferenceChangeListener((Preference p, Object newValue) -> {
if ((boolean) newValue) {
Logger.setDebugLevel();
} else {
Logger.setDefaultLevel();
}
Logger.enableDebugLevel((boolean) newValue);
return true;
});
}