mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-24 21:33:16 +08:00
fix: floaty not working
This commit is contained in:
parent
e64afaa88f
commit
4dc37bc4ff
@ -37,7 +37,7 @@
|
||||
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="2.1" />
|
||||
android:value="2.1"/>
|
||||
|
||||
<activity
|
||||
android:name=".ui.splash.SplashActivity"
|
||||
@ -126,6 +126,33 @@
|
||||
|
||||
<activity android:name=".external.tasker.TaskPrefEditActivity_"/>
|
||||
|
||||
<service
|
||||
android:name=".external.tile.LayoutBoundsTile"
|
||||
android:icon="@drawable/ic_circular_menu_bounds"
|
||||
android:label="@string/text_inspect_layout_bounds"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
<meta-data
|
||||
android:name="android.service.quicksettings.ACTIVE_TILE"
|
||||
android:value="false"/>
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".external.tile.LayoutHierarchyTile"
|
||||
android:icon="@drawable/ic_circular_menu_hierarchy"
|
||||
android:label="@string/text_inspect_layout_hierarchy"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
|
||||
<meta-data
|
||||
android:name="android.service.quicksettings.ACTIVE_TILE"
|
||||
android:value="false"/>
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity-alias
|
||||
android:name=".external.tasker.PluginActivity"
|
||||
android:exported="true"
|
||||
@ -138,10 +165,10 @@
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<receiver android:name="org.autojs.autojs.external.receiver.StaticBroadcastReceiver" >
|
||||
<receiver android:name="org.autojs.autojs.external.receiver.StaticBroadcastReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
|
||||
<action android:name="android.intent.action.TIME_SET"/>
|
||||
<action android:name="android.intent.action.TIMEZONE_CHANGED"/>
|
||||
<action android:name="android.intent.action.UID_REMOVED"/>
|
||||
@ -170,6 +197,7 @@
|
||||
<action android:name="android.intent.action.PACKAGE_DATA_CLEARED"/>
|
||||
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
|
||||
<action android:name="android.intent.action.PACKAGE_RESTARTED"/>
|
||||
|
||||
<data android:scheme="package"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
23
app/src/main/java/org/autojs/autojs/external/tile/LayoutBoundsTile.java
vendored
Normal file
23
app/src/main/java/org/autojs/autojs/external/tile/LayoutBoundsTile.java
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
package org.autojs.autojs.external.tile;
|
||||
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import com.stardust.view.accessibility.NodeInfo;
|
||||
|
||||
import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
|
||||
import org.autojs.autojs.ui.floating.layoutinspector.LayoutBoundsFloatyWindow;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public class LayoutBoundsTile extends LayoutInspectTileService {
|
||||
@Override
|
||||
protected FullScreenFloatyWindow onCreateWindow(NodeInfo capture) {
|
||||
return new LayoutBoundsFloatyWindow(capture) {
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
inactive();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
23
app/src/main/java/org/autojs/autojs/external/tile/LayoutHierarchyTile.java
vendored
Normal file
23
app/src/main/java/org/autojs/autojs/external/tile/LayoutHierarchyTile.java
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
package org.autojs.autojs.external.tile;
|
||||
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import com.stardust.view.accessibility.NodeInfo;
|
||||
|
||||
import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
|
||||
import org.autojs.autojs.ui.floating.layoutinspector.LayoutHierarchyFloatyWindow;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public class LayoutHierarchyTile extends LayoutInspectTileService {
|
||||
@Override
|
||||
protected FullScreenFloatyWindow onCreateWindow(NodeInfo capture) {
|
||||
return new LayoutHierarchyFloatyWindow(capture) {
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
inactive();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
90
app/src/main/java/org/autojs/autojs/external/tile/LayoutInspectTileService.java
vendored
Normal file
90
app/src/main/java/org/autojs/autojs/external/tile/LayoutInspectTileService.java
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
package org.autojs.autojs.external.tile;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.service.quicksettings.TileService;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.view.accessibility.LayoutInspector;
|
||||
import com.stardust.view.accessibility.NodeInfo;
|
||||
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.accessibility.AccessibilityService;
|
||||
import org.autojs.autojs.autojs.AutoJs;
|
||||
import org.autojs.autojs.tool.AccessibilityServiceTool;
|
||||
import org.autojs.autojs.ui.floating.FloatyWindowManger;
|
||||
import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public abstract class LayoutInspectTileService extends TileService implements LayoutInspector.CaptureAvailableListener {
|
||||
|
||||
private boolean mCapturing = false;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.d(getClass().getName(), "onCreate");
|
||||
AutoJs.getInstance().getLayoutInspector().addCaptureAvailableListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartListening() {
|
||||
super.onStartListening();
|
||||
Log.d(getClass().getName(), "onStartListening");
|
||||
inactive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.d(getClass().getName(), "onDestroy");
|
||||
AutoJs.getInstance().getLayoutInspector().removeCaptureAvailableListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
super.onClick();
|
||||
Log.d(getClass().getName(), "onClick");
|
||||
sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||
if (AccessibilityService.getInstance() == null) {
|
||||
Toast.makeText(this, R.string.text_no_accessibility_permission_to_capture, Toast.LENGTH_SHORT).show();
|
||||
AccessibilityServiceTool.goToAccessibilitySetting();
|
||||
inactive();
|
||||
return;
|
||||
}
|
||||
mCapturing = true;
|
||||
GlobalAppContext.postDelayed(() ->
|
||||
AutoJs.getInstance().getLayoutInspector().captureCurrentWindow()
|
||||
, 1000);
|
||||
}
|
||||
|
||||
protected void inactive() {
|
||||
Tile qsTile = getQsTile();
|
||||
if (qsTile == null)
|
||||
return;
|
||||
qsTile.setState(Tile.STATE_INACTIVE);
|
||||
qsTile.updateTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCaptureAvailable(NodeInfo capture) {
|
||||
Log.d(getClass().getName(), "onCaptureAvailable: capturing = " + mCapturing);
|
||||
if (!mCapturing) {
|
||||
return;
|
||||
}
|
||||
mCapturing = false;
|
||||
GlobalAppContext.post(() -> {
|
||||
FullScreenFloatyWindow window = onCreateWindow(capture);
|
||||
if (!FloatyWindowManger.addWindow(getApplicationContext(), window)) {
|
||||
inactive();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected abstract FullScreenFloatyWindow onCreateWindow(NodeInfo capture);
|
||||
}
|
||||
@ -99,7 +99,7 @@ public class FunctionsKeyboardView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void initPropertiesView() {
|
||||
WrapContentGridLayoutManger manager = new WrapContentGridLayoutManger(getContext(), 2);
|
||||
WrapContentGridLayoutManger manager = new WrapContentGridLayoutManger(getContext(), SPAN_COUNT);
|
||||
manager.setDebugInfo("FunctionsKeyboardView");
|
||||
mPropertiesView.setLayoutManager(manager);
|
||||
mPropertiesView.setAdapter(new PropertiesAdapter());
|
||||
|
||||
@ -32,18 +32,21 @@ public class FloatyWindowManger {
|
||||
|
||||
private static WeakReference<CircularMenu> sCircularMenu;
|
||||
|
||||
public static void addWindow(Context context, FloatyWindow window) {
|
||||
public static boolean addWindow(Context context, FloatyWindow window) {
|
||||
context.startService(new Intent(context, FloatyService.class));
|
||||
FloatingPermission.ensurePermissionGranted(context);
|
||||
boolean hasPermission = FloatingPermission.ensurePermissionGranted(context);
|
||||
try {
|
||||
FloatyService.addWindow(window);
|
||||
return true;
|
||||
// SecurityException: https://github.com/hyb1996-guest/AutoJsIssueReport/issues/4781
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
manageDrawOverlays(context);
|
||||
Toast.makeText(context, R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||
|
||||
if(hasPermission){
|
||||
manageDrawOverlays(context);
|
||||
Toast.makeText(context, R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isCircularMenuShowing() {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.autojs.autojs.ui.shortcut;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@ -58,12 +59,13 @@ public class ShortcutIconSelectActivity extends BaseActivity {
|
||||
|
||||
private void setupApps() {
|
||||
mApps.setAdapter(new AppsAdapter());
|
||||
WrapContentGridLayoutManger manager = new WrapContentGridLayoutManger(this, 2);
|
||||
WrapContentGridLayoutManger manager = new WrapContentGridLayoutManger(this, 5);
|
||||
manager.setDebugInfo("IconSelectView");
|
||||
mApps.setLayoutManager(manager);
|
||||
loadApps();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void loadApps() {
|
||||
List<ApplicationInfo> packages = mPackageManager.getInstalledApplications(PackageManager.GET_META_DATA);
|
||||
Observable.fromIterable(packages)
|
||||
|
||||
@ -26,13 +26,8 @@ module.exports = function(runtime, global){
|
||||
get: function(name) {
|
||||
var value = window[name];
|
||||
if(typeof(value) == 'undefined'){
|
||||
value = viewCache[name];
|
||||
if(!value){
|
||||
value = window.findView(name);
|
||||
if(value){
|
||||
value = ui.__decorate__(value);
|
||||
viewCache[name] = value;
|
||||
}
|
||||
}
|
||||
if(!value){
|
||||
value = undefined;
|
||||
|
||||
@ -42,6 +42,10 @@ module.exports = function (runtime, global) {
|
||||
return ui.findByStringId(ui.view, id);
|
||||
}
|
||||
|
||||
ui.findView = function(id) {
|
||||
return ui.findById(id);
|
||||
}
|
||||
|
||||
ui.isUiThread = function () {
|
||||
let Looper = android.os.Looper;
|
||||
return Looper.myLooper() == Looper.getMainLooper();
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package com.stardust.autojs.core.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.widget.DefaultItemAnimator;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.stardust.autojs.R;
|
||||
import com.stardust.autojs.core.ui.inflater.DynamicLayoutInflater;
|
||||
|
||||
@ -12,13 +12,9 @@ import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.R;
|
||||
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
|
||||
import com.stardust.enhancedfloaty.util.FloatingWindowPermissionUtil;
|
||||
import com.stardust.lang.ThreadCompat;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Set;
|
||||
|
||||
import ezy.assist.compat.RomUtil;
|
||||
import ezy.assist.compat.SettingsCompat;
|
||||
@ -42,12 +38,13 @@ public class FloatingPermission {
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensurePermissionGranted(Context context) {
|
||||
public static boolean ensurePermissionGranted(Context context) {
|
||||
if (!canDrawOverlays(context)) {
|
||||
Toast.makeText(context, R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||
manageDrawOverlays(context);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void waitForPermissionGranted(Context context) throws InterruptedException {
|
||||
|
||||
@ -72,4 +72,8 @@ public class GlobalAppContext {
|
||||
public static void post(Runnable r) {
|
||||
sHandler.post(r);
|
||||
}
|
||||
|
||||
public static void postDelayed(Runnable r, long m) {
|
||||
sHandler.postDelayed(r, m);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user