opt: layout inspector view
This commit is contained in:
@@ -9,8 +9,10 @@ import android.view.WindowManager;
|
|||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.afollestad.materialdialogs.Theme;
|
import com.afollestad.materialdialogs.Theme;
|
||||||
|
import com.stardust.app.DialogUtils;
|
||||||
import com.stardust.enhancedfloaty.FloatyService;
|
import com.stardust.enhancedfloaty.FloatyService;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
|
import com.stardust.scriptdroid.ui.codegeneration.CodeGenerateDialog;
|
||||||
import com.stardust.scriptdroid.ui.floating.FullScreenFloatyWindow;
|
import com.stardust.scriptdroid.ui.floating.FullScreenFloatyWindow;
|
||||||
import com.stardust.view.accessibility.NodeInfo;
|
import com.stardust.view.accessibility.NodeInfo;
|
||||||
import com.stardust.scriptdroid.ui.widget.BubblePopupMenu;
|
import com.stardust.scriptdroid.ui.widget.BubblePopupMenu;
|
||||||
@@ -82,22 +84,27 @@ public class LayoutHierarchyFloatyWindow extends FullScreenFloatyWindow {
|
|||||||
return;
|
return;
|
||||||
mBubblePopMenu = new BubblePopupMenu(mContext, Arrays.asList(
|
mBubblePopMenu = new BubblePopupMenu(mContext, Arrays.asList(
|
||||||
mContext.getString(R.string.text_show_widget_infomation),
|
mContext.getString(R.string.text_show_widget_infomation),
|
||||||
mContext.getString(R.string.text_show_layout_bounds)));
|
mContext.getString(R.string.text_show_layout_bounds),
|
||||||
mBubblePopMenu.setOnItemClickListener(new BubblePopupMenu.OnItemClickListener() {
|
mContext.getString(R.string.text_generate_code)));
|
||||||
@Override
|
mBubblePopMenu.setOnItemClickListener((view, position) -> {
|
||||||
public void onClick(View view, int position) {
|
mBubblePopMenu.dismiss();
|
||||||
mBubblePopMenu.dismiss();
|
if (position == 0) {
|
||||||
if (position == 0) {
|
showNodeInfo();
|
||||||
showNodeInfo();
|
} else if (position == 1) {
|
||||||
} else {
|
showLayoutBounds();
|
||||||
showLayoutBounds();
|
} else {
|
||||||
}
|
generateCode();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mBubblePopMenu.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
|
mBubblePopMenu.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
mBubblePopMenu.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
mBubblePopMenu.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void generateCode() {
|
||||||
|
DialogUtils.showDialog(new CodeGenerateDialog(mContext, mRootNode, mSelectedNode)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
private void showLayoutBounds() {
|
private void showLayoutBounds() {
|
||||||
close();
|
close();
|
||||||
LayoutBoundsFloatyWindow window = new LayoutBoundsFloatyWindow(mRootNode);
|
LayoutBoundsFloatyWindow window = new LayoutBoundsFloatyWindow(mRootNode);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class NodeInfoView extends RecyclerView {
|
|||||||
"editable",
|
"editable",
|
||||||
"enabled",
|
"enabled",
|
||||||
"focusable",
|
"focusable",
|
||||||
|
"indexInParent",
|
||||||
"longClickable",
|
"longClickable",
|
||||||
"row",
|
"row",
|
||||||
"rowCount",
|
"rowCount",
|
||||||
|
|||||||
@@ -34,12 +34,7 @@ public class BubblePopupMenu extends PopupWindow {
|
|||||||
View view = View.inflate(context, R.layout.bubble_popup_menu, null);
|
View view = View.inflate(context, R.layout.bubble_popup_menu, null);
|
||||||
mLittleTriangle = view.findViewById(R.id.little_triangle);
|
mLittleTriangle = view.findViewById(R.id.little_triangle);
|
||||||
mRecyclerView = (RecyclerView) view.findViewById(R.id.list);
|
mRecyclerView = (RecyclerView) view.findViewById(R.id.list);
|
||||||
mRecyclerView.setAdapter(new SimpleRecyclerViewAdapter<>(R.layout.bubble_popup_menu_item, options, new SimpleRecyclerViewAdapter.ViewHolderFactory<MenuItemViewHolder>() {
|
mRecyclerView.setAdapter(new SimpleRecyclerViewAdapter<>(R.layout.bubble_popup_menu_item, options, MenuItemViewHolder::new));
|
||||||
@Override
|
|
||||||
public MenuItemViewHolder create(View itemView) {
|
|
||||||
return new MenuItemViewHolder(itemView);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
setContentView(view);
|
setContentView(view);
|
||||||
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
setOutsideTouchable(true);
|
setOutsideTouchable(true);
|
||||||
@@ -53,8 +48,8 @@ public class BubblePopupMenu extends PopupWindow {
|
|||||||
public void showAsDropDownAtLocation(View parent, int contentHeight, int x, int y) {
|
public void showAsDropDownAtLocation(View parent, int contentHeight, int x, int y) {
|
||||||
int screenWidth = getContentView().getResources().getDisplayMetrics().widthPixels;
|
int screenWidth = getContentView().getResources().getDisplayMetrics().widthPixels;
|
||||||
int screenHeight = getContentView().getResources().getDisplayMetrics().heightPixels;
|
int screenHeight = getContentView().getResources().getDisplayMetrics().heightPixels;
|
||||||
int width = getContentView().getWidth();
|
int width = getContentView().getMeasuredWidth();
|
||||||
int height = getContentView().getHeight();
|
int height = getContentView().getMeasuredHeight();
|
||||||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mLittleTriangle.getLayoutParams();
|
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mLittleTriangle.getLayoutParams();
|
||||||
if (x + width > screenWidth) {
|
if (x + width > screenWidth) {
|
||||||
params.leftMargin = x + width - screenWidth;
|
params.leftMargin = x + width - screenWidth;
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ public class ScriptRuntime {
|
|||||||
throw new IllegalStateException("already initialized");
|
throw new IllegalStateException("already initialized");
|
||||||
timers = new Timers(bridges);
|
timers = new Timers(bridges);
|
||||||
loopers = new Loopers(this);
|
loopers = new Loopers(this);
|
||||||
events = new Events(uiHandler.getContext(), accessibilityBridge, bridges, loopers);
|
events = new Events(uiHandler.getContext(), accessibilityBridge, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setApplicationContext(Context context) {
|
public static void setApplicationContext(Context context) {
|
||||||
|
|||||||
@@ -50,9 +50,11 @@ public class NodeInfo {
|
|||||||
public boolean checkable;
|
public boolean checkable;
|
||||||
public boolean focused;
|
public boolean focused;
|
||||||
public boolean visibleToUser;
|
public boolean visibleToUser;
|
||||||
|
public int indexInParent;
|
||||||
public NodeInfo parent;
|
public NodeInfo parent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public NodeInfo(UiObject node, NodeInfo parent) {
|
public NodeInfo(UiObject node, NodeInfo parent) {
|
||||||
id = simplifyId(node.getViewIdResourceName());
|
id = simplifyId(node.getViewIdResourceName());
|
||||||
desc = node.desc();
|
desc = node.desc();
|
||||||
@@ -87,6 +89,7 @@ public class NodeInfo {
|
|||||||
node.getBoundsInScreen(mBoundsInScreen);
|
node.getBoundsInScreen(mBoundsInScreen);
|
||||||
node.getBoundsInParent(mBoundsInParent);
|
node.getBoundsInParent(mBoundsInParent);
|
||||||
bounds = boundsToString(mBoundsInScreen);
|
bounds = boundsToString(mBoundsInScreen);
|
||||||
|
indexInParent = node.indexInParent();
|
||||||
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user