这是indexloc提供的服务,不要输入任何密码
Skip to content

Commit 63e7645

Browse files
Changed: Use termux-shared
- All hardcoded `com.termux` constants have been removed and will be handled by `TermuxConstants` and `TermuxPreferenceConstants`. - Use extra constants returned by `TermuxService` defined in `TermuxConstants` for `PluginUtils`. - Use `FileUtils` and `TermuxFileUtils` provided by `termux-shared` to handle all file related functionality which has better, safer and more updated code. - Use `TermuxTaskerAppSharedPreferences` provided by `termux-shared` for handling `SharedPreferences` functionality. - Use `Logger` provided by `termux-shared` for logging. Log level will not be got from `SharedPreferences` for each log entry but will be loaded from `SharedPreferences` into the `Logger.CURRENT_LOG_LEVEL` variable at application startup and also in `FireReceiver` which runs as a separate process and maintains separate `Logger` instance. The `termux-app` can also set the log level from its settings. - Fix issue where log level was not being read from file, which has been fixed in `TermuxTaskerAppSharedPreferences` in upstream. - Added crash handler so that crash notifications can be shown in `termux-app` at startup. - Fix javadocs. - Move functions to `PluginUtils` from `PluginResultsService`. The `Context` requirement is gone too since `Logger` doesn't need it. - Previously working directory would only be created automatically if it was under `TermuxConstants.TERMUX_HOME_DIR_PATH` but now it will be created even if its under `TermuxConstants.TERMUX_FILES_DIR_PATH`. - Catch exceptions thrown by `startService()` `startForegroundService()` when sending intent to `TermuxService` for execution. - Use `ExecutionCommand` class to handle intent extras in `FireReceiver` since they are consistent with that of `TermuxService` `ACTION_SERVICE_EXECUTE` intent. - Use `TermuxUtils` and `PackageUtils` provided by `termux-shared` and remove existing `TermuxUtils`. The `TermuxUtils.isTermuxAppAccessible()` will also check if `termux-tasker` can access `termux-app` package `Context`.
1 parent 552d592 commit 63e7645

22 files changed

+803
-1243
lines changed

app/build.gradle

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 28
4+
compileSdkVersion project.properties.compileSdkVersion.toInteger()
55
defaultConfig {
66
applicationId "com.termux.tasker"
7-
minSdkVersion 24
8-
targetSdkVersion 28
7+
minSdkVersion project.properties.minSdkVersion.toInteger()
8+
targetSdkVersion project.properties.targetSdkVersion.toInteger()
99
versionCode 5
1010
versionName "0.5"
1111
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
12+
13+
manifestPlaceholders.TERMUX_PACKAGE_NAME = "com.termux"
14+
manifestPlaceholders.TERMUX_APP_NAME = "Termux"
15+
manifestPlaceholders.TERMUX_TASKER_APP_NAME = "Termux:Tasker"
1216
}
1317

1418
signingConfigs {
@@ -40,12 +44,20 @@ android {
4044
}
4145

4246
dependencies {
43-
implementation 'com.google.android.material:material:1.2.1'
47+
testImplementation 'junit:junit:4.13.2'
48+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
49+
androidTestImplementation 'androidx.test:runner:1.4.0'
50+
androidTestImplementation 'androidx.test:rules:1.4.0'
51+
52+
implementation "androidx.annotation:annotation:1.2.0"
53+
implementation 'com.google.android.material:material:1.4.0'
54+
implementation 'com.google.guava:guava:24.1-jre'
55+
56+
implementation 'com.termux.termux-app:termux-shared:f00738fe3a'
4457

45-
testImplementation 'junit:junit:4.13.1'
46-
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
47-
androidTestImplementation 'androidx.test:runner:1.3.0'
48-
androidTestImplementation 'androidx.test:rules:1.3.0'
58+
// Use if below libraries are published locally by termux-app with `./gradlew publishReleasePublicationToMavenLocal` and used with `mavenLocal()`.
59+
// If updates are done, republish there and sync project with gradle files here
60+
//implementation 'com.termux:termux-shared:0.117'
4961
}
5062

5163
task versionName {

app/src/androidTest/java/com/termux/tasker/ExampleInstrumentedTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import androidx.test.platform.app.InstrumentationRegistry;
55
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
66

7+
import com.termux.shared.termux.TermuxConstants;
8+
79
import org.junit.Test;
810
import org.junit.runner.RunWith;
911

@@ -22,6 +24,6 @@ public void useAppContext() {
2224
// Context of the app under test.
2325
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
2426

25-
assertEquals("com.termux.tasker", appContext.getPackageName());
27+
assertEquals(TermuxConstants.TERMUX_TASKER_PACKAGE_NAME, appContext.getPackageName());
2628
}
2729
}

app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.termux.tasker"
4-
android:sharedUserId="com.termux">
4+
android:sharedUserId="${TERMUX_PACKAGE_NAME}"
5+
android:sharedUserLabel="@string/shared_user_label" >
56

67
<application
7-
android:allowBackup="true"
8+
android:name=".TermuxTaskerApplication"
9+
android:label="@string/application_name"
810
android:icon="@drawable/ic_launcher"
9-
android:label="@string/app_name"
10-
android:supportsRtl="true"
11-
android:theme="@style/AppTheme">
11+
android:theme="@style/AppTheme"
12+
13+
android:allowBackup="true"
14+
android:fullBackupOnly="false"
15+
android:supportsRtl="true" >
1216

1317
<!--
1418
This is the "edit" Activity. Note that Locale will reject plug-in Activities for the following reasons:·
@@ -42,7 +46,7 @@
4246
android:name=".FireReceiver"
4347
android:exported="true"
4448
android:process=":background"
45-
android:permission="com.termux.permission.RUN_COMMAND">
49+
android:permission="${TERMUX_PACKAGE_NAME}.permission.RUN_COMMAND">
4650
<!-- This Intent filter allows the plug-in to discovered by Locale. -->
4751
<intent-filter>
4852
<action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING" />
@@ -52,7 +56,7 @@
5256
<!--
5357
This is service that will receive execution result from the execution service via a PendingIntent
5458
-->
55-
<service android:name=".PluginResultsService"/>
59+
<service android:name=".PluginResultsService" />
5660
</application>
5761

5862
</manifest>

app/src/main/java/com/termux/tasker/AbstractPluginActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import android.view.Menu;
55
import android.view.MenuItem;
66

7-
import com.termux.tasker.utils.Logger;
8-
97
/**
108
* Superclass for plug-in Activities. This class takes care of initializing aspects of the plug-in's UI to
119
* look more integrated with the plug-in host.
@@ -51,7 +49,8 @@ public boolean onOptionsItemSelected(final MenuItem item) {
5149
* During {@link #finish()}, subclasses can call this method to determine whether the Activity was
5250
* canceled.
5351
*
54-
* @return True if the Activity was canceled. False if the Activity was not canceled.
52+
* @return Returns {@code true} if the Activity was canceled, otherwise returns {@code false}
53+
* if the Activity was not canceled.
5554
*/
5655
protected boolean isCanceled() {
5756
return mIsCancelled;

app/src/main/java/com/termux/tasker/BundleScrubber.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ public final class BundleScrubber {
1414
* Bundle is null, has no extras, or the extras do not contain a private serializable subclass, the Bundle
1515
* is not mutated.
1616
*
17-
* @param intent {@code Intent} to scrub. This parameter may be mutated if scrubbing is necessary. This
18-
* parameter may be null.
19-
* @return true if the Intent was scrubbed, false if the Intent was not modified.
17+
* @param intent The {@link Intent} to scrub. This parameter may be mutated if scrubbing is
18+
* necessary. This parameter may be {@code null}.
19+
* @return Returns {@code true} if the Intent was scrubbed, otherwise returns {@code false} if
20+
* the {@link Intent} was not modified.
2021
*/
2122
public static boolean scrub(final Intent intent) {
2223
return null != intent && scrub(intent.getExtras());
@@ -27,9 +28,10 @@ public static boolean scrub(final Intent intent) {
2728
* private serializable subclass, the Bundle is cleared. If the Bundle is null, has no extras, or the
2829
* extras do not contain a private serializable subclass, the Bundle is not mutated.
2930
*
30-
* @param bundle {@code Bundle} to scrub. This parameter may be mutated if scrubbing is necessary. This
31-
* parameter may be null.
32-
* @return true if the Bundle was scrubbed, false if the Bundle was not modified.
31+
* @param bundle The {@link Bundle} to scrub. This parameter may be mutated if scrubbing is necessary.
32+
* This parameter may be {@code null}.
33+
* @return Returns {@code true} if the Bundle was scrubbed, otheriwse {@code false} if the
34+
* {@link Bundle} was not modified.
3335
*/
3436
public static boolean scrub(final Bundle bundle) {
3537
if (null == bundle) return false;

app/src/main/java/com/termux/tasker/Constants.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)