zhanghai / MaterialFiles

Material Design file manager for Android
https://play.google.com/store/apps/details?id=me.zhanghai.android.files
GNU General Public License v3.0
5.33k stars 371 forks source link

Prompt user when terminal not installed and support more terminals. #32

Open zhanghai opened 5 years ago

Ilia1 commented 4 years ago

Connectbot terminal support possible? https://github.com/connectbot/connectbot

zhanghai commented 4 years ago

No, ConnectBot doesn't allow specifying an initial path.

linsui commented 3 years ago

Does this method work for Termux?

ioogithub commented 3 years ago

Which terminals are compatible with this feature? I have several and none of them seem to work. Please let me know which ones work and I will install and test them.

My preferred terminal would be Termux.

zhanghai commented 3 years ago

Currently only jackpal/Android-Terminal-Emulator supports this feature. I've replied to the Termux issue at https://github.com/termux/termux-app/issues/1070#issuecomment-731920021

Android-X13 commented 2 years ago

Hello @zhanghai. As you know issue #1070 is already 3 years old but I bet that most users who would like to open a terminal would prefer to use Termux these days. I've read your comment in that thread but until (and if) they implement your suggestions, I see no reason why not to include the proposed solution in your app:

am startservice --user 0 \
-n com.termux/com.termux.app.RunCommandService \
-a com.termux.RUN_COMMAND \
--es com.termux.RUN_COMMAND_PATH '/data/data/com.termux/files/usr/bin/login' \
--es com.termux.RUN_COMMAND_WORKDIR "$FOLDER_PATH" \
--ez com.termux.RUN_COMMAND_BACKGROUND 'false'

I have actually placed this along with some other code inside a background task (~/.shortcuts/tasks) which I have added in my home screen. First I copy the folder's path from your app, then I run this task and it displays a termux input dialog where I paste that path. If the path is legit it then runs the above command which opens an interactive Termux session at the specified location, otherwise it shows an error dialog. Obviously if you decide to integrate Termux in your app then I will have no use for that task anymore as it will be much more convenient to open the path directly from Material Files.

SESSION NAME

As you probably know when we open a new interactive Termux session its name is briefly displayed in a toast and it's also permanently shown in the sidebar as a digit between square brackets. However if you open a Termux session with the RUN_COMMAND Intent, the name will be the session counter + the name of the command that was run, and this will be reflected to both the toast and the sidebar. So when calling Termux from your app, the session name will either be [X] login or [X] bash.

Unfortunately I don't think there's a way to change this name programmatically, but if you want to add something to the sidebar's name so that users are able to identify sessions opened by your app (in case there are already many sessions open), then you can use something like this, modified for Java accordingly:

am startservice --user 0 \
-n com.termux/com.termux.app.RunCommandService \
-a com.termux.RUN_COMMAND \
--es com.termux.RUN_COMMAND_PATH '/data/data/com.termux/files/usr/bin/bash' \
--esa com.termux.RUN_COMMAND_ARGUMENTS '-c, echo -en "\e]0;Material Files\a"; $SHELL' \
--es com.termux.RUN_COMMAND_WORKDIR "$FOLDER_PATH" \
--ez com.termux.RUN_COMMAND_BACKGROUND 'false'

So in this case the session name will be displayed in the sidebar like so:

[X] bash Material Files

PERMISSIONS

As for the permissions perhaps you could display successive dialogs to the user when setting up the terminal, each one requesting a separate permission. I count 3 permissions needed of which only one is on your app's side, so firstly you can request to be granted the com.termux.permission.RUN_COMMAND for Material Files, then a dialog to enable Draw Over Apps for Termux, and finally an instruction to enable allow-external-apps for Termux. Most users who would like to open a folder in Termux will probably already have configured these last two anyway.

P.S. Thanks for your great app

SodaWithoutSparkles commented 1 year ago

Any updates? It has been half a year since the last update.

babaric-dev commented 1 year ago

901

b2sql commented 1 month ago

Currently only jackpal/Android-Terminal-Emulator supports this feature. I've replied to the Termux issue at termux/termux-app#1070 (comment)

This app is archived and won't get installed on Android 14. Any other terminal apps working with material files?