Exemplo n.º 1
0
 public String getCopyright() {
   return appInfo.getAppCopyright();
 }
Exemplo n.º 2
0
 public String getGUID() {
   return appInfo.getAppGUID();
 }
Exemplo n.º 3
0
 public String getURL() {
   return appInfo.getAppURL();
 }
Exemplo n.º 4
0
 public String getDescription() {
   return appInfo.getAppDescription();
 }
Exemplo n.º 5
0
 public String getVersion() {
   return appInfo.getAppVersion();
 }
Exemplo n.º 6
0
 public String getPublisher() {
   return appInfo.getAppPublisher();
 }
Exemplo n.º 7
0
 public String getModuleName() {
   return appInfo.getAppName();
 }
Exemplo n.º 8
0
 public String getID() {
   return appInfo.getAppId();
 }
Exemplo n.º 9
0
 public TitaniumApp(TitaniumModuleManager moduleMgr, String name, TitaniumAppInfo appInfo) {
   super(moduleMgr, name);
   this.appInfo = appInfo;
   this.appProperties = new TitaniumProperties(moduleMgr.getActivity(), "titanium", false);
   systemProperties = appInfo.getSystemProperties();
 }
 public TitaniumWindowInfo getWindowInfo(TitaniumAppInfo appInfo) {
   return appInfo.findWindowInfo(getWindowId());
 }
Exemplo n.º 11
0
  public void showCamera(
      final String successCallback,
      final String cancelCallback,
      final String errorCallback,
      final String options,
      ITitaniumFile file) {
    if (DBG) {
      Log.d(LCAT, "showCamera called");
    }
    if (!(file instanceof TitaniumBlob)) {
      throw new IllegalArgumentException("blob parameter must be of type TitaniumBlob");
    }
    Camera camera = null;
    try {
      camera = Camera.open();
      if (camera != null) {
        camera.release();
        camera = null;
      }
    } catch (Throwable t) {
      if (camera != null) {
        camera.release();
      }
      invokeUserCallback(errorCallback, createJSONError(0, "Camera not available."));
      return;
    }
    boolean saveToPhotoGallery = false;
    try {
      JSONObject json = new JSONObject(options);
      try {
        saveToPhotoGallery = json.getBoolean("saveToPhotoGallery");
      } catch (JSONException e) {
        if (DBG) {
          Log.d(LCAT, "options does not have saveToPhotoGallery option or value is not boolean");
        }
      }
      // TODO allowImageEditing. Don't know if I can do this yet
    } catch (JSONException e) {
      Log.w(LCAT, "Invalid options JSON: " + options, e);
    }

    final TitaniumBlob blob = (TitaniumBlob) file;
    TitaniumActivity activity = getActivity();
    TitaniumFileHelper tfh = new TitaniumFileHelper(getContext());

    File imageDir = null;
    File imageFile = null;

    try {
      if (saveToPhotoGallery) {
        imageDir = new File(PHOTO_DCIM_CAMERA);
        if (!imageDir.exists()) {
          imageDir.mkdirs();
        }
      } else {
        if (activity.getIntent() != null) {
          TitaniumIntentWrapper intent = new TitaniumIntentWrapper(activity.getIntent());
          TitaniumAppInfo appInfo = intent.getAppInfo(activity);
          String name = appInfo.getAppName();
          imageDir = new File(PHOTO_DCIM_CAMERA, name);
          if (!imageDir.exists()) {
            imageDir.mkdirs();
          }
        } else {
          imageDir = tfh.getDataDirectory(false);
        }
      }
      imageFile = tfh.getTempFile(imageDir, ".jpg");

    } catch (IOException e) {
      Log.e(LCAT, "Unable to create temp file", e);
      invokeUserCallback(errorCallback, createJSONError(0, e.getMessage()));
      return;
    }

    final File finalImageFile = imageFile;
    final String imageUrl = "file://" + imageFile.getAbsolutePath();

    TitaniumIntentWrapper cameraIntent = new TitaniumIntentWrapper(new Intent());
    cameraIntent.getIntent().setAction(MediaStore.ACTION_IMAGE_CAPTURE);
    cameraIntent.getIntent().putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse(imageUrl));
    cameraIntent.getIntent().addCategory(Intent.CATEGORY_DEFAULT);
    cameraIntent.setWindowId(TitaniumIntentWrapper.createActivityName("CAMERA"));

    final int code = activity.getUniqueResultCode();
    final boolean finalSaveToPhotoGallery = saveToPhotoGallery;

    activity.launchActivityForResult(
        cameraIntent,
        code,
        new TitaniumResultHandler() {

          public void onResult(
              TitaniumActivity activity, int requestCode, int resultCode, Intent data) {
            if (resultCode == Activity.RESULT_CANCELED) {
              if (finalImageFile != null) {
                finalImageFile.delete();
              }
              invokeUserCallback(cancelCallback, null);
            } else {
              ContentValues values = new ContentValues(7);
              values.put(Images.Media.TITLE, finalImageFile.getName());
              values.put(Images.Media.DISPLAY_NAME, finalImageFile.getName());
              values.put(Images.Media.DATE_TAKEN, new Date().getTime());
              values.put(Images.Media.MIME_TYPE, "image/jpeg");
              if (finalSaveToPhotoGallery) {
                values.put(
                    Images.ImageColumns.BUCKET_ID, PHOTO_DCIM_CAMERA.toLowerCase().hashCode());
                values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, "Camera");
              } else {
                values.put(
                    Images.ImageColumns.BUCKET_ID,
                    finalImageFile.getPath().toLowerCase().hashCode());
                values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, finalImageFile.getName());
              }
              values.put("_data", finalImageFile.getAbsolutePath());

              Uri imageUri =
                  activity.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);

              String result = fillBlob(activity, blob, imageUri.toString());
              invokeUserCallback(successCallback, result);
            }
          }

          public void onError(TitaniumActivity activity, int requestCode, Exception e) {
            if (finalImageFile != null) {
              finalImageFile.delete();
            }
            Log.e(LCAT, "Camera problem: ", e);
            invokeUserCallback(errorCallback, createJSONError(0, e.getMessage()));
          }
        });
  }