Hi Viktor!
Я
Hello. On the forum, you wrote that you provide a sample plugin so that
everyone else can make them. Can you send them to me?
My E-Mail is: ***
Name: Victor
OK, here is a small sample plugin which just mirrors the file
system:
https://ghisler.filebu…id/tcsampleplugin2.zipTo write your own plugin, unpack this project to a directory under your
Android Studio project directory. Make sure to give it a meaningful
name!
Then choose in Android Studio:
- File - Open
- Choose directory with the Plugin
- OK
To create your own plugin, you need to rename the project name.
Important: Google doesn't accept names starting with
com.android or com.google in the play store!
1. Click on "1. Project" to see the project.
2. Open the file AndroidManifest.xml
3. Change the text package="com.ghisler.tcplugins.sample" to
package="com.yourpluginname"
4. Open the file build.gradle (module app)
5. Change the text applicationId "com.ghisler.tcplugins.sample" to
applicationId "com.yourpluginname"
6. change the string "com.ghisler.tcplugins.sample.R" to
"com.yourpluginname.R" in the files:
PluginFunctions.java
PluginService.java
7. Change the display name in res - values - strings.xml:
<string name="app_name">TcSamplePlugin</string>
8. In "Run" - "Edit configurations", set "Launch" to "nothing"
Now you should be able to start the test plugin:
Pres the "play" button in Android Studio. This will
just install the plugin, it will not run anything.
You can see it in the TC home folder and use it.
PluginFunctions contains the Functions called by
Total Commander. The function names should sufficiently
explain what the functions do. First, you should
implement the function getDirectoryList, then you can
browse through the file system.
I suggest that you don't set targetSdkVersion to
a value higher than 29, otherwise you can no longer
access the file system. If you want to put the plugin
in the Play Store, you must target 32 or higher. Then
you need to return
FS_REQUIRES_CONTENT_URLS |
FS_SUPPORTS_CONTENT_URLS
to receive content: URLs instead of paths to the
file system for uploads and downloads. Opening
a content URL is almost as easy as a local file.
For uploads, open the local file like this:
Uri uri=Uri.parse(filename);
if (uri==null)
return null;
try {
ContentResolver resolver=context.getContentResolver();
return resolver.openInputStream(uri);
} catch (Throwable e) {
return null;
}
or for downloads, call:
return resolver.openOutputStream(uri,"wt");
The PicoServer.java file is a very simple web server,
used to stream the files to a Media Player (optional).
With the getSupportedFunctions function you can tell
Total Commander which features your Plugin supports.
If you want to write a plugin that supports different
Servers like some of my plugin, I can send the code
for the WebDAV plugin. This is probably most suitable
as a base. It contains classes to manage multiple
servers.
The functions are all called from a background thread,
and may block as much as they want. Total Commander calls
setAbortFlag from the foreground thread when the user
clicks Cancel, so use that to set a flag to abort the
operation.
registerCallbacks passes 2 callback functions over which
you can report the copying progress, and make TC show
message boxes in the context of TC's main window.
Just ask if you have questions about the functions.
Best regards
Christian Ghisler