fix hyb1996-guest//AutoJsIssueReport#4781, hyb1996-guest//AutoJsIssueReport#4793

This commit is contained in:
hyb1996 2017-07-05 18:55:27 +08:00
parent ee4c818007
commit d72d9c0413
10 changed files with 106 additions and 209 deletions

View File

@ -5,7 +5,10 @@ import android.content.Context;
import android.text.TextUtils;
import android.widget.Toast;
import com.stardust.autojs.runtime.ScriptRuntime;
import com.stardust.scriptdroid.Pref;
import com.stardust.scriptdroid.autojs.AutoJs;
import com.stardust.util.UiHandler;
import com.stardust.view.accessibility.AccessibilityService;
import com.stardust.scriptdroid.App;
import com.stardust.scriptdroid.R;
@ -33,12 +36,12 @@ public class AccessibilityServiceTool {
public static void goToAccessibilitySetting() {
Context context = App.getApp();
if (Pref.isFirstGoToAccessibilitySetting()) {
Toast.makeText(context, context.getString(R.string.text_please_choose) + context.getString(R.string._app_name), Toast.LENGTH_LONG).show();
App.getApp().getUiHandler().toast(context.getString(R.string.text_please_choose) + context.getString(R.string._app_name));
}
try {
AccessibilityServiceUtils.goToAccessibilitySetting(context);
} catch (ActivityNotFoundException e) {
Toast.makeText(context, context.getString(R.string.go_to_accessibility_settings) + context.getString(R.string._app_name), Toast.LENGTH_LONG).show();
App.getApp().getUiHandler().toast(context.getString(R.string.go_to_accessibility_settings) + context.getString(R.string._app_name));
}
}

View File

@ -242,10 +242,15 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
}
private void init() {
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 2);
setLayoutManager(layoutManager);//new WrapContentLinearLayoutManager(getContext()));
setLayoutManager(new WrapContentLinearLayoutManager(getContext()));
mAdapter = new Adapter(mDefaultViewHolderSupplier);
setAdapter(mAdapter);
addItemDecoration(new HorizontalDividerItemDecoration.Builder(getContext())
.color(0xffd9d9d9)
.size(2)
.marginResId(R.dimen.script_and_folder_list_divider_left_margin, R.dimen.script_and_folder_list_divider_right_margin)
.showLastDivider()
.build());
}

View File

@ -1,115 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:padding="8dp"
android:gravity="bottom">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:foreground="?selectableItemBackground"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:rotation="8"
app:cardBackgroundColor="#ffffff"
app:cardCornerRadius="4dp"
app:cardElevation="2dp"
app:cardUseCompatPadding="true"/>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:foreground="?selectableItemBackground"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:rotation="4"
app:cardBackgroundColor="#ffffff"
app:cardCornerRadius="4dp"
app:cardElevation="4dp"
app:cardUseCompatPadding="true"/>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?selectableItemBackground"
android:paddingLeft="2dp"
android:paddingRight="2dp"
app:cardBackgroundColor="#ffffff"
app:cardCornerRadius="4dp"
app:cardElevation="6dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/name"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item"
android:layout_width="match_parent"
android:layout_height="40dp"
android:ellipsize="end"
android:maxLines="1"
android:paddingBottom="10dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="10dp"
android:textColor="#99000000"
android:textSize="14sp"
tools:text="正在运行的服务"/>
android:layout_height="wrap_content"
android:foreground="?android:selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:gravity="right"
android:orientation="horizontal"
android:weightSum="4">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:src="@drawable/ic_rename_gray"
android:tint="#767886"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:src="@drawable/ic_more_vert_black_24dp"
android:tint="#767886"/>
<ImageView
android:id="@+id/icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="4dp"
android:contentDescription="@string/_app_name"
android:scaleType="fitCenter"
android:src="@drawable/ic_folder_yellow_100px"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="80dp"
android:layout_toRightOf="@id/icon"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@android:color/secondary_text_light"
android:textSize="16sp"
tools:text="示例脚本"/>
</android.support.v7.widget.CardView>
</FrameLayout>
</RelativeLayout>

View File

@ -1,94 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?selectableItemBackground"
android:paddingLeft="2dp"
android:paddingRight="2dp"
app:cardBackgroundColor="#ffffff"
app:cardCornerRadius="4dp"
app:cardElevation="1.5dp"
app:cardUseCompatPadding="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:selectableItemBackground">
<ImageView
android:id="@+id/icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="4dp"
android:contentDescription="@string/_app_name"
android:scaleType="fitCenter"
android:src="@drawable/ic_node_js_black"/>
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="80dp"
android:layout_toRightOf="@id/icon"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@android:color/secondary_text_light"
android:textSize="16sp"
tools:text="正在运行的服务"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/run"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="12dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:contentDescription="@string/_app_name"
android:src="@drawable/ic_ali_run"/>
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:paddingBottom="10dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="10dp"
android:textColor="#99000000"
android:textSize="14sp"
tools:text="正在运行的服务"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_gravity="right"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/run"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:src="@drawable/ic_run_gray"
android:tint="#767886"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:src="@drawable/ic_mode_edit_black_24dp"
android:tint="#767886"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:src="@drawable/ic_share_black_24dp"
android:tint="#767886"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:src="@drawable/ic_more_vert_black_24dp"
android:tint="#767886"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>

View File

@ -11,10 +11,7 @@
<com.stardust.scriptdroid.ui.main.script_list.ScriptAndFolderListRecyclerView
android:id="@+id/script_list_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="8dp"/>
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>

View File

@ -11,6 +11,7 @@ import android.view.WindowManager;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.afollestad.materialdialogs.Theme;
import com.stardust.concurrent.VolatileBox;
import com.stardust.util.UiHandler;
@ -50,6 +51,7 @@ public class BlockedMaterialDialog extends MaterialDialog {
public Builder(Context context, UiHandler uiHandler) {
super(context);
super.theme(Theme.LIGHT);
mUiHandler = uiHandler;
}

View File

@ -23,6 +23,7 @@ public class Dialogs {
private AppUtils mAppUtils;
private UiHandler mUiHandler;
private ContextThemeWrapper mThemeWrapper;
public Dialogs(AppUtils appUtils, UiHandler uiHandler) {
mAppUtils = appUtils;
@ -70,7 +71,10 @@ public class Dialogs {
}
private Context getContext() {
return mUiHandler.getContext();
if (mThemeWrapper != null)
return mThemeWrapper;
mThemeWrapper = new ContextThemeWrapper(mUiHandler.getContext(), R.style.Theme_AppCompat_Light);
return mThemeWrapper;
}
@ScriptInterface

View File

@ -127,7 +127,8 @@ public class StardustConsole extends AbstractConsole {
public void run() {
try {
FloatyService.addWindow(mFloatyWindow);
} catch (WindowManager.BadTokenException e) {
// SecurityException: https://github.com/hyb1996-guest/AutoJsIssueReport/issues/4781
} catch (WindowManager.BadTokenException | SecurityException e) {
e.printStackTrace();
mUiHandler.toast(R.string.text_no_floating_window_permission);
}

View File

@ -2,9 +2,9 @@
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFeedbackType="feedbackGeneric"
android:accessibilityFlags="flagReportViewIds|flagRequestEnhancedWebAccessibility|flagRequestFilterKeyEvents"
android:accessibilityFlags="flagIncludeNotImportantViews|flagReportViewIds|flagRequestEnhancedWebAccessibility|flagRequestFilterKeyEvents"
android:canPerformGestures="true"
android:canRequestEnhancedWebAccessibility="true"
android:canRetrieveWindowContent="true"
android:description="@string/text_accessibility_service_description"
android:notificationTimeout="100"/>
android:notificationTimeout="0"/>

View File

@ -54,12 +54,11 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
@Override
public void onAccessibilityEvent(final AccessibilityEvent event) {
Log.v(TAG, "onAccessibilityEvent: " + event);
Log.v(TAG, "getRootInActiveWindow: " + super.getRootInActiveWindow());
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
|| event.getEventType() == AccessibilityEvent.TYPE_VIEW_HOVER_ENTER
|| event.getEventType() == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
if (!event.getPackageName().equals(getPackageName())) {
mRootInActiveWindow = super.getRootInActiveWindow();
}
mRootInActiveWindow = super.getRootInActiveWindow();
}
if (!containsAllEventTypes && !eventTypes.contains(event.getEventType()))
return;