Android Open Source - PreCTS Event






From Project

Back to project page PreCTS.

License

The source code is released under:

Apache License

If you think the Android project PreCTS listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.androidhuman.ctsprepare.data;
// www . j a v a2 s  . c om
import org.json.simple.JSONObject;


public class Event {
  
  public static class Type{
    public static final int KEYSTROKE = 0;
    public static final int TEXT = 1;
    public static final int DELAY = 2;
    public static final int LAUNCH = 3;
  }
  
  @Override
  public String toString(){
    switch(type){
    case Type.KEYSTROKE:
      return "Key";
    case Type.TEXT:
      return "Text";
    case Type.DELAY:
      return "Delay";
    case Type.LAUNCH:
      return "Launch";
    default:
      throw new IllegalArgumentException();
    }
  }
  
  private int type = -1;
  private String data;
  
  private Event(){
    
  }
  
  public static Event fromJson(JSONObject obj){
    Event event = new Event();
    event.type = Long.valueOf((Long)obj.get("type")).intValue();
    event.data = (String)obj.get("value");
    return event;
  }
  
  @SuppressWarnings("unchecked")
  public JSONObject toJson(){
    JSONObject obj = new JSONObject();
    obj.put("type", type);
    obj.put("value", data);
    return obj;
  }
  
  public static Event newTextEvent(String text){
    Event event = new Event();
    event.type = Type.TEXT;
    event.data = text;
    return event;
  }
  
  public static Event newKeyStrokeEvent(int keyCode){
    Event event = new Event();
    event.type = Type.KEYSTROKE;
    event.data = Integer.toString(keyCode);
    return event;
  }
  
  public static Event newHoldEvent(int msToDelay){
    Event event = new Event();
    event.type = Type.DELAY;
    event.data = Integer.toString(msToDelay);
    return event;
  }
  
  public static Event newLaunchEvent(String adbCommand){
    Event event = new Event();
    event.type = Type.LAUNCH;
    event.data = String.format("am start %s", adbCommand);
    return event;
  }
  
  public int getType(){
    return type;
  }
  
  public String getText(){
    return data;
  }
  
  public int getKeyCode(){
    return Integer.parseInt(data);
  }

}




Java Source Code List

com.androidhuman.ctsprepare.automator.GoogleAccount.java
com.androidhuman.ctsprepare.automator.PreCTSAutomate.java
com.androidhuman.ctsprepare.automator.WifiAp.java
com.androidhuman.ctsprepare.data.BasicDeviceInfo.java
com.androidhuman.ctsprepare.data.Event.java
com.androidhuman.ctsprepare.data.GoogleAccount.java
com.androidhuman.ctsprepare.data.Model.java
com.androidhuman.ctsprepare.data.ProxySettings.java
com.androidhuman.ctsprepare.data.Task.java
com.androidhuman.ctsprepare.data.Waiver.java
com.androidhuman.ctsprepare.data.WifiAp.java
com.androidhuman.ctsprepare.dialog.CtsMediaDownloadDialog.java
com.androidhuman.ctsprepare.dialog.EditGoogleAccountDialog.java
com.androidhuman.ctsprepare.dialog.EditMacroDialog.java
com.androidhuman.ctsprepare.dialog.EditProxyDialog.java
com.androidhuman.ctsprepare.dialog.EditSdkPathDialog.java
com.androidhuman.ctsprepare.dialog.EditWifiApDialog.java
com.androidhuman.ctsprepare.dialog.TargetSelectionDialog.java
com.androidhuman.ctsprepare.shell.ConfigureMacroShell.java
com.androidhuman.ctsprepare.shell.Main.java
com.androidhuman.ctsprepare.util.AdbCommand.java
com.androidhuman.ctsprepare.util.AdbWrapper.java
com.androidhuman.ctsprepare.util.AsyncTask.java
com.androidhuman.ctsprepare.util.Download.java
com.androidhuman.ctsprepare.util.Utils.java
com.androidhuman.ctsprepare.util.Worker.java
com.androidhuman.prectsandroidsettingsapp.EnableSyncActivity.java
com.androidhuman.prectsandroidsettingsapp.FinishHandler.java
com.androidhuman.prectsandroidsettingsapp.MainActivity.java