mirror of https://github.com/sipwise/jitsi.git
parent
b88978488c
commit
6ae5d6b90f
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.notification;
|
||||
|
||||
/**
|
||||
* <tt>VibrateNotificationAction</tt> is meant to define haptic feedback
|
||||
* notification using device's vibrator.<br/><br/>
|
||||
*
|
||||
* Given array of <tt>long</tt> are
|
||||
* the duration for which to turn on or off the vibrator in miliseconds.
|
||||
* The first value indicates the number of miliseconds to wait before turning
|
||||
* the vibrator on. The next value indicates the number of miliseconds for which
|
||||
* to keep the vibrator on before turning it off and so on.<br/><br/>
|
||||
*
|
||||
* The <tt>repeat</tt> parameter is an index into the pattern at which it will
|
||||
* be looped until the {@link VibrateNotificationHandler#cancel()} method is
|
||||
* called.
|
||||
*
|
||||
* @author Pawel Domas
|
||||
*/
|
||||
public class VibrateNotificationAction
|
||||
extends NotificationAction
|
||||
{
|
||||
/**
|
||||
* The patter of off/on intervals in milis that will be played.
|
||||
*/
|
||||
private final long[] pattern;
|
||||
|
||||
/**
|
||||
* Repeat index into the pattern(-1 to disable repeat).
|
||||
*/
|
||||
private final int repeat;
|
||||
|
||||
/**
|
||||
* Descriptor that can be used to identify action.
|
||||
*/
|
||||
private final String descriptor;
|
||||
|
||||
/**
|
||||
* Vibrate constantly for the specified period of time.
|
||||
*
|
||||
* @param descriptor string identifier of this action.
|
||||
* @param milis the number of miliseconds to vibrate.
|
||||
*/
|
||||
public VibrateNotificationAction(String descriptor, long milis)
|
||||
{
|
||||
super(NotificationAction.ACTION_VIBRATE);
|
||||
this.pattern = new long[2];
|
||||
pattern[0] = 0;
|
||||
pattern[1] = milis;
|
||||
repeat = -1;
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vibrate using given <tt>patter</tt> and optionally loop if the
|
||||
* <tt>repeat</tt> index is not <tt>-1</tt>.
|
||||
*
|
||||
* @param descriptor the string identifier of this action.
|
||||
* @param patter the array containing vibrate pattern intervals.
|
||||
* @param repeat the index into the patter at which it will be looped
|
||||
* (-1 to disable repeat).
|
||||
*
|
||||
* @see VibrateNotificationAction
|
||||
*/
|
||||
public VibrateNotificationAction( String descriptor,
|
||||
long[] patter,
|
||||
int repeat )
|
||||
{
|
||||
super(NotificationAction.ACTION_VIBRATE);
|
||||
this.pattern = patter;
|
||||
this.repeat = repeat;
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* The string identifier of this action.
|
||||
*
|
||||
* @return string identifier of this action which can be used to distinguish
|
||||
* different actions.
|
||||
*/
|
||||
public String getDescriptor()
|
||||
{
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns vibrate pattern array.
|
||||
* @return vibrate pattern array.
|
||||
*/
|
||||
public long[] getPattern()
|
||||
{
|
||||
return pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* The index at which the pattern shall be looped during playback
|
||||
* or <tt>-1</tt> to play it once.
|
||||
*
|
||||
* @return the index at which the pattern will be looped or <tt>-1</tt> to
|
||||
* play it once.
|
||||
*/
|
||||
public int getRepeat()
|
||||
{
|
||||
return repeat;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.notification;
|
||||
|
||||
/**
|
||||
* The <tt>VibrateNotificationHandler</tt> interface is meant to be
|
||||
* implemented by the notification bundle in order to provide handling of
|
||||
* vibrate actions.
|
||||
*
|
||||
* @author Pawel Domas
|
||||
*/
|
||||
public interface VibrateNotificationHandler
|
||||
extends NotificationHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Perform vibration patter defined in given <tt>vibrateAction</tt>.
|
||||
*
|
||||
* @param vibrateAction the <tt>VibrateNotificationAction</tt> containing
|
||||
* vibration pattern details.
|
||||
*/
|
||||
public void vibrate(VibrateNotificationAction vibrateAction);
|
||||
|
||||
/**
|
||||
* Turn the vibrator off.
|
||||
*/
|
||||
public void cancel();
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue