How to setup complex toolbar buttons

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
SkipR
Junior Member
Junior Member
Posts: 69
Joined: 2008-03-27, 10:39 UTC
Location: W. Australia

How to setup complex toolbar buttons

Post by *SkipR »

Issue 1:
I would like to setup a button that starts an app called "terminal emulator for Android" - https://play.google.com/store/apps/details?id=jackpal.androidterm and opens terminal shell in current directory I am looking at in TC for Android (TCA) folder view. I found this note about the app's command line but I don't know how to relate this to TCA button settings - https://github.com/jackpal/Android-Terminal-Emulator/wiki/Launching-Terminal-Emulator-for-Android-from-another-App as this is written for an app developer. I have looked at the TCA help but I don't understand when to use which options or how to find out what apps accept parameters other than trial and error. Is there something out there that explains this to a non developer user?

Potentially 28 possible combinations function type & parameters - obviously some combinations would not make sense. In Windows a toolbar button could not be any easier to setup.

Function type:
  1. Launch app (main function)
  2. View file with app
  3. Send to app
  4. 8 ways to pass parameters to apps
Available Parameters in help lists:
  1. file:/path/name
  2. url:http://www.server.com
  3. stream:/path/name
  4. type:text/plain
  5. extra0:NAME:data
  6. extra2:NAME:data
  7. list:NAME
I expected "send to app" is only right choice and tried these parameter tests:
extra:TEXT:"cd %P"
extra:iInitialCommand:cd %P
extra0:jackpal.androidterm.iInitialCommand:cd %P
Can some tell me which one is likely to work I have tried a few but shell is always opening in "/" (Samsung S4 AOS 5.0.1, no root access)?

Edit: I just found thread https://www.ghisler.ch/board/viewtopic.php?t=30393 so was it fixed sometime in the past or is it still a problem?

Is jackpal.androidterm.permission.RUN_SCRIPT permission mentioned on github link above the issue?

Is there another way to set working directory when an app is started?

Issue 2:
I want to setup a button that will pass a text file created in by a shell command to an Android app Jota Text Editor.

(I am not an Android developer)
Last edited by SkipR on 2017-12-24, 16:55 UTC, edited 1 time in total.
Skip
User avatar
SkipR
Junior Member
Junior Member
Posts: 69
Joined: 2008-03-27, 10:39 UTC
Location: W. Australia

Post by *SkipR »

Here is how I figured out an answer for Issue 2 mainly by experimenting.

I worked out first part noting output has to go to internal storage, and command fails when it hits certain directory on scan of "/".

Function type: Send shell command
Command: sh
parameters:
ls -alR %P > /storage/emulated/0/documents/dir_$$.txt"
To open output file it in jota text editor (android app) - https://play.google.com/store/apps/details?id=jp.sblo.pandora.jota or similar like parameters:
ls -alR %P > /storage/emulated/0/documents/test.txt & something-cmd /storage/emulated/0/documents/test.txt
Here is what I have researched there are two ways:

Code: Select all

am start -a <ACTION> -n <COMPONENT>
am start -n <COMPONENT>
where ACTION is like package-name.action_name
COMPONENT is like package-name/package-name.ActivityName
ref: https://stackoverflow.com/a/6613947/1473017

To get these values I used app ES explorer app to create a backup APK file , I looked at Androidmanifest.xml file in zipped package (it did not look like a proper text XML that a browser could decode but I could see these text strings:

Code: Select all

application
jp.sblo.pandora.jota.JotaTextEditor
activity
jp.sblo.pandora.jota.Main
intent-filter
action
android.intent.action.MAIN
category
android.intent.category.LAUNCHER
android.intent.action.VIEW
android.intent.category.DEFAULT
data
file
content
text
android.intent.action.SEND
com.googlecode.android_scripting.action.EDIT_SCRIPT
jp.sblo.pandora.jota.MainForResult
android.intent.action.GET_CONTENT
jp.sblo.pandora.jota.FileSelectorActivity
jp.sblo.pandora.jota.ActivityPicker
jp.sblo.pandora.jota.AboutActivity
jp.sblo.pandora.jota.SettingsActivity
jp.sblo.pandora.jota.SettingsShortcutActivity
jp.sblo.pandora.jota.SettingsToolbarActivity
jp.sblo.pandora.jota.RecoveryActivity
jp.sblo.pandora.jota.PreviewThemeActivity
ref: https://stackoverflow.com/a/2903954/1473017


Tried this in terminal emulater rather than adb shell:

Code: Select all

am start --user 0 -n jp.sblo.pandora.jota/.Main
I tried many variations and this was the only one I found that worked.

In TCA button you pass parameter

Code: Select all

file:%P%N
I tried the am "-d" option but that did not work. I Found this worked:

Code: Select all

am start --user 0 -n jp.sblo.pandora.jota/.Main  file:/storage/emulated/0/documents/init.sh
so that just leaves the first question.

(--user 0 was to fix a specific error message)
Skip
User avatar
SkipR
Junior Member
Junior Member
Posts: 69
Joined: 2008-03-27, 10:39 UTC
Location: W. Australia

Re: How to setup complex toolbar buttons

Post by *SkipR »

SkipR wrote:Issue 1:
...
Is there another way to set working directory when an app is started?
I thought about using a shell command to set directory and then launch the app. I tried starting Terminal emulator from the button with shell command basing it on how TCA button can directly launch the app:

Code: Select all

am start --user 0 -n jackpal.androidterm /.TermHere
That crashes Terminal Emulator with the generic screen "Unfortunately <app> has stopped. [REPORT] [OK]" system info mentions "NullPointerException" class ".RemoteInterface" method "handleIntent" line 113 so something is missing from the start call ??
Tried:

Code: Select all

am start --user 0 -a jackpal.androidterm.OPEN_NEW_WINDOW
which opens a new instance of terminal emulator but still has wrong working dir. Tried RUN_SCRIPT but don't know how to pass command to it
ref: https://github.com/jackpal/Android-Terminal-Emulator/blob/master/term/src/main/AndroidManifest.xml
Any suggestiions?
Post Reply