新增 app.intent()支持flags
This commit is contained in:
1
.idea/dictionaries/Stardust.xml
generated
1
.idea/dictionaries/Stardust.xml
generated
@@ -4,6 +4,7 @@
|
|||||||
<w>autojs</w>
|
<w>autojs</w>
|
||||||
<w>capturer</w>
|
<w>capturer</w>
|
||||||
<w>dismissable</w>
|
<w>dismissable</w>
|
||||||
|
<w>fileprovider</w>
|
||||||
<w>flowable</w>
|
<w>flowable</w>
|
||||||
<w>imgproc</w>
|
<w>imgproc</w>
|
||||||
<w>interruptible</w>
|
<w>interruptible</w>
|
||||||
|
|||||||
@@ -29,6 +29,17 @@ module.exports = function(runtime, global){
|
|||||||
}
|
}
|
||||||
intent.setAction(i.action);
|
intent.setAction(i.action);
|
||||||
}
|
}
|
||||||
|
if (i.flags) {
|
||||||
|
let flags = 0;
|
||||||
|
if (Array.isArray(i.flags)) {
|
||||||
|
for (let j = 0; j < i.flags.length; j++) {
|
||||||
|
flags |= parseIntentFlag(i.flags[j]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
flags = parseIntentFlag(i.flags);
|
||||||
|
}
|
||||||
|
intent.setFlags(flags);
|
||||||
|
}
|
||||||
if (i.type) {
|
if (i.type) {
|
||||||
if (i.data) {
|
if (i.data) {
|
||||||
intent.setDataAndType(android.net.Uri.parse(i.data), i.type);
|
intent.setDataAndType(android.net.Uri.parse(i.data), i.type);
|
||||||
@@ -110,8 +121,12 @@ module.exports = function(runtime, global){
|
|||||||
if (path.startsWith("file://")) {
|
if (path.startsWith("file://")) {
|
||||||
path = path.substring(7);
|
path = path.substring(7);
|
||||||
}
|
}
|
||||||
|
let file = new java.io.File(files.path(path));
|
||||||
|
if (app.fileProviderAuthority == null) {
|
||||||
|
return android.net.Uri.fromFile(file);
|
||||||
|
}
|
||||||
return android.support.v4.content.FileProvider.getUriForFile(context,
|
return android.support.v4.content.FileProvider.getUriForFile(context,
|
||||||
"org.autojs.autojs.fileprovider", new java.io.File(files.path(path)));
|
app.fileProviderAuthority, file);
|
||||||
};
|
};
|
||||||
|
|
||||||
app.launch = app.launchPackage;
|
app.launch = app.launchPackage;
|
||||||
@@ -126,6 +141,13 @@ module.exports = function(runtime, global){
|
|||||||
|
|
||||||
global.__asGlobal__(app, ['launchPackage', 'launch', 'launchApp', 'getPackageName', 'getAppName', 'openAppSetting']);
|
global.__asGlobal__(app, ['launchPackage', 'launch', 'launchApp', 'getPackageName', 'getAppName', 'openAppSetting']);
|
||||||
|
|
||||||
|
function parseIntentFlag(flag) {
|
||||||
|
if (typeof (flag) == 'string') {
|
||||||
|
return android.content.Intent["FLAG_" + flag.toUpperCase()];
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.FileProvider;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ import com.stardust.autojs.annotation.ScriptInterface;
|
|||||||
import com.stardust.util.IntentUtil;
|
import com.stardust.util.IntentUtil;
|
||||||
import com.stardust.util.MimeTypes;
|
import com.stardust.util.MimeTypes;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -92,6 +94,10 @@ public class AppUtils {
|
|||||||
return IntentUtil.goToAppDetailSettings(mContext, packageName);
|
return IntentUtil.goToAppDetailSettings(mContext, packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFileProviderAuthority() {
|
||||||
|
return mFileProviderAuthority;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Activity getCurrentActivity() {
|
public Activity getCurrentActivity() {
|
||||||
Log.d("App", "getCurrentActivity: " + mCurrentActivity.get());
|
Log.d("App", "getCurrentActivity: " + mCurrentActivity.get());
|
||||||
|
|||||||
@@ -150,7 +150,6 @@ public class IntentUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean viewFile(Context context, String path, String mimeType, String fileProviderAuthority) {
|
public static boolean viewFile(Context context, String path, String mimeType, String fileProviderAuthority) {
|
||||||
|
|||||||
Reference in New Issue
Block a user