1111
1212import androidx .databinding .DataBindingUtil ;
1313
14+ import org .mozilla .vrbrowser .BuildConfig ;
1415import org .mozilla .vrbrowser .R ;
1516import org .mozilla .vrbrowser .browser .SettingsStore ;
1617import org .mozilla .vrbrowser .browser .engine .SessionStore ;
@@ -56,6 +57,12 @@ private void initialize(Context aContext) {
5657 mBinding .performanceMonitorSwitch .setOnCheckedChangeListener (mPerformanceListener );
5758 setPerformance (SettingsStore .getInstance (getContext ()).isPerformanceMonitorEnabled (), false );
5859
60+ if (BuildConfig .DEBUG ) {
61+ mBinding .debugLoggingSwitch .setVisibility (View .GONE );
62+ } else {
63+ setDebugLogging (SettingsStore .getInstance (getContext ()).isDebugLogginEnabled (), false );
64+ }
65+
5966 if (!isServoAvailable ()) {
6067 mBinding .servoSwitch .setVisibility (View .GONE );
6168
@@ -81,6 +88,10 @@ private void initialize(Context aContext) {
8188 setPerformance (value , doApply );
8289 };
8390
91+ private SwitchSetting .OnCheckedChangeListener mDebugLogginListener = (compoundButton , value , doApply ) -> {
92+ setDebugLogging (value , doApply );
93+ };
94+
8495 private SwitchSetting .OnCheckedChangeListener mServoListener = (compoundButton , b , doApply ) -> {
8596 setServo (b , true );
8697 };
@@ -89,7 +100,6 @@ private void initialize(Context aContext) {
89100 boolean restart = false ;
90101 if (mBinding .remoteDebuggingSwitch .isChecked () != SettingsStore .REMOTE_DEBUGGING_DEFAULT ) {
91102 setRemoteDebugging (SettingsStore .REMOTE_DEBUGGING_DEFAULT , true );
92- restart = true ;
93103 }
94104
95105 if (mBinding .showConsoleSwitch .isChecked () != SettingsStore .CONSOLE_LOGS_DEFAULT ) {
@@ -106,7 +116,12 @@ private void initialize(Context aContext) {
106116 setPerformance (SettingsStore .PERFORMANCE_MONITOR_DEFAULT , true );
107117 }
108118
109- if (restart && mDelegate != null ) {
119+ if (mBinding .debugLoggingSwitch .isChecked () != SettingsStore .DEBUG_LOGGING_DEFAULT ) {
120+ setDebugLogging (SettingsStore .DEBUG_LOGGING_DEFAULT , true );
121+ restart = true ;
122+ }
123+
124+ if (restart ) {
110125 showRestartDialog ();
111126 }
112127 };
@@ -157,6 +172,17 @@ private void setPerformance(boolean value, boolean doApply) {
157172 }
158173 }
159174
175+ private void setDebugLogging (boolean value , boolean doApply ) {
176+ mBinding .debugLoggingSwitch .setOnCheckedChangeListener (null );
177+ mBinding .debugLoggingSwitch .setValue (value , false );
178+ mBinding .debugLoggingSwitch .setOnCheckedChangeListener (mDebugLogginListener );
179+
180+ if (doApply ) {
181+ SettingsStore .getInstance (getContext ()).setDebugLoggingEnabled (value );
182+ showRestartDialog ();
183+ }
184+ }
185+
160186 private void setServo (boolean value , boolean doApply ) {
161187 mBinding .servoSwitch .setOnCheckedChangeListener (null );
162188 mBinding .servoSwitch .setValue (value , false );
0 commit comments