Home | History | Annotate | Download | only in shadows
      1 package org.robolectric.shadows;
      2 
      3 import android.os.Vibrator;
      4 import org.robolectric.annotation.Implements;
      5 
      6 @Implements(Vibrator.class)
      7 public class ShadowVibrator {
      8   boolean vibrating;
      9   boolean cancelled;
     10   long milliseconds;
     11   protected long[] pattern;
     12   int repeat;
     13   boolean hasVibrator = true;
     14   boolean hasAmplitudeControl = false;
     15 
     16   /**
     17    * Controls the return value of {@link Vibrator#hasVibrator()} the default is true.
     18    */
     19   public void setHasVibrator(boolean hasVibrator) {
     20     this.hasVibrator = hasVibrator;
     21   }
     22 
     23   /**
     24    * Controls the return value of {@link Vibrator#hasAmplitudeControl()} the default is false.
     25    */
     26   public void setHasAmplitudeControl(boolean hasAmplitudeControl) {
     27     this.hasAmplitudeControl = hasAmplitudeControl;
     28   }
     29 
     30   /**
     31    * Returns true if the Vibrator is currently vibrating as controlled by {@link Vibrator#vibrate(long)}
     32    */
     33   public boolean isVibrating() {
     34     return vibrating;
     35   }
     36 
     37   /**
     38    * Returns true if the Vibrator has been cancelled.
     39    */
     40   public boolean isCancelled() {
     41     return cancelled;
     42   }
     43 
     44   /**
     45    * Returns the last vibration duration in MS.
     46    */
     47   public long getMilliseconds() {
     48     return milliseconds;
     49   }
     50 
     51   /**
     52    * Returns the last vibration pattern.
     53    */
     54   public long[] getPattern() {
     55     return pattern;
     56   }
     57 
     58   /**
     59    * Returns the last vibration repeat times.
     60    */
     61   public int getRepeat() {
     62     return repeat;
     63   }
     64 
     65 }
     66