forked from pocmo/Yaaic
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for LED light notification on nickname highlight
- Loading branch information
1 parent
e444354
commit 89ff98b
Showing
6 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
Yaaic - Yet Another Android IRC Client | ||
Copyright 2009-2012 Sebastian Kaspari | ||
Copyright 2012 Daniel E. Moctezuma <[email protected]> | ||
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"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
Yaaic - Yet Another Android IRC Client | ||
Copyright 2009-2012 Sebastian Kaspari | ||
Copyright 2012 Daniel E. Moctezuma <[email protected]> | ||
This file is part of Yaaic. | ||
|
@@ -281,7 +282,8 @@ protected void onAction(String sender, String login, String hostname, String tar | |
conversation, | ||
conversation.getName() + ": " + sender + " " + action, | ||
service.getSettings().isVibrateHighlightEnabled(), | ||
service.getSettings().isSoundHighlightEnabled() | ||
service.getSettings().isSoundHighlightEnabled(), | ||
service.getSettings().isLedHighlightEnabled() | ||
); | ||
} | ||
} | ||
|
@@ -458,7 +460,8 @@ protected void onMessage(String target, String sender, String login, String host | |
conversation, | ||
target + ": <" + sender + "> " + text, | ||
service.getSettings().isVibrateHighlightEnabled(), | ||
service.getSettings().isSoundHighlightEnabled() | ||
service.getSettings().isSoundHighlightEnabled(), | ||
service.getSettings().isLedHighlightEnabled() | ||
); | ||
} | ||
|
||
|
@@ -669,7 +672,8 @@ protected void onPrivateMessage(String sender, String login, String hostname, St | |
conversation, | ||
"<" + sender + "> " + text, | ||
service.getSettings().isVibrateHighlightEnabled(), | ||
service.getSettings().isSoundHighlightEnabled() | ||
service.getSettings().isSoundHighlightEnabled(), | ||
service.getSettings().isLedHighlightEnabled() | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
Yaaic - Yet Another Android IRC Client | ||
Copyright 2009-2012 Sebastian Kaspari | ||
Copyright 2012 Daniel E. Moctezuma <[email protected]> | ||
This file is part of Yaaic. | ||
|
@@ -211,14 +212,15 @@ private void handleCommand(Intent intent) | |
} | ||
|
||
/** | ||
* 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 @@ private void updateNotification(String text, String contentText, boolean vibrate | |
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 String getConversationId(int serverId, String title) { | |
* @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 synchronized void addNewMention(int serverId, Conversation conversation, | |
} | ||
|
||
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 synchronized void ackNewMentions(int serverId, String convTitle) | |
newMentions = 0; | ||
} | ||
|
||
updateNotification(null, null, false, false); | ||
updateNotification(null, null, false, false, false); | ||
} | ||
|
||
/** | ||
|
@@ -327,7 +337,7 @@ public synchronized void ackNewMentions(int serverId, String convTitle) | |
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 synchronized void notifyConnected(String title) | |
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); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
Yaaic - Yet Another Android IRC Client | ||
Copyright 2009-2012 Sebastian Kaspari | ||
Copyright 2012 Daniel E. Moctezuma <[email protected]> | ||
This file is part of Yaaic. | ||
|
@@ -222,6 +223,19 @@ public boolean isVibrateHighlightEnabled() | |
); | ||
} | ||
|
||
/** | ||
* 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? | ||
* | ||
|