コード例 #1
0
ファイル: ComposeView.java プロジェクト: prairied0gg/qksms
  private void attachFromCamera() {

    AnalyticsManager.getInstance()
        .sendEvent(
            AnalyticsManager.CATEGORY_MESSAGES, AnalyticsManager.ACTION_ATTACH_FROM_CAMERA, mLabel);

    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (cameraIntent.resolveActivity(mContext.getPackageManager()) != null) {

      File file = null;
      try {
        file = createImageFile();
      } catch (IOException e) {
        e.printStackTrace();
      }

      if (file != null) {
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
        mActivityLauncher.startActivityForResult(cameraIntent, REQUEST_CODE_CAMERA);
      }
    } else {
      // Send a toast saying there was a camera error
      if (mContext != null) {
        String message = mContext.getResources().getString(R.string.attachment_camera_error);
        Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
      }
    }
  }
コード例 #2
0
ファイル: ComposeView.java プロジェクト: prairied0gg/qksms
  private void chooseAttachmentFromGallery() {

    AnalyticsManager.getInstance()
        .sendEvent(
            AnalyticsManager.CATEGORY_MESSAGES, AnalyticsManager.ACTION_ATTACH_IMAGE, mLabel);

    try {
      Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
      photoPickerIntent.setType("image/*");
      mActivityLauncher.startActivityForResult(photoPickerIntent, REQUEST_CODE_IMAGE);
    } catch (ActivityNotFoundException e) {
      // Send a toast saying no picture apps
      if (mContext != null) {
        String message = mContext.getResources().getString(R.string.attachment_app_not_found);
        Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
      }
    }
  }
コード例 #3
0
ファイル: ComposeView.java プロジェクト: prairied0gg/qksms
  public ComposeView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mContext = (QKActivity) context;
    mPrefs = mContext.getPrefs();
    mRes = mContext.getResources();

    mDelayedMessagingEnabled = mPrefs.getBoolean(SettingsFragment.DELAYED, false);
    try {
      mDelayDuration = Integer.parseInt(mPrefs.getString(SettingsFragment.DELAY_DURATION, "3"));
      if (mDelayDuration < 1) {
        mDelayDuration = 1;
      } else if (mDelayDuration > 30) {
        mDelayDuration = 30;
      }
      mDelayDuration *= 1000;
    } catch (Exception e) {
      mDelayDuration = 3000;
    }
  }