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
.gradle
/tools
/local.properties
/.idea/workspace.xml
/.idea/libraries

2
app/.gitignore vendored
View File

@ -1 +1 @@
/build
/build

View File

@ -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 {

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) {
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) {

View File

@ -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

View File

@ -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);
});
}
}

1
docs

@ -1 +0,0 @@
Subproject commit bf1f1544afe9b960add066074586e2674f64c66b