Added support for LED light notification on nickname highlight

This commit is contained in:
Daniel E. Moctezuma 2012-09-27 16:18:20 -07:00 committed by Sebastian Kaspari
parent e444354d48
commit 89ff98b93d
6 changed files with 50 additions and 11 deletions

View File

@ -42,6 +42,9 @@
<string name="key_sound_highlight">sound_highlight</string>
<string name="default_sound_highlight">false</string>
<string name="key_led_highlight">led_highlight</string>
<string name="default_led_highlight">true</string>
<string name="key_notice_server_window">notice_server_window</string>
<string name="default_notice_server_window">false</string>

View File

@ -205,6 +205,8 @@
<string name="settings_sound_highlight_desc">Play sound when your nick is mentioned</string>
<string name="settings_vibrate_highlight_title">Vibrate on highlight</string>
<string name="settings_vibrate_highlight_desc">Vibrate when your nick is mentioned</string>
<string name="settings_led_highlight_title">Flash LED on highlight</string>
<string name="settings_led_highlight_desc">Flash LED light when your nick is mentioned</string>
<string name="settings_misc">Misc</string>
<string name="settings_quitmessage_title">Quit message</string>

View File

@ -3,6 +3,7 @@
Yaaic - Yet Another Android IRC Client
Copyright 2009-2012 Sebastian Kaspari
Copyright 2012 Daniel E. Moctezuma <democtezuma@gmail.com>
This file is part of Yaaic.
@ -133,6 +134,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:summary="@string/settings_vibrate_highlight_desc"
android:key="@string/key_vibrate_highlight"
android:defaultValue="@string/default_vibrate_highlight" />
<CheckBoxPreference
android:title="@string/settings_led_highlight_title"
android:summary="@string/settings_led_highlight_desc"
android:key="@string/key_led_highlight"
android:defaultValue="@string/default_led_highlight" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/settings_misc">

View File

@ -2,6 +2,7 @@
Yaaic - Yet Another Android IRC Client
Copyright 2009-2012 Sebastian Kaspari
Copyright 2012 Daniel E. Moctezuma <democtezuma@gmail.com>
This file is part of Yaaic.
@ -281,7 +282,8 @@ public class IRCConnection extends PircBot
conversation,
conversation.getName() + ": " + sender + " " + action,
service.getSettings().isVibrateHighlightEnabled(),
service.getSettings().isSoundHighlightEnabled()
service.getSettings().isSoundHighlightEnabled(),
service.getSettings().isLedHighlightEnabled()
);
}
}
@ -458,7 +460,8 @@ public class IRCConnection extends PircBot
conversation,
target + ": <" + sender + "> " + text,
service.getSettings().isVibrateHighlightEnabled(),
service.getSettings().isSoundHighlightEnabled()
service.getSettings().isSoundHighlightEnabled(),
service.getSettings().isLedHighlightEnabled()
);
}
@ -669,7 +672,8 @@ public class IRCConnection extends PircBot
conversation,
"<" + sender + "> " + text,
service.getSettings().isVibrateHighlightEnabled(),
service.getSettings().isSoundHighlightEnabled()
service.getSettings().isSoundHighlightEnabled(),
service.getSettings().isLedHighlightEnabled()
);
}

View File

@ -2,6 +2,7 @@
Yaaic - Yet Another Android IRC Client
Copyright 2009-2012 Sebastian Kaspari
Copyright 2012 Daniel E. Moctezuma <democtezuma@gmail.com>
This file is part of Yaaic.
@ -211,14 +212,15 @@ public class IRCService extends Service
}
/**
* Update notification and vibrate if needed
* Update notification and vibrate and/or flash a LED light if needed
*
* @param text The ticker text to display
* @param contentText The text to display in the notification dropdown
* @param vibrate True if the device should vibrate, false otherwise
* @param sound True if the device should make sound, false otherwise
* @param light True if the device should flash a LED light, false otherwise
*/
private void updateNotification(String text, String contentText, boolean vibrate, boolean sound)
private void updateNotification(String text, String contentText, boolean vibrate, boolean sound, boolean light)
{
if (foreground) {
notification = new Notification(R.drawable.icon, text, System.currentTimeMillis());
@ -254,6 +256,13 @@ public class IRCService extends Service
notification.defaults |= Notification.DEFAULT_SOUND;
}
if (light) {
notification.ledARGB = 0xff00ff00;
notification.ledOnMS = 300;
notification.ledOffMS = 1000;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
}
notification.number = newMentions;
notificationManager.notify(FOREGROUND_NOTIFICATION, notification);
@ -274,8 +283,9 @@ public class IRCService extends Service
* @param msg The text of the new message
* @param vibrate Whether the notification should include vibration
* @param sound Whether the notification should include sound
* @param light Whether the notification should include a flashing LED light
*/
public synchronized void addNewMention(int serverId, Conversation conversation, String msg, boolean vibrate, boolean sound)
public synchronized void addNewMention(int serverId, Conversation conversation, String msg, boolean vibrate, boolean sound, boolean light)
{
if (conversation == null) {
return;
@ -289,9 +299,9 @@ public class IRCService extends Service
}
if (newMentions == 1) {
updateNotification(msg, msg, vibrate, sound);
updateNotification(msg, msg, vibrate, sound, light);
} else {
updateNotification(msg, null, vibrate, sound);
updateNotification(msg, null, vibrate, sound, light);
}
}
@ -316,7 +326,7 @@ public class IRCService extends Service
newMentions = 0;
}
updateNotification(null, null, false, false);
updateNotification(null, null, false, false, false);
}
/**
@ -327,7 +337,7 @@ public class IRCService extends Service
public synchronized void notifyConnected(String title)
{
connectedServerTitles.add(title);
updateNotification(getString(R.string.notification_connected, title), null, false, false);
updateNotification(getString(R.string.notification_connected, title), null, false, false, false);
}
/**
@ -338,7 +348,7 @@ public class IRCService extends Service
public synchronized void notifyDisconnected(String title)
{
connectedServerTitles.remove(title);
updateNotification(getString(R.string.notification_disconnected, title), null, false, false);
updateNotification(getString(R.string.notification_disconnected, title), null, false, false, false);
}

View File

@ -2,6 +2,7 @@
Yaaic - Yet Another Android IRC Client
Copyright 2009-2012 Sebastian Kaspari
Copyright 2012 Daniel E. Moctezuma <democtezuma@gmail.com>
This file is part of Yaaic.
@ -222,6 +223,19 @@ public class Settings
);
}
/**
* LED light notification on highlight?
*
* @return True if LED light on highlight is enabled, false otherwise
*/
public boolean isLedHighlightEnabled()
{
return preferences.getBoolean(
resources.getString(R.string.key_led_highlight),
Boolean.parseBoolean(resources.getString(R.string.default_led_highlight))
);
}
/**
* Should join, part and quit messages be displayed?
*