Repository: PojavLauncherTeam/PojavLauncher (language: java)

Issue:
[F-Req] Better in-game log display
### Is this request related to a bug?

no

### Describe the request.

Add an auto-scroll switch for in-game log output
This prevents the automatic scrolling from becoming invisible due to new logs when viewing the low

### Anything else?

The above description is filled by the translation software, because I can't speak English.


Discussion / hints:
I personally just highlight a text in the log output, this prevents it from scrolling. Such a workaround

Fix patch:
diff --git a/app_pojavlauncher/src/main/java/com/kdt/LoggerView.java b/app_pojavlauncher/src/main/java/com/kdt/LoggerView.java
index 9d34e9209d..8409fa2686 100644
--- a/app_pojavlauncher/src/main/java/com/kdt/LoggerView.java
+++ b/app_pojavlauncher/src/main/java/com/kdt/LoggerView.java
@@ -5,7 +5,6 @@
 import android.util.AttributeSet;
 import android.view.View;
 import android.widget.ImageButton;
-import android.widget.ScrollView;
 import android.widget.TextView;
 import android.widget.ToggleButton;
 
@@ -22,8 +21,8 @@
  */
 public class LoggerView extends ConstraintLayout {
     private Logger.eventLogListener mLogListener;
-    private ToggleButton mToggleButton;
-    private ScrollView mScrollView;
+    private ToggleButton mLogToggle;
+    private DefocusableScrollView mScrollView;
     private TextView mLogTextView;
 
 
@@ -40,7 +39,7 @@ public LoggerView(@NonNull Context context, @Nullable AttributeSet attrs) {
     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 +55,8 @@ private void init(){
         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 +67,7 @@ private void init(){
                         // NOTE: was tested by rapidly smashing the log on/off button, no sync issues found :)
                     }
                 });
-        mToggleButton.setChecked(false);
+        mLogToggle.setChecked(false);
 
         // Remove the loggerView from the user View
         ImageButton cancelButton = findViewById(R.id.log_view_cancel);
@@ -76,13 +75,24 @@ private void init(){
 
         // Set the scroll view
         mScrollView = findViewById(R.id.content_log_scroll);
+        mScrollView.setKeepFocusing(true);
+
+        //Set up the autoscroll switch
+        ToggleButton autoscrollToggle = findViewById(R.id.content_log_toggle_autoscroll);
+        autoscrollToggle.setOnCheckedChangeListener(
+                (compoundButton, isChecked) -> {
+                    if(isChecked) mScrollView.fullScroll(View.FOCUS_DOWN);
+                    mScrollView.setKeepFocusing(isChecked);
+                }
+        );
+        autoscrollToggle.setChecked(true);
 
         // Listen to logs
         mLogListener = text -> {
             if(mLogTextView.getVisibility() != VISIBLE) return;
             post(() -> {
                 mLogTextView.append(text + '\n');
-                mScrollView.fullScroll(View.FOCUS_DOWN);
+                if(mScrollView.isKeepFocusing()) 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 3ea53922b6..89afc2f207 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" />
 
+    <ToggleButton
+        android:id="@+id/content_log_toggle_autoscroll"
+        android:layout_width="wrap_content"
+        android:layout_height="0dp"
+        android:layout_marginHorizontal="10dp"
+        android:textOff="@string/log_view_button_scroll_off"
+        android:textOn="@string/log_view_button_scroll_on"
+        app:layout_constraintBottom_toBottomOf="@+id/top_log_view"
+        app:layout_constraintEnd_toStartOf="@+id/content_log_toggle_log"
+        app:layout_constraintTop_toTopOf="parent"/>
+
     <ToggleButton
         android:id="@+id/content_log_toggle_log"
         android:layout_width="wrap_content"
         android:layout_height="0dp"
         android:layout_marginHorizontal="10dp"
+        android:textOff="@string/log_view_button_output_off"
+        android:textOn="@string/log_view_button_output_on"
         app:layout_constraintBottom_toBottomOf="@+id/top_log_view"
         app:layout_constraintEnd_toStartOf="@+id/log_view_cancel"
         app:layout_constraintTop_toTopOf="parent" />
@@ -41,7 +54,7 @@
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
 
-    <ScrollView
+    <com.kdt.DefocusableScrollView
         android:id="@+id/content_log_scroll"
         android:layout_width="match_parent"
         android:layout_height="0dp"
@@ -56,6 +69,6 @@
             android:layout_height="wrap_content"
             android:textIsSelectable="true"/>
 
-    </ScrollView>
+    </com.kdt.DefocusableScrollView>
 
 </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/app_pojavlauncher/src/main/res/values/strings.xml b/app_pojavlauncher/src/main/res/values/strings.xml
index daeaf5fc71..beba6b88c2 100644
--- a/app_pojavlauncher/src/main/res/values/strings.xml
+++ b/app_pojavlauncher/src/main/res/values/strings.xml
@@ -376,4 +376,9 @@
     <string name="cropper_lock_horizontal">H. lock</string>
     <string name="cropper_reset">Reset</string>
     <string name="cropper_select_cancelled">Selection cancelled</string>
+    <string name="log_view_button_scroll_off">Autoscroll\nOFF</string>
+    <string name="log_view_button_scroll_on">Autoscroll\nON</string>
+    <string name="log_view_button_output_off">Output\nOFF</string>
+    <string name="log_view_button_output_on">Output\nON</string>
+    <string name="log_view_label_log_output">Log output:</string>
 </resources>


Test patch: