support sublime text command save_to_phone
This commit is contained in:
1 parent
10fd45b6c2
commit
6888f88f77
14 files changed
+94
-270
No files matched your search
Generated
+1
-1
@@ -48,7 +48,7 @@
|
|||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
Vendored
-90
@@ -1,90 +0,0 @@
|
|||||||
package com.stardust.scriptdroid.external.floatingwindow;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.support.annotation.RequiresApi;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.stardust.scriptdroid.App;
|
|
||||||
import com.stardust.scriptdroid.R;
|
|
||||||
import com.stardust.scriptdroid.external.floatingwindow.menu.HoverMenuService;
|
|
||||||
import com.stardust.util.IntentUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Stardust on 2017/3/10.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class FloatingWindowManger {
|
|
||||||
|
|
||||||
private static final String KEY_FLOATING_WINDOW_PERMISSION = "May we go back..I...miss..you..Eating..17.5.9";
|
|
||||||
private static final String TAG = "FloatingWindowManger";
|
|
||||||
|
|
||||||
public static void showHoverMenu() {
|
|
||||||
if (!HoverMenuService.isServiceRunning()) {
|
|
||||||
if (!hasFloatingWindowPermission(App.getApp())) {
|
|
||||||
Toast.makeText(App.getApp(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
|
||||||
goToFloatingWindowPermissionSetting();
|
|
||||||
} else {
|
|
||||||
HoverMenuService.startService(App.getApp());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void goToFloatingWindowPermissionSetting() {
|
|
||||||
IntentUtil.goToAppDetailSettings(App.getApp());
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
||||||
private static void goToOverlayPermissionSettings(Context context, String packageName) {
|
|
||||||
try {
|
|
||||||
App.getApp().startActivity(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
|
||||||
Uri.parse("package:" + context))
|
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
|
||||||
} catch (Exception e) {
|
|
||||||
IntentUtil.goToAppDetailSettings(App.getApp());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkPermission() {
|
|
||||||
final OverlayPermissionChecker checker = new OverlayPermissionChecker(App.getApp());
|
|
||||||
checker.setCallback(new OverlayPermissionChecker.Callback() {
|
|
||||||
@Override
|
|
||||||
public void onCheckResult(boolean granted) {
|
|
||||||
checker.setCallback(null);
|
|
||||||
Log.d(TAG, "onCheckResult:" + granted);
|
|
||||||
setHasFloatingWindowPermission(App.getApp(), granted);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
checker.check(1500);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasFloatingWindowPermission(Context context) {
|
|
||||||
return hasOverlayPermission();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setHasFloatingWindowPermission(Context context, boolean has) {
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(KEY_FLOATING_WINDOW_PERMISSION, has).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasOverlayPermission() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
return Settings.canDrawOverlays(App.getApp());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isHoverMenuShowing() {
|
|
||||||
return HoverMenuService.isServiceRunning();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void hideHoverMenu() {
|
|
||||||
if (HoverMenuService.isServiceRunning())
|
|
||||||
App.getApp().stopService(new Intent(App.getApp(), HoverMenuService.class));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package com.stardust.scriptdroid.external.floatingwindow;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.support.annotation.RequiresApi;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.stardust.scriptdroid.App;
|
||||||
|
import com.stardust.scriptdroid.R;
|
||||||
|
import com.stardust.scriptdroid.external.floatingwindow.menu.HoverMenuService;
|
||||||
|
import com.stardust.util.IntentUtil;
|
||||||
|
|
||||||
|
import ezy.assist.compat.SettingsCompat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/3/10.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class HoverMenuManger {
|
||||||
|
|
||||||
|
private static final String KEY_FLOATING_WINDOW_PERMISSION = "May we go back..I...miss..you..Eating..17.5.9";
|
||||||
|
private static final String TAG = "HoverMenuManger";
|
||||||
|
|
||||||
|
public static void showHoverMenu() {
|
||||||
|
if (!HoverMenuService.isServiceRunning()) {
|
||||||
|
if (!SettingsCompat.canDrawOverlays(App.getApp())) {
|
||||||
|
Toast.makeText(App.getApp(), R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||||
|
SettingsCompat.manageDrawOverlays(App.getApp());
|
||||||
|
} else {
|
||||||
|
HoverMenuService.startService(App.getApp());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isHoverMenuShowing() {
|
||||||
|
return HoverMenuService.isServiceRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void hideHoverMenu() {
|
||||||
|
App.getApp().stopService(new Intent(App.getApp(), HoverMenuService.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
-118
@@ -1,118 +0,0 @@
|
|||||||
package com.stardust.scriptdroid.external.floatingwindow;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.PixelFormat;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
import com.stardust.enhancedfloaty.FloatyService;
|
|
||||||
import com.stardust.enhancedfloaty.FloatyWindow;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Stardust on 2017/5/9.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class OverlayPermissionChecker {
|
|
||||||
|
|
||||||
public interface Callback {
|
|
||||||
void onCheckResult(boolean granted);
|
|
||||||
}
|
|
||||||
|
|
||||||
private OnePixelWindow mOnePixelWindow = new OnePixelWindow();
|
|
||||||
private Callback mCallback;
|
|
||||||
private Context mContext;
|
|
||||||
private Handler mHandler;
|
|
||||||
private Boolean mCheckResult = null;
|
|
||||||
|
|
||||||
public OverlayPermissionChecker(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
mHandler = new Handler(context.getMainLooper());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void check() {
|
|
||||||
mCheckResult = null;
|
|
||||||
try {
|
|
||||||
FloatyService.addWindow(mOnePixelWindow);
|
|
||||||
mContext.startService(new Intent(mContext, FloatyService.class));
|
|
||||||
} catch (WindowManager.BadTokenException e) {
|
|
||||||
onCheckResult(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void check(int timeOut) {
|
|
||||||
check();
|
|
||||||
mHandler.postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (mCheckResult == null) {
|
|
||||||
onCheckResult(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, timeOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCallback(Callback callback) {
|
|
||||||
mCallback = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onCheckResult(boolean b) {
|
|
||||||
mCheckResult = b;
|
|
||||||
if (mCallback != null) {
|
|
||||||
mCallback.onCheckResult(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private class OnePixelWindow implements FloatyWindow {
|
|
||||||
|
|
||||||
private View mOnePixelView;
|
|
||||||
private WindowManager mWindowManager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(FloatyService floatyService, WindowManager windowManager) {
|
|
||||||
mWindowManager = windowManager;
|
|
||||||
mOnePixelView = new View(floatyService) {
|
|
||||||
@Override
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
super.onDraw(canvas);
|
|
||||||
notifyWindowVisible();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onWindowVisibilityChanged(int visibility) {
|
|
||||||
super.onWindowVisibilityChanged(visibility);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
mOnePixelView.setWillNotDraw(false);
|
|
||||||
mOnePixelView.setBackgroundColor(Color.RED);
|
|
||||||
WindowManager.LayoutParams params = new WindowManager.LayoutParams(10, 10,
|
|
||||||
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
|
|
||||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
|
|
||||||
PixelFormat.TRANSLUCENT);
|
|
||||||
params.gravity = Gravity.TOP | Gravity.START;
|
|
||||||
windowManager.addView(mOnePixelView, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyWindowVisible() {
|
|
||||||
onCheckResult(true);
|
|
||||||
//close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceDestroy(FloatyService floatyService) {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
mWindowManager.removeView(mOnePixelView);
|
|
||||||
FloatyService.removeWindow(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Vendored
+2
-2
@@ -17,7 +17,6 @@ import com.stardust.hover.SimpleHoverMenuTransitionListener;
|
|||||||
import com.stardust.hover.WindowHoverMenu;
|
import com.stardust.hover.WindowHoverMenu;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.external.floatingwindow.FloatingWindowManger;
|
|
||||||
import com.stardust.scriptdroid.external.floatingwindow.menu.layout_inspector.NodeInfo;
|
import com.stardust.scriptdroid.external.floatingwindow.menu.layout_inspector.NodeInfo;
|
||||||
import com.stardust.scriptdroid.external.floatingwindow.menu.view.FloatingLayoutBoundsView;
|
import com.stardust.scriptdroid.external.floatingwindow.menu.view.FloatingLayoutBoundsView;
|
||||||
import com.stardust.scriptdroid.external.floatingwindow.menu.view.FloatingLayoutHierarchyView;
|
import com.stardust.scriptdroid.external.floatingwindow.menu.view.FloatingLayoutHierarchyView;
|
||||||
@@ -29,6 +28,7 @@ import com.stardust.util.MessageIntent;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import ezy.assist.compat.SettingsCompat;
|
||||||
import io.mattcarroll.hover.HoverMenu;
|
import io.mattcarroll.hover.HoverMenu;
|
||||||
import io.mattcarroll.hover.defaulthovermenu.window.WindowViewController;
|
import io.mattcarroll.hover.defaulthovermenu.window.WindowViewController;
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ public class HoverMenuService extends Service {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Toast.makeText(this, R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.text_no_floating_window_permission, Toast.LENGTH_SHORT).show();
|
||||||
FloatingWindowManger.goToFloatingWindowPermissionSetting();
|
SettingsCompat.manageDrawOverlays(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class SublimePluginClient {
|
|||||||
private void tryClose() {
|
private void tryClose() {
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,11 @@ import com.google.gson.JsonObject;
|
|||||||
import com.stardust.autojs.execution.ScriptExecution;
|
import com.stardust.autojs.execution.ScriptExecution;
|
||||||
import com.stardust.autojs.script.StringScriptSource;
|
import com.stardust.autojs.script.StringScriptSource;
|
||||||
import com.stardust.pio.PFile;
|
import com.stardust.pio.PFile;
|
||||||
|
import com.stardust.scriptdroid.App;
|
||||||
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.script.Scripts;
|
import com.stardust.scriptdroid.script.Scripts;
|
||||||
|
import com.stardust.scriptdroid.script.StorageScriptProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/5/11.
|
* Created by Stardust on 2017/5/11.
|
||||||
@@ -39,6 +42,15 @@ public class SublimeResponseHandler implements Handler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.handler("save", new Handler() {
|
||||||
|
@Override
|
||||||
|
public boolean handle(JsonObject data) {
|
||||||
|
String script = data.get("script").getAsString();
|
||||||
|
String name = getName(data);
|
||||||
|
saveScript(name, script);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
.handler("rerun", new Handler() {
|
.handler("rerun", new Handler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -91,4 +103,18 @@ public class SublimeResponseHandler implements Handler {
|
|||||||
}
|
}
|
||||||
return element.getAsString();
|
return element.getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveScript(String name, String script) {
|
||||||
|
if (TextUtils.isEmpty(name)) {
|
||||||
|
name = "untitled";
|
||||||
|
}
|
||||||
|
name = PFile.getNameWithoutExtension(name);
|
||||||
|
if (!name.endsWith(".js")) {
|
||||||
|
name = "<remote>" + name + ".js";
|
||||||
|
} else {
|
||||||
|
name = "<remote>" + name;
|
||||||
|
}
|
||||||
|
PFile.write(StorageScriptProvider.DEFAULT_DIRECTORY_PATH + name, script);
|
||||||
|
App.getApp().getUiHandler().toast(R.string.text_script_save_successfully);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ import com.stardust.scriptdroid.BuildConfig;
|
|||||||
import com.stardust.scriptdroid.Pref;
|
import com.stardust.scriptdroid.Pref;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.external.floatingwindow.FloatingWindowManger;
|
import com.stardust.scriptdroid.external.floatingwindow.HoverMenuManger;
|
||||||
import com.stardust.scriptdroid.script.ScriptFile;
|
import com.stardust.scriptdroid.script.ScriptFile;
|
||||||
import com.stardust.scriptdroid.script.StorageScriptProvider;
|
import com.stardust.scriptdroid.script.StorageScriptProvider;
|
||||||
import com.stardust.scriptdroid.script.sample.Sample;
|
import com.stardust.scriptdroid.script.sample.Sample;
|
||||||
@@ -46,7 +46,6 @@ import com.stardust.scriptdroid.ui.BaseActivity;
|
|||||||
import com.stardust.scriptdroid.ui.main.sample_list.SampleScriptListFragment;
|
import com.stardust.scriptdroid.ui.main.sample_list.SampleScriptListFragment;
|
||||||
import com.stardust.scriptdroid.ui.main.script_list.MyScriptListFragment;
|
import com.stardust.scriptdroid.ui.main.script_list.MyScriptListFragment;
|
||||||
import com.stardust.scriptdroid.ui.main.script_list.ScriptFileChooserDialogBuilder;
|
import com.stardust.scriptdroid.ui.main.script_list.ScriptFileChooserDialogBuilder;
|
||||||
import com.stardust.scriptdroid.ui.main.task.TaskManagerFragment;
|
|
||||||
import com.stardust.scriptdroid.ui.settings.SettingsActivity_;
|
import com.stardust.scriptdroid.ui.settings.SettingsActivity_;
|
||||||
import com.stardust.scriptdroid.ui.update.VersionGuard;
|
import com.stardust.scriptdroid.ui.update.VersionGuard;
|
||||||
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||||
@@ -275,7 +274,7 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
|||||||
|
|
||||||
@Click(R.id.exit)
|
@Click(R.id.exit)
|
||||||
public void exitCompletely() {
|
public void exitCompletely() {
|
||||||
FloatingWindowManger.hideHoverMenu();
|
HoverMenuManger.hideHoverMenu();
|
||||||
stopService(new Intent(this, FloatyService.class));
|
stopService(new Intent(this, FloatyService.class));
|
||||||
AutoJs.getInstance().getScriptEngineService().stopAll();
|
AutoJs.getInstance().getScriptEngineService().stopAll();
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import com.stardust.scriptdroid.App;
|
|||||||
import com.stardust.scriptdroid.Pref;
|
import com.stardust.scriptdroid.Pref;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||||
import com.stardust.scriptdroid.external.floatingwindow.FloatingWindowManger;
|
import com.stardust.scriptdroid.external.floatingwindow.HoverMenuManger;
|
||||||
import com.stardust.scriptdroid.external.floatingwindow.menu.HoverMenuService;
|
import com.stardust.scriptdroid.external.floatingwindow.menu.HoverMenuService;
|
||||||
import com.stardust.view.accessibility.AccessibilityService;
|
import com.stardust.view.accessibility.AccessibilityService;
|
||||||
import com.stardust.scriptdroid.sublime.SublimePluginClient;
|
import com.stardust.scriptdroid.sublime.SublimePluginClient;
|
||||||
@@ -89,7 +89,7 @@ public class SideMenuFragment extends android.support.v4.app.Fragment {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 450);
|
}, 450);
|
||||||
mFloatingWindowSwitch.setChecked(FloatingWindowManger.isHoverMenuShowing());
|
mFloatingWindowSwitch.setChecked(HoverMenuManger.isHoverMenuShowing());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,10 +122,10 @@ public class SideMenuFragment extends android.support.v4.app.Fragment {
|
|||||||
|
|
||||||
@CheckedChange(R.id.sw_floating_window)
|
@CheckedChange(R.id.sw_floating_window)
|
||||||
void setFloatingWindowEnable(CompoundButton button, boolean enable) {
|
void setFloatingWindowEnable(CompoundButton button, boolean enable) {
|
||||||
if (enable && !FloatingWindowManger.isHoverMenuShowing()) {
|
if (enable && !HoverMenuManger.isHoverMenuShowing()) {
|
||||||
FloatingWindowManger.showHoverMenu();
|
HoverMenuManger.showHoverMenu();
|
||||||
} else if (!enable && FloatingWindowManger.isHoverMenuShowing()) {
|
} else if (!enable && HoverMenuManger.isHoverMenuShowing()) {
|
||||||
FloatingWindowManger.hideHoverMenu();
|
HoverMenuManger.hideHoverMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,20 +51,16 @@ public class SplashActivity extends BaseActivity {
|
|||||||
private SplashAD mSplashAD;
|
private SplashAD mSplashAD;
|
||||||
private boolean mCanEnterNextActivity = false;
|
private boolean mCanEnterNextActivity = false;
|
||||||
private boolean mNotStartMainActivity;
|
private boolean mNotStartMainActivity;
|
||||||
private boolean mForceShowAd = false;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mNotStartMainActivity = getIntent().getBooleanExtra(NOT_START_MAIN_ACTIVITY, false);
|
mNotStartMainActivity = getIntent().getBooleanExtra(NOT_START_MAIN_ACTIVITY, false);
|
||||||
mForceShowAd = getIntent().getBooleanExtra(FORCE_SHOW_AD, false);
|
boolean forceShowAd = getIntent().getBooleanExtra(FORCE_SHOW_AD, false);
|
||||||
if (!mForceShowAd && !Pref.shouldShowAd()) {
|
if (!forceShowAd && !Pref.shouldShowAd()) {
|
||||||
enterNextActivity();
|
enterNextActivity();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Pref.isFirstShowingAd()) {
|
|
||||||
Toast.makeText(this, R.string.text_can_close_ad_in_settings, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
checkPermission(Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
checkPermission(Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,7 @@
|
|||||||
<string name="show_ad">欣赏广告</string>
|
<string name="show_ad">欣赏广告</string>
|
||||||
<string name="text_ad_showing_settings">广告显示设置</string>
|
<string name="text_ad_showing_settings">广告显示设置</string>
|
||||||
<string name="text_default">Default</string>
|
<string name="text_default">Default</string>
|
||||||
|
<string name="text_script_save_successfully">保存成功,请刷新目录</string>
|
||||||
|
|
||||||
<string-array name="record_control_keys">
|
<string-array name="record_control_keys">
|
||||||
<item>无</item>
|
<item>无</item>
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import com.stardust.autojs.runtime.api.AbstractConsole;
|
|||||||
import com.stardust.autojs.runtime.api.Console;
|
import com.stardust.autojs.runtime.api.Console;
|
||||||
import com.stardust.enhancedfloaty.FloatyService;
|
import com.stardust.enhancedfloaty.FloatyService;
|
||||||
import com.stardust.enhancedfloaty.ResizableExpandableFloatyWindow;
|
import com.stardust.enhancedfloaty.ResizableExpandableFloatyWindow;
|
||||||
import com.stardust.util.FloatingWindowUtils;
|
|
||||||
import com.stardust.util.IntentUtil;
|
|
||||||
import com.stardust.util.UiHandler;
|
import com.stardust.util.UiHandler;
|
||||||
import com.stardust.autojs.R;
|
import com.stardust.autojs.R;
|
||||||
|
|
||||||
@@ -21,6 +19,8 @@ import java.util.List;
|
|||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
|
||||||
|
import ezy.assist.compat.SettingsCompat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/5/2.
|
* Created by Stardust on 2017/5/2.
|
||||||
*/
|
*/
|
||||||
@@ -123,8 +123,8 @@ public class StardustConsole extends AbstractConsole {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
if (!FloatingWindowUtils.hasOverlayPermission(mUiHandler.getContext())) {
|
if (!SettingsCompat.canDrawOverlays(mUiHandler.getContext())) {
|
||||||
IntentUtil.goToAppDetailSettings(mUiHandler.getContext());
|
SettingsCompat.manageDrawOverlays(mUiHandler.getContext());
|
||||||
mUiHandler.toast(R.string.text_no_floating_window_permission);
|
mUiHandler.toast(R.string.text_no_floating_window_permission);
|
||||||
}
|
}
|
||||||
startFloatyService();
|
startFloatyService();
|
||||||
|
|||||||
@@ -27,4 +27,5 @@ dependencies {
|
|||||||
})
|
})
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
compile 'com.android.support:support-annotations:25.3.1'
|
compile 'com.android.support:support-annotations:25.3.1'
|
||||||
|
compile 'com.github.czy1121:settingscompat:1.1.4'
|
||||||
}
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package com.stardust.util;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Stardust on 2017/3/10.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class FloatingWindowUtils {
|
|
||||||
|
|
||||||
public static boolean checkFloatingWindowPermission(Context context, int messageResId) {
|
|
||||||
if (!hasOverlayPermission(context)) {
|
|
||||||
Toast.makeText(context, messageResId, Toast.LENGTH_SHORT).show();
|
|
||||||
IntentUtil.goToAppDetailSettings(context, context.getPackageName());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isFloatingWindowPermitted(Context context) {
|
|
||||||
PackageManager pm = context.getPackageManager();
|
|
||||||
return pm.checkPermission(Manifest.permission.SYSTEM_ALERT_WINDOW, context.getPackageName())
|
|
||||||
== PackageManager.PERMISSION_GRANTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasOverlayPermission(Context context) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
return Settings.canDrawOverlays(context);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user