Commit Graph

37 Commits

Author SHA1 Message Date
agnostic-apollo 682ce08314 Create termux-shared library package for all termux constants and shared utils
The termux plugins should use this library instead of hardcoding "com.termux" values in their source code.

The library can be included as a dependency by plugins and third party apps by including the following line in the build.gradle where x.xxx is the version number, once its published.

`implementation 'com.termux:termux-shared:x.xxx'`

The `TermuxConstants` class has been updated to `v0.17.0`, `TermuxPreferenceConstants` to `v0.9.0` and `TermuxPropertyConstants` to `v0.6.0`. Check their Changelog sections for info on changes.

Some typos and redundant code has also been fixed.
2021-04-07 11:31:30 +05:00
agnostic-apollo b2cd20c035 Use FileUtils for bootstrap and shared storage symlinks setup 2021-04-06 06:00:21 +05:00
agnostic-apollo 92b804dc9c Add logging for termux bootstrap package installation and setup of storage symlinks 2021-03-24 04:55:10 +05:00
agnostic-apollo d39972b3bf Implement GUI based Termux settings manager and a centralized logging framework
The settings activity can be accessed by long pressing on terminal view and selecting "Settings" from the popup shown. It uses the Android's Preference framework. Currently only debugging preferences to set log level and enabling terminal view key logging are provided. The Preference framework by default uses the keys set in `app:key` attribute in the respective preferences XML file to store the values in the default `SharedPreferences` file of the app. However, since we rely on `TermuxPreferenceConstants` and `TermuxPropertyConstants` classes to define key names so that they can be easily shared between termux and its plugin apps, we provide our own `PreferenceDataStore` for storing key/value pairs. The key name in the XML file can optionally be the same. Check `DebuggingPreferencesFragment` class for a sample. Each new preference category fragment should be added to `app/settings/` with its data store.

This commit may allow support to be added for modifying `termux.properties` file directly from the UI but that requires more work, since writing to property files with comments require in-place modification.

The `Logger` class provides various static functions for logging that should be used from now on instead of directly calling android `Log.*` functions. The log level is automatically loaded from shared preferences at application startup via `TermuxApplication` and set in the static `Logger.CURRENT_LOG_LEVEL` variable. Changing the log level through the settings activity also changes the log level immediately.

The 4 supported log levels are:
- LOG_LEVEL_OFF which will log nothing.
- LOG_LEVEL_NORMAL which will start logging error, warn and info messages and stacktraces.
- LOG_LEVEL_DEBUG which will start logging debug messages.
- LOG_LEVEL_VERBOSE which will start logging verbose messages.

The default log level is `LOG_LEVEL_NORMAL` which will not log debug or verbose messages. Contributors can add useful log entries at those levels where ever they feel is appropriate so that it allows users and devs to more easily help solve issues or find bugs, specially without having to recompile termux after having to manually add general log entries to the source. DO NOT log data that may have private info of users like command arguments at log levels below debug, like `BackgroundJob` was doing previously.

Logging to file support may be added later, will require log file rotation support and storage permissions.
2021-03-13 16:49:29 +05:00
agnostic-apollo ef9e406300 Update TermuxConstants
The `TermuxConstants` and `TermuxPropertyConstants` classes have both been updated to `v0.2.0`. Check their Changelog sections for info on changes.
Some other hardcoded termux paths have been removed as well and are now referenced from `TermuxConstants` class.
2021-03-11 20:11:59 +05:00
agnostic-apollo 14c49867f7 Define `TermuxConstants` class to store all shared constants of Termux app and its plugins
This commit removes almost all hardcoded paths in Termux app and moves the references to the `TermuxConstants` class.

The `TermuxConstants` class should be imported by other termux plugin apps instead of copying and defining their own constants. The 3rd party apps can also import it for interacting with termux apps. App and sub class specific constants are defined in their own nested classes to keep them segregated from each other and for better readability.
2021-03-08 15:09:22 +05:00
mao 9ebedc4740 Merge remote-tracking branch 'remotes/origin/master' 2019-12-19 00:43:45 +08:00
Fredrik Fornwall c76cec186a Include bootstrap zips as shared libraries 2019-10-20 20:15:50 +02:00
Fredrik Fornwall 6218d08037 Use https://termux.org/bootstrap-${ARCH}.zip
This will redirect to the desired version of the bootstrap zip in
bintray.
2019-04-08 19:06:57 +02:00
Fredrik Fornwall 70a786613d Install from bintray on Android 7 and later 2019-04-03 23:02:31 +02:00
Fredrik Fornwall 063ef02f2b Let the installer create directories when necessary
By creating directories when necessary before trying to install files we
depend on less details in how the bootstrap zip is constructed.
2018-11-17 22:50:27 +01:00
Fredrik Fornwall b61da23be7 Enable java 8 2018-09-29 00:49:05 +02:00
Leonid Plyushch b7864d6ac2 deleteFolder(): check if passed argument is a symlink
Prevents possible data loss when user replaced directory '~/storage' with
a symlink.
2018-07-01 18:00:54 +02:00
Leonid Plyushch d3b4d35b2a deleteFolder(): don't treat symlinks as directory 2018-06-25 14:08:28 +02:00
Quasic c5923201a4 fix indent with vim on termux
web interface would have worked, if I had deleted the tabs, first
This vim is adding tabs instead of matching the previous line's
indentation. Looking into fixing that now...
2018-06-22 00:33:35 +02:00
Quasic bafd21bb39 fmt indentation 2018-06-22 00:33:35 +02:00
Quasic 0f20fab02c I think this is it 2018-06-22 00:33:35 +02:00
Quasic c5ae5bb06a oops, should have local Java 2018-06-22 00:33:35 +02:00
Quasic bbd46a763c Fix for #572 using recursive delete
Also see #578
2018-06-22 00:33:35 +02:00
Edward Betts 81fb669d0e correct spelling mistake 2017-09-13 16:16:08 +01:00
Fredrik Fornwall 357b17e972 Improve setup of symlinks to external storage
The context.getExternalFilesDirs(null) call may return several
elements, and some of them may be null.
2016-12-04 01:04:19 +01:00
Fredrik Fornwall 1dc92b2a12 Remove unused imports 2016-08-22 16:54:55 +02:00
Fredrik Fornwall 5532421ab2 Check arches in order of preference
The documentation for Build.SUPPORTED_ABIS says:
"An ordered list of ABIs supported by this device. The most preferred
ABI is the first element in the list."

Respect that preference when checking for which arch to install
packages for.

Fixes #131.
2016-08-08 23:22:47 +02:00
Fredrik Fornwall 6b62e65154 Some minor AS lint warnings tweaks 2016-07-31 22:28:17 +02:00
Fredrik Fornwall 2db6923bc4 Reformat code project-wide (getting rid of tabs) 2016-06-28 01:03:03 +02:00
Fredrik Fornwall 9519727f38 Enable installation of x86-64 packages 2016-06-22 01:31:21 +02:00
Fredrik Fornwall 9686127f81 Fix installer to check supported abi:s
This fixes installation on e.g. the Samsung Galaxy S5 Neo which has
a 64-bit cpu but no 64-bit runtime available (closes #69).
2016-04-16 21:18:21 +02:00
Fredrik Fornwall 5c02448521 Install 64-bit arm packages on capable devices
This will only affect new installations. Existing users wishing to
install 64-bit packages can re-install the app completely, or just
'rm -Rf $PREFIX' and exit all sessions, which will cause Termux to
re-install all packages at next startup.
2016-03-20 22:24:05 +01:00
Fredrik Fornwall 048af64093 Map everything starting with x86 to i686
This fixes CPU detection for ARC welder which reports x86.
2016-02-14 00:42:34 +01:00
Fredrik Fornwall c3aa9d9662 Updated storage handling
Let the user run termux-setup-storage, which will ensure that storage
permission has been granted and setup $HOME/storage/ folder with
symlinks to storage folders.
2015-12-28 01:37:00 +01:00
Fredrik Fornwall 468185efb3 Transition to https://termux.net for bootstrap
The initial bootstrap zip was previously downloaded from
http://apt.termux.com, which lacked security and was not behind a CDN.

By moving to https://termux.net we improve security (as it's https)
and reliability (as it's using a CDN).

Fixes https://github.com/termux/termux-packages/issues/89.
2015-12-27 08:17:29 +01:00
Fredrik Fornwall dd38965c46 Use $PREFIX/storage for symlinks. Rix null check. 2015-12-24 09:29:14 +01:00
Fredrik Fornwall 2326c52199 Implement support for termux.properties
Also some symlink-to-storage improvements and experimenting with
requesting read storage permission.
2015-12-23 01:43:41 +01:00
Fredrik Fornwall bce65f7db1 Setup $HOME/storage symlink for external symlink
At startup Termux now checks if there is external storage available,
and creates a private area on the external storage if one exists as
well as creating a symlink to the private are at $HOME/storage.
2015-12-12 03:02:06 +01:00
Fredrik Fornwall 89912be500 Fix crash on installation if activity destroyed
If the activity had been destroyed waiting for the installation to
finish the code would crash trying to display welcome dialogs (on
success) or error dialogs (on error).
2015-11-13 00:10:21 +01:00
Fredrik Fornwall 05e250bb96 Fix minor Android Studio inspection warnings 2015-10-25 16:39:34 +01:00
Fredrik Fornwall a18ee58f7a Initial commit 2015-10-25 15:27:32 +01:00