fix: exposed uri error
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:name=".external.fileprovider.AppFileProvider"
|
||||
android:authorities="org.autojs.autojs.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
|
||||
16
app/src/main/java/org/autojs/autojs/external/fileprovider/AppFileProvider.java
vendored
Normal file
16
app/src/main/java/org/autojs/autojs/external/fileprovider/AppFileProvider.java
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
package org.autojs.autojs.external.fileprovider;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.content.FileProvider;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class AppFileProvider extends FileProvider {
|
||||
|
||||
public static final String AUTHORITY = "org.autojs.autojs.fileprovider";
|
||||
|
||||
public static Uri getUriForFile(Context context, File file){
|
||||
return FileProvider.getUriForFile(context, AUTHORITY, file);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,13 @@ import com.stardust.autojs.execution.ScriptExecutionListener;
|
||||
import com.stardust.autojs.execution.SimpleScriptExecutionListener;
|
||||
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
|
||||
import com.stardust.autojs.script.ScriptSource;
|
||||
import com.stardust.util.IntentUtil;
|
||||
|
||||
import org.autojs.autojs.Pref;
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.autojs.AutoJs;
|
||||
import org.autojs.autojs.external.ScriptIntents;
|
||||
import org.autojs.autojs.external.fileprovider.AppFileProvider;
|
||||
import org.autojs.autojs.external.shortcut.Shortcut;
|
||||
import org.autojs.autojs.external.shortcut.ShortcutActivity;
|
||||
import org.autojs.autojs.ui.edit.EditActivity;
|
||||
@@ -71,8 +73,7 @@ public class Scripts {
|
||||
|
||||
|
||||
public static void openByOtherApps(String path) {
|
||||
Uri uri = Uri.parse("file://" + path);
|
||||
GlobalAppContext.get().startActivity(new Intent(Intent.ACTION_VIEW).setDataAndType(uri, "text/plain").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
IntentUtil.viewFile(GlobalAppContext.get(), path, "text/plain", AppFileProvider.AUTHORITY);
|
||||
}
|
||||
|
||||
public static void openByOtherApps(File file) {
|
||||
@@ -111,8 +112,8 @@ public class Scripts {
|
||||
public static ScriptExecution run(ScriptSource source) {
|
||||
try {
|
||||
return AutoJs.getInstance().getScriptEngineService().execute(source, new ExecutionConfig()
|
||||
.executePath(Pref.getScriptDirPath())
|
||||
.requirePath(Pref.getScriptDirPath()));
|
||||
.executePath(Pref.getScriptDirPath())
|
||||
.requirePath(Pref.getScriptDirPath()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(GlobalAppContext.get(), e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
|
||||
@@ -5,10 +5,8 @@ import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.util.BackPressedHandler;
|
||||
import com.stardust.util.IntentUtil;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
@@ -16,6 +14,7 @@ import org.androidannotations.annotations.EFragment;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
import org.autojs.autojs.Pref;
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.external.fileprovider.AppFileProvider;
|
||||
import org.autojs.autojs.model.explorer.ExplorerDirPage;
|
||||
import org.autojs.autojs.model.explorer.Explorers;
|
||||
import org.autojs.autojs.model.script.Scripts;
|
||||
@@ -28,7 +27,6 @@ import org.autojs.autojs.ui.main.ViewPagerFragment;
|
||||
import org.autojs.autojs.ui.project.ProjectConfigActivity;
|
||||
import org.autojs.autojs.ui.project.ProjectConfigActivity_;
|
||||
import org.autojs.autojs.ui.viewmodel.ExplorerItemList;
|
||||
import org.autojs.autojs.ui.widget.ExpandableRecyclerView;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
@@ -66,7 +64,7 @@ public class MyScriptListFragment extends ViewPagerFragment implements FloatingA
|
||||
if (item.isEditable()) {
|
||||
Scripts.edit(item.toScriptFile());
|
||||
} else {
|
||||
IntentUtil.viewFile(GlobalAppContext.get(), item.getPath());
|
||||
IntentUtil.viewFile(GlobalAppContext.get(), item.getPath(), AppFileProvider.AUTHORITY);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="external_files" path="."/>
|
||||
<files-path name="sample" path="sample"/>
|
||||
<root-path name="root_files" path="." />
|
||||
</paths>
|
||||
Reference in New Issue
Block a user