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

Commit a46762a

Browse files
Changed: Use termux-shared
- All hardcoded `com.termux` constants have been removed and will be handled by `TermuxConstants` and `TermuxPreferenceConstants`. - Fixed issue with losing reference to `TermuxFloatView` in `TermuxFloatService` and destroying view not working. - Removed unnecessary toasts and fixed custom broken ones by using the one provided by `Logger` class. - Updated `TerminalView` and `TerminalSession` to latest versions and removed duplicated `TerminalSession` code based on old `TermuxService` and start using `TermuxSession` which will also have consistent shell environment as `termux-app`. - Removed `SharedPrefernces` management and use the one in `termux-shared` provided by `TermuxFloatAppSharedPreferences`. - Use action constants defined in `TermuxConstants` for `TermuxFloatService`. - Use notification constants defined in `TermuxConstants` for `TermuxFloatService`. - Use `KeyboardUtils` for showing and hiding keyboard. - Implement logging system based on `Logger` class. Log levels can be changed in `termux-app` settings but require restarting `termux-float` for changes to take effect since both apps run in different processes. - Fixed potential `IllegalArgumentException` when adding and removing `TermuxFloatView` to `WindowManager`. - Added crash handler so that crash notifications can be shown in `termux-app` at startup.
1 parent 529268a commit a46762a

File tree

10 files changed

+381
-279
lines changed

10 files changed

+381
-279
lines changed

app/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ android {
88
targetSdkVersion project.properties.targetSdkVersion.toInteger()
99
versionCode 14
1010
versionName "0.14"
11+
12+
manifestPlaceholders.TERMUX_PACKAGE_NAME = "com.termux"
13+
manifestPlaceholders.TERMUX_APP_NAME = "Termux"
14+
manifestPlaceholders.TERMUX_FLOAT_APP_NAME = "Termux:Float"
1115
}
1216

1317
signingConfigs {
@@ -49,7 +53,8 @@ android {
4953

5054
dependencies {
5155
implementation 'androidx.annotation:annotation:1.2.0'
52-
implementation 'com.termux:terminal-view:0.106'
56+
implementation 'com.termux.termux-app:termux-shared:9f1203f049'
57+
implementation 'com.termux.termux-app:terminal-view:9f1203f049'
5358

5459
testImplementation 'junit:junit:4.13.2'
5560
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.termux.window"
5-
android:sharedUserId="com.termux">
5+
android:sharedUserId="${TERMUX_PACKAGE_NAME}">
66

77
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
88

@@ -11,6 +11,7 @@
1111
<uses-permission android:name="android.permission.VIBRATE" />
1212

1313
<application
14+
android:name=".TermuxFloatApplication"
1415
android:allowBackup="true"
1516
android:extractNativeLibs="true"
1617
android:icon="@drawable/ic_launcher"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.termux.window;
2+
3+
import android.app.Application;
4+
import android.content.Context;
5+
6+
import com.termux.shared.crash.TermuxCrashUtils;
7+
import com.termux.shared.logger.Logger;
8+
import com.termux.shared.settings.preferences.TermuxFloatAppSharedPreferences;
9+
10+
11+
public class TermuxFloatApplication extends Application {
12+
public void onCreate() {
13+
super.onCreate();
14+
15+
// Set crash handler for the app
16+
TermuxCrashUtils.setCrashHandler(this);
17+
18+
// Set log level for the app
19+
setLogLevel(getApplicationContext());
20+
21+
Logger.logDebug("Starting Application");
22+
}
23+
24+
public static void setLogLevel(Context context) {
25+
// Load the log level from shared preferences and set it to the {@link Logger.CURRENT_LOG_LEVEL}
26+
TermuxFloatAppSharedPreferences preferences = TermuxFloatAppSharedPreferences.build(context);
27+
if (preferences == null) return;
28+
preferences.setLogLevel(null, preferences.getLogLevel(true), true);
29+
}
30+
}
31+

app/src/main/java/com/termux/window/TermuxFloatPrefs.java

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

0 commit comments

Comments
 (0)