fix: FloatyWindow.setSize() not working

This commit is contained in:
hyb1996
2017-12-29 20:53:51 +08:00
parent 4188b2027c
commit 084a8ea033
8 changed files with 29 additions and 16 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
*.iml *.iml
.gradle .gradle
/tools
/local.properties /local.properties
/.idea/workspace.xml /.idea/workspace.xml
/.idea/libraries /.idea/libraries

View File

@@ -8,8 +8,8 @@ android {
applicationId "com.stardust.scriptdroid" applicationId "com.stardust.scriptdroid"
minSdkVersion 17 minSdkVersion 17
targetSdkVersion 23 targetSdkVersion 23
versionCode 236 versionCode 238
versionName "3.0.0 Alpha36" versionName "3.0.0 Alpha38"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true
ndk { ndk {

View File

@@ -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"}}] [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":34},"path":"inrt-release.apk","properties":{"packageId":"com.stardust.auojs.inrt","split":"","minSdkVersion":"17"}}]

View File

@@ -26,9 +26,9 @@ public class ApkBuilderPluginHelper {
public static InputStream openTemplateApk(Context context) { public static InputStream openTemplateApk(Context context) {
try { try {
if (BuildConfig.DEBUG) { //if (BuildConfig.DEBUG) {
return context.getAssets().open(TEMPLATE_APK_PATH); // return context.getAssets().open(TEMPLATE_APK_PATH);
} //}
return context.getPackageManager().getResourcesForApplication(PLUGIN_PACKAGE_NAME) return context.getPackageManager().getResourcesForApplication(PLUGIN_PACKAGE_NAME)
.getAssets().open(TEMPLATE_APK_PATH); .getAssets().open(TEMPLATE_APK_PATH);
} catch (IOException e) { } catch (IOException e) {

View File

@@ -7,6 +7,7 @@ import android.view.WindowManager;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import com.stardust.autojs.R; import com.stardust.autojs.R;
import com.stardust.autojs.runtime.api.Floaty;
import com.stardust.enhancedfloaty.FloatyService; import com.stardust.enhancedfloaty.FloatyService;
import com.stardust.enhancedfloaty.ResizableFloaty; import com.stardust.enhancedfloaty.ResizableFloaty;
import com.stardust.enhancedfloaty.ResizableFloatyWindow; import com.stardust.enhancedfloaty.ResizableFloatyWindow;
@@ -22,13 +23,19 @@ public class FloatyWindow extends ResizableFloatyWindow {
private boolean mCreated = false; private boolean mCreated = false;
private View mMoveCursor; private View mMoveCursor;
private View mResizer; private View mResizer;
private MyFloaty mFloaty;
public FloatyWindow(View view) { public FloatyWindow(View view) {
super(new MyFloaty(view)); this(new MyFloaty(view));
mView = view; mView = view;
} }
private FloatyWindow(MyFloaty floaty) {
super(floaty);
mFloaty = floaty;
}
public void waitFor() { public void waitFor() {
synchronized (LOCK) { synchronized (LOCK) {
if (mCreated) { if (mCreated) {
@@ -68,10 +75,15 @@ public class FloatyWindow extends ResizableFloatyWindow {
return mMoveCursor.getVisibility() == View.VISIBLE; return mMoveCursor.getVisibility() == View.VISIBLE;
} }
public View getRootView() {
return mFloaty.mRootView;
}
private static class MyFloaty implements ResizableFloaty { private static class MyFloaty implements ResizableFloaty {
private View mContentView; private View mContentView;
private View mRootView;
public MyFloaty(View view) { public MyFloaty(View view) {
@@ -80,9 +92,9 @@ public class FloatyWindow extends ResizableFloatyWindow {
@Override @Override
public View inflateView(FloatyService floatyService, ResizableFloatyWindow resizableFloatyWindow) { public View inflateView(FloatyService floatyService, ResizableFloatyWindow resizableFloatyWindow) {
View view = View.inflate(mContentView.getContext(), R.layout.floaty_window, null); mRootView = View.inflate(mContentView.getContext(), R.layout.floaty_window, null);
((FrameLayout) view.findViewById(R.id.container)).addView(mContentView); ((FrameLayout) mRootView.findViewById(R.id.container)).addView(mContentView);
return view; return mRootView;
} }
@Nullable @Nullable

View File

@@ -91,7 +91,7 @@ public class Floaty {
FloatyService.addWindow(mWindow); FloatyService.addWindow(mWindow);
}); });
mWindow.waitFor(); mWindow.waitFor();
setSize(mWindow.getWindowBridge().getScreenWidth() / 2, mWindow.getWindowBridge().getScreenHeight() / 2); //setSize(mWindow.getWindowBridge().getScreenWidth() / 2, mWindow.getWindowBridge().getScreenHeight() / 2);
mView = view; mView = view;
} }
@@ -117,11 +117,12 @@ public class Floaty {
public void setSize(int w, int h) { public void setSize(int w, int h) {
if (Looper.myLooper() == Looper.getMainLooper()) { if (Looper.myLooper() == Looper.getMainLooper()) {
mWindow.getWindowBridge().updateMeasure(w, h); ViewUtil.setViewMeasure(mWindow.getRootView(), w, h);
// mWindow.getWindowBridge().updateMeasure(w, h);
} else { } else {
mUiHandler.post(() -> { mUiHandler.post(() -> {
ViewUtil.setViewMeasure(mView, w, h); ViewUtil.setViewMeasure(mWindow.getRootView(), w, h);
mWindow.getWindowBridge().updateMeasure(w, h); // mWindow.getWindowBridge().updateMeasure(w, h);
}); });
} }
} }

1
docs

Submodule docs deleted from bf1f1544af