mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-11 11:44:59 -05:00
Added setting to vibrate on highlight.
This commit is contained in:
parent
1d2f6e5237
commit
81f2c94b87
@ -94,4 +94,7 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
<uses-sdk android:minSdkVersion="3" />
|
<uses-sdk android:minSdkVersion="3" />
|
||||||
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
||||||
|
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
|
||||||
</manifest>
|
</manifest>
|
@ -26,4 +26,7 @@
|
|||||||
|
|
||||||
<string name="key_voice_recognition">voice_recognition</string>
|
<string name="key_voice_recognition">voice_recognition</string>
|
||||||
<string name="default_voice_recognition">false</string>
|
<string name="default_voice_recognition">false</string>
|
||||||
|
|
||||||
|
<string name="key_vibrate_highlight">vibrate_highlight</string>
|
||||||
|
<string name="default_vibrate_highlight">true</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -85,8 +85,8 @@
|
|||||||
<string name="query_exists">Query already exists</string>
|
<string name="query_exists">Query already exists</string>
|
||||||
<string name="line_missing">Line is missing</string>
|
<string name="line_missing">Line is missing</string>
|
||||||
<string name="nickname_in_use">Nickname %1$s already in use</string>
|
<string name="nickname_in_use">Nickname %1$s already in use</string>
|
||||||
<string name="irc_login_error">Could not log into the IRC server %1$s:%1$d</string>
|
<string name="irc_login_error">Could not log into the IRC server %1$s:%2$d</string>
|
||||||
<string name="could_not_connect">Could not connect to %1$s:%1$d</string>
|
<string name="could_not_connect">Could not connect to %1$s:%2$d</string>
|
||||||
|
|
||||||
<string name="command_desc_amsg">Send a message to all channels</string>
|
<string name="command_desc_amsg">Send a message to all channels</string>
|
||||||
<string name="command_desc_away">Sets you away</string>
|
<string name="command_desc_away">Sets you away</string>
|
||||||
@ -182,4 +182,6 @@
|
|||||||
<string name="settings_fontsize_dialog_title">Font size</string>
|
<string name="settings_fontsize_dialog_title">Font size</string>
|
||||||
<string name="settings_voice_recognition_title">Voice recognition</string>
|
<string name="settings_voice_recognition_title">Voice recognition</string>
|
||||||
<string name="settings_voice_recognition_desc">Show button for voice recognition</string>
|
<string name="settings_voice_recognition_desc">Show button for voice recognition</string>
|
||||||
|
<string name="settings_vibrate_highlight_title">Vibrate on highlight</string>
|
||||||
|
<string name="settings_vibrate_highlight_desc">Vibrate when your nick is mentioned</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -80,5 +80,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:defaultValue="@string/default_quitmessage"
|
android:defaultValue="@string/default_quitmessage"
|
||||||
android:dialogTitle="@string/settings_quitmessage_dialog_title"
|
android:dialogTitle="@string/settings_quitmessage_dialog_title"
|
||||||
android:dialogMessage="@string/settings_quitmessage_dialog_desc" />
|
android:dialogMessage="@string/settings_quitmessage_dialog_desc" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:title="@string/settings_vibrate_highlight_title"
|
||||||
|
android:summary="@string/settings_vibrate_highlight_desc"
|
||||||
|
android:key="@string/key_vibrate_highlight"
|
||||||
|
android:defaultValue="@string/default_vibrate_highlight" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -195,7 +195,7 @@ public class IRCConnection extends PircBot
|
|||||||
if (action.contains(getNick())) {
|
if (action.contains(getNick())) {
|
||||||
// highlight
|
// highlight
|
||||||
message.setColor(Message.COLOR_RED);
|
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);
|
server.getConversation(target).setStatus(Conversation.STATUS_HIGHLIGHT);
|
||||||
}
|
}
|
||||||
@ -390,7 +390,7 @@ public class IRCConnection extends PircBot
|
|||||||
if (text.contains(getNick())) {
|
if (text.contains(getNick())) {
|
||||||
// highlight
|
// highlight
|
||||||
message.setColor(Message.COLOR_RED);
|
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);
|
server.getConversation(target).setStatus(Conversation.STATUS_HIGHLIGHT);
|
||||||
}
|
}
|
||||||
@ -536,7 +536,7 @@ public class IRCConnection extends PircBot
|
|||||||
|
|
||||||
if (text.contains(getNick())) {
|
if (text.contains(getNick())) {
|
||||||
message.setColor(Message.COLOR_RED);
|
message.setColor(Message.COLOR_RED);
|
||||||
service.updateNotification("<" + sender + "> " + text);
|
service.updateNotification("<" + sender + "> " + text, service.getSettings().isVibrateHighlightEnabled());
|
||||||
|
|
||||||
server.getConversation(sender).setStatus(Conversation.STATUS_HIGHLIGHT);
|
server.getConversation(sender).setStatus(Conversation.STATUS_HIGHLIGHT);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ import android.app.NotificationManager;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The background service for managing the irc connections
|
* The background service for managing the irc connections
|
||||||
@ -161,7 +162,6 @@ public class IRCService extends Service
|
|||||||
if (foreground) {
|
if (foreground) {
|
||||||
return; // XXX: We are already in foreground...
|
return; // XXX: We are already in foreground...
|
||||||
}
|
}
|
||||||
|
|
||||||
foreground = true;
|
foreground = true;
|
||||||
|
|
||||||
// Set the icon, scrolling text and timestamp
|
// Set the icon, scrolling text and timestamp
|
||||||
@ -184,13 +184,19 @@ public class IRCService extends Service
|
|||||||
*
|
*
|
||||||
* @param text The text to display
|
* @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) {
|
if (foreground) {
|
||||||
notificationManager.cancel(R.string.app_name);
|
notificationManager.cancel(R.string.app_name);
|
||||||
notification = new Notification(R.drawable.icon, text, System.currentTimeMillis());
|
notification = new Notification(R.drawable.icon, text, System.currentTimeMillis());
|
||||||
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ServersActivity.class), 0);
|
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ServersActivity.class), 0);
|
||||||
notification.setLatestEventInfo(this, getText(R.string.app_name), text, contentIntent);
|
notification.setLatestEventInfo(this, getText(R.string.app_name), text, contentIntent);
|
||||||
|
if (vibrate) {
|
||||||
|
notification.defaults |= Notification.DEFAULT_VIBRATE;
|
||||||
|
}
|
||||||
notificationManager.notify(R.string.app_name, notification);
|
notificationManager.notify(R.string.app_name, notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,4 +169,17 @@ public class Settings
|
|||||||
Boolean.parseBoolean(resources.getString(R.string.default_voice_recognition))
|
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))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user