|
|
@ -49,6 +49,7 @@ import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -69,7 +70,9 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
private ImageView ivStop;
|
|
|
|
private ImageView ivStop;
|
|
|
|
private TextView tvCondition;
|
|
|
|
private TextView tvCondition;
|
|
|
|
private TextView tvAction;
|
|
|
|
private TextView tvAction;
|
|
|
|
|
|
|
|
private TextView tvApplied;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private NumberFormat NF = NumberFormat.getNumberInstance();
|
|
|
|
private TwoStateOwner powner = new TwoStateOwner(owner, "RulePopup");
|
|
|
|
private TwoStateOwner powner = new TwoStateOwner(owner, "RulePopup");
|
|
|
|
|
|
|
|
|
|
|
|
ViewHolder(View itemView) {
|
|
|
|
ViewHolder(View itemView) {
|
|
|
@ -81,6 +84,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
ivStop = itemView.findViewById(R.id.ivStop);
|
|
|
|
ivStop = itemView.findViewById(R.id.ivStop);
|
|
|
|
tvCondition = itemView.findViewById(R.id.tvCondition);
|
|
|
|
tvCondition = itemView.findViewById(R.id.tvCondition);
|
|
|
|
tvAction = itemView.findViewById(R.id.tvAction);
|
|
|
|
tvAction = itemView.findViewById(R.id.tvAction);
|
|
|
|
|
|
|
|
tvApplied = itemView.findViewById(R.id.tvApplied);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void wire() {
|
|
|
|
private void wire() {
|
|
|
@ -163,6 +167,8 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
tvAction.setText(ex.getMessage());
|
|
|
|
tvAction.setText(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvApplied.setText(NF.format(rule.applied));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -197,8 +203,9 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
.setCheckable(true).setChecked(rule.enabled);
|
|
|
|
.setCheckable(true).setChecked(rule.enabled);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_rule_execute, 2, R.string.title_rule_execute)
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_rule_execute, 2, R.string.title_rule_execute)
|
|
|
|
.setEnabled(ActivityBilling.isPro(context));
|
|
|
|
.setEnabled(ActivityBilling.isPro(context));
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_move_to_folder, 3, R.string.title_move_to_folder);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_reset, 3, R.string.title_reset);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 4, R.string.title_copy);
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_move_to_folder, 4, R.string.title_move_to_folder);
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 5, R.string.title_copy);
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -212,6 +219,10 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
onActionExecute();
|
|
|
|
onActionExecute();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case R.string.title_reset:
|
|
|
|
|
|
|
|
onActionReset();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
case R.string.title_move_to_folder:
|
|
|
|
case R.string.title_move_to_folder:
|
|
|
|
onActionMove();
|
|
|
|
onActionMove();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -306,6 +317,28 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
|
|
|
|
}.execute(context, owner, args, "rule:execute");
|
|
|
|
}.execute(context, owner, args, "rule:execute");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onActionReset() {
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putLong("id", rule.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
db.rule().resetRule(id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Helper.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.execute(context, owner, args, "rule:execute");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onActionMove() {
|
|
|
|
private void onActionMove() {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putString("title", context.getString(R.string.title_move_to_folder));
|
|
|
|
args.putString("title", context.getString(R.string.title_move_to_folder));
|
|
|
|