|
6 | 6 | import android.support.v7.app.AlertDialog; |
7 | 7 | import android.os.Bundle; |
8 | 8 | import android.view.LayoutInflater; |
| 9 | +import android.view.Menu; |
| 10 | +import android.view.MenuInflater; |
| 11 | +import android.view.MenuItem; |
9 | 12 | import android.view.View; |
10 | 13 | import android.view.ViewGroup; |
11 | 14 | import android.widget.EditText; |
12 | 15 | import android.widget.LinearLayout; |
13 | 16 | import android.widget.ScrollView; |
14 | 17 | import android.widget.TextView; |
15 | | - |
16 | 18 | import com.kevin.share.Common; |
17 | 19 | import com.kevin.share.utils.ToastUtils; |
18 | | -import com.kevin.share.utils.logUtil; |
19 | 20 | import com.kevin.testool.MyApplication; |
20 | 21 | import com.kevin.testool.R; |
21 | 22 |
|
@@ -52,10 +53,10 @@ protected void onCreate(Bundle savedInstanceState) { |
52 | 53 | LinearLayout viewItem = new LinearLayout(this); |
53 | 54 | LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams( |
54 | 55 | LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); |
55 | | - vp.setMargins(15, 5, 15, 5); |
| 56 | + vp.setMargins(15, 5, 15, 20); |
56 | 57 | viewItem.setLayoutParams(vp);//设置布局参数 |
57 | 58 | viewItem.setOrientation(LinearLayout.VERTICAL);// 设置子View的Linearlayout// 为垂直方向布局 |
58 | | - viewItem.setBackgroundColor(getResources().getColor(R.color.alice_blue)); |
| 59 | + viewItem.setBackgroundColor(getResources().getColor(R.color.white)); |
59 | 60 |
|
60 | 61 | TextView tv1 = new TextView(this); |
61 | 62 | TextView tv2 = new TextView(this); |
@@ -98,6 +99,55 @@ public void onClick(View view) { |
98 | 99 |
|
99 | 100 | } |
100 | 101 |
|
| 102 | + @Override |
| 103 | + public boolean onCreateOptionsMenu(Menu menu){ |
| 104 | + MenuInflater inflater = getMenuInflater(); |
| 105 | + inflater.inflate(R.menu.menu_config, menu); |
| 106 | + return true; |
| 107 | + } |
| 108 | + |
| 109 | + @Override |
| 110 | + public boolean onOptionsItemSelected(MenuItem item) { |
| 111 | + int id = item.getItemId(); |
| 112 | + if (id == R.id.toConfigDetail) { |
| 113 | + AlertDialog.Builder popWindow = new AlertDialog.Builder(ConfigActivity.this); |
| 114 | + View dialogView = LayoutInflater.from(ConfigActivity.this).inflate(R.layout.case_detail,null); |
| 115 | + //设置对话框标题 |
| 116 | + popWindow.setTitle("配置文件"); |
| 117 | +// 设置对话框消息 |
| 118 | + popWindow.setView(dialogView); |
| 119 | +// String res = FileUtils.readJsonFile(CONFIG_FILE); |
| 120 | + String res = Common.reloadCONFIG().toString(); |
| 121 | + final TextView case_detail = dialogView.findViewById(R.id.case_detail); |
| 122 | + case_detail.setText(res.replace("}},","}},\n").replace("\",", "\",\n").replace("\n\n", "\n")); |
| 123 | + case_detail.setTextIsSelectable(true); |
| 124 | + |
| 125 | +// 添加选择按钮并注册监听 |
| 126 | + popWindow.setPositiveButton("编辑", (dialog, which) -> { |
| 127 | + AlertDialog.Builder editWindow = new AlertDialog.Builder(ConfigActivity.this); |
| 128 | + View editWindowView = LayoutInflater.from(MyApplication.getContext()).inflate(R.layout.case_edit,null); |
| 129 | +// editWindow.setTitle("编辑用例"); |
| 130 | + editWindow.setView(editWindowView); |
| 131 | + final EditText et = editWindowView.findViewById(R.id.caseEdit); |
| 132 | + et.setText(res.replace("}},","}},\n").replace("\",", "\",\n").replace("\n\n", "\n")); |
| 133 | + editWindow.setPositiveButton("保存", (dialog1, which1) -> { |
| 134 | + Common.updateCONFIG(et.getText().toString()); |
| 135 | + |
| 136 | + }); |
| 137 | + editWindow.setNegativeButton("取消", null); |
| 138 | + editWindow.show(); |
| 139 | + }); |
| 140 | + popWindow.setNegativeButton("关闭", null); |
| 141 | + //对话框显示 |
| 142 | + popWindow.show(); |
| 143 | + |
| 144 | + |
| 145 | + return true; |
| 146 | + } |
| 147 | + |
| 148 | + return super.onOptionsItemSelected(item); |
| 149 | + } |
| 150 | + |
101 | 151 | private Object exchangeType(String value, String theType) throws Exception { |
102 | 152 | switch (theType) { |
103 | 153 | case "Integer": |
|
0 commit comments