@@ -64,6 +64,7 @@ public final class EditConfigurationActivity extends AbstractPluginActivity {
6464 private AutoCompleteTextView mWorkingDirectoryPathText ;
6565 private TextView mStdinView ;
6666 private EditText mSessionAction ;
67+ private EditText mBackgroundCustomLogLevel ;
6768 private CheckBox mInTerminalCheckbox ;
6869 private CheckBox mWaitForResult ;
6970 private TextView mExecutableAbsolutePathText ;
@@ -113,6 +114,7 @@ protected void onCreate(final Bundle savedInstanceState) {
113114 mWorkingDirectoryPathText = findViewById (R .id .working_directory_path );
114115 mStdinView = findViewById (R .id .view_stdin );
115116 mSessionAction = findViewById (R .id .session_action );
117+ mBackgroundCustomLogLevel = findViewById (R .id .background_custom_log_level );
116118 mInTerminalCheckbox = findViewById (R .id .in_terminal );
117119 mWaitForResult = findViewById (R .id .wait_for_result );
118120 mExecutableAbsolutePathText = findViewById (R .id .executable_absolute_path );
@@ -126,6 +128,7 @@ protected void onCreate(final Bundle savedInstanceState) {
126128 setWorkingDirectoryPathViews ();
127129 setStdinView ();
128130 setSessionActionViews ();
131+ setBackgroundCustomLogLevelViews ();
129132 setInTerminalView ();
130133
131134 // Currently savedInstanceState bundle is not supported
@@ -164,6 +167,11 @@ protected void onCreate(final Bundle savedInstanceState) {
164167 processSessionAction (sessionAction );
165168 updateSessionActionViewVisibility (inTerminal );
166169
170+ final String backgroundCustomLogLevel = localeBundle .getString (PluginBundleManager .EXTRA_BACKGROUND_CUSTOM_LOG_LEVEL );
171+ mBackgroundCustomLogLevel .setText (backgroundCustomLogLevel );
172+ processBackgroundCustomLogLevel (backgroundCustomLogLevel );
173+ updateBackgroundCustomLogLevelViewVisibility (inTerminal );
174+
167175 final boolean waitForResult = localeBundle .getBoolean (PluginBundleManager .EXTRA_WAIT_FOR_RESULT );
168176 mWaitForResult .setChecked (waitForResult );
169177 }
@@ -280,12 +288,28 @@ private void updateSessionActionViewVisibility(boolean inTerminal) {
280288 }
281289
282290
291+ private void setBackgroundCustomLogLevelViews () {
292+ mBackgroundCustomLogLevel .addTextChangedListener (new AfterTextChangedWatcher () {
293+ @ Override
294+ public void afterTextChanged (Editable editable ) {
295+ processBackgroundCustomLogLevel (editable == null ? null : editable .toString ());
296+ }
297+ });
298+ }
299+
300+ private void updateBackgroundCustomLogLevelViewVisibility (boolean inTerminal ) {
301+ if (mBackgroundCustomLogLevel == null ) return ;
302+ mBackgroundCustomLogLevel .setVisibility (inTerminal ? View .GONE : View .VISIBLE );
303+ }
304+
305+
283306 private void setInTerminalView () {
284307 mInTerminalCheckbox .setOnCheckedChangeListener (new CompoundButton .OnCheckedChangeListener () {
285308 @ Override
286309 public void onCheckedChanged (CompoundButton buttonView , boolean isChecked ) {
287310 updateStdinViewVisibility (isChecked );
288311 updateSessionActionViewVisibility (isChecked );
312+ updateBackgroundCustomLogLevelViewVisibility (isChecked );
289313 }
290314 });
291315 }
@@ -582,6 +606,11 @@ private void processSessionAction(String sessionActionString) {
582606 TERMUX_SERVICE .MIN_VALUE_EXTRA_SESSION_ACTION , TERMUX_SERVICE .MAX_VALUE_EXTRA_SESSION_ACTION );
583607 }
584608
609+ private void processBackgroundCustomLogLevel (String backgroundCustomLogLevelString ) {
610+ processIntFieldValue (mBackgroundCustomLogLevel , backgroundCustomLogLevelString ,
611+ Logger .LOG_LEVEL_OFF , Logger .MAX_LOG_LEVEL );
612+ }
613+
585614 private void processIntFieldValue (EditText editText , String stringValue , int min , int max ) {
586615 if (editText == null ) return ;
587616 editText .setError (null );
@@ -618,6 +647,7 @@ public void finish() {
618647 final String arguments = DataUtils .getDefaultIfUnset (mArgumentsText .getText () == null ? null : mArgumentsText .getText ().toString (), null );
619648 final String workingDirectory = DataUtils .getDefaultIfUnset (mWorkingDirectoryPathText .getText () == null ? null : mWorkingDirectoryPathText .getText ().toString (), null );
620649 final String sessionAction = DataUtils .getDefaultIfUnset (mSessionAction .getText () == null ? null : mSessionAction .getText ().toString (), null );
650+ final String backgroundCustomLogLevel = DataUtils .getDefaultIfUnset (mBackgroundCustomLogLevel .getText () == null ? null : mBackgroundCustomLogLevel .getText ().toString (), null );
621651 final boolean inTerminal = mInTerminalCheckbox .isChecked ();
622652 final boolean waitForResult = mWaitForResult .isChecked ();
623653
@@ -637,7 +667,7 @@ public void finish() {
637667 * stored in the Bundle, as Locale's classloader will not recognize it).
638668 */
639669 final Bundle resultBundle = PluginBundleManager .generateBundle (getApplicationContext (),
640- executable , arguments , workingDirectory , mStdin , sessionAction , inTerminal , waitForResult );
670+ executable , arguments , workingDirectory , mStdin , sessionAction , backgroundCustomLogLevel , inTerminal , waitForResult );
641671 if (resultBundle == null ) {
642672 Logger .showToast (this , getString (R .string .error_generate_plugin_bundle_failed ), true );
643673 setResult (RESULT_CODE_FAILED , resultIntent );
@@ -649,7 +679,7 @@ public void finish() {
649679
650680 // The blurb is a concise status text to be displayed in the host's UI.
651681 final String blurb = PluginBundleManager .generateBlurb (this , executable , arguments ,
652- workingDirectory , mStdin , sessionAction , inTerminal , waitForResult );
682+ workingDirectory , mStdin , sessionAction , backgroundCustomLogLevel , inTerminal , waitForResult );
653683
654684 // If host supports variable replacement when running plugin action, then
655685 // request it to replace variables in following fields
@@ -659,7 +689,8 @@ public void finish() {
659689 PluginBundleManager .EXTRA_ARGUMENTS ,
660690 PluginBundleManager .EXTRA_WORKDIR ,
661691 PluginBundleManager .EXTRA_STDIN ,
662- PluginBundleManager .EXTRA_SESSION_ACTION
692+ PluginBundleManager .EXTRA_SESSION_ACTION ,
693+ PluginBundleManager .EXTRA_BACKGROUND_CUSTOM_LOG_LEVEL
663694 });
664695 }
665696
0 commit comments