mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Moved Termux app settings into dedicated "directory" in Termux Settings and added About page
The `TermuxConstants` class has been updated to `v0.20.0`. Check its Changelog sections for info on changes.
This commit is contained in:
@@ -92,8 +92,8 @@ public class ReportActivity extends AppCompatActivity {
|
||||
|
||||
final Markwon markwon = MarkdownUtils.getRecyclerMarkwonBuilder(this);
|
||||
|
||||
final MarkwonAdapter adapter = MarkwonAdapter.builderTextViewIsRoot(R.layout.activity_report_adapter_node_default)
|
||||
.include(FencedCodeBlock.class, SimpleEntry.create(R.layout.activity_report_adapter_node_code_block, R.id.code_text_view))
|
||||
final MarkwonAdapter adapter = MarkwonAdapter.builderTextViewIsRoot(R.layout.markdown_adapter_node_default)
|
||||
.include(FencedCodeBlock.class, SimpleEntry.create(R.layout.markdown_adapter_node_code_block, R.id.code_text_view))
|
||||
.build();
|
||||
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
@@ -1,12 +1,18 @@
|
||||
package com.termux.app.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.termux.R;
|
||||
import com.termux.app.models.ReportInfo;
|
||||
import com.termux.app.models.UserAction;
|
||||
import com.termux.shared.termux.TermuxConstants;
|
||||
import com.termux.shared.termux.TermuxUtils;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
@@ -37,6 +43,32 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
setPreferencesFromResource(R.xml.root_preferences, rootKey);
|
||||
|
||||
setAboutOnPreferenceClickListener();
|
||||
}
|
||||
|
||||
private void setAboutOnPreferenceClickListener() {
|
||||
Context context = getContext();
|
||||
Preference about = findPreference("about");
|
||||
if (context != null && about != null) {
|
||||
about.setOnPreferenceClickListener(preference -> {
|
||||
String title = "About";
|
||||
|
||||
StringBuilder aboutString = new StringBuilder();
|
||||
aboutString.append(TermuxUtils.getAppInfoMarkdownString(context, false));
|
||||
|
||||
String termuxPluginAppsInfo = TermuxUtils.getTermuxPluginAppsInfoMarkdownString(context);
|
||||
if (termuxPluginAppsInfo != null)
|
||||
aboutString.append("\n\n").append(termuxPluginAppsInfo);
|
||||
|
||||
aboutString.append("\n\n").append(TermuxUtils.getDeviceInfoMarkdownString(context));
|
||||
aboutString.append("\n\n").append(TermuxUtils.getImportantLinksMarkdownString(context));
|
||||
|
||||
ReportActivity.startReportActivity(context, new ReportInfo(UserAction.ABOUT, TermuxConstants.TERMUX_APP.TERMUX_SETTINGS_ACTIVITY_NAME, title, null, aboutString.toString(), null, false));
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,46 @@
|
||||
package com.termux.app.fragments.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.preference.PreferenceDataStore;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.termux.R;
|
||||
import com.termux.shared.settings.preferences.TermuxAppSharedPreferences;
|
||||
|
||||
@Keep
|
||||
public class TermuxPreferencesFragment extends PreferenceFragmentCompat {
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
PreferenceManager preferenceManager = getPreferenceManager();
|
||||
preferenceManager.setPreferenceDataStore(TermuxPreferencesDataStore.getInstance(getContext()));
|
||||
|
||||
setPreferencesFromResource(R.xml.termux_preferences, rootKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TermuxPreferencesDataStore extends PreferenceDataStore {
|
||||
|
||||
private final Context mContext;
|
||||
private final TermuxAppSharedPreferences mPreferences;
|
||||
|
||||
private static TermuxPreferencesDataStore mInstance;
|
||||
|
||||
private TermuxPreferencesDataStore(Context context) {
|
||||
mContext = context;
|
||||
mPreferences = new TermuxAppSharedPreferences(context);
|
||||
}
|
||||
|
||||
public static synchronized TermuxPreferencesDataStore getInstance(Context context) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new TermuxPreferencesDataStore(context.getApplicationContext());
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.termux.app.fragments.settings;
|
||||
package com.termux.app.fragments.settings.termux;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -23,7 +23,7 @@ public class DebuggingPreferencesFragment extends PreferenceFragmentCompat {
|
||||
PreferenceManager preferenceManager = getPreferenceManager();
|
||||
preferenceManager.setPreferenceDataStore(DebuggingPreferencesDataStore.getInstance(getContext()));
|
||||
|
||||
setPreferencesFromResource(R.xml.debugging_preferences, rootKey);
|
||||
setPreferencesFromResource(R.xml.termux_debugging_preferences, rootKey);
|
||||
|
||||
PreferenceCategory loggingCategory = findPreference("logging");
|
||||
|
||||
@@ -125,11 +125,11 @@ class DebuggingPreferencesDataStore extends PreferenceDataStore {
|
||||
public boolean getBoolean(String key, boolean defValue) {
|
||||
switch (key) {
|
||||
case "terminal_view_key_logging_enabled":
|
||||
return mPreferences.getTerminalViewKeyLoggingEnabled();
|
||||
return mPreferences.isTerminalViewKeyLoggingEnabled();
|
||||
case "plugin_error_notifications_enabled":
|
||||
return mPreferences.getPluginErrorNotificationsEnabled();
|
||||
return mPreferences.arePluginErrorNotificationsEnabled();
|
||||
case "crash_report_notifications_enabled":
|
||||
return mPreferences.getCrashReportNotificationsEnabled();
|
||||
return mPreferences.areCrashReportNotificationsEnabled();
|
||||
default:
|
||||
return false;
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.termux.app.fragments.settings;
|
||||
package com.termux.app.fragments.settings.termux;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -19,7 +19,7 @@ public class TerminalIOPreferencesFragment extends PreferenceFragmentCompat {
|
||||
PreferenceManager preferenceManager = getPreferenceManager();
|
||||
preferenceManager.setPreferenceDataStore(TerminalIOPreferencesDataStore.getInstance(getContext()));
|
||||
|
||||
setPreferencesFromResource(R.xml.terminal_io_preferences, rootKey);
|
||||
setPreferencesFromResource(R.xml.termux_terminal_io_preferences, rootKey);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -65,9 +65,9 @@ class TerminalIOPreferencesDataStore extends PreferenceDataStore {
|
||||
public boolean getBoolean(String key, boolean defValue) {
|
||||
switch (key) {
|
||||
case "soft_keyboard_enabled":
|
||||
return mPreferences.getSoftKeyboardEnabled();
|
||||
return mPreferences.isSoftKeyboardEnabled();
|
||||
case "soft_keyboard_enabled_only_if_no_hardware":
|
||||
return mPreferences.getSoftKeyboardEnabledOnlyIfNoHardware();
|
||||
return mPreferences.isSoftKeyboardEnabledOnlyIfNoHardware();
|
||||
default:
|
||||
return false;
|
||||
}
|
@@ -2,8 +2,9 @@ package com.termux.app.models;
|
||||
|
||||
public enum UserAction {
|
||||
|
||||
PLUGIN_EXECUTION_COMMAND("plugin execution command"),
|
||||
ABOUT("about"),
|
||||
CRASH_REPORT("crash report"),
|
||||
PLUGIN_EXECUTION_COMMAND("plugin execution command"),
|
||||
REPORT_ISSUE_FROM_TRANSCRIPT("report issue from transcript");
|
||||
|
||||
private final String name;
|
||||
|
20
app/src/main/res/layout/preference_markdown_text.xml
Normal file
20
app/src/main/res/layout/preference_markdown_text.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-appcompat-release/preference/preference/res/layout/preference.xml
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
|
||||
<include android:id="@android:id/summary" layout="@layout/markdown_adapter_node_default" />
|
||||
|
||||
</LinearLayout>
|
@@ -122,42 +122,55 @@
|
||||
<!-- Termux Settings -->
|
||||
<string name="title_activity_termux_settings">&TERMUX_APP_NAME; Settings</string>
|
||||
|
||||
<!-- Termux App Preferences -->
|
||||
<string name="termux_preferences_title">&TERMUX_APP_NAME;</string>
|
||||
<string name="termux_preferences_summary">Preferences for &TERMUX_APP_NAME; app</string>
|
||||
|
||||
<!-- Debugging Preferences -->
|
||||
<string name="debugging_preferences">Debugging</string>
|
||||
<string name="termux_debugging_preferences_title">Debugging</string>
|
||||
<string name="termux_debugging_preferences_summary">Preferences for debugging</string>
|
||||
|
||||
<!-- Logging Category -->
|
||||
<string name="logging_header">Logging</string>
|
||||
<string name="termux_logging_header">Logging</string>
|
||||
|
||||
<!-- Log Level -->
|
||||
<string name="termux_log_level_title">Log Level</string>
|
||||
|
||||
<!-- Terminal View Key Logging -->
|
||||
<string name="terminal_view_key_logging_title">Terminal View Key Logging</string>
|
||||
<string name="terminal_view_key_logging_off">Logs will not have entries for terminal view keys. (Default)</string>
|
||||
<string name="terminal_view_key_logging_on">Logcat logs will have entries for terminal view keys. These are very verbose and should be disabled under normal circumstances or will cause performance issues.</string>
|
||||
<string name="termux_terminal_view_key_logging_enabled_title">Terminal View Key Logging</string>
|
||||
<string name="termux_terminal_view_key_logging_enabled_off">Logs will not have entries for terminal view keys. (Default)</string>
|
||||
<string name="termux_terminal_view_key_logging_enabled_on">Logcat logs will have entries for terminal view keys. These are very verbose and should be disabled under normal circumstances or will cause performance issues.</string>
|
||||
|
||||
<!-- Plugin Error Notifications -->
|
||||
<string name="plugin_error_notifications_title">Plugin Error Notifications</string>
|
||||
<string name="plugin_error_notifications_off">Disable flashes and notifications for plugin errors.</string>
|
||||
<string name="plugin_error_notifications_on">Show flashes and notifications for plugin errors. (Default)</string>
|
||||
<string name="termux_plugin_error_notifications_enabled_title">Plugin Error Notifications</string>
|
||||
<string name="termux_plugin_error_notifications_enabled_off">Disable flashes and notifications for plugin errors.</string>
|
||||
<string name="termux_plugin_error_notifications_enabled_on">Show flashes and notifications for plugin errors. (Default)</string>
|
||||
|
||||
<!-- Crash Report Notifications -->
|
||||
<string name="crash_report_notifications_title">Crash Report Notifications</string>
|
||||
<string name="crash_report_notifications_off">Disable notifications for crash reports.</string>
|
||||
<string name="crash_report_notifications_on">Show notifications for crash reports. (Default)</string>
|
||||
<string name="termux_crash_report_notifications_enabled_title">Crash Report Notifications</string>
|
||||
<string name="termux_crash_report_notifications_enabled_off">Disable notifications for crash reports.</string>
|
||||
<string name="termux_crash_report_notifications_enabled_on">Show notifications for crash reports. (Default)</string>
|
||||
|
||||
|
||||
<!-- Terminal IO Preferences -->
|
||||
<string name="terminal_io_preferences">Terminal I/O</string>
|
||||
<string name="termux_terminal_io_preferences_title">Terminal I/O</string>
|
||||
<string name="termux_terminal_io_preferences_summary">Preferences for terminal I/O</string>
|
||||
|
||||
<!-- Keyboard Category -->
|
||||
<string name="keyboard_header">Keyboard</string>
|
||||
<string name="termux_keyboard_header">Keyboard</string>
|
||||
|
||||
<!-- Soft Keyboard -->
|
||||
<string name="soft_keyboard_title">Soft Keyboard Enabled</string>
|
||||
<string name="soft_keyboard_off">Soft keyboard will be disabled.</string>
|
||||
<string name="soft_keyboard_on">Soft keyboard will be enabled. (Default)</string>
|
||||
<string name="termux_soft_keyboard_enabled_title">Soft Keyboard Enabled</string>
|
||||
<string name="termux_soft_keyboard_enabled_off">Soft keyboard will be disabled.</string>
|
||||
<string name="termux_soft_keyboard_enabled_on">Soft keyboard will be enabled. (Default)</string>
|
||||
|
||||
<!-- Soft Keyboard Only If No Hardware-->
|
||||
<string name="soft_keyboard_enabled_only_if_no_hardware_title">Soft Keyboard If No Hardware</string>
|
||||
<string name="soft_keyboard_enabled_only_if_no_hardware_off">Soft keyboard will be enabled even if hardware keyboard is connected. (Default)</string>
|
||||
<string name="soft_keyboard_enabled_only_if_no_hardware_on">Soft keyboard will be enabled only if no hardware keyboard is connected.</string>
|
||||
<string name="termux_soft_keyboard_enabled_only_if_no_hardware_title">Soft Keyboard Only If No Hardware</string>
|
||||
<string name="termux_soft_keyboard_enabled_only_if_no_hardware_off">Soft keyboard will be enabled even if hardware keyboard is connected. (Default)</string>
|
||||
<string name="termux_soft_keyboard_enabled_only_if_no_hardware_on">Soft keyboard will be enabled only if no hardware keyboard is connected.</string>
|
||||
|
||||
|
||||
<!-- About Preferences -->
|
||||
<string name="about_preferences_title">About</string>
|
||||
|
||||
</resources>
|
||||
|
@@ -1,33 +0,0 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory
|
||||
app:key="logging"
|
||||
app:title="@string/logging_header">
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="1"
|
||||
app:key="log_level"
|
||||
app:title="@string/log_level_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="terminal_view_key_logging_enabled"
|
||||
app:summaryOff="@string/terminal_view_key_logging_off"
|
||||
app:summaryOn="@string/terminal_view_key_logging_on"
|
||||
app:title="@string/terminal_view_key_logging_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="plugin_error_notifications_enabled"
|
||||
app:summaryOff="@string/plugin_error_notifications_off"
|
||||
app:summaryOn="@string/plugin_error_notifications_on"
|
||||
app:title="@string/plugin_error_notifications_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="crash_report_notifications_enabled"
|
||||
app:summaryOff="@string/crash_report_notifications_off"
|
||||
app:summaryOn="@string/crash_report_notifications_on"
|
||||
app:title="@string/crash_report_notifications_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@@ -1,13 +1,15 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Preference
|
||||
app:title="@string/debugging_preferences"
|
||||
app:summary="Preferences for debugging"
|
||||
app:fragment="com.termux.app.fragments.settings.DebuggingPreferencesFragment"/>
|
||||
app:key="termux"
|
||||
app:title="@string/termux_preferences_title"
|
||||
app:summary="@string/termux_preferences_summary"
|
||||
app:fragment="com.termux.app.fragments.settings.TermuxPreferencesFragment"/>
|
||||
|
||||
<Preference
|
||||
app:title="@string/terminal_io_preferences"
|
||||
app:summary="Preferences for terminal I/O"
|
||||
app:fragment="com.termux.app.fragments.settings.TerminalIOPreferencesFragment"/>
|
||||
app:key="about"
|
||||
app:title="@string/about_preferences_title"
|
||||
app:persistent="false"/>
|
||||
<!-- app:layout="@layout/preference_markdown_text" -->
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -1,21 +0,0 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory
|
||||
app:key="keyboard"
|
||||
app:title="@string/keyboard_header">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="soft_keyboard_enabled"
|
||||
app:summaryOff="@string/soft_keyboard_off"
|
||||
app:summaryOn="@string/soft_keyboard_on"
|
||||
app:title="@string/soft_keyboard_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="soft_keyboard_enabled_only_if_no_hardware"
|
||||
app:summaryOff="@string/soft_keyboard_enabled_only_if_no_hardware_off"
|
||||
app:summaryOn="@string/soft_keyboard_enabled_only_if_no_hardware_on"
|
||||
app:title="@string/soft_keyboard_enabled_only_if_no_hardware_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
33
app/src/main/res/xml/termux_debugging_preferences.xml
Normal file
33
app/src/main/res/xml/termux_debugging_preferences.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory
|
||||
app:key="logging"
|
||||
app:title="@string/termux_logging_header">
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="1"
|
||||
app:key="log_level"
|
||||
app:title="@string/termux_log_level_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="terminal_view_key_logging_enabled"
|
||||
app:summaryOff="@string/termux_terminal_view_key_logging_enabled_off"
|
||||
app:summaryOn="@string/termux_terminal_view_key_logging_enabled_on"
|
||||
app:title="@string/termux_terminal_view_key_logging_enabled_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="plugin_error_notifications_enabled"
|
||||
app:summaryOff="@string/termux_plugin_error_notifications_enabled_off"
|
||||
app:summaryOn="@string/termux_plugin_error_notifications_enabled_on"
|
||||
app:title="@string/termux_plugin_error_notifications_enabled_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="crash_report_notifications_enabled"
|
||||
app:summaryOff="@string/termux_crash_report_notifications_enabled_off"
|
||||
app:summaryOn="@string/termux_crash_report_notifications_enabled_on"
|
||||
app:title="@string/termux_crash_report_notifications_enabled_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
13
app/src/main/res/xml/termux_preferences.xml
Normal file
13
app/src/main/res/xml/termux_preferences.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Preference
|
||||
app:title="@string/termux_debugging_preferences_title"
|
||||
app:summary="@string/termux_debugging_preferences_summary"
|
||||
app:fragment="com.termux.app.fragments.settings.termux.DebuggingPreferencesFragment"/>
|
||||
|
||||
<Preference
|
||||
app:title="@string/termux_terminal_io_preferences_title"
|
||||
app:summary="@string/termux_terminal_io_preferences_summary"
|
||||
app:fragment="com.termux.app.fragments.settings.termux.TerminalIOPreferencesFragment"/>
|
||||
|
||||
</PreferenceScreen>
|
21
app/src/main/res/xml/termux_terminal_io_preferences.xml
Normal file
21
app/src/main/res/xml/termux_terminal_io_preferences.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory
|
||||
app:key="keyboard"
|
||||
app:title="@string/termux_keyboard_header">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="soft_keyboard_enabled"
|
||||
app:summaryOff="@string/termux_soft_keyboard_enabled_off"
|
||||
app:summaryOn="@string/termux_soft_keyboard_enabled_on"
|
||||
app:title="@string/termux_soft_keyboard_enabled_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="soft_keyboard_enabled_only_if_no_hardware"
|
||||
app:summaryOff="@string/termux_soft_keyboard_enabled_only_if_no_hardware_off"
|
||||
app:summaryOn="@string/termux_soft_keyboard_enabled_only_if_no_hardware_on"
|
||||
app:title="@string/termux_soft_keyboard_enabled_only_if_no_hardware_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@@ -179,7 +179,7 @@ public class MarkdownUtils {
|
||||
.setFactory(Code.class, (configuration, props) -> new Object[]{
|
||||
new BackgroundColorSpan(ContextCompat.getColor(context, R.color.background_markdown_code_inline)),
|
||||
new TypefaceSpan("monospace"),
|
||||
new AbsoluteSizeSpan(8)
|
||||
new AbsoluteSizeSpan(48)
|
||||
})
|
||||
// NB! both ordered and bullet list items
|
||||
.setFactory(ListItem.class, (configuration, props) -> new BulletSpan());
|
||||
|
@@ -3,9 +3,11 @@ package com.termux.shared.termux;
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Version: v0.19.0
|
||||
* Version: v0.20.0
|
||||
*
|
||||
* Changelog
|
||||
*
|
||||
@@ -135,6 +137,11 @@ import java.io.File;
|
||||
* - Added `TERMUX_SERVICE.EXTRA_STDIN`.
|
||||
* - Added `RUN_COMMAND_SERVICE.EXTRA_STDIN`.
|
||||
* - Deprecated `TERMUX_ACTIVITY.EXTRA_RELOAD_STYLE`.
|
||||
*
|
||||
* - 0.20.0 (2021-05-13)
|
||||
* - Added `TERMUX_WIKI`, `TERMUX_WIKI_URL`, `TERMUX_PLUGIN_APP_NAMES_LIST`, `TERMUX_PLUGIN_APP_PACKAGE_NAMES_LIST`.
|
||||
* - Added `TERMUX_SETTINGS_ACTIVITY_NAME`.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -194,6 +201,12 @@ public final class TermuxConstants {
|
||||
/** Termux support email mailto url */
|
||||
public static final String TERMUX_SUPPORT_EMAIL_MAILTO_URL = "mailto:" + TERMUX_SUPPORT_EMAIL_URL; // Default: "mailto:termuxreports@groups.io"
|
||||
|
||||
/** Termux Wiki */
|
||||
public static final String TERMUX_WIKI = "Termux Wiki"; // Default: "Termux Wiki"
|
||||
|
||||
/** Termux Wiki url */
|
||||
public static final String TERMUX_WIKI_URL = "https://wiki.termux.com"; // Default: "https://wiki.termux.com"
|
||||
|
||||
/** Termux Reddit subreddit */
|
||||
public static final String TERMUX_REDDIT_SUBREDDIT = "r/termux"; // Default: "r/termux"
|
||||
|
||||
@@ -314,6 +327,30 @@ public final class TermuxConstants {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Termux plugin apps lists.
|
||||
*/
|
||||
|
||||
public static final List<String> TERMUX_PLUGIN_APP_NAMES_LIST = Arrays.asList(
|
||||
TERMUX_API_APP_NAME,
|
||||
TERMUX_BOOT_APP_NAME,
|
||||
TERMUX_FLOAT_APP_NAME,
|
||||
TERMUX_STYLING_APP_NAME,
|
||||
TERMUX_TASKER_APP_NAME,
|
||||
TERMUX_WIDGET_APP_NAME);
|
||||
|
||||
public static final List<String> TERMUX_PLUGIN_APP_PACKAGE_NAMES_LIST = Arrays.asList(
|
||||
TERMUX_API_PACKAGE_NAME,
|
||||
TERMUX_BOOT_PACKAGE_NAME,
|
||||
TERMUX_FLOAT_PACKAGE_NAME,
|
||||
TERMUX_STYLING_PACKAGE_NAME,
|
||||
TERMUX_TASKER_PACKAGE_NAME,
|
||||
TERMUX_WIDGET_PACKAGE_NAME);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Termux packages urls.
|
||||
*/
|
||||
@@ -654,6 +691,13 @@ public final class TermuxConstants {
|
||||
|
||||
|
||||
|
||||
/** Termux app settings activity name. */
|
||||
public static final String TERMUX_SETTINGS_ACTIVITY_NAME = TERMUX_PACKAGE_NAME + ".app.activities.SettingsActivity"; // Default: "com.termux.app.activities.SettingsActivity"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Termux app core service name. */
|
||||
public static final String TERMUX_SERVICE_NAME = TERMUX_PACKAGE_NAME + ".app.TermuxService"; // Default: "com.termux.app.TermuxService"
|
||||
|
||||
|
@@ -132,6 +132,38 @@ public class TermuxUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a markdown {@link String} for the apps info of all/any termux plugin apps installed.
|
||||
*
|
||||
* @param currentPackageContext The context of current package.
|
||||
* @return Returns the markdown {@link String}.
|
||||
*/
|
||||
public static String getTermuxPluginAppsInfoMarkdownString(@NonNull final Context currentPackageContext) {
|
||||
if (currentPackageContext == null) return "null";
|
||||
|
||||
StringBuilder markdownString = new StringBuilder();
|
||||
|
||||
List<String> termuxPluginAppPackageNamesList = TermuxConstants.TERMUX_PLUGIN_APP_PACKAGE_NAMES_LIST;
|
||||
|
||||
if (termuxPluginAppPackageNamesList != null) {
|
||||
for (int i = 0; i < termuxPluginAppPackageNamesList.size(); i++) {
|
||||
String termuxPluginAppPackageName = termuxPluginAppPackageNamesList.get(i);
|
||||
Context termuxPluginAppContext = PackageUtils.getContextForPackage(currentPackageContext, termuxPluginAppPackageName);
|
||||
// If the package context for the plugin app is not null, then assume its installed and get its info
|
||||
if (termuxPluginAppContext != null) {
|
||||
if (i != 0)
|
||||
markdownString.append("\n\n");
|
||||
markdownString.append(TermuxUtils.getAppInfoMarkdownString(termuxPluginAppContext, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (markdownString.toString().isEmpty())
|
||||
return null;
|
||||
|
||||
return markdownString.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a markdown {@link String} for the app info. If the {@code context} passed is different
|
||||
* from the {@link TermuxConstants#TERMUX_PACKAGE_NAME} package context, then this function
|
||||
@@ -291,6 +323,45 @@ public class TermuxUtils {
|
||||
return markdownString.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a markdown {@link String} for important links.
|
||||
*
|
||||
* @param context The context for operations.
|
||||
* @return Returns the markdown {@link String}.
|
||||
*/
|
||||
public static String getImportantLinksMarkdownString(@NonNull final Context context) {
|
||||
if (context == null) return "null";
|
||||
|
||||
StringBuilder markdownString = new StringBuilder();
|
||||
|
||||
markdownString.append("## Important Links");
|
||||
|
||||
markdownString.append("\n\n### Github\n");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_APP_NAME, TermuxConstants.TERMUX_GITHUB_REPO_URL)).append(" ");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_API_APP_NAME, TermuxConstants.TERMUX_API_GITHUB_REPO_URL)).append(" ");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_BOOT_APP_NAME, TermuxConstants.TERMUX_BOOT_GITHUB_REPO_URL)).append(" ");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_FLOAT_APP_NAME, TermuxConstants.TERMUX_FLOAT_GITHUB_REPO_URL)).append(" ");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_STYLING_APP_NAME, TermuxConstants.TERMUX_STYLING_GITHUB_REPO_URL)).append(" ");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_TASKER_APP_NAME, TermuxConstants.TERMUX_TASKER_GITHUB_REPO_URL)).append(" ");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_WIDGET_APP_NAME, TermuxConstants.TERMUX_WIDGET_GITHUB_REPO_URL)).append(" ");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_PACKAGES_GITHUB_REPO_NAME, TermuxConstants.TERMUX_PACKAGES_GITHUB_REPO_URL)).append(" ");
|
||||
|
||||
markdownString.append("\n\n### Email\n");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_SUPPORT_EMAIL_URL, TermuxConstants.TERMUX_SUPPORT_EMAIL_MAILTO_URL)).append(" ");
|
||||
|
||||
markdownString.append("\n\n### Reddit\n");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_REDDIT_SUBREDDIT, TermuxConstants.TERMUX_REDDIT_SUBREDDIT_URL)).append(" ");
|
||||
|
||||
markdownString.append("\n\n### Wiki\n");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_WIKI, TermuxConstants.TERMUX_WIKI_URL)).append(" ");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_APP_NAME, TermuxConstants.TERMUX_GITHUB_WIKI_REPO_URL)).append(" ");
|
||||
markdownString.append("\n").append(MarkdownUtils.getLinkMarkdownString(TermuxConstants.TERMUX_PACKAGES_GITHUB_REPO_NAME, TermuxConstants.TERMUX_PACKAGES_GITHUB_WIKI_REPO_URL)).append(" ");
|
||||
|
||||
markdownString.append("\n##\n");
|
||||
|
||||
return markdownString.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user