mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-09 03:54:17 +08:00
Added: Add TextIOActivity and TextIOInfo
The `TextIOActivity` can be used to edit or view text based on various config options defined by `TextIOInfo` and supports `monospace` font and horizontal scrolling for editing scripts, etc. Current max text limit is `95KB`, which can be increased in future.
This commit is contained in:
93
termux-shared/src/main/res/layout/activity_text_io.xml
Normal file
93
termux-shared/src/main/res/layout/activity_text_io.xml
Normal file
@@ -0,0 +1,93 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
layout="@layout/partial_toolbar"
|
||||
android:id="@+id/partial_toolbar"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_io_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/content_padding"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@android:color/black"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<View
|
||||
android:id="@+id/text_io_label_separator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginHorizontal="@dimen/content_padding"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:visibility="invisible" />
|
||||
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- id must be assigned to scroll views to restore scroll position automatically on activity resume -->
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/text_io_nested_scroll_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:padding="@dimen/content_padding_half"
|
||||
android:fillViewport="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/text_io_text_character_usage"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/text_io_horizontal_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/text_io_text_linear_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/text_io_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="start|top"
|
||||
android:inputType="textMultiLine"
|
||||
android:importantForAutofill="no"
|
||||
tools:ignore="LabelFor" />
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_io_text_character_usage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingEnd="@dimen/content_padding_half"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:gravity="end|center_vertical"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
20
termux-shared/src/main/res/menu/menu_text_io.xml
Normal file
20
termux-shared/src/main/res/menu/menu_text_io.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_item_cancel"
|
||||
android:title="@string/action_cancel"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/menu_item_share_text"
|
||||
android:icon="@drawable/ic_share"
|
||||
android:title="@string/action_share"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/menu_item_copy_text"
|
||||
android:icon="@drawable/ic_copy"
|
||||
android:title="@string/action_copy"
|
||||
app:showAsAction="never" />
|
||||
|
||||
</menu>
|
@@ -33,9 +33,6 @@
|
||||
|
||||
|
||||
<!-- ReportActivity -->
|
||||
<string name="action_copy">Copy</string>
|
||||
<string name="action_share">Share</string>
|
||||
<string name="action_save_to_file">Save To File</string>
|
||||
<string name="title_report_text">Report Text</string>
|
||||
<string name="msg_report_truncated">**Report Truncated**\n\nReport is too large to view here.
|
||||
Use `Save To File` option from options menu (3-dots on top right) and view it in an external text editor app.\n\n##\n\n</string>
|
||||
@@ -87,6 +84,10 @@
|
||||
<!-- Miscellaneous -->
|
||||
<string name="action_yes">Yes</string>
|
||||
<string name="action_no">No</string>
|
||||
<string name="action_copy">Copy</string>
|
||||
<string name="action_share">Share</string>
|
||||
<string name="action_cancel">Cancel</string>
|
||||
<string name="action_save_to_file">Save To File</string>
|
||||
|
||||
|
||||
|
||||
|
@@ -4,6 +4,10 @@
|
||||
<item name="colorPrimaryDark">#FF0000</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.AppCompat.TermuxTextIOActivity" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimaryDark">#FF0000</item>
|
||||
</style>
|
||||
|
||||
<style name="Toolbar.Title" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user