fix some many bugs

This commit is contained in:
hyb1996
2018-02-04 16:18:05 +08:00
parent 2e1f09061c
commit 204acdaf82
8 changed files with 83 additions and 23 deletions

View File

@@ -7,6 +7,7 @@ import com.stardust.scriptdroid.model.indices.Modules;
import com.stardust.scriptdroid.model.indices.Property;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -120,6 +121,8 @@ public class AutoCompletion {
}
private List<CodeCompletion> findCodeCompletionForGlobal(String propertyPrefill) {
if (propertyPrefill == null)
return Collections.emptyList();
List<DictionaryTree.Entry<Property>> result = mGlobalPropertyTree.searchByPrefill(propertyPrefill);
List<CodeCompletion> completions = new ArrayList<>();
for (DictionaryTree.Entry<Property> entry : result) {

View File

@@ -9,6 +9,7 @@ import com.stardust.scriptdroid.network.api.DownloadApi;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketTimeoutException;
import java.net.URLDecoder;
import java.util.concurrent.ConcurrentHashMap;

View File

@@ -214,7 +214,8 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
@Override
public void onCaptureAvailable(NodeInfo capture) {
mCaptureDeferred.resolve(capture);
if (mCaptureDeferred != null && mCaptureDeferred.isPending())
mCaptureDeferred.resolve(capture);
}
private boolean ensureCapture() {

View File

@@ -50,6 +50,13 @@ public class FloatyWindowManger {
return sCircularMenu != null && sCircularMenu.get() != null;
}
public static void showCircularMenuIfNeeded() {
if (isCircularMenuShowing()) {
return;
}
showCircularMenu();
}
public static boolean showCircularMenu() {
if (!SettingsCompat.canDrawOverlays(App.getApp())) {
Toast.makeText(App.getApp(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();

View File

@@ -131,7 +131,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
ThemeColorManager.addViewBackground(mHeaderView);
initMenuItems();
if (Pref.isFloatingMenuShown()) {
FloatyWindowManger.showCircularMenu();
FloatyWindowManger.showCircularMenuIfNeeded();
setChecked(mFloatingWindowItem, true);
}
setChecked(mConnectionItem, DevPluginService.getInstance().isConnected());
@@ -164,12 +164,20 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
.me()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe((user ->
WebActivity_.intent(this)
.extra(WebActivity.EXTRA_URL, NodeBB.url("user/" + user.getUserslug()))
.extra(Intent.EXTRA_TITLE, user.getUsername())
.start()),
error -> LoginActivity_.intent(getActivity()).start());
.subscribe(user -> {
if (getActivity() == null)
return;
WebActivity_.intent(this)
.extra(WebActivity.EXTRA_URL, NodeBB.url("user/" + user.getUserslug()))
.extra(Intent.EXTRA_TITLE, user.getUsername())
.start();
},
error -> {
if (getActivity() == null)
return;
LoginActivity_.intent(getActivity()).start();
}
);
}

View File

@@ -163,6 +163,8 @@ public class MyScriptListFragment extends ViewPagerFragment implements BackPress
@Override
public void onClick(FloatingActionButton button, int pos) {
if (mScriptFileList == null)
return;
switch (pos) {
case 0:
new ScriptOperations(getContext(), mScriptFileList, mScriptFileList.getCurrentDirectory())

View File

@@ -17,6 +17,7 @@ import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.Log;
import com.stardust.autojs.runtime.exception.ScriptException;
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
import com.stardust.util.ScreenMetrics;
@@ -35,6 +36,7 @@ public class ScreenCapturer {
private volatile Image mUnderUsingImage;
private volatile Image mCachedImage;
private volatile boolean mImageAvailable = false;
private volatile Exception mException;
private final int mScreenWidth;
private final int mScreenHeight;
private final int mScreenDensity;
@@ -82,18 +84,23 @@ public class ScreenCapturer {
private void setImageListener(Handler handler) {
mImageReader.setOnImageAvailableListener(reader -> {
if (mCachedImage != null) {
synchronized (mCachedImageLock) {
if (mCachedImage != null) {
mCachedImage.close();
try {
if (mCachedImage != null) {
synchronized (mCachedImageLock) {
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);
}
@@ -102,6 +109,11 @@ public class ScreenCapturer {
if (!mImageAvailable) {
waitForImageAvailable();
}
if (mException != null) {
Exception e = mException;
mException = null;
throw new ScriptException(e);
}
synchronized (mCachedImageLock) {
if (mCachedImage != null) {
if (mUnderUsingImage != null)

View File

@@ -5,9 +5,11 @@ import android.app.Activity;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
import android.support.annotation.Nullable;
import android.util.Base64;
@@ -73,14 +75,38 @@ public class DeveloperUtils {
public static boolean isActivityRegistered(Context context, Class<? extends Activity> c) {
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(new Intent(context, c),
PackageManager.MATCH_DEFAULT_ONLY);
return list != null && list.size() > 0;
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES);
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) {
List<ResolveInfo> list = context.getPackageManager().queryIntentServices(new Intent(context, c),
PackageManager.MATCH_DEFAULT_ONLY);
return list != null && list.size() > 0;
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SERVICES);
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;
}
}
}