Esempio n. 1
0
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    String pManufacturer = android.os.Build.MANUFACTURER;
    String pModel = android.os.Build.MODEL;

    if ("GT-I9300".equals(pModel) && "samsung".equals(pManufacturer)) {

      RelativeLayout main = (RelativeLayout) findViewById(R.id.relativeLayout_main);
      main.invalidate();

      setContentView(R.layout.activity_camera_crop);

      mImageView = (CroppedImageView) findViewById(R.id.ivCameraCropPhoto);
      mImageView.setDrawingCacheEnabled(true);

      scaleView();

      // Cancel button
      findViewById(R.id.btnCameraCancel)
          .setOnClickListener(
              new OnClickListener() {

                @Override
                public void onClick(View v) {

                  finish();
                  if (getIntent().getStringExtra("type").equals("gallery")) {
                    Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class);
                    intent.putExtra("type", "gallery");
                    startActivity(intent);
                  } else {
                    Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class);
                    intent.putExtra("type", "camera");
                    startActivity(intent);
                  }
                }
              });

      // Next button
      findViewById(R.id.btnCameraOk)
          .setOnClickListener(
              new OnClickListener() {

                @Override
                public void onClick(View v) {
                  Bitmap resizedBitmap = getBitmapFromView(mImageView);

                  ByteArrayOutputStream bs = new ByteArrayOutputStream();
                  resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bs);

                  if (saveBitmapToFile(resizedBitmap, mFilePath) == true) {

                    if (mForProfile == true) {
                      MyProfileActivity.gProfileImage = getBitmapFromView(mImageView);
                      MyProfileActivity.gProfileImagePath = mFilePath;
                    } else if (mForGroup == true) {
                      CreateGroupActivity.gGroupImage = getBitmapFromView(mImageView);
                      CreateGroupActivity.gGroupImagePath = mFilePath;
                    } else if (mForGroupUpdate == true) {
                      GroupProfileActivity.gGroupImage = getBitmapFromView(mImageView);
                      GroupProfileActivity.gGroupImagePath = mFilePath;
                    } else {
                      fileUploadAsync(mFilePath);

                      //									new FileUploadAsync(CameraCropActivity.this)
                      //											.execute(mFilePath);
                      // new
                      // SendMessageAsync(getApplicationContext(),
                      // SendMessageAsync.TYPE_PHOTO)
                      // .execute(resizedBitmap);
                    }
                  } else {
                    Toast.makeText(
                            CameraCropActivity.this, "Failed to send photo", Toast.LENGTH_LONG)
                        .show();
                  }
                }
              });

      File file = new File(_path);
      boolean exists = file.exists();
      if (exists) onPhotoTaken(_path);
      else
        Toast.makeText(
                getBaseContext(),
                "Something went wrong while taking picture, please try again.",
                Toast.LENGTH_SHORT)
            .show();
    }
  }
Esempio n. 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera_crop);

    getImageIntents();
    mImageView = (CroppedImageView) findViewById(R.id.ivCameraCropPhoto);
    mImageView.setDrawingCacheEnabled(true);

    return_flag = false;

    Button btnBack = (Button) findViewById(R.id.btnBack);
    btnBack.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            finish();
          }
        });

    // Cancel button
    findViewById(R.id.btnCameraCancel)
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                finish();
                if (getIntent().getStringExtra("type").equals("gallery")) {
                  Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class);
                  intent.putExtra("type", "gallery");
                  startActivity(intent);
                } else {
                  Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class);
                  intent.putExtra("type", "camera");
                  startActivity(intent);
                }
              }
            });

    // Next button
    findViewById(R.id.btnCameraOk)
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                Bitmap resizedBitmap = getBitmapFromView(mImageView);
                ByteArrayOutputStream bs = new ByteArrayOutputStream();
                resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bs);

                if (saveBitmapToFile(resizedBitmap, mFilePath) == true) {

                  if (mForProfile == true) {
                    MyProfileActivity.gProfileImage = getBitmapFromView(mImageView);
                    MyProfileActivity.gProfileImagePath = mFilePath;
                    finish();
                  } else if (mForGroup == true) {
                    CreateGroupActivity.gGroupImage = getBitmapFromView(mImageView);
                    CreateGroupActivity.gGroupImagePath = mFilePath;
                    finish();
                  } else if (mForGroupUpdate == true) {
                    GroupProfileActivity.gGroupImage = getBitmapFromView(mImageView);
                    GroupProfileActivity.gGroupImagePath = mFilePath;
                    finish();
                  } else {
                    fileUploadAsync(mFilePath);

                    //								new FileUploadAsync(CameraCropActivity.this)
                    //										.execute(mFilePath);
                    // new SendMessageAsync(getApplicationContext(),
                    // SendMessageAsync.TYPE_PHOTO)
                    // .execute(resizedBitmap);
                  }

                } else {
                  Toast.makeText(CameraCropActivity.this, "Failed to send photo", Toast.LENGTH_LONG)
                      .show();
                }
              }
            });
  }