[app] Allow automatic line feed of log text (#1333)
This commit is contained in:
parent
67fd7ca054
commit
b4a37ab4da
|
|
@ -24,6 +24,7 @@ import static org.lsposed.manager.App.TAG;
|
|||
import static java.lang.Math.max;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
|
@ -31,6 +32,7 @@ import android.os.Looper;
|
|||
import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -80,6 +82,7 @@ public class LogsFragment extends BaseFragment {
|
|||
private final Handler handler = new Handler(Looper.getMainLooper());
|
||||
private FragmentLogsBinding binding;
|
||||
private LinearLayoutManager layoutManager;
|
||||
private final SharedPreferences preferences = App.getPreferences();
|
||||
private final ActivityResultLauncher<String> saveLogsLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.CreateDocument(),
|
||||
uri -> {
|
||||
|
|
@ -163,10 +166,21 @@ public class LogsFragment extends BaseFragment {
|
|||
} else if (itemId == R.id.menu_clear) {
|
||||
clear();
|
||||
return true;
|
||||
} else if (itemId == R.id.item_word_wrap) {
|
||||
item.setChecked(!item.isChecked());
|
||||
preferences.edit().putBoolean("enable_word_wrap", item.isChecked()).apply();
|
||||
reloadLogs();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(@NonNull Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
menu.findItem(R.id.item_word_wrap).setChecked(preferences.getBoolean("enable_word_wrap", false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
|
@ -299,7 +313,7 @@ public class LogsFragment extends BaseFragment {
|
|||
TextView view = holder.textView;
|
||||
view.setText(logs.get(position));
|
||||
view.measure(0, 0);
|
||||
int desiredWidth = view.getMeasuredWidth();
|
||||
int desiredWidth = (preferences.getBoolean("enable_word_wrap", false)) ? binding.getRoot().getWidth() : view.getMeasuredWidth();
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
layoutParams.width = desiredWidth;
|
||||
if (binding.recyclerView.getWidth() < desiredWidth) {
|
||||
|
|
|
|||
|
|
@ -18,33 +18,37 @@
|
|||
~ Copyright (C) 2021 LSPosed Contributors
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/menu_save"
|
||||
android:icon="@drawable/ic_save"
|
||||
android:title="@string/menuSaveToSd"
|
||||
app:showAsAction="ifRoom" />
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/menuSaveToSd" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_refresh"
|
||||
android:icon="@drawable/ic_refresh"
|
||||
android:title="@string/menuReload"
|
||||
app:showAsAction="ifRoom" />
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/menuReload" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_scroll_top"
|
||||
android:title="@string/scroll_top"
|
||||
app:showAsAction="never" />
|
||||
android:showAsAction="never"
|
||||
android:title="@string/scroll_top" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_scroll_down"
|
||||
android:title="@string/scroll_bottom"
|
||||
app:showAsAction="never" />
|
||||
android:showAsAction="never"
|
||||
android:title="@string/scroll_bottom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_clear"
|
||||
android:title="@string/menuClearLog"
|
||||
app:showAsAction="never" />
|
||||
android:showAsAction="never"
|
||||
android:title="@string/menuClearLog" />
|
||||
<item
|
||||
android:id="@+id/item_word_wrap"
|
||||
android:checkable="true"
|
||||
android:checked="false"
|
||||
android:title="@string/menu_enable_word_wrap" />
|
||||
|
||||
</menu>
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@
|
|||
<string name="logs_cannot_read">无法读取日志: \n</string>
|
||||
<string name="menuReload">重新加载</string>
|
||||
<string name="logs_clear_failed_2">日志清除失败</string>
|
||||
<string name="menu_enable_word_wrap">自动换行</string>
|
||||
<!-- Notification -->
|
||||
<string name="module_is_not_activated_yet">Xposed 模块尚未激活</string>
|
||||
<string name="module_is_not_activated_yet_detailed">%s 已安装, 但尚未激活</string>
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
<string name="logs_cannot_read">Cannot read log: \n</string>
|
||||
<string name="menuReload">Reload</string>
|
||||
<string name="logs_clear_failed_2">Failed to clear the log</string>
|
||||
<string name="menu_enable_word_wrap">Word Wrap</string>
|
||||
|
||||
<!-- Notification -->
|
||||
<string name="module_is_not_activated_yet">Xposed module is not activated yet</string>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<androidx.preference.PreferenceCategory android:title="@string/group_network">
|
||||
<PreferenceCategory android:title="@string/group_network">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
|
|
@ -27,9 +27,9 @@
|
|||
android:key="doh"
|
||||
android:summary="@string/dns_over_http_summary"
|
||||
android:title="@string/dns_over_http" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory android:title="@string/settings_language">
|
||||
<PreferenceCategory android:title="@string/settings_language">
|
||||
|
||||
<rikka.preference.SimpleMenuPreference
|
||||
android:defaultValue="SYSTEM"
|
||||
|
|
@ -47,9 +47,9 @@
|
|||
<Preference
|
||||
android:key="translation"
|
||||
android:title="@string/settings_translation" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory android:title="@string/settings_group_theme">
|
||||
<PreferenceCategory android:title="@string/settings_group_theme">
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="follow_system_accent"
|
||||
|
|
@ -75,9 +75,9 @@
|
|||
android:key="black_dark_theme"
|
||||
android:summary="@string/pure_black_dark_theme_summary"
|
||||
android:title="@string/pure_black_dark_theme" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory android:title="@string/settings_group_framework">
|
||||
<PreferenceCategory android:title="@string/settings_group_framework">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
|
|
@ -99,9 +99,9 @@
|
|||
android:persistent="false"
|
||||
android:summary="@string/settings_enable_auto_add_shortcut_summary"
|
||||
android:title="@string/pref_title_enable_auto_add_shortcut" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory android:title="@string/settings_group_repo">
|
||||
<PreferenceCategory android:title="@string/settings_group_repo">
|
||||
<rikka.preference.SimpleMenuPreference
|
||||
android:defaultValue="CHANNEL_STABLE"
|
||||
android:entries="@array/update_channel_texts"
|
||||
|
|
@ -109,9 +109,9 @@
|
|||
android:key="update_channel"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_update_channel" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory
|
||||
<PreferenceCategory
|
||||
android:icon="@drawable/ic_baseline_settings_backup_restore_24"
|
||||
android:summary="@string/settings_backup_and_restore_summery"
|
||||
android:title="@string/settings_backup_and_restore">
|
||||
|
|
@ -121,9 +121,9 @@
|
|||
<Preference
|
||||
android:key="restore"
|
||||
android:title="@string/settings_restore" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory
|
||||
<PreferenceCategory
|
||||
android:key="settings_group_system"
|
||||
android:title="@string/settings_group_system">
|
||||
<SwitchPreference
|
||||
|
|
@ -133,5 +133,5 @@
|
|||
android:persistent="false"
|
||||
android:summary="@string/settings_show_hidden_icon_apps_enabled_summary"
|
||||
android:title="@string/settings_show_hidden_icon_apps_enabled" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<androidx.preference.PreferenceCategory android:title="@string/group_network">
|
||||
<PreferenceCategory android:title="@string/group_network">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
|
|
@ -28,9 +28,9 @@
|
|||
android:key="doh"
|
||||
android:summary="@string/dns_over_http_summary"
|
||||
android:title="@string/dns_over_http" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory android:title="@string/settings_language">
|
||||
<PreferenceCategory android:title="@string/settings_language">
|
||||
|
||||
<rikka.preference.SimpleMenuPreference
|
||||
android:defaultValue="SYSTEM"
|
||||
|
|
@ -48,9 +48,9 @@
|
|||
<Preference
|
||||
android:key="translation"
|
||||
android:title="@string/settings_translation" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory android:title="@string/settings_group_theme">
|
||||
<PreferenceCategory android:title="@string/settings_group_theme">
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="follow_system_accent"
|
||||
|
|
@ -76,9 +76,9 @@
|
|||
android:key="black_dark_theme"
|
||||
android:summary="@string/pure_black_dark_theme_summary"
|
||||
android:title="@string/pure_black_dark_theme" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory android:title="@string/settings_group_framework">
|
||||
<PreferenceCategory android:title="@string/settings_group_framework">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
|
|
@ -100,9 +100,9 @@
|
|||
android:persistent="false"
|
||||
android:summary="@string/settings_enable_auto_add_shortcut_summary"
|
||||
android:title="@string/pref_title_enable_auto_add_shortcut" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory android:title="@string/settings_group_repo">
|
||||
<PreferenceCategory android:title="@string/settings_group_repo">
|
||||
<rikka.preference.SimpleMenuPreference
|
||||
android:defaultValue="CHANNEL_STABLE"
|
||||
android:entries="@array/update_channel_texts"
|
||||
|
|
@ -110,9 +110,9 @@
|
|||
android:key="update_channel"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_update_channel" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.PreferenceCategory
|
||||
<PreferenceCategory
|
||||
android:icon="@drawable/ic_baseline_settings_backup_restore_24"
|
||||
android:summary="@string/settings_backup_and_restore_summery"
|
||||
android:title="@string/settings_backup_and_restore">
|
||||
|
|
@ -122,5 +122,5 @@
|
|||
<Preference
|
||||
android:key="restore"
|
||||
android:title="@string/settings_restore" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
|||
Loading…
Reference in New Issue