diff --git a/app_pojavlauncher/src/main/java/com/kdt/LoggerView.java b/app_pojavlauncher/src/main/java/com/kdt/LoggerView.java index 9d34e9209..773f797bd 100644 --- a/app_pojavlauncher/src/main/java/com/kdt/LoggerView.java +++ b/app_pojavlauncher/src/main/java/com/kdt/LoggerView.java @@ -22,9 +22,15 @@ import net.kdt.pojavlaunch.R; */ public class LoggerView extends ConstraintLayout { private Logger.eventLogListener mLogListener; - private ToggleButton mToggleButton; + private ToggleButton mLogToggle; private ScrollView mScrollView; + /* + * android:descendantFocusability="blocksDescendants" + * This is set for the ScrollView, since under focus the TextView always autoscrolls. + * By not allowing focus, we are able to control its behaviour from the code that we have here. + */ private TextView mLogTextView; + private boolean mAutoScroll = true; public LoggerView(@NonNull Context context) { @@ -40,7 +46,7 @@ public class LoggerView extends ConstraintLayout { public void setVisibility(int visibility) { super.setVisibility(visibility); // Triggers the log view shown state by default when viewing it - mToggleButton.setChecked(visibility == VISIBLE); + mLogToggle.setChecked(visibility == VISIBLE); } /** @@ -56,8 +62,8 @@ public class LoggerView extends ConstraintLayout { mLogTextView.setVisibility(GONE); // Toggle log visibility - mToggleButton = findViewById(R.id.content_log_toggle_log); - mToggleButton.setOnCheckedChangeListener( + mLogToggle = findViewById(R.id.content_log_toggle_log); + mLogToggle.setOnCheckedChangeListener( (compoundButton, isChecked) -> { mLogTextView.setVisibility(isChecked ? VISIBLE : GONE); if(isChecked) { @@ -68,7 +74,13 @@ public class LoggerView extends ConstraintLayout { // NOTE: was tested by rapidly smashing the log on/off button, no sync issues found :) } }); - mToggleButton.setChecked(false); + mLogToggle.setChecked(false); + + ToggleButton autoscrollToggle = findViewById(R.id.content_log_toggle_autoscroll); + autoscrollToggle.setOnCheckedChangeListener( + (compoundButton, isChecked) -> mAutoScroll = isChecked + ); + autoscrollToggle.setChecked(true); // Remove the loggerView from the user View ImageButton cancelButton = findViewById(R.id.log_view_cancel); @@ -82,7 +94,7 @@ public class LoggerView extends ConstraintLayout { if(mLogTextView.getVisibility() != VISIBLE) return; post(() -> { mLogTextView.append(text + '\n'); - mScrollView.fullScroll(View.FOCUS_DOWN); + if(mAutoScroll) mScrollView.fullScroll(View.FOCUS_DOWN); }); }; diff --git a/app_pojavlauncher/src/main/res/layout/view_logger.xml b/app_pojavlauncher/src/main/res/layout/view_logger.xml index 3ea53922b..548795220 100644 --- a/app_pojavlauncher/src/main/res/layout/view_logger.xml +++ b/app_pojavlauncher/src/main/res/layout/view_logger.xml @@ -15,18 +15,31 @@ android:id="@+id/log_title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingStart="25dp" - android:text="Log output:" + android:paddingHorizontal="25dp" + android:text="@string/log_view_label_log_output" android:textAppearance="?android:attr/textAppearanceMedium" app:layout_constraintBottom_toBottomOf="@+id/top_log_view" app:layout_constraintStart_toStartOf="@+id/top_log_view" app:layout_constraintTop_toTopOf="parent" /> + + @@ -47,6 +60,7 @@ android:layout_height="0dp" android:alpha="0.8" android:background="#000000" + android:descendantFocusability="blocksDescendants" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@+id/top_log_view"> diff --git a/app_pojavlauncher/src/main/res/values/strings.xml b/app_pojavlauncher/src/main/res/values/strings.xml index daeaf5fc7..beba6b88c 100644 --- a/app_pojavlauncher/src/main/res/values/strings.xml +++ b/app_pojavlauncher/src/main/res/values/strings.xml @@ -376,4 +376,9 @@ H. lock Reset Selection cancelled + Autoscroll\nOFF + Autoscroll\nON + Output\nOFF + Output\nON + Log output: