From 084a8ea033476cdfe76cb04fea54c3fcda1e3602 Mon Sep 17 00:00:00 2001 From: hyb1996 <946994919@qq.com> Date: Fri, 29 Dec 2017 20:53:51 +0800 Subject: [PATCH] fix: FloatyWindow.setSize() not working --- .gitignore | 1 + app/.gitignore | 2 +- app/build.gradle | 4 ++-- app/release/output.json | 2 +- .../build/ApkBuilderPluginHelper.java | 6 +++--- .../autojs/core/floaty/FloatyWindow.java | 20 +++++++++++++++---- .../stardust/autojs/runtime/api/Floaty.java | 9 +++++---- docs | 1 - 8 files changed, 29 insertions(+), 16 deletions(-) delete mode 160000 docs diff --git a/.gitignore b/.gitignore index 1bed7cda..424e5614 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.iml .gradle +/tools /local.properties /.idea/workspace.xml /.idea/libraries diff --git a/app/.gitignore b/app/.gitignore index 796b96d1..42afabfd 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1 @@ -/build +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 320bd957..536f1541 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.stardust.scriptdroid" minSdkVersion 17 targetSdkVersion 23 - versionCode 236 - versionName "3.0.0 Alpha36" + versionCode 238 + versionName "3.0.0 Alpha38" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true ndk { diff --git a/app/release/output.json b/app/release/output.json index c84162ff..aaa06e73 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":234},"path":"release-3.0.0 Alpha34.apk","properties":{"packageId":"com.stardust.scriptdroid","split":"","minSdkVersion":"17"}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":34},"path":"inrt-release.apk","properties":{"packageId":"com.stardust.auojs.inrt","split":"","minSdkVersion":"17"}}] \ No newline at end of file diff --git a/app/src/main/java/com/stardust/scriptdroid/build/ApkBuilderPluginHelper.java b/app/src/main/java/com/stardust/scriptdroid/build/ApkBuilderPluginHelper.java index 4cdc4197..b7992505 100644 --- a/app/src/main/java/com/stardust/scriptdroid/build/ApkBuilderPluginHelper.java +++ b/app/src/main/java/com/stardust/scriptdroid/build/ApkBuilderPluginHelper.java @@ -26,9 +26,9 @@ public class ApkBuilderPluginHelper { public static InputStream openTemplateApk(Context context) { try { - if (BuildConfig.DEBUG) { - return context.getAssets().open(TEMPLATE_APK_PATH); - } + //if (BuildConfig.DEBUG) { + // return context.getAssets().open(TEMPLATE_APK_PATH); + //} return context.getPackageManager().getResourcesForApplication(PLUGIN_PACKAGE_NAME) .getAssets().open(TEMPLATE_APK_PATH); } catch (IOException e) { diff --git a/autojs/src/main/java/com/stardust/autojs/core/floaty/FloatyWindow.java b/autojs/src/main/java/com/stardust/autojs/core/floaty/FloatyWindow.java index 604fac1a..ab2c6314 100644 --- a/autojs/src/main/java/com/stardust/autojs/core/floaty/FloatyWindow.java +++ b/autojs/src/main/java/com/stardust/autojs/core/floaty/FloatyWindow.java @@ -7,6 +7,7 @@ import android.view.WindowManager; import android.widget.FrameLayout; import com.stardust.autojs.R; +import com.stardust.autojs.runtime.api.Floaty; import com.stardust.enhancedfloaty.FloatyService; import com.stardust.enhancedfloaty.ResizableFloaty; import com.stardust.enhancedfloaty.ResizableFloatyWindow; @@ -22,13 +23,19 @@ public class FloatyWindow extends ResizableFloatyWindow { private boolean mCreated = false; private View mMoveCursor; private View mResizer; + private MyFloaty mFloaty; public FloatyWindow(View view) { - super(new MyFloaty(view)); + this(new MyFloaty(view)); mView = view; } + private FloatyWindow(MyFloaty floaty) { + super(floaty); + mFloaty = floaty; + } + public void waitFor() { synchronized (LOCK) { if (mCreated) { @@ -68,10 +75,15 @@ public class FloatyWindow extends ResizableFloatyWindow { return mMoveCursor.getVisibility() == View.VISIBLE; } + public View getRootView() { + return mFloaty.mRootView; + } + private static class MyFloaty implements ResizableFloaty { private View mContentView; + private View mRootView; public MyFloaty(View view) { @@ -80,9 +92,9 @@ public class FloatyWindow extends ResizableFloatyWindow { @Override public View inflateView(FloatyService floatyService, ResizableFloatyWindow resizableFloatyWindow) { - View view = View.inflate(mContentView.getContext(), R.layout.floaty_window, null); - ((FrameLayout) view.findViewById(R.id.container)).addView(mContentView); - return view; + mRootView = View.inflate(mContentView.getContext(), R.layout.floaty_window, null); + ((FrameLayout) mRootView.findViewById(R.id.container)).addView(mContentView); + return mRootView; } @Nullable diff --git a/autojs/src/main/java/com/stardust/autojs/runtime/api/Floaty.java b/autojs/src/main/java/com/stardust/autojs/runtime/api/Floaty.java index 78057b83..5180ca4a 100644 --- a/autojs/src/main/java/com/stardust/autojs/runtime/api/Floaty.java +++ b/autojs/src/main/java/com/stardust/autojs/runtime/api/Floaty.java @@ -91,7 +91,7 @@ public class Floaty { FloatyService.addWindow(mWindow); }); mWindow.waitFor(); - setSize(mWindow.getWindowBridge().getScreenWidth() / 2, mWindow.getWindowBridge().getScreenHeight() / 2); + //setSize(mWindow.getWindowBridge().getScreenWidth() / 2, mWindow.getWindowBridge().getScreenHeight() / 2); mView = view; } @@ -117,11 +117,12 @@ public class Floaty { public void setSize(int w, int h) { if (Looper.myLooper() == Looper.getMainLooper()) { - mWindow.getWindowBridge().updateMeasure(w, h); + ViewUtil.setViewMeasure(mWindow.getRootView(), w, h); + // mWindow.getWindowBridge().updateMeasure(w, h); } else { mUiHandler.post(() -> { - ViewUtil.setViewMeasure(mView, w, h); - mWindow.getWindowBridge().updateMeasure(w, h); + ViewUtil.setViewMeasure(mWindow.getRootView(), w, h); + // mWindow.getWindowBridge().updateMeasure(w, h); }); } } diff --git a/docs b/docs deleted file mode 160000 index bf1f1544..00000000 --- a/docs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bf1f1544afe9b960add066074586e2674f64c66b