コード例 #1
0
  @JavascriptInterface
  public void takeAPicture(String resultfilename) {
    new File(this.mOutputDir).mkdirs();

    if (this.D) Log.d(this.TAG, "This is what the image file looked like:" + resultfilename);
    String tempurlstring = "";
    tempurlstring = resultfilename.replaceFirst("/", "").replaceFirst("file:", "");
    this.mTakeAPictureFileUrl = this.mOutputDir + tempurlstring;
    if (this.D)
      Log.d(this.TAG, "This is what the image file looks like:" + this.mTakeAPictureFileUrl);

    // Publish picture taking started
    LoadUrlToWebView v = new LoadUrlToWebView();
    v.setMessage(
        "javascript:OPrime.hub.publish('pictureCaptureSucessfullyStarted','"
            + this.mTakeAPictureFileUrl
            + "');");
    v.execute();

    Intent intent;
    // intent = new Intent(OPrime.INTENT_TAKE_PICTURE);
    intent = new Intent(this.mContext, TakePicture.class);
    intent.putExtra(Config.EXTRA_RESULT_FILENAME, this.mTakeAPictureFileUrl);
    this.getUIParent().startActivityForResult(intent, Config.CODE_PICTURE_TAKEN);
  }
コード例 #2
0
  @JavascriptInterface
  public void startAudioRecordingService(String resultfilename) {
    if ("".equals(resultfilename.trim())) {
      if (this.D) Log.d(this.TAG, "The resultfilename in startAudioRecordingService was empty.");
      return;
    }
    new File(this.mOutputDir).mkdirs();
    if (this.mAudioRecordFileUrl != null) {
      return;
    }
    if (this.D) Log.d(this.TAG, "This is what the audiofile looked like:" + resultfilename);
    String tempurlstring = "";
    tempurlstring = resultfilename.replaceFirst("/", "").replaceFirst("file:", "");
    this.mAudioRecordFileUrl = this.mOutputDir + tempurlstring;
    if (this.D)
      Log.d(this.TAG, "This is what the audiofile looks like:" + this.mAudioRecordFileUrl);

    Intent intent;
    intent = new Intent(this.mContext, AudioRecorder.class);
    intent.putExtra(Config.EXTRA_RESULT_FILENAME, this.mAudioRecordFileUrl);
    this.getUIParent().startService(intent);
    // Publish audio recording started
    LoadUrlToWebView v = new LoadUrlToWebView();
    v.setMessage(
        "javascript:OPrime.hub.publish('audioRecordingSucessfullyStarted','"
            + this.mAudioRecordFileUrl
            + "');");
    v.execute();
  }
コード例 #3
0
 @JavascriptInterface
 public void getConnectivityType() {
   // TODO get Connectivity status
   String connectivityType = "WiFi";
   LoadUrlToWebView v = new LoadUrlToWebView();
   v.setMessage("javascript:OPrime.hub.publish('connectivityType','" + connectivityType + "');");
   v.execute();
 }
コード例 #4
0
  @JavascriptInterface
  public void getHardwareDetails() {
    if (this.mDeviceDetails == null) {
      this.mDeviceDetails = new DeviceDetails(this.getUIParent(), this.D, this.TAG);
    }
    String deviceType = this.mDeviceDetails.getCurrentDeviceDetails();

    LoadUrlToWebView v = new LoadUrlToWebView();
    v.setMessage("javascript:OPrime.hub.publish('hardwareDetails'," + deviceType + ");");
    v.execute();
  }
コード例 #5
0
 @JavascriptInterface
 public void stopAudioRecordingService(String resultfilename) {
   // TODO could do some checking to see if the same file the HTML5 wants us to
   // stop is similarly named to the one in the Java
   // if(mAudioRecordFileUrl.contains(resultfilename))
   if (this.mAudioRecordFileUrl == null) {
     return;
   }
   Intent audio = new Intent(this.mContext, AudioRecorder.class);
   this.getUIParent().stopService(audio);
   // Publish stopped audio
   LoadUrlToWebView v = new LoadUrlToWebView();
   v.setMessage(
       "javascript:OPrime.hub.publish('audioRecordingSucessfullyStopped','"
           + this.mAudioRecordFileUrl
           + "');");
   v.execute();
   // TODO add broadcast and listener from audio service to be sure the file
   // works(?)
   LoadUrlToWebView t = new LoadUrlToWebView();
   t.setMessage(
       "javascript:OPrime.hub.publish('audioRecordingCompleted','"
           + this.mAudioRecordFileUrl
           + "');");
   t.execute();
   // null out the audio file to be sure this is called once per audio file.
   this.mAudioRecordFileUrl = null;
 }