fix some many bugs
This commit is contained in:
@@ -7,6 +7,7 @@ import com.stardust.scriptdroid.model.indices.Modules;
|
|||||||
import com.stardust.scriptdroid.model.indices.Property;
|
import com.stardust.scriptdroid.model.indices.Property;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -120,6 +121,8 @@ public class AutoCompletion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<CodeCompletion> findCodeCompletionForGlobal(String propertyPrefill) {
|
private List<CodeCompletion> findCodeCompletionForGlobal(String propertyPrefill) {
|
||||||
|
if (propertyPrefill == null)
|
||||||
|
return Collections.emptyList();
|
||||||
List<DictionaryTree.Entry<Property>> result = mGlobalPropertyTree.searchByPrefill(propertyPrefill);
|
List<DictionaryTree.Entry<Property>> result = mGlobalPropertyTree.searchByPrefill(propertyPrefill);
|
||||||
List<CodeCompletion> completions = new ArrayList<>();
|
List<CodeCompletion> completions = new ArrayList<>();
|
||||||
for (DictionaryTree.Entry<Property> entry : result) {
|
for (DictionaryTree.Entry<Property> entry : result) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.stardust.scriptdroid.network.api.DownloadApi;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,8 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCaptureAvailable(NodeInfo capture) {
|
public void onCaptureAvailable(NodeInfo capture) {
|
||||||
mCaptureDeferred.resolve(capture);
|
if (mCaptureDeferred != null && mCaptureDeferred.isPending())
|
||||||
|
mCaptureDeferred.resolve(capture);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean ensureCapture() {
|
private boolean ensureCapture() {
|
||||||
|
|||||||
@@ -50,6 +50,13 @@ public class FloatyWindowManger {
|
|||||||
return sCircularMenu != null && sCircularMenu.get() != null;
|
return sCircularMenu != null && sCircularMenu.get() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showCircularMenuIfNeeded() {
|
||||||
|
if (isCircularMenuShowing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showCircularMenu();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean showCircularMenu() {
|
public static boolean showCircularMenu() {
|
||||||
if (!SettingsCompat.canDrawOverlays(App.getApp())) {
|
if (!SettingsCompat.canDrawOverlays(App.getApp())) {
|
||||||
Toast.makeText(App.getApp(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
Toast.makeText(App.getApp(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
|||||||
ThemeColorManager.addViewBackground(mHeaderView);
|
ThemeColorManager.addViewBackground(mHeaderView);
|
||||||
initMenuItems();
|
initMenuItems();
|
||||||
if (Pref.isFloatingMenuShown()) {
|
if (Pref.isFloatingMenuShown()) {
|
||||||
FloatyWindowManger.showCircularMenu();
|
FloatyWindowManger.showCircularMenuIfNeeded();
|
||||||
setChecked(mFloatingWindowItem, true);
|
setChecked(mFloatingWindowItem, true);
|
||||||
}
|
}
|
||||||
setChecked(mConnectionItem, DevPluginService.getInstance().isConnected());
|
setChecked(mConnectionItem, DevPluginService.getInstance().isConnected());
|
||||||
@@ -164,12 +164,20 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
|||||||
.me()
|
.me()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe((user ->
|
.subscribe(user -> {
|
||||||
WebActivity_.intent(this)
|
if (getActivity() == null)
|
||||||
.extra(WebActivity.EXTRA_URL, NodeBB.url("user/" + user.getUserslug()))
|
return;
|
||||||
.extra(Intent.EXTRA_TITLE, user.getUsername())
|
WebActivity_.intent(this)
|
||||||
.start()),
|
.extra(WebActivity.EXTRA_URL, NodeBB.url("user/" + user.getUserslug()))
|
||||||
error -> LoginActivity_.intent(getActivity()).start());
|
.extra(Intent.EXTRA_TITLE, user.getUsername())
|
||||||
|
.start();
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
if (getActivity() == null)
|
||||||
|
return;
|
||||||
|
LoginActivity_.intent(getActivity()).start();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,8 @@ public class MyScriptListFragment extends ViewPagerFragment implements BackPress
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(FloatingActionButton button, int pos) {
|
public void onClick(FloatingActionButton button, int pos) {
|
||||||
|
if (mScriptFileList == null)
|
||||||
|
return;
|
||||||
switch (pos) {
|
switch (pos) {
|
||||||
case 0:
|
case 0:
|
||||||
new ScriptOperations(getContext(), mScriptFileList, mScriptFileList.getCurrentDirectory())
|
new ScriptOperations(getContext(), mScriptFileList, mScriptFileList.getCurrentDirectory())
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import android.support.annotation.Nullable;
|
|||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.stardust.autojs.runtime.exception.ScriptException;
|
||||||
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
|
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
|
||||||
import com.stardust.util.ScreenMetrics;
|
import com.stardust.util.ScreenMetrics;
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ public class ScreenCapturer {
|
|||||||
private volatile Image mUnderUsingImage;
|
private volatile Image mUnderUsingImage;
|
||||||
private volatile Image mCachedImage;
|
private volatile Image mCachedImage;
|
||||||
private volatile boolean mImageAvailable = false;
|
private volatile boolean mImageAvailable = false;
|
||||||
|
private volatile Exception mException;
|
||||||
private final int mScreenWidth;
|
private final int mScreenWidth;
|
||||||
private final int mScreenHeight;
|
private final int mScreenHeight;
|
||||||
private final int mScreenDensity;
|
private final int mScreenDensity;
|
||||||
@@ -82,18 +84,23 @@ public class ScreenCapturer {
|
|||||||
|
|
||||||
private void setImageListener(Handler handler) {
|
private void setImageListener(Handler handler) {
|
||||||
mImageReader.setOnImageAvailableListener(reader -> {
|
mImageReader.setOnImageAvailableListener(reader -> {
|
||||||
if (mCachedImage != null) {
|
try {
|
||||||
synchronized (mCachedImageLock) {
|
if (mCachedImage != null) {
|
||||||
if (mCachedImage != null) {
|
synchronized (mCachedImageLock) {
|
||||||
mCachedImage.close();
|
if (mCachedImage != null) {
|
||||||
|
mCachedImage.close();
|
||||||
|
}
|
||||||
|
mCachedImage = reader.acquireLatestImage();
|
||||||
|
mImageAvailable = true;
|
||||||
|
mCachedImageLock.notify();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
mCachedImage = reader.acquireLatestImage();
|
|
||||||
mImageAvailable = true;
|
|
||||||
mCachedImageLock.notify();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
mCachedImage = reader.acquireLatestImage();
|
||||||
|
} catch (Exception e) {
|
||||||
|
mException = e;
|
||||||
}
|
}
|
||||||
mCachedImage = reader.acquireLatestImage();
|
|
||||||
}, handler);
|
}, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +109,11 @@ public class ScreenCapturer {
|
|||||||
if (!mImageAvailable) {
|
if (!mImageAvailable) {
|
||||||
waitForImageAvailable();
|
waitForImageAvailable();
|
||||||
}
|
}
|
||||||
|
if (mException != null) {
|
||||||
|
Exception e = mException;
|
||||||
|
mException = null;
|
||||||
|
throw new ScriptException(e);
|
||||||
|
}
|
||||||
synchronized (mCachedImageLock) {
|
synchronized (mCachedImageLock) {
|
||||||
if (mCachedImage != null) {
|
if (mCachedImage != null) {
|
||||||
if (mUnderUsingImage != null)
|
if (mUnderUsingImage != null)
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import android.app.Activity;
|
|||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.pm.ServiceInfo;
|
||||||
import android.content.pm.Signature;
|
import android.content.pm.Signature;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
@@ -73,14 +75,38 @@ public class DeveloperUtils {
|
|||||||
|
|
||||||
|
|
||||||
public static boolean isActivityRegistered(Context context, Class<? extends Activity> c) {
|
public static boolean isActivityRegistered(Context context, Class<? extends Activity> c) {
|
||||||
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(new Intent(context, c),
|
try {
|
||||||
PackageManager.MATCH_DEFAULT_ONLY);
|
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES);
|
||||||
return list != null && list.size() > 0;
|
ActivityInfo[] activities = packageInfo.activities;
|
||||||
|
if (activities == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (ActivityInfo info : activities) {
|
||||||
|
if (c.getName().equals(info.name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isServiceRegistered(Context context, Class<? extends Service> c) {
|
public static boolean isServiceRegistered(Context context, Class<? extends Service> c) {
|
||||||
List<ResolveInfo> list = context.getPackageManager().queryIntentServices(new Intent(context, c),
|
try {
|
||||||
PackageManager.MATCH_DEFAULT_ONLY);
|
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SERVICES);
|
||||||
return list != null && list.size() > 0;
|
ServiceInfo[] activities = packageInfo.services;
|
||||||
|
if (activities == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (ServiceInfo info : activities) {
|
||||||
|
if (c.getName().equals(info.name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user