Skip to content

Commit

Permalink
Changed: Use termux-shared
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
agnostic-apollo committed Sep 2, 2021
1 parent 529268a commit a46762a
Show file tree
Hide file tree
Showing 10 changed files with 381 additions and 279 deletions.
7 changes: 6 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ android {
targetSdkVersion project.properties.targetSdkVersion.toInteger()
versionCode 14
versionName "0.14"

manifestPlaceholders.TERMUX_PACKAGE_NAME = "com.termux"
manifestPlaceholders.TERMUX_APP_NAME = "Termux"
manifestPlaceholders.TERMUX_FLOAT_APP_NAME = "Termux:Float"
}

signingConfigs {
Expand Down Expand Up @@ -49,7 +53,8 @@ android {

dependencies {
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'com.termux:terminal-view:0.106'
implementation 'com.termux.termux-app:termux-shared:9f1203f049'
implementation 'com.termux.termux-app:terminal-view:9f1203f049'

testImplementation 'junit:junit:4.13.2'
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.termux.window"
android:sharedUserId="com.termux">
android:sharedUserId="${TERMUX_PACKAGE_NAME}">

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

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

<application
android:name=".TermuxFloatApplication"
android:allowBackup="true"
android:extractNativeLibs="true"
android:icon="@drawable/ic_launcher"
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/java/com/termux/window/TermuxFloatApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.termux.window;

import android.app.Application;
import android.content.Context;

import com.termux.shared.crash.TermuxCrashUtils;
import com.termux.shared.logger.Logger;
import com.termux.shared.settings.preferences.TermuxFloatAppSharedPreferences;


public class TermuxFloatApplication extends Application {
public void onCreate() {
super.onCreate();

// Set crash handler for the app
TermuxCrashUtils.setCrashHandler(this);

// Set log level for the app
setLogLevel(getApplicationContext());

Logger.logDebug("Starting Application");
}

public static void setLogLevel(Context context) {
// Load the log level from shared preferences and set it to the {@link Logger.CURRENT_LOG_LEVEL}
TermuxFloatAppSharedPreferences preferences = TermuxFloatAppSharedPreferences.build(context);
if (preferences == null) return;
preferences.setLogLevel(null, preferences.getLogLevel(true), true);
}
}

32 changes: 0 additions & 32 deletions app/src/main/java/com/termux/window/TermuxFloatPrefs.java

This file was deleted.

Loading

0 comments on commit a46762a

Please # to comment.