Commit Graph

1425 Commits

Author SHA1 Message Date
agnostic-apollo 3e518a6a75 Fixed: Fix termux-open failing to open files with "#" and remove hardcoded "content" and "file" strings
termux-open "/data/data/com.termux/files/home/te#st.sh"
2022-01-23 01:40:22 +05:00
agnostic-apollo d96883c4d6 Changed|Deprecated: Deprecate `use-black-ui` termux property and replace it with `night-mode`
This will not break existing `use-black-ui` settings for users and it will automatically be converted to `night-mode` when properties are loaded from disk but a deprecation message will be logged.

This `night-mode` key can be used to set the day/night theme variant for activities used by termux app and its plugin. The user can set a string value to `true` to force use dark variant of theme, `false` to force use light variant of theme or `system` to automatically set theme based on current system settings. The default value is still `system`. The app must be restarted for changes to take effect for existing activities, including main terminal `TermuxActivity`.

This is required since "theme != night mode". In future custom theme or color support may be provided that will have both dark and night modes for the same theme.
2022-01-23 01:40:22 +05:00
agnostic-apollo 28ecb64992 Changed: Automatically use default properties file and client for TermuxSharedProperties.getTermuxInternalPropertyValue() 2022-01-23 01:40:22 +05:00
agnostic-apollo 5d64f1225c Added: Add support in SharedProperties to modify properties loaded from disk before they are mapped to internal values 2022-01-23 01:40:22 +05:00
agnostic-apollo aed4b96a31 Added: Add FileUtils.regularOrDirectoryFileExists() 2022-01-23 01:40:22 +05:00
agnostic-apollo 5b2aca9cf7 Changed: Fix minor typos in FileUtils and FileUtilsErrno 2022-01-23 01:40:22 +05:00
agnostic-apollo 93d738ae63 Fixed: Remove all trailing slashes when normalizing path 2022-01-23 01:40:22 +05:00
agnostic-apollo f7ebcae7b3 Added: Add functions to get dirname and basename in FileUtils 2022-01-23 01:40:22 +05:00
agnostic-apollo 63c106c746 Added: Add Error.logErrorAndShowToast() and provide non-static logging functions to be used when Error may not be null 2022-01-23 01:40:22 +05:00
agnostic-apollo 2c0e9c6c5c Added: Add Logger.logInfoAndShowToast() and log messages even if not showing toast due to null Context 2022-01-23 01:40:22 +05:00
agnostic-apollo 9eeb2babd7 Added: Add support for MANAGE_EXTERNAL_STORAGE when targeting targetSdkVersion 30
Termux will now automatically request legacy `WRITE_EXTERNAL_STORAGE` or `MANAGE_EXTERNAL_STORAGE` permissions if targeting targetSdkVersion `30` (android `11`) and running on sdk `30` (android `11`) and higher when `termux-setup-storage` is run.

Functions have been added to `PermissionUtils` to automatically check and request either permission depending on app `targetSdkVersion` and android version. Functions have been added to `PackagUtils` to get `requestLegacyExternalStorage` value from app manifest if added. If legacy storage is possible, then it must be set to `true`. Check `PermissionUtils.checkAndRequestLegacyOrManageExternalStoragePermission()`, `PermissionUtils.isLegacyExternalStoragePossible()` and `PermissionUtils.checkIfHasRequestedLegacyExternalStorage()` for details.
2022-01-23 01:40:22 +05:00
agnostic-apollo 32dd7eab03 Changed|Fixed: Add java docs to PermissionUtils and fix permission checking
ContextCompat.checkSelfPermission() may return true for permissions not even requested so it now checked if permissions are even requested in app manifest before checking if they are granted and before asking for permission to be granted.

Also some general improvements in code quality, including using ActivityUtils to request non-standard permissions and added support for AppCompatActivity instances to request permissions in addition to Activity instances.
2022-01-23 01:40:22 +05:00
agnostic-apollo 50a97b1977 Added: Add ReflectionUtils and add dependency for org.lsposed.hiddenapibypass:hiddenapibypass
The call to bypassHiddenAPIReflectionRestrictions() must be made before trying to reflect hidden or non-sdk APIs.

Reflection will be used for accessing hidden (@hide) APIs by Termux and its plugins later.

https://github.com/LSPosed/AndroidHiddenApiBypass
https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces
2022-01-23 01:40:22 +05:00
agnostic-apollo f4a997b7dd Added: Add ActivityUtils with functions to start activities for result 2022-01-23 01:40:22 +05:00
agnostic-apollo 3c202928b4 Changed: Fix typos is PackageUtils 2022-01-23 01:40:22 +05:00
agnostic-apollo aca0000ee6 Update LICENSE.md as per 5252fbbe 2022-01-23 01:40:21 +05:00
agnostic-apollo 5252fbbe11 Changed!: Move Termux specific classes to com.termux.shared.termux package
This will allow segregation of Termux utils/classes from general ones and also allow easier management of GPLv3 License for Termux classes
2022-01-23 01:36:41 +05:00
agnostic-apollo 304aed3063 Added: Add UrlUtils 2022-01-23 01:36:41 +05:00
agnostic-apollo cbac7c8fbd Changed: Get user handle for package instead of process user handle when getting profile user serial number 2022-01-23 01:36:41 +05:00
agnostic-apollo 65252dc640 Changed: Use cached PackageInfo while getting version code and name for app 2022-01-23 01:36:41 +05:00
agnostic-apollo 2c6d009657 Added: Add uid to app info 2022-01-23 01:36:41 +05:00
agnostic-apollo a987246bd8 Added: Add comment for why clearing of $TMPDIR may be skipped on termux exit 2022-01-23 01:36:41 +05:00
agnostic-apollo 059feaacf1 Changed: Move UrlUtils to TermuxUrlUtils 2022-01-23 01:36:41 +05:00
agnostic-apollo f62997a60e Fixed: Log exception instead of crashing app on NumberFormatException for invalid termcap/terminfo string requested
java.lang.NumberFormatException: For input string: " a"
at java.lang.Long.parseLong(Long.java:583)
at java.lang.Long.valueOf(Long.java:781)
at java.lang.Long.decode(Long.java:933)
at com.termux.terminal.TerminalEmulator.doDeviceControl(TerminalEmulator.java:940)
at com.termux.terminal.TerminalEmulator.processCodePoint(TerminalEmulator.java:813)
2022-01-23 01:36:41 +05:00
agnostic-apollo 79980a07a8 Fixed: Use android.util.Log for terminal-emulator logging if TerminalSessionClient is null like when running tests 2022-01-23 01:36:41 +05:00
agnostic-apollo 4faf2b9d28 Fixed: Fix CSI Delete Ps Column(s) (DECDC)
Firstly, `TerminalBuffer.blockSet()` was throwing the exception since `sx + w > mColumns` which was technically passed by TerminalEmulator.blockClear()`. Actual value would be `mCursorRow + columnsToMove + columnsToDelete > mColumns`.

Secondly, the call to `blockClear()` should not be needed since it the `blockCopy()` would overwrite the columns to be deleted on copy.

Run `printf "\e['~"` to delete 1 column and `printf "\e[3'~"` to delete 3 columns. Run `printf "\e[3'}"` to insert 2 columns.

java.lang.IllegalArgumentException: Illegal arguments! blockSet(78, 0, 1, 30, 32, 56, 30)
at com.termux.terminal.TerminalBuffer.blockSet(TerminalBuffer.java:397)
at com.termux.terminal.TerminalEmulator.blockClear(TerminalEmulator.java:2035)
at com.termux.terminal.TerminalEmulator.processCodePoint(TerminalEmulator.java:799)
2022-01-23 01:36:41 +05:00
agnostic-apollo 701b5ccd5c Fixed: Fix ArrayIndexOutOfBoundsException thrown because length was less than 0 when selecting text from terminal buffer
java.lang.ArrayIndexOutOfBoundsException: src.length=132 srcPos=90 dst.length=16 dstPos=0 length=-2
at java.lang.System.arraycopy(System.java:469)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:597)
at java.lang.StringBuilder.append(StringBuilder.java:191)
at com.termux.terminal.TerminalBuffer.getSelectedText(TerminalBuffer.java:97)
at com.termux.terminal.TerminalBuffer.getSelectedText(TerminalBuffer.java:57)
at com.termux.terminal.TerminalBuffer.getSelectedText(TerminalBuffer.java:53)
at com.termux.terminal.TerminalEmulator.getSelectedText(TerminalEmulator.java:2401)
at com.termux.view.textselection.TextSelectionCursorController$1.onActionItemClicked(TextSelectionCursorController.java:140)
2022-01-23 01:36:41 +05:00
agnostic-apollo 9798b30c76 Fixed: Fix issue where menu wouldn't show when text on bottom row of terminal was selected
Closes #2233
2022-01-23 01:36:41 +05:00
agnostic-apollo fa91205bca Changed!: Move ReportInfo parameters from constructor to functions 2022-01-23 01:36:41 +05:00
agnostic-apollo 64adc521de Added: Add info of all Termux plugins in bootstrap error reports and refactor notification functions
Now in case of bootstrap failure, the app info of all installed termux plugin apps will be added as well, including whether they are installed on external/portable sd card. Apparently, as per reports, installing termux app or even plugin apps on external/portable sd cards prevents termux apps from accessing its files directory `/data/data/com.termux/file` and bootstrap checks fail. This commit should provide more info or proof of it.

Moreover, adding plugin info would be useful in future for diagnosing targetsdk mismatch between Termux and its plugins when sdk `30` is targeted by Termux app.
2022-01-23 01:36:41 +05:00
agnostic-apollo 9814438ae5 Added: Add info of Termux API calling app in plugin command error reports and refactor notification functions
Now when a Termux API command like `RUN_COMMAND` intent is called by an external app with PendingIntent, then the info of the app will be shown in error reports as well. This should provide more info about the caller which should be useful for debugging or in case a malicious app ran commands with `allow-external-app` disabled.

Moreover, `PluginUtils.sendPluginCommandErrorNotification()` has been refactored to send generic messages instead of just for `ExecutionCommand`. This will allow usage with other Termux APIs as well.
2022-01-23 01:36:41 +05:00
agnostic-apollo ae7f141aca Added: Add info of installed plugin apps when report issue report is generated with debug mode enabled 2022-01-23 01:36:41 +05:00
agnostic-apollo fd4159f1ba Added: Add generic function TermuxUtils to get app info for termux app, its installed plugin apps and external apps 2022-01-23 01:36:41 +05:00
agnostic-apollo 1327cef7b4 Added: Add support for getting external app info
PackageUtils were previously based on using `Context` object to get app info, which was only possible to get for Termux app and its sharedUserId plugins. Now it has been refactored to used `PackageInfo` and `ApplicationInfo` objects to get the info, which will also allow getting info of external apps. However, when targeting sdk `30`, queries entries or `QUERY_ALL_PACKAGES` permission will be required. Check `PackageUtils.isAppInstalled()` for more info.
2022-01-23 01:36:41 +05:00
agnostic-apollo 0da1984b59 Changed: Do not show toast if text null or empty 2022-01-23 01:36:41 +05:00
agnostic-apollo 09412da9d7 Fixed: Fix NullPointerException when getting spanned markdown like for notification 2022-01-23 01:36:41 +05:00
agnostic-apollo 009c128052 Changed: Move termux apps properties file list to TermuxConstants and do not follow symlinks 2022-01-23 01:36:41 +05:00
agnostic-apollo 9259ef0be1 Changed: Bump to v0.118.0 2022-01-23 01:36:41 +05:00
agnostic-apollo 480f92880c Fixed: Fix bootstrap checksum check if it contained leading zeros 2022-01-23 01:36:41 +05:00
agnostic-apollo b01a738791 Docs: Update README.md 2022-01-23 01:36:41 +05:00
agnostic-apollo 0eaaa1372a Changed: Bump bootstrap to v2022.01.07-r1 2022-01-23 01:36:41 +05:00
agnostic-apollo 903b1c75a2 Fixed: Fix bootstrap checksum check if it contained leading zeros 2022-01-23 01:36:41 +05:00
agnostic-apollo 085b17e496 Changed: Bump dependency versions 2022-01-23 01:36:41 +05:00
agnostic-apollo 897d911a52 Changed: Move to semantic versioning for app and library versions and add commit hash and `github` to APK file names
The `versionName` will now follow semantic version `2.0.0` spec in the format `major.minor.patch(-prerelease)(+buildmetadata)`. This will make versioning the prerelease and github debug builds versions easier and follow a spec. The @termux devs should make sure that when bumping `versionName` in `build.gradle` files and when creating a tag for new releases on github that they include the patch number as well, like `v0.1.0` instead of just `v0.1`. The `build.gradle` files and `attach_debug_apks_to_release` workflow will now validate the version as well and the build/attachment will fail if `versionName` does not follow the spec. https://semver.org/spec/v2.0.0.html

APKs released on github for debug build workflows and releases are now referred as `Github` releases as per 7b10a35f and 94e01d68, so APK filenames have been modified to include `github` in the filename. The APKs are still debuggable, so that tag remains too.

For github workflows the apk filename format will be `termux-app_<current_version>+<last_commit_hash>-github-debug_<arch>.apk`, like `termux-app_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk` and for github releases it will be `termux-app_<release_version>+github-debug_<arch>.apk`, like `termux-app_v0.1+github-debug_arm64-v8a.apk`. The `last_commit_hash` will be the first `8` characters of the commit hash. The `<last_commit_hash>-github-debug` will act as `buildmetadata` and will not affect versioning precedence.

For github workflows triggered by `push` and `pull_request` triggers, `<current_version>+<last_commit_hash>` will be used as new `versionName`, like `v0.1.0+xxxxxxxx`. This will make tracking which build a user is using easier and help in resolving issues as well.

Note that users using github releases and termux devs using `$TERMUX_VERSION` environment variables in scripts should take commit hash into consideration and possibly use something like `dpkg --compare-versions "$TERMUX_VERSION" ge 0.1` where appropriate instead of mathematical comparisons.

The `app/build.gradle` now also supports following `TERMUX_` scoped environmental variables and `RELEASE_TAG` variable will not be used anymore since it may conflict with possibly other variables used by users. They will also allow enabling split APKs for both debug and release builds.

- `TERMUX_APP_VERSION_NAME` will be used as `versionName` if its set.
- `TERMUX_APK_VERSION_TAG` will be used as `termux-app_<TERMUX_APK_VERSION_TAG>_<arch>.apk` if its set. The `_<arch>` will only exist for split APKs.
- `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` will define whether split APKs should be enabled for debug builds. Default value is `1`.
- `TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS` will define whether split APKs should be enabled for release builds. Default value is `0` since F-Droid does not support split APKs, check #1904.

So based on above, if in future github releases are to be converted to `release` builds instead of `debug` builds, something like following can be done and even a workflow can be created for it. Users can also build split APKs release builds for themselves if they want.

```
export TERMUX_SPLIT_APKS_FOR_RELEASE_BUILDS=1
./gradlew assembleRelease -Pandroid.injected.signing.store.file="$(pwd)/app/dev_keystore.jks" -Pandroid.injected.signing.store.password=xrj45yWGLbsO7W0v -Pandroid.injected.signing.key.alias=alias -Pandroid.injected.signing.key.password=xrj45yWGLbsO7W0v
```

The APK will be found at `./app/build/outputs/apk/release/termux-app_<version>_<arch>.apk`

The `TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS` can be set to `0` to disable building split APKs which may be helpful for users building termux on device considering they will extra space and build time. Instructions for building are at https://github.com/termux/termux-packages/pull/7227#issuecomment-893022283.

```
export TERMUX_SPLIT_APKS_FOR_DEBUG_BUILDS=0
./gradlew assembleDebug
```

The APK will be found at `./app/build/outputs/apk/debug/termux-app_debug_universal.apk`

Note that F-Droid uses algorithm at https://gitlab.com/fdroid/fdroidserver/-/blob/2.1a0/fdroidserver/build.py#L746 to automatically detect built APKs, so ensure any modifications to location or file name are compliant. Current updates should be.

Auto updates are detected by checkupdates bot at https://gitlab.com/fdroid/fdroidserver/-/blob/master/fdroidserver/checkupdates.py
2022-01-23 01:36:41 +05:00
Henrik Grimler cd5962c696 bootstrap archives: update to 2022.01.02-r1 2022-01-23 01:36:41 +05:00
Henrik Grimler 6e6da752bd Fixed: Fix copy&paste error in areHardwareKeyboardShortcutsDisabled
Fixes 829cc39868 ("Allow users to disable hardware keyboard
shortcuts").

Reported-by: @amogusissofunnyhahalmaogenzhumorbelike
2022-01-23 01:36:41 +05:00
Leonid Pliushch 6d60bc669b bootstrap archives: update to 2021.12.02-r1 2022-01-23 01:36:41 +05:00
Henrik Grimler 6c24e6ac3b
termux-shared: add android.permission.VIBRATE to manifest
./gradlew lint complains about vibrations being used in
termux-shared/src/main/java/com/termux/shared/terminal/io/BellHandler.java
without the permission being declared.
2021-11-20 22:03:09 +01:00
YAKSH BARIYA edf3b622e4
chore: Fix Discord server ID in shields.io badge
Based on dd59986a8c
2021-11-05 11:36:14 +05:30
agnostic-apollo af16e79bf8
Merge pull request #2146 from trygveaa/click-on-url
Added: Allow users to directly open URL links in terminal transcript when clicked or tapped

The user can add `terminal-onclick-url-open=true` entry to `termux.properties` file to enable opening of URL links in terminal transcript when clicked or tapped. The default value is `false`. Running `termux-reload-settings` command will also update the behaviour instantaneously if changed.

Implemented in #2146
2021-10-13 22:36:52 +05:00