fix: console resize not working

This commit is contained in:
hyb1996
2017-12-29 17:06:28 +08:00
parent 174e1d933c
commit 4188b2027c
6 changed files with 16 additions and 24 deletions

View File

@@ -21,7 +21,7 @@ public class IssueReporterActivity extends AbstractIssueReporterActivity {
@Override
protected GithubTarget getTarget() {
return new GithubTarget("hyb1996-guest", "AutoJsIssueReport");
return new GithubTarget("hyb1996-guest", "auto.js3-issues");
}

View File

@@ -5,6 +5,7 @@ import android.content.ContextWrapper;
import android.support.annotation.Nullable;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import com.stardust.enhancedfloaty.FloatyService;
@@ -37,12 +38,12 @@ public class ConsoleFloaty extends ResizableExpandableFloaty.AbstractResizableEx
@Override
public int getInitialWidth() {
return ScreenMetrics.getDeviceScreenWidth() * 2 / 3;
return WindowManager.LayoutParams.WRAP_CONTENT; //ScreenMetrics.getDeviceScreenWidth() * 2 / 3;
}
@Override
public int getInitialHeight() {
return ScreenMetrics.getDeviceScreenHeight() / 3;
return WindowManager.LayoutParams.WRAP_CONTENT;//ScreenMetrics.getDeviceScreenHeight() / 3;
}
@Override
@@ -73,7 +74,8 @@ public class ConsoleFloaty extends ResizableExpandableFloaty.AbstractResizableEx
}
private void setInitialMeasure(final View view) {
view.post(() -> ViewUtil.setViewMeasure(view, getInitialWidth(), getInitialHeight()));
view.post(() -> ViewUtil.setViewMeasure(view, ScreenMetrics.getDeviceScreenWidth() * 2 / 3,
ScreenMetrics.getDeviceScreenHeight() / 3));
}
private void initConsoleTitle(View view) {
@@ -125,12 +127,7 @@ public class ConsoleFloaty extends ResizableExpandableFloaty.AbstractResizableEx
public void setTitle(final CharSequence title) {
mTitle = title;
if (mTitleView != null) {
mTitleView.post(new Runnable() {
@Override
public void run() {
mTitleView.setText(title);
}
});
mTitleView.post(() -> mTitleView.setText(title));
}
}
}

View File

@@ -73,8 +73,6 @@ public class StardustConsole extends AbstractConsole {
private BlockingQueue<String> mInput = new ArrayBlockingQueue<>(1);
private WeakReference<ConsoleView> mConsoleView;
private volatile boolean mShown = false;
private int mWidth;
private int mHeight;
private int mX, mY;
public StardustConsole(UiHandler uiHandler) {
@@ -85,14 +83,11 @@ public class StardustConsole extends AbstractConsole {
mUiHandler = uiHandler;
mConsoleFloaty = new ConsoleFloaty(this);
mGlobalConsole = globalConsole;
mWidth = mConsoleFloaty.getInitialWidth();
mHeight = mConsoleFloaty.getInitialHeight();
mFloatyWindow = new ResizableExpandableFloatyWindow(mConsoleFloaty) {
@Override
public void onCreate(FloatyService service, WindowManager manager) {
super.onCreate(service, manager);
expand();
mFloatyWindow.getWindowBridge().updateMeasure(mWidth, mHeight);
mFloatyWindow.getWindowBridge().updatePosition(mX, mY);
synchronized (WINDOW_SHOW_LOCK) {
mShown = true;
@@ -205,13 +200,10 @@ public class StardustConsole extends AbstractConsole {
}
public void setSize(int w, int h) {
mWidth = w;
mHeight = h;
if (mShown) {
mUiHandler.post(() -> {
if (mShown) {
ViewUtil.setViewMeasure(mConsoleFloaty.getExpandedView(), w, h);
mFloatyWindow.getWindowBridge().updateMeasure(w, h);
}
});
}

View File

@@ -318,7 +318,7 @@ public class ScriptRuntime {
public void onExit() {
//清除interrupt状态
// Thread.interrupted();
Thread.interrupted();
//悬浮窗需要第一时间关闭以免出现恶意脚本全屏悬浮窗屏蔽屏幕并且在exit中写死循环的问题
ignoresException(floaty::closeAll);
try {

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"

View File

@@ -351,9 +351,12 @@ public class PFiles {
public static boolean deleteRecursively(File file) {
if (file.isFile())
return file.delete();
for (File child : file.listFiles()) {
if (!deleteRecursively(child))
return false;
File[] children = file.listFiles();
if (children != null) {
for (File child : children) {
if (!deleteRecursively(child))
return false;
}
}
return file.delete();
}