From 4262cbcd15a5247ed17bf1770bb83af0ac0263b6 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Tue, 15 Mar 2011 20:53:47 +0100 Subject: [PATCH] New Setting: Show notices in server window. Closes #47. --- application/res/values/settings.xml | 3 +++ application/res/values/strings.xml | 2 ++ application/res/xml/preferences.xml | 5 +++++ application/src/org/yaaic/irc/IRCConnection.java | 12 +++++++++--- application/src/org/yaaic/model/Settings.java | 13 +++++++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/application/res/values/settings.xml b/application/res/values/settings.xml index 5666c8d..b210835 100644 --- a/application/res/values/settings.xml +++ b/application/res/values/settings.xml @@ -35,4 +35,7 @@ sound_highlight false + + notice_server_window + false diff --git a/application/res/values/strings.xml b/application/res/values/strings.xml index 850dd68..fd2e3ea 100644 --- a/application/res/values/strings.xml +++ b/application/res/values/strings.xml @@ -194,4 +194,6 @@ Show button for voice recognition Show join, part and quit Show join, part and quit messages in channels + Notices server window + Show notices in server window diff --git a/application/res/xml/preferences.xml b/application/res/xml/preferences.xml index 1bed452..71632c2 100644 --- a/application/res/xml/preferences.xml +++ b/application/res/xml/preferences.xml @@ -70,6 +70,11 @@ along with Yaaic. If not, see . android:summary="@string/settings_joinpartquit_desc" android:key="@string/key_show_joinpartquit" android:defaultValue="@string/default_show_joinpartquit" /> + diff --git a/application/src/org/yaaic/irc/IRCConnection.java b/application/src/org/yaaic/irc/IRCConnection.java index 4a61fe3..82d79fb 100644 --- a/application/src/org/yaaic/irc/IRCConnection.java +++ b/application/src/org/yaaic/irc/IRCConnection.java @@ -486,11 +486,17 @@ public class IRCConnection extends PircBot notice = Colors.removeFormattingAndColors(notice); // Post notice to currently selected conversation - Conversation conversation = server.getConversation(server.getSelectedConversation()); + Conversation conversation; - if (conversation == null) { - // Fallback: Use ServerInfo view + if (service.getSettings().showNoticeInServerWindow()) { conversation = server.getConversation(ServerInfo.DEFAULT_NAME); + } else { + conversation = server.getConversation(server.getSelectedConversation()); + + if (conversation == null) { + // Fallback: Use ServerInfo view + conversation = server.getConversation(ServerInfo.DEFAULT_NAME); + } } Message message = new Message("-" + sourceNick + "- " + notice); diff --git a/application/src/org/yaaic/model/Settings.java b/application/src/org/yaaic/model/Settings.java index c20e052..889a788 100644 --- a/application/src/org/yaaic/model/Settings.java +++ b/application/src/org/yaaic/model/Settings.java @@ -208,4 +208,17 @@ public class Settings Boolean.parseBoolean(resources.getString(R.string.default_show_joinpartquit)) ); } + + /** + * Should notices be shown in the server window instead in the focused window? + * + * @return True if notices should be shown in the server window + */ + public boolean showNoticeInServerWindow() + { + return preferences.getBoolean( + resources.getString(R.string.key_notice_server_window), + Boolean.parseBoolean(resources.getString(R.string.default_notice_server_window)) + ); + } }