diff --git a/application/AndroidManifest.xml b/application/AndroidManifest.xml index 3a30cd2..c323f5f 100644 --- a/application/AndroidManifest.xml +++ b/application/AndroidManifest.xml @@ -94,4 +94,7 @@ along with Yaaic. If not, see . + + + \ No newline at end of file diff --git a/application/res/values/settings.xml b/application/res/values/settings.xml index 563f250..755bc43 100644 --- a/application/res/values/settings.xml +++ b/application/res/values/settings.xml @@ -26,4 +26,7 @@ voice_recognition false + + vibrate_highlight + true diff --git a/application/res/values/strings.xml b/application/res/values/strings.xml index 68ee7d9..3caf4c5 100644 --- a/application/res/values/strings.xml +++ b/application/res/values/strings.xml @@ -85,8 +85,8 @@ Query already exists Line is missing Nickname %1$s already in use - Could not log into the IRC server %1$s:%1$d - Could not connect to %1$s:%1$d + Could not log into the IRC server %1$s:%2$d + Could not connect to %1$s:%2$d Send a message to all channels Sets you away @@ -182,4 +182,6 @@ Font size Voice recognition Show button for voice recognition + Vibrate on highlight + Vibrate when your nick is mentioned diff --git a/application/res/xml/preferences.xml b/application/res/xml/preferences.xml index ff3eba2..91e0cb1 100644 --- a/application/res/xml/preferences.xml +++ b/application/res/xml/preferences.xml @@ -80,5 +80,11 @@ along with Yaaic. If not, see . android:defaultValue="@string/default_quitmessage" android:dialogTitle="@string/settings_quitmessage_dialog_title" android:dialogMessage="@string/settings_quitmessage_dialog_desc" /> + + diff --git a/application/src/org/yaaic/irc/IRCConnection.java b/application/src/org/yaaic/irc/IRCConnection.java index 2eeabc2..3ea4a29 100644 --- a/application/src/org/yaaic/irc/IRCConnection.java +++ b/application/src/org/yaaic/irc/IRCConnection.java @@ -195,7 +195,7 @@ public class IRCConnection extends PircBot if (action.contains(getNick())) { // highlight message.setColor(Message.COLOR_RED); - service.updateNotification(target + ": " + sender + " " + action); + service.updateNotification(target + ": " + sender + " " + action, service.getSettings().isVibrateHighlightEnabled()); server.getConversation(target).setStatus(Conversation.STATUS_HIGHLIGHT); } @@ -390,7 +390,7 @@ public class IRCConnection extends PircBot if (text.contains(getNick())) { // highlight message.setColor(Message.COLOR_RED); - service.updateNotification(target + ": <" + sender + "> " + text); + service.updateNotification(target + ": <" + sender + "> " + text, service.getSettings().isVibrateHighlightEnabled()); server.getConversation(target).setStatus(Conversation.STATUS_HIGHLIGHT); } @@ -536,7 +536,7 @@ public class IRCConnection extends PircBot if (text.contains(getNick())) { message.setColor(Message.COLOR_RED); - service.updateNotification("<" + sender + "> " + text); + service.updateNotification("<" + sender + "> " + text, service.getSettings().isVibrateHighlightEnabled()); server.getConversation(sender).setStatus(Conversation.STATUS_HIGHLIGHT); } diff --git a/application/src/org/yaaic/irc/IRCService.java b/application/src/org/yaaic/irc/IRCService.java index 0f48a2b..1d58ef9 100644 --- a/application/src/org/yaaic/irc/IRCService.java +++ b/application/src/org/yaaic/irc/IRCService.java @@ -43,6 +43,7 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Intent; +import android.util.Log; /** * The background service for managing the irc connections @@ -157,11 +158,10 @@ public class IRCService extends Service */ private void handleCommand(Intent intent) { - if (ACTION_FOREGROUND.equals(intent.getAction())) { + if (ACTION_FOREGROUND.equals(intent.getAction())) { if (foreground) { return; // XXX: We are already in foreground... } - foreground = true; // Set the icon, scrolling text and timestamp @@ -184,13 +184,19 @@ public class IRCService extends Service * * @param text The text to display */ - public void updateNotification(String text) + public void updateNotification(String text) { + updateNotification(text, false); + } + public void updateNotification(String text, boolean vibrate) { if (foreground) { notificationManager.cancel(R.string.app_name); notification = new Notification(R.drawable.icon, text, System.currentTimeMillis()); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ServersActivity.class), 0); notification.setLatestEventInfo(this, getText(R.string.app_name), text, contentIntent); + if (vibrate) { + notification.defaults |= Notification.DEFAULT_VIBRATE; + } notificationManager.notify(R.string.app_name, notification); } } diff --git a/application/src/org/yaaic/model/Settings.java b/application/src/org/yaaic/model/Settings.java index 2661bf3..634f761 100644 --- a/application/src/org/yaaic/model/Settings.java +++ b/application/src/org/yaaic/model/Settings.java @@ -169,4 +169,17 @@ public class Settings Boolean.parseBoolean(resources.getString(R.string.default_voice_recognition)) ); } + + /** + * Vibrate on highlight? + * + * @return True if vibrate on highlight is enabled, false otherwise + */ + public boolean isVibrateHighlightEnabled() + { + return preferences.getBoolean( + resources.getString(R.string.key_vibrate_highlight), + Boolean.parseBoolean(resources.getString(R.string.default_vibrate_highlight)) + ); + } }