修复 悬浮窗布局分析"复制成功"的信息被遮挡的问题
This commit is contained in:
@@ -9,15 +9,13 @@ import android.os.Looper;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.core.console.GlobalStardustConsole;
|
||||
import com.stardust.autojs.core.console.GlobalConsole;
|
||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
||||
import com.stardust.autojs.runtime.accessibility.AccessibilityConfig;
|
||||
import com.stardust.autojs.runtime.api.AppUtils;
|
||||
import com.stardust.autojs.runtime.exception.ScriptException;
|
||||
import com.stardust.autojs.runtime.api.Console;
|
||||
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
|
||||
|
||||
import org.autojs.autojs.App;
|
||||
import org.autojs.autojs.BuildConfig;
|
||||
import org.autojs.autojs.Pref;
|
||||
import org.autojs.autojs.R;
|
||||
@@ -28,10 +26,8 @@ import org.autojs.autojs.ui.floating.FullScreenFloatyWindow;
|
||||
import org.autojs.autojs.ui.floating.layoutinspector.LayoutBoundsFloatyWindow;
|
||||
import org.autojs.autojs.ui.floating.layoutinspector.LayoutHierarchyFloatyWindow;
|
||||
import org.autojs.autojs.ui.log.LogActivity_;
|
||||
import org.autojs.autojs.ui.settings.SettingsActivity;
|
||||
import org.autojs.autojs.ui.settings.SettingsActivity_;
|
||||
|
||||
import com.stardust.concurrent.VolatileBox;
|
||||
import com.stardust.view.accessibility.AccessibilityService;
|
||||
import com.stardust.view.accessibility.LayoutInspector;
|
||||
import com.stardust.view.accessibility.NodeInfo;
|
||||
@@ -114,8 +110,8 @@ public class AutoJs extends com.stardust.autojs.AutoJs {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GlobalStardustConsole createGlobalConsole() {
|
||||
return new GlobalStardustConsole(getUiHandler()) {
|
||||
protected GlobalConsole createGlobalConsole() {
|
||||
return new GlobalConsole(getUiHandler()) {
|
||||
@Override
|
||||
public String println(int level, CharSequence charSequence) {
|
||||
String log = super.println(level, charSequence);
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
package org.autojs.autojs.ui.floating.layoutinspector;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.autojs.autojs.R;
|
||||
|
||||
import com.stardust.view.accessibility.NodeInfo;
|
||||
import com.stardust.util.ClipboardUtil;
|
||||
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.Optional;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/10.
|
||||
*/
|
||||
|
||||
public class NodeInfoView extends RecyclerView {
|
||||
|
||||
private static final String[] FIELD_NAMES = {
|
||||
"id",
|
||||
"idHex",
|
||||
"fullId",
|
||||
"bounds",
|
||||
"depth",
|
||||
"desc",
|
||||
"className",
|
||||
"packageName",
|
||||
"text",
|
||||
"drawingOrder",
|
||||
"accessibilityFocused",
|
||||
"checked",
|
||||
"clickable",
|
||||
"contextClickable",
|
||||
"dismissable",
|
||||
"editable",
|
||||
"enabled",
|
||||
"focusable",
|
||||
"indexInParent",
|
||||
"longClickable",
|
||||
"row",
|
||||
"rowCount",
|
||||
"rowSpan",
|
||||
"column",
|
||||
"columnCount",
|
||||
"columnSpan",
|
||||
"selected",
|
||||
"scrollable",
|
||||
};
|
||||
private static final Field[] FIELDS = new Field[FIELD_NAMES.length];
|
||||
|
||||
static {
|
||||
Arrays.sort(FIELD_NAMES);
|
||||
for (int i = 0; i < FIELD_NAMES.length; i++) {
|
||||
try {
|
||||
FIELDS[i] = NodeInfo.class.getDeclaredField(FIELD_NAMES[i]);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String[][] mData = new String[FIELDS.length + 1][2];
|
||||
|
||||
public NodeInfoView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public NodeInfoView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public NodeInfoView(Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setNodeInfo(NodeInfo nodeInfo) {
|
||||
for (int i = 0; i < FIELDS.length; i++) {
|
||||
try {
|
||||
Object value = FIELDS[i].get(nodeInfo);
|
||||
mData[i + 1][1] = value == null ? "" : value.toString();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
initData();
|
||||
setAdapter(new Adapter());
|
||||
setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
addItemDecoration(new HorizontalDividerItemDecoration.Builder(getContext())
|
||||
.color(0x1e000000)
|
||||
.size(2)
|
||||
.build());
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
mData[0][0] = getResources().getString(R.string.text_attribute);
|
||||
mData[0][1] = getResources().getString(R.string.text_value);
|
||||
for (int i = 1; i < mData.length; i++) {
|
||||
mData[i][0] = FIELD_NAMES[i - 1];
|
||||
mData[i][1] = "";
|
||||
}
|
||||
}
|
||||
|
||||
private class Adapter extends RecyclerView.Adapter<ViewHolder> {
|
||||
|
||||
final int VIEW_TYPE_HEADER = 0;
|
||||
final int VIEW_TYPE_ITEM = 1;
|
||||
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
int layoutRes = viewType == VIEW_TYPE_HEADER ? R.layout.node_info_view_header : R.layout.node_info_view_item;
|
||||
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(layoutRes, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
holder.attrName.setText(mData[position][0]);
|
||||
holder.attrValue.setText(mData[position][1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mData.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position == 0 ? VIEW_TYPE_HEADER : VIEW_TYPE_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
|
||||
@BindView(R.id.name)
|
||||
TextView attrName;
|
||||
|
||||
@BindView(R.id.value)
|
||||
TextView attrValue;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
}
|
||||
|
||||
@Optional
|
||||
@OnClick(R.id.item)
|
||||
void onItemClick() {
|
||||
int pos = getAdapterPosition();
|
||||
if (pos < 1 || pos >= mData.length)
|
||||
return;
|
||||
ClipboardUtil.setClip(getContext(), mData[pos][0] + " = " + mData[pos][1]);
|
||||
Toast.makeText(getContext(), R.string.text_already_copy_to_clip, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package org.autojs.autojs.ui.floating.layoutinspector
|
||||
|
||||
import android.content.Context
|
||||
import android.support.design.widget.Snackbar
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import butterknife.BindView
|
||||
import com.stardust.util.ClipboardUtil
|
||||
import com.stardust.util.sortedArrayOf
|
||||
import com.stardust.view.accessibility.NodeInfo
|
||||
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration
|
||||
import org.autojs.autojs.R
|
||||
import java.lang.reflect.Field
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/10.
|
||||
*/
|
||||
|
||||
class NodeInfoView : RecyclerView {
|
||||
|
||||
private val mData = Array(FIELDS.size + 1) { Array(2) { "" } }
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle) {
|
||||
init()
|
||||
}
|
||||
|
||||
fun setNodeInfo(nodeInfo: NodeInfo) {
|
||||
for (i in FIELDS.indices) {
|
||||
try {
|
||||
val value = FIELDS[i].get(nodeInfo)
|
||||
mData[i + 1][1] = value?.toString() ?: ""
|
||||
} catch (e: Exception) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
|
||||
}
|
||||
adapter!!.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
initData()
|
||||
adapter = Adapter()
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
addItemDecoration(HorizontalDividerItemDecoration.Builder(context)
|
||||
.color(0x1e000000)
|
||||
.size(2)
|
||||
.build())
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
mData[0][0] = resources.getString(R.string.text_attribute)
|
||||
mData[0][1] = resources.getString(R.string.text_value)
|
||||
for (i in 1 until mData.size) {
|
||||
mData[i][0] = FIELD_NAMES[i - 1]
|
||||
mData[i][1] = ""
|
||||
}
|
||||
}
|
||||
|
||||
private inner class Adapter : RecyclerView.Adapter<ViewHolder>() {
|
||||
|
||||
internal val VIEW_TYPE_HEADER = 0
|
||||
internal val VIEW_TYPE_ITEM = 1
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val layoutRes = if (viewType == VIEW_TYPE_HEADER) R.layout.node_info_view_header else R.layout.node_info_view_item
|
||||
return ViewHolder(LayoutInflater.from(parent.context).inflate(layoutRes, parent, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
holder.attrName.text = mData[position][0]
|
||||
holder.attrValue.text = mData[position][1]
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return mData.size
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (position == 0) VIEW_TYPE_HEADER else VIEW_TYPE_ITEM
|
||||
}
|
||||
}
|
||||
|
||||
internal inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
@BindView(R.id.name)
|
||||
val attrName: TextView = itemView.findViewById(R.id.name)
|
||||
|
||||
val attrValue: TextView = itemView.findViewById(R.id.value)
|
||||
|
||||
init {
|
||||
itemView.setOnClickListener {
|
||||
val pos = adapterPosition
|
||||
if (pos < 1 || pos >= mData.size)
|
||||
return@setOnClickListener
|
||||
ClipboardUtil.setClip(context, mData[pos][0] + " = " + mData[pos][1])
|
||||
Snackbar.make(this@NodeInfoView, R.string.text_already_copy_to_clip, Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private val FIELD_NAMES = sortedArrayOf(
|
||||
"id",
|
||||
"idHex",
|
||||
"fullId",
|
||||
"bounds",
|
||||
"depth",
|
||||
"desc",
|
||||
"className",
|
||||
"packageName",
|
||||
"text",
|
||||
"drawingOrder",
|
||||
"accessibilityFocused",
|
||||
"checked",
|
||||
"clickable",
|
||||
"contextClickable",
|
||||
"dismissable",
|
||||
"editable",
|
||||
"enabled",
|
||||
"focusable",
|
||||
"indexInParent",
|
||||
"longClickable",
|
||||
"row",
|
||||
"rowCount",
|
||||
"rowSpan",
|
||||
"column",
|
||||
"columnCount",
|
||||
"columnSpan",
|
||||
"selected",
|
||||
"scrollable")
|
||||
private val FIELDS = Array<Field>(FIELD_NAMES.size) {
|
||||
val field = NodeInfo::class.java.getDeclaredField(FIELD_NAMES[it])
|
||||
field.isAccessible = true
|
||||
field
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.stardust.autojs.core.console.ConsoleView;
|
||||
import com.stardust.autojs.core.console.StardustConsole;
|
||||
import com.stardust.autojs.core.console.ConsoleImpl;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
@@ -21,7 +21,7 @@ public class LogActivity extends BaseActivity {
|
||||
@ViewById(R.id.console)
|
||||
ConsoleView mConsoleView;
|
||||
|
||||
private StardustConsole mStardustConsole;
|
||||
private ConsoleImpl mConsoleImpl;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -32,13 +32,13 @@ public class LogActivity extends BaseActivity {
|
||||
@AfterViews
|
||||
void setupViews() {
|
||||
setToolbarAsBack(getString(R.string.text_log));
|
||||
mStardustConsole = AutoJs.getInstance().getGlobalConsole();
|
||||
mConsoleView.setConsole(mStardustConsole);
|
||||
mConsoleImpl = AutoJs.getInstance().getGlobalConsole();
|
||||
mConsoleView.setConsole(mConsoleImpl);
|
||||
mConsoleView.findViewById(R.id.input_container).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Click(R.id.fab)
|
||||
void clearConsole() {
|
||||
mStardustConsole.clear();
|
||||
mConsoleImpl.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user