Added editing rule groups

This commit is contained in:
M66B
2023-04-14 10:07:33 +02:00
parent 4c8866585d
commit 35993af770
5 changed files with 191 additions and 6 deletions

View File

@@ -93,10 +93,11 @@ public class FragmentRules extends FragmentBase {
private static final int REQUEST_EXPORT = 1;
private static final int REQUEST_IMPORT = 2;
static final int REQUEST_MOVE = 3;
static final int REQUEST_RULE_COPY_ACCOUNT = 4;
static final int REQUEST_RULE_COPY_FOLDER = 5;
private static final int REQUEST_CLEAR = 6;
static final int REQUEST_GROUP = 3;
static final int REQUEST_MOVE = 4;
static final int REQUEST_RULE_COPY_ACCOUNT = 5;
static final int REQUEST_RULE_COPY_FOLDER = 6;
private static final int REQUEST_CLEAR = 7;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -266,6 +267,7 @@ public class FragmentRules extends FragmentBase {
String sort = prefs.getString("rule_sort", "order");
adapter.set(protocol, sort, rules);
rvRule.invalidateItemDecorations();
pbWait.setVisibility(View.GONE);
grpReady.setVisibility(View.VISIBLE);
@@ -287,6 +289,10 @@ public class FragmentRules extends FragmentBase {
if (resultCode == RESULT_OK && data != null)
onImport(data);
break;
case REQUEST_GROUP:
if (resultCode == RESULT_OK && data != null)
onGroup(data.getBundleExtra("args"));
break;
case REQUEST_MOVE:
if (resultCode == RESULT_OK && data != null)
onMove(data.getBundleExtra("args"));
@@ -675,6 +681,25 @@ public class FragmentRules extends FragmentBase {
}.execute(this, args, "rules:import");
}
private void onGroup(Bundle args) {
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("rule");
String name = args.getString("name");
DB db = DB.getInstance(context);
db.rule().setRuleGroup(id, name);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, args, "rule:group");
}
private void onMove(Bundle args) {
new SimpleTask<Void>() {
@Override