plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

`opener` can only open URLs.

Open NyaomiDEV opened this issue 10 months ago • 1 comments

When a local app-owned file path is passed to the opener plugin, it will tell us that there's no Activity that can open that uri. This is because FileProvider is not used, therefore a local uri is never converted to a ContentProvider uri, and therefore other apps cannot open our local files.

This code would work btw

import android.content.Intent
import androidx.core.content.FileProvider
import java.io.File
[...]

    fun openPath(path: String) {
        try {
            val file = File(path);
            val uri = FileProvider.getUriForFile(activity, activity.packageName + ".fileprovider", file);
            val intent = Intent(Intent.ACTION_VIEW);
            intent.setData(uri);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            activity.applicationContext?.startActivity(intent);
        }catch (e: Exception){
            
        }
    }

NyaomiDEV avatar Feb 01 '25 19:02 NyaomiDEV

(changed from bug to enhancement because this limitation is documented)

FabianLars avatar Feb 02 '25 15:02 FabianLars