|
|
@ -168,10 +168,11 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
JSONObject jaction = new JSONObject(rule.action);
|
|
|
|
JSONObject jaction = new JSONObject(rule.action);
|
|
|
|
|
|
|
|
|
|
|
|
String to = null;
|
|
|
|
String to = null;
|
|
|
|
|
|
|
|
boolean resend = false;
|
|
|
|
int type = jaction.getInt("type");
|
|
|
|
int type = jaction.getInt("type");
|
|
|
|
if (type == EntityRule.TYPE_SNOOZE) {
|
|
|
|
if (type == EntityRule.TYPE_SNOOZE) {
|
|
|
|
int duration = jaction.optInt("duration", 0);
|
|
|
|
int duration = jaction.optInt("duration", 0);
|
|
|
|
setAction(type, Integer.toString(duration));
|
|
|
|
setAction(getAction(type), Integer.toString(duration));
|
|
|
|
} else if (type == EntityRule.TYPE_IMPORTANCE) {
|
|
|
|
} else if (type == EntityRule.TYPE_IMPORTANCE) {
|
|
|
|
int importance = jaction.optInt("value");
|
|
|
|
int importance = jaction.optInt("value");
|
|
|
|
|
|
|
|
|
|
|
@ -183,15 +184,17 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
else if (importance == EntityMessage.PRIORITIY_HIGH)
|
|
|
|
else if (importance == EntityMessage.PRIORITIY_HIGH)
|
|
|
|
value = context.getString(R.string.title_importance_high);
|
|
|
|
value = context.getString(R.string.title_importance_high);
|
|
|
|
|
|
|
|
|
|
|
|
setAction(type, value);
|
|
|
|
setAction(getAction(type), value);
|
|
|
|
} else if (type == EntityRule.TYPE_KEYWORD) {
|
|
|
|
} else if (type == EntityRule.TYPE_KEYWORD) {
|
|
|
|
setAction(type, jaction.optString("keyword"));
|
|
|
|
setAction(getAction(type), jaction.optString("keyword"));
|
|
|
|
} else if (type == EntityRule.TYPE_ANSWER) {
|
|
|
|
} else if (type == EntityRule.TYPE_ANSWER) {
|
|
|
|
to = jaction.optString("to");
|
|
|
|
to = jaction.optString("to");
|
|
|
|
if (!TextUtils.isEmpty(to))
|
|
|
|
if (!TextUtils.isEmpty(to)) {
|
|
|
|
setAction(type, to);
|
|
|
|
resend = jaction.optBoolean("resend");
|
|
|
|
|
|
|
|
setAction(resend ? R.string.title_rule_resend : getAction(type), to);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
setAction(type, null);
|
|
|
|
setAction(getAction(type), null);
|
|
|
|
|
|
|
|
|
|
|
|
if (type == EntityRule.TYPE_MOVE || type == EntityRule.TYPE_COPY ||
|
|
|
|
if (type == EntityRule.TYPE_MOVE || type == EntityRule.TYPE_COPY ||
|
|
|
|
(type == EntityRule.TYPE_ANSWER && TextUtils.isEmpty(to))) {
|
|
|
|
(type == EntityRule.TYPE_ANSWER && TextUtils.isEmpty(to))) {
|
|
|
@ -228,7 +231,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
if (id != AdapterRule.this.getItemId(pos))
|
|
|
|
if (id != AdapterRule.this.getItemId(pos))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
setAction(args.getInt("type"), value);
|
|
|
|
setAction(getAction(args.getInt("type")), value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -453,74 +456,58 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void setAction(int type, String value) {
|
|
|
|
private void setAction(int resid, String value) {
|
|
|
|
int resid;
|
|
|
|
if (TextUtils.isEmpty(value))
|
|
|
|
|
|
|
|
tvAction.setText(resid);
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
SpannableStringBuilder ssb = new SpannableStringBuilderEx();
|
|
|
|
|
|
|
|
ssb.append(context.getString(resid));
|
|
|
|
|
|
|
|
ssb.append(" \"");
|
|
|
|
|
|
|
|
int start = ssb.length();
|
|
|
|
|
|
|
|
ssb.append(value);
|
|
|
|
|
|
|
|
ssb.setSpan(new StyleSpan(Typeface.ITALIC), start, ssb.length(), 0);
|
|
|
|
|
|
|
|
ssb.append("\"");
|
|
|
|
|
|
|
|
tvAction.setText(ssb);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int getAction(int type) {
|
|
|
|
switch (type) {
|
|
|
|
switch (type) {
|
|
|
|
case EntityRule.TYPE_NOOP:
|
|
|
|
case EntityRule.TYPE_NOOP:
|
|
|
|
resid = R.string.title_rule_noop;
|
|
|
|
return R.string.title_rule_noop;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_SEEN:
|
|
|
|
case EntityRule.TYPE_SEEN:
|
|
|
|
resid = R.string.title_rule_seen;
|
|
|
|
return R.string.title_rule_seen;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_UNSEEN:
|
|
|
|
case EntityRule.TYPE_UNSEEN:
|
|
|
|
resid = R.string.title_rule_unseen;
|
|
|
|
return R.string.title_rule_unseen;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_HIDE:
|
|
|
|
case EntityRule.TYPE_HIDE:
|
|
|
|
resid = R.string.title_rule_hide;
|
|
|
|
return R.string.title_rule_hide;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_IGNORE:
|
|
|
|
case EntityRule.TYPE_IGNORE:
|
|
|
|
resid = R.string.title_rule_ignore;
|
|
|
|
return R.string.title_rule_ignore;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_SNOOZE:
|
|
|
|
case EntityRule.TYPE_SNOOZE:
|
|
|
|
resid = R.string.title_rule_snooze;
|
|
|
|
return R.string.title_rule_snooze;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_FLAG:
|
|
|
|
case EntityRule.TYPE_FLAG:
|
|
|
|
resid = R.string.title_rule_flag;
|
|
|
|
return R.string.title_rule_flag;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_IMPORTANCE:
|
|
|
|
case EntityRule.TYPE_IMPORTANCE:
|
|
|
|
resid = R.string.title_rule_importance;
|
|
|
|
return R.string.title_rule_importance;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_KEYWORD:
|
|
|
|
case EntityRule.TYPE_KEYWORD:
|
|
|
|
resid = R.string.title_rule_keyword;
|
|
|
|
return R.string.title_rule_keyword;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_MOVE:
|
|
|
|
case EntityRule.TYPE_MOVE:
|
|
|
|
resid = R.string.title_rule_move;
|
|
|
|
return R.string.title_rule_move;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_COPY:
|
|
|
|
case EntityRule.TYPE_COPY:
|
|
|
|
resid = R.string.title_rule_copy;
|
|
|
|
return R.string.title_rule_copy;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_ANSWER:
|
|
|
|
case EntityRule.TYPE_ANSWER:
|
|
|
|
resid = R.string.title_rule_answer;
|
|
|
|
return R.string.title_rule_answer;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_TTS:
|
|
|
|
case EntityRule.TYPE_TTS:
|
|
|
|
resid = R.string.title_rule_tts;
|
|
|
|
return R.string.title_rule_tts;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_AUTOMATION:
|
|
|
|
case EntityRule.TYPE_AUTOMATION:
|
|
|
|
resid = R.string.title_rule_automation;
|
|
|
|
return R.string.title_rule_automation;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_DELETE:
|
|
|
|
case EntityRule.TYPE_DELETE:
|
|
|
|
resid = R.string.title_rule_delete;
|
|
|
|
return R.string.title_rule_delete;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EntityRule.TYPE_SOUND:
|
|
|
|
case EntityRule.TYPE_SOUND:
|
|
|
|
resid = R.string.title_rule_sound;
|
|
|
|
return R.string.title_rule_sound;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new IllegalArgumentException("Unknown action type=" + type);
|
|
|
|
throw new IllegalArgumentException("Unknown action type=" + type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(value))
|
|
|
|
|
|
|
|
tvAction.setText(resid);
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
SpannableStringBuilder ssb = new SpannableStringBuilderEx();
|
|
|
|
|
|
|
|
ssb.append(context.getString(resid));
|
|
|
|
|
|
|
|
ssb.append(" \"");
|
|
|
|
|
|
|
|
int start = ssb.length();
|
|
|
|
|
|
|
|
ssb.append(value);
|
|
|
|
|
|
|
|
ssb.setSpan(new StyleSpan(Typeface.ITALIC), start, ssb.length(), 0);
|
|
|
|
|
|
|
|
ssb.append("\"");
|
|
|
|
|
|
|
|
tvAction.setText(ssb);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|