Skip to content

Commit

Permalink
chanfilter_list
Browse files Browse the repository at this point in the history
  • Loading branch information
c99koder committed Mar 28, 2019
1 parent e090523 commit f25f46e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/com/irccloud/android/NetworkConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.firebase.iid.FirebaseInstanceId;
import com.irccloud.android.data.IRCCloudDatabase;
import com.irccloud.android.data.collection.ImageList;
import com.irccloud.android.data.collection.LogExportsList;
import com.irccloud.android.data.collection.NotificationsList;
Expand Down Expand Up @@ -205,6 +203,7 @@ public interface IRCResultCallback {
public static final int EVENT_MESSAGECHANGE = 57;
public static final int EVENT_WATCHSTATUS = 58;
public static final int EVENT_TEXTLIST = 59;
public static final int EVENT_CHANFILTERLIST = 60;

public static final int EVENT_BACKLOG_START = 100;
public static final int EVENT_BACKLOG_END = 101;
Expand Down Expand Up @@ -2897,6 +2896,7 @@ public void parse(IRCCloudJSONObject object) throws JSONException {
put("quiet_list", new BroadcastParser(EVENT_QUIETLIST));
put("ban_exception_list", new BroadcastParser(EVENT_BANEXCEPTIONLIST));
put("invite_list", new BroadcastParser(EVENT_INVITELIST));
put("chanfilter_list", new BroadcastParser(EVENT_CHANFILTERLIST));
put("channel_query", new BroadcastParser(EVENT_CHANNELQUERY));
put("text", new BroadcastParser(EVENT_TEXTLIST));
put("who_special_response", new BroadcastParser(EVENT_WHOSPECIALRESPONSE));
Expand Down
34 changes: 34 additions & 0 deletions src/com/irccloud/android/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2776,6 +2776,40 @@ public void run() {
}
});
break;
case NetworkConnection.EVENT_CHANFILTERLIST:
event = (IRCCloudJSONObject) obj;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (event != null && event.cid() == buffer.getCid()) {
hide_keyboard();
Bundle args = new Bundle();
args.putInt("cid", event.cid());
Buffer b = BuffersList.getInstance().getBufferByName(event.cid(), event.getString("channel"));
if(b != null)
args.putInt("bid", b.getBid());
args.putString("mode", "g");
args.putString("placeholder", "Empty filter pattern list.");
args.putString("mask", "pattern");
args.putString("list", "list");
args.putString("title", "Channel filter list for " + event.getString("channel"));
args.putString("event", event.toString());
ChannelModeListFragment channelModeList = (ChannelModeListFragment) getSupportFragmentManager().findFragmentByTag("chanfilterlist");
if (channelModeList == null) {
channelModeList = new ChannelModeListFragment();
channelModeList.setArguments(args);
try {
channelModeList.show(getSupportFragmentManager(), "chanfilterlist");
} catch (IllegalStateException e) {
//App lost focus already
}
} else {
channelModeList.setArguments(args);
}
}
}
});
break;
case NetworkConnection.EVENT_INVITELIST:
event = (IRCCloudJSONObject) obj;
runOnUiThread(new Runnable() {
Expand Down
12 changes: 10 additions & 2 deletions src/com/irccloud/android/fragment/ChannelModeListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public void onBindViewHolder(ViewHolder holder, final int position) {
if(node.has("usermask") && node.get("usermask") != null && node.get("usermask").asText() != null)
row.setSetBy("Set " + DateUtils.getRelativeTimeSpanString(node.get("time").asLong() * 1000L, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS)
+ " by " + node.get("usermask").asText());
else if(node.has("author") && node.get("author") != null && node.get("author").asText() != null)
row.setSetBy("Set " + DateUtils.getRelativeTimeSpanString(node.get("time").asLong() * 1000L, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS)
+ " by " + node.get("author").asText());
else
row.setSetBy("");
if (canChangeMode) {
Expand Down Expand Up @@ -196,8 +199,13 @@ public void onClick(DialogInterface d, int which) {
View view = inflater.inflate(R.layout.dialog_textprompt, null);
TextView prompt = view.findViewById(R.id.prompt);
final EditText input = view.findViewById(R.id.textInput);
input.setHint("nickname!user@host.name");
prompt.setText("Add this hostmask");
if(event.getString("type").equals("chanfilter_list")) {
input.setHint("\\*key\\*word\\*");
prompt.setText("Add this pattern");
} else {
input.setHint("nickname!user@host.name");
prompt.setText("Add this hostmask");
}
builder.setTitle(server.getName() + " (" + server.getHostname() + ":" + (server.getPort()) + ")");
builder.setView(view);
builder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
Expand Down

0 comments on commit f25f46e

Please sign in to comment.