Improved rule URL action

This commit is contained in:
M66B
2023-10-03 16:11:42 +02:00
parent abb876ba0f
commit 5df3cad93f
4 changed files with 89 additions and 6 deletions

View File

@@ -172,7 +172,9 @@ public class FragmentRule extends FragmentBase {
private EditText etNotes;
private ViewButtonColor btnColorNotes;
private Spinner spUrlMethod;
private EditText etUrl;
private TextView tvUrlHint;
private BottomNavigationView bottom_navigation;
private ContentLoadingProgressBar pbWait;
@@ -365,7 +367,9 @@ public class FragmentRule extends FragmentBase {
etNotes = view.findViewById(R.id.etNotes);
btnColorNotes = view.findViewById(R.id.btnColorNotes);
spUrlMethod = view.findViewById(R.id.spUrlMethod);
etUrl = view.findViewById(R.id.etUrl);
tvUrlHint = view.findViewById(R.id.tvUrlHint);
bottom_navigation = view.findViewById(R.id.bottom_navigation);
@@ -820,6 +824,15 @@ public class FragmentRule extends FragmentBase {
}
});
tvUrlHint.setText(getString(R.string.title_rule_url_hint,
TextUtils.join(", ", new String[]{
"$" + EntityRule.EXTRA_RULE + "$",
"$" + EntityRule.EXTRA_SENDER + "$",
"$" + EntityRule.EXTRA_NAME + "$",
"$" + EntityRule.EXTRA_SUBJECT + "$",
"$" + EntityRule.EXTRA_RECEIVED + "$",
})));
bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
@@ -1369,6 +1382,13 @@ public class FragmentRule extends FragmentBase {
case EntityRule.TYPE_URL:
etUrl.setText(jaction.getString("url"));
String method = jaction.optString("method");
if (TextUtils.isEmpty(method))
method = "GET";
int pos = Arrays.asList(getResources().getStringArray(R.array.httpMethodNames))
.indexOf(method);
if (pos >= 0)
spUrlMethod.setSelection(pos);
break;
}
@@ -1779,6 +1799,12 @@ public class FragmentRule extends FragmentBase {
case EntityRule.TYPE_URL:
jaction.put("url", etUrl.getText().toString().trim());
int pos = spUrlMethod.getSelectedItemPosition();
String[] methods = getResources().getStringArray(R.array.httpMethodNames);
if (pos >= 0 && pos < methods.length)
jaction.put("method", methods[pos]);
else
jaction.put("method", "GET");
break;
}
}