diff --git a/src/com/irccloud/android/NetworkConnection.java b/src/com/irccloud/android/NetworkConnection.java index ca1e6ca8c..15d8911c6 100644 --- a/src/com/irccloud/android/NetworkConnection.java +++ b/src/com/irccloud/android/NetworkConnection.java @@ -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; @@ -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; @@ -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)); diff --git a/src/com/irccloud/android/activity/MainActivity.java b/src/com/irccloud/android/activity/MainActivity.java index 3387fec1d..60009c9d5 100644 --- a/src/com/irccloud/android/activity/MainActivity.java +++ b/src/com/irccloud/android/activity/MainActivity.java @@ -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() { diff --git a/src/com/irccloud/android/fragment/ChannelModeListFragment.java b/src/com/irccloud/android/fragment/ChannelModeListFragment.java index 9bbf8f14a..cabe127b7 100644 --- a/src/com/irccloud/android/fragment/ChannelModeListFragment.java +++ b/src/com/irccloud/android/fragment/ChannelModeListFragment.java @@ -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) { @@ -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() {