mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-21 21:01:43 +08:00
add: floating window switch saves state on exit
This commit is contained in:
parent
d830e13031
commit
02a9091ddb
@ -18,6 +18,7 @@ public class Pref {
|
||||
private static final String KEY_SHOULD_SHOW_ANNUNCIATION = "Sing about all the things you forgot, things you are not";
|
||||
private static final String KEY_FIRST_SHOW_AD = "En, Today is 17.7.7, but, I'm still love you so....";
|
||||
private static final String KEY_LAST_SHOW_AD_MILLIS = "But... it seems that...you will not come back any more...";
|
||||
private static final String KEY_FLOATING_MENU_SHOWN = "17.10.28 I have idea of what you think...maybe...I'm overthinking...";
|
||||
private static SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
@ -147,4 +148,12 @@ public class Pref {
|
||||
public static String getDocumentationUrl() {
|
||||
return "file:///android_asset/docs/";
|
||||
}
|
||||
|
||||
public static boolean isFloatingMenuShown() {
|
||||
return def().getBoolean(KEY_FLOATING_MENU_SHOWN, false);
|
||||
}
|
||||
|
||||
public static void setFloatingMenuShown(boolean checked) {
|
||||
def().edit().putBoolean(KEY_FLOATING_MENU_SHOWN, checked).apply();
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener {
|
||||
}
|
||||
|
||||
@Optional
|
||||
@OnClick(R.id.package_name)
|
||||
@OnClick(R.id.class_name)
|
||||
void copyActivityName() {
|
||||
dismissSettingsDialog();
|
||||
if (TextUtils.isEmpty(mRunningActivity))
|
||||
|
||||
@ -184,10 +184,10 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
||||
|
||||
@Click(R.id.exit)
|
||||
public void exitCompletely() {
|
||||
finish();
|
||||
FloatyWindowManger.hideCircularMenu();
|
||||
stopService(new Intent(this, FloatyService.class));
|
||||
AutoJs.getInstance().getScriptEngineService().stopAll();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -89,7 +89,6 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
@ViewById(R.id.default_cover)
|
||||
View mDefaultCover;
|
||||
|
||||
|
||||
private Disposable mConnectionStateDisposable;
|
||||
|
||||
|
||||
@ -101,6 +100,7 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
.doOnNext(connected -> mConnectionItem.getSwitchCompat().setChecked(connected))
|
||||
.subscribe();
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -118,6 +118,9 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
@AfterViews
|
||||
void setUpViews() {
|
||||
ThemeColorManager.addViewBackground(mHeaderView);
|
||||
if (Pref.isFloatingMenuShown()) {
|
||||
mFloatingWindowItem.getSwitchCompat().setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncUserInfo() {
|
||||
@ -204,6 +207,9 @@ public class DrawerFragment extends android.support.v4.app.Fragment {
|
||||
void showOrDismissFloatingWindow() {
|
||||
boolean isFloatingWindowShowing = FloatyWindowManger.isCircularMenuShowing();
|
||||
boolean checked = mFloatingWindowItem.getSwitchCompat().isChecked();
|
||||
if (getActivity() != null && !getActivity().isFinishing()) {
|
||||
Pref.setFloatingMenuShown(checked);
|
||||
}
|
||||
if (checked && !isFloatingWindowShowing) {
|
||||
FloatyWindowManger.showCircularMenu();
|
||||
enableAccessibilityServiceByRootIfNeeded();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user