New Setting: Show notices in server window. Closes #47.

This commit is contained in:
Sebastian Kaspari 2011-03-15 20:53:47 +01:00
parent b855b7ea92
commit 4262cbcd15
5 changed files with 32 additions and 3 deletions

View File

@ -35,4 +35,7 @@
<string name="key_sound_highlight">sound_highlight</string>
<string name="default_sound_highlight">false</string>
<string name="key_notice_server_window">notice_server_window</string>
<string name="default_notice_server_window">false</string>
</resources>

View File

@ -194,4 +194,6 @@
<string name="settings_voice_recognition_desc">Show button for voice recognition</string>
<string name="settings_joinpartquit_title">Show join, part and quit</string>
<string name="settings_joinpartquit_desc">Show join, part and quit messages in channels</string>
<string name="settings_noticeserverwindow_title">Notices server window</string>
<string name="settings_noticeserverwindow_desc">Show notices in server window</string>
</resources>

View File

@ -70,6 +70,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:summary="@string/settings_joinpartquit_desc"
android:key="@string/key_show_joinpartquit"
android:defaultValue="@string/default_show_joinpartquit" />
<CheckBoxPreference
android:title="@string/settings_noticeserverwindow_title"
android:summary="@string/settings_noticeserverwindow_desc"
android:key="@string/key_notice_server_window"
android:defaultValue="@string/default_notice_server_window" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/settings_highlight">

View File

@ -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);

View File

@ -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))
);
}
}