fixed the debug log setting not being applied on startup
This commit is contained in:
parent
c7045b79af
commit
312a6734d5
7 changed files with 12 additions and 11 deletions
|
|
@ -2,11 +2,13 @@
|
||||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto" app:orderingFromXml="true">
|
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto" app:orderingFromXml="true">
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
|
app:defaultValue="false"
|
||||||
app:key="pref_enable_debug_logs"
|
app:key="pref_enable_debug_logs"
|
||||||
app:layout="@layout/pref_switch"
|
app:layout="@layout/pref_switch"
|
||||||
app:title="@string/pref_debug_logs" />
|
app:title="@string/pref_debug_logs" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
|
app:defaultValue="false"
|
||||||
app:key="pref_enable_system_logs"
|
app:key="pref_enable_system_logs"
|
||||||
app:layout="@layout/pref_switch"
|
app:layout="@layout/pref_switch"
|
||||||
app:title="@string/pref_system_logs" />
|
app:title="@string/pref_system_logs" />
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,14 @@
|
||||||
app:singleLineTitle="true">
|
app:singleLineTitle="true">
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
|
app:defaultValue="false"
|
||||||
app:key="pref_alternative_suggestion_scrolling"
|
app:key="pref_alternative_suggestion_scrolling"
|
||||||
app:layout="@layout/pref_switch"
|
app:layout="@layout/pref_switch"
|
||||||
app:title="@string/pref_alternative_suggestion_scrolling"
|
app:title="@string/pref_alternative_suggestion_scrolling"
|
||||||
app:summary="@string/pref_alternative_suggestion_scrolling_summary"/>
|
app:summary="@string/pref_alternative_suggestion_scrolling_summary"/>
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
|
app:defaultValue="false"
|
||||||
app:key="pref_hack_fb_messenger"
|
app:key="pref_hack_fb_messenger"
|
||||||
app:layout="@layout/pref_switch"
|
app:layout="@layout/pref_switch"
|
||||||
app:title="@string/pref_hack_fb_messenger"
|
app:title="@string/pref_hack_fb_messenger"
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,8 @@ public class Logger {
|
||||||
return LEVEL == Log.DEBUG;
|
return LEVEL == Log.DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDebugLevel() {
|
public static void enableDebugLevel(boolean yes) {
|
||||||
LEVEL = Log.DEBUG;
|
LEVEL = yes ? Log.DEBUG : Log.ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
public static void setDefaultLevel() {
|
|
||||||
LEVEL = Log.ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void v(String tag, String msg) {
|
static public void v(String tag, String msg) {
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
|
|
||||||
initTyping();
|
initTyping();
|
||||||
initUi();
|
initUi();
|
||||||
|
Logger.enableDebugLevel(settings.getDebugLogsEnabled());
|
||||||
|
|
||||||
isActive = true;
|
isActive = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import androidx.fragment.app.FragmentTransaction;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
|
import io.github.sspanak.tt9.Logger;
|
||||||
import io.github.sspanak.tt9.R;
|
import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.db.DictionaryDb;
|
import io.github.sspanak.tt9.db.DictionaryDb;
|
||||||
import io.github.sspanak.tt9.db.DictionaryLoader;
|
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));
|
globalKeyboardSettings = new GlobalKeyboardSettings(this, (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE));
|
||||||
settings = new SettingsStore(this);
|
settings = new SettingsStore(this);
|
||||||
applyTheme();
|
applyTheme();
|
||||||
|
Logger.enableDebugLevel(settings.getDebugLogsEnabled());
|
||||||
|
|
||||||
DictionaryDb.init(this);
|
DictionaryDb.init(this);
|
||||||
DictionaryDb.normalizeWordFrequencies(settings);
|
DictionaryDb.normalizeWordFrequencies(settings);
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,8 @@ public class SettingsStore {
|
||||||
|
|
||||||
/************* internal settings *************/
|
/************* internal settings *************/
|
||||||
|
|
||||||
|
public boolean getDebugLogsEnabled() { return prefs.getBoolean("pref_enable_debug_logs", Logger.isDebugLevel()); }
|
||||||
|
|
||||||
public int getDictionaryImportProgressUpdateInterval() { return 250; /* ms */ }
|
public int getDictionaryImportProgressUpdateInterval() { return 250; /* ms */ }
|
||||||
public int getDictionaryImportWordChunkSize() { return 1000; /* words */ }
|
public int getDictionaryImportWordChunkSize() { return 1000; /* words */ }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,7 @@ public class DebugScreen extends BaseScreenFragment {
|
||||||
|
|
||||||
msgSwitch.setChecked(Logger.isDebugLevel());
|
msgSwitch.setChecked(Logger.isDebugLevel());
|
||||||
msgSwitch.setOnPreferenceChangeListener((Preference p, Object newValue) -> {
|
msgSwitch.setOnPreferenceChangeListener((Preference p, Object newValue) -> {
|
||||||
if ((boolean) newValue) {
|
Logger.enableDebugLevel((boolean) newValue);
|
||||||
Logger.setDebugLevel();
|
|
||||||
} else {
|
|
||||||
Logger.setDefaultLevel();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue