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

X #3795

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
928ce40
making it a launcher
chedim May 22, 2020
87006aa
termux: app: add apps-cache intent
thewisenerd Sep 10, 2017
3621452
Fixes android keyboard not showing up on tap
chedim May 25, 2020
900a893
Updated README
chedim May 25, 2020
36c2592
Updated README
chedim May 25, 2020
6ecdca3
Updated README
chedim May 25, 2020
b451fcb
Updated README
chedim May 25, 2020
3c14cee
Voices
chedim Oct 11, 2022
a3ced00
look ma, its a launcher again!
Jun 24, 2021
2dabb7a
Fixes constant name
chedim Oct 11, 2022
bdd9be2
Fixes #6
chedim Oct 13, 2022
0c2f389
Update README.md
chedim Oct 11, 2022
d0d126b
Update README.md
chedim Oct 11, 2022
4098f59
NOW it is a full launcher
chedim Oct 13, 2022
f43539b
updates readme
chedim Oct 13, 2022
6a7df72
Adds basic notification announcer service
chedim Nov 11, 2022
43e51c6
termux: app: add apps-cache intent
thewisenerd Sep 10, 2017
1d2707e
Updated README
chedim May 25, 2020
e28d48b
Updated README
chedim May 25, 2020
c06be41
Updated README
chedim May 25, 2020
22d5bee
Updated README
chedim May 25, 2020
efdc699
Voices
chedim Oct 11, 2022
6436b85
Fixes constant name
chedim Oct 11, 2022
78694dd
Update README.md
chedim Oct 11, 2022
b766b4b
NOW it is a full launcher
chedim Oct 13, 2022
d72cd4a
updates readme
chedim Oct 13, 2022
86005d4
Adds basic notification announcer service
chedim Nov 11, 2022
8371bf7
Update README.md
chedim Nov 11, 2022
0f3a9ac
Russian language support (yes, I receive notifications in Russian :)
chedim Nov 11, 2022
db0927c
Makes notification announcer respect the DND mode
chedim Nov 11, 2022
8707a3b
[doc](readme)modified the links in file
nikam14 Mar 13, 2023
22807ed
termux: app: add apps-cache intent
thewisenerd Sep 10, 2017
deb174a
Fixes android keyboard not showing up on tap
chedim May 25, 2020
1ac9dca
Voices
chedim Oct 11, 2022
a0712ac
NOW it is a full launcher
chedim Oct 13, 2022
f578e12
Adds basic notification announcer service
chedim Nov 11, 2022
ca58d50
removes voice stuff
chedim Aug 21, 2023
473ec52
Fixes .bashrc being overridden upon startup
chedim Aug 29, 2023
ca969cf
Launcher bits
chedim Nov 22, 2023
d3f344d
Merge branch 'master' into master
xplshn Jan 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ local.properties
.swp
ehthumbs.db
Thumbs.db

.project
.settings
.classpath
tags
277 changes: 270 additions & 7 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ android {
(gradle.startParameter.taskNames.any { it.contains("Release") } && splitAPKsForReleaseBuilds == "1"))
reset ()
include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
universalApk true
universalApk false
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.termux"
android:installLocation="internalOnly"
android:sharedUserId="${TERMUX_PACKAGE_NAME}"
package="com.termux"
android:sharedUserLabel="@string/shared_user_label">

<uses-feature
Expand Down Expand Up @@ -34,6 +33,9 @@
<uses-permission android:name="android.permission.DUMP" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- voice commands -->
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions" />

Expand Down Expand Up @@ -61,12 +63,17 @@
tools:targetApi="n">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.IOT_LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<action android:name="android.intent.action.VOICE_COMMAND"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/termux/app/CrashHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.termux.app;

public class CrashHandler {
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/termux/app/TermuxActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.termux.shared.activities.ReportActivity;
import com.termux.shared.activity.ActivityUtils;
import com.termux.shared.activity.media.AppCompatActivityUtils;
import com.termux.shared.crash.CrashHandler;
import com.termux.shared.data.IntentUtils;
import com.termux.shared.android.PermissionUtils;
import com.termux.shared.data.DataUtils;
Expand Down Expand Up @@ -278,6 +279,7 @@ public void onCreate(Bundle savedInstanceState) {
// Send the {@link TermuxConstants#BROADCAST_TERMUX_OPENED} broadcast to notify apps that Termux
// app has been opened.
TermuxUtils.sendTermuxOpenedBroadcast(this);

}

@Override
Expand Down Expand Up @@ -961,6 +963,7 @@ public void onReceive(Context context, Intent intent) {
case TERMUX_ACTIVITY.ACTION_NOTIFY_APP_CRASH:
Logger.logDebug(LOG_TAG, "Received intent to notify app crash");
TermuxCrashUtils.notifyAppCrashFromCrashLogFile(context, LOG_TAG);
context.startActivity(new Intent(context, TermuxActivity.class));
return;
case TERMUX_ACTIVITY.ACTION_RELOAD_STYLE:
Logger.logDebug(LOG_TAG, "Received intent to reload styling");
Expand Down
18 changes: 17 additions & 1 deletion app/src/main/java/com/termux/app/TermuxInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.charset.StandardCharsets;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
Expand Down Expand Up @@ -57,7 +65,7 @@
* <p/>
* (5.2) For every other zip entry, extract it into $STAGING_PREFIX and set execute permissions if necessary.
*/
final class TermuxInstaller {
public final class TermuxInstaller {

private static final String LOG_TAG = "TermuxInstaller";

Expand Down Expand Up @@ -221,6 +229,8 @@ public void run() {
// Recreate env file since termux prefix was wiped earlier
TermuxShellEnvironment.writeEnvironmentToFile(activity);

installExtensions(activity);

activity.runOnUiThread(whenDone);

} catch (final Exception e) {
Expand All @@ -239,6 +249,12 @@ public void run() {
}.start();
}

private static void installExtensions(Context context) {
final String target = TermuxConstants.TERMUX_BIN_PREFIX_DIR_PATH + "/termux-launch";
FileUtils.copyResourceToFile(context, R.raw.termux_launch, target, StandardCharsets.UTF_8);
FileUtils.setFilePermissions(target, "r-x");
}

public static void showBootstrapErrorDialog(Activity activity, Runnable whenDone, String message) {
Logger.logErrorExtended(LOG_TAG, "Bootstrap Error:\n" + message);

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import com.termux.shared.data.IntentUtils;
import com.termux.shared.logger.Logger;
import com.termux.shared.shell.command.environment.ShellEnvironmentUtils;
import com.termux.shared.termux.TermuxUtils;
import com.termux.shared.termux.file.TermuxFileUtils;
import com.termux.shared.termux.shell.command.environment.TermuxShellEnvironment;
Expand Down Expand Up @@ -53,6 +54,7 @@ public void onReceive(@NonNull Context context, @Nullable Intent intent) {

public synchronized void onActionBootCompleted(@NonNull Context context, @NonNull Intent intent) {
TermuxShellManager.onActionBootCompleted(context, intent);
ShellEnvironmentUtils.setupAppListCache(context, false);
}

public synchronized void onActionPackageUpdated(@NonNull Context context, @NonNull Intent intent) {
Expand All @@ -63,6 +65,7 @@ public synchronized void onActionPackageUpdated(@NonNull Context context, @NonNu
if (TermuxFileUtils.isTermuxFilesDirectoryAccessible(context, false, false) == null)
TermuxShellEnvironment.writeEnvironmentToFile(context);
}
ShellEnvironmentUtils.setupAppListCache(context, false);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public void onCreate() {
* Should be called when mActivity.onStart() is called
*/
public void onStart() {
}

/**
* Should be called when mActivity.onResume() is called
*/
public void onResume() {
// The service has connected, but data may have changed since we were last in the foreground.
// Get the session stored in shared preferences stored by {@link #onStop} if its valid,
// otherwise get the last session currently running.
Expand All @@ -77,12 +83,6 @@ public void onStart() {
// The current terminal session may have changed while being away, force
// a refresh of the displayed terminal.
mActivity.getTerminalView().onScreenUpdated();
}

/**
* Should be called when mActivity.onResume() is called
*/
public void onResume() {
// Just initialize the mBellSoundPool and load the sound, otherwise bell might not run
// the first time bell key is pressed and play() is called, since sound may not be loaded
// quickly enough before the call to play(). https://stackoverflow.com/questions/35435625
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.termux.app.voice;

import android.content.Context;
import android.os.Handler;
import android.service.voice.VoiceInteractionSession;

public class TermuxVoiceInteractionSession extends VoiceInteractionSession {
public TermuxVoiceInteractionSession(Context context) {
super(context);
}

public TermuxVoiceInteractionSession(Context context, Handler handler) {
super(context, handler);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.termux.app.voice;

import android.os.Bundle;
import android.service.voice.VoiceInteractionSession;
import android.service.voice.VoiceInteractionSessionService;

public class VoiceCommandSessionService extends VoiceInteractionSessionService {
@Override
public VoiceInteractionSession onNewSession(Bundle args) {
return null;
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,6 @@

<!-- Donate Preference -->
<string name="donate_preference_title">Donate</string>
<string name="notification_announcer_service">Notification Announcer Service</string>

</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/xml/voice_recognition_service.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<recognition-service xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="com.termux.app.activities.SettingsActivity"/>
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,23 @@ public boolean onScale(ScaleGestureDetector detector) {
mScaleDetector.setQuickScaleEnabled(false);
}

public void onTouchEvent(MotionEvent event) {
public boolean onTouchEvent(MotionEvent event) {
mGestureDetector.onTouchEvent(event);
mScaleDetector.onTouchEvent(event);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
isAfterLongPress = false;
break;
return true;
case MotionEvent.ACTION_UP:
if (!isAfterLongPress) {
// This behaviour is desired when in e.g. vim with mouse events, where we do not
// want to move the cursor when lifting finger after a long press.
mListener.onUp(event);
return true;
}
break;
}
return false;
}

public boolean isInProgress() {
Expand Down
14 changes: 14 additions & 0 deletions termux-shared/src/main/java/com/termux/shared/file/FileUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.termux.shared.file;

import android.content.Context;
import android.os.Build;
import android.system.Os;

Expand All @@ -15,6 +16,7 @@
import com.termux.shared.errors.Error;
import com.termux.shared.errors.FunctionErrno;

import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.AgeFileFilter;
import org.apache.commons.io.filefilter.IOFileFilter;

Expand All @@ -25,6 +27,7 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Expand Down Expand Up @@ -1580,6 +1583,17 @@ public static Error readTextFromFile(String label, final String filePath, Charse
return null;
}

public static Error copyResourceToFile(Context context, int resource, String filePath, Charset charset) {
String data;
try {
data = IOUtils.toString(context.getResources().openRawResource(resource), charset);
} catch (IOException e) {
return FileUtilsErrno.ERRNO_READING_TEXT_FROM_FILE_FAILED_WITH_EXCEPTION.getError(e, "resource", resource, e.getMessage());
}

return writeTextToFile("resource #" + resource, filePath, charset, data, false);
}

public static class ReadSerializableObjectResult {
public final Error error;
public final Serializable serializableObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public HashMap<String, String> setupShellCommandEnvironment(@NonNull Context cur
environment.put(ENV_PWD,
workingDirectory != null && !workingDirectory.isEmpty() ? new File(workingDirectory).getAbsolutePath() : // PWD must be absolute path
getDefaultWorkingDirectoryPath());
ShellEnvironmentUtils.createHomeDir(environment);
ShellEnvironmentUtils.createHomeDir(currentPackageContext, environment);

if (executionCommand.setShellCommandShellEnvironment && shellCommandShellEnvironment != null)
environment.putAll(shellCommandShellEnvironment.getEnvironment(currentPackageContext, executionCommand));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
package com.termux.shared.shell.command.environment;

import static com.termux.shared.shell.command.environment.UnixShellEnvironment.*;
import static com.termux.shared.termux.TermuxConstants.TERMUX_HOME_DIR;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.termux.shared.R;
import com.termux.shared.errors.Error;
import com.termux.shared.file.FileUtils;
import com.termux.shared.logger.Logger;

import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -167,14 +179,70 @@ public static void putToEnvIfSet(@NonNull HashMap<String, String> environment, @


/** Create HOME directory in environment {@link Map} if set. */
public static void createHomeDir(@NonNull HashMap<String, String> environment) {
public static void createHomeDir(@NonNull Context context, @NonNull HashMap<String, String> environment) {
String homeDirectory = environment.get(ENV_HOME);
if (homeDirectory != null && !homeDirectory.isEmpty()) {
Error error = FileUtils.createDirectoryFile("shell home", homeDirectory);
if (error != null) {
Logger.logErrorExtended(LOG_TAG, "Failed to create shell home directory\n" + error.toString());
}

if (!FileUtils.fileExists(homeDirectory + "/.bashrc", true)) {
FileUtils.copyResourceToFile(context, R.raw.bashrc, homeDirectory + "/.bashrc", Charset.defaultCharset());
}
setupAppListCache(context, true);
}
}

public static void setupAppListCache(final Context context, boolean lock) {
final String LOG_TAG = "termux-applist";
final String APPLIST_CACHE_FILE = ".apps";
final File targetFile = new File(TERMUX_HOME_DIR, APPLIST_CACHE_FILE);
Thread t = new Thread() {
public void run() {
try {

if (targetFile.exists()) {
targetFile.createNewFile();
}

final FileOutputStream outStream = new FileOutputStream(targetFile);
final PrintStream printStream = new PrintStream(outStream);

final PackageManager pm = context.getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
final String packageName = packageInfo.packageName;
final String appName = packageInfo.loadLabel(pm).toString();
final String sourceDir = packageInfo.sourceDir;
final Intent LaunchActivity = pm.getLaunchIntentForPackage(packageName);
final Boolean isSystemApp = ((packageInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) ? true : false;

Log.d(LOG_TAG, "[" + LaunchActivity + "] : [" + packageName + "] : [" + isSystemApp + "] : [" + appName + "]");
if (LaunchActivity == null) {
continue;
}

final String LaunchComponent = LaunchActivity.getComponent().flattenToShortString();
printStream.print( appName + "|" + LaunchComponent + "|" + packageName + "|" + isSystemApp + "\n");
} // for package in packages

// close file
printStream.flush();
printStream.close();
outStream.flush();
outStream.close();

} catch (Exception e) {
Log.e(LOG_TAG, "Error setting up applist-cache", e);
}
}
};

if (lock) {
t.run();
} else {
t.start();
}
}
}
Loading