正在查看: Hyouka private v5.8.9 应用的 CropImageActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Hyouka private v5.8.9 应用的 CropImageActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.theartofdev.edmodo.cropper;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView;
import java.io.File;
import java.io.IOException;
public class CropImageActivity extends AppCompatActivity implements CropImageView.i, CropImageView.e {
private Uri mCropImageUri;
private CropImageView mCropImageView;
private CropImageOptions mOptions;
private void updateMenuItemIconColor(Menu menu, int i2, int i3) {
Drawable icon;
MenuItem findItem = menu.findItem(i2);
if (findItem == null || (icon = findItem.getIcon()) == null) {
return;
}
try {
icon.mutate();
icon.setColorFilter(i3, PorterDuff.Mode.SRC_ATOP);
findItem.setIcon(icon);
} catch (Exception e2) {
Log.w("AIC", "Failed to update menu item color", e2);
}
}
protected void cropImage() {
if (this.mOptions.W) {
setResult(null, null, 1);
return;
}
Uri outputUri = getOutputUri();
CropImageView cropImageView = this.mCropImageView;
CropImageOptions cropImageOptions = this.mOptions;
cropImageView.saveCroppedImageAsync(outputUri, cropImageOptions.R, cropImageOptions.S, cropImageOptions.T, cropImageOptions.U, cropImageOptions.V);
}
protected Uri getOutputUri() {
Uri uri = this.mOptions.Q;
if (uri != null && !uri.equals(Uri.EMPTY)) {
return uri;
}
try {
Bitmap.CompressFormat compressFormat = this.mOptions.R;
return Uri.fromFile(File.createTempFile("cropped", compressFormat == Bitmap.CompressFormat.JPEG ? ".jpg" : compressFormat == Bitmap.CompressFormat.PNG ? ".png" : ".webp", getCacheDir()));
} catch (IOException e2) {
throw new RuntimeException("Failed to create temp file for output image", e2);
}
}
protected Intent getResultIntent(Uri uri, Exception exc, int i2) {
CropImage.ActivityResult activityResult = new CropImage.ActivityResult(this.mCropImageView.getImageUri(), uri, exc, this.mCropImageView.getCropPoints(), this.mCropImageView.getCropRect(), this.mCropImageView.getRotatedDegrees(), this.mCropImageView.getWholeImageRect(), i2);
Intent intent = new Intent();
intent.putExtras(getIntent());
intent.putExtra("CROP_IMAGE_EXTRA_RESULT", activityResult);
return intent;
}
@Override
@SuppressLint({"NewApi"})
public void onActivityResult(int i2, int i3, Intent intent) {
if (i2 == 200) {
if (i3 == 0) {
setResultCancel();
}
if (i3 == -1) {
Uri h2 = CropImage.h(this, intent);
this.mCropImageUri = h2;
if (CropImage.k(this, h2)) {
requestPermissions(new String[]{"android.permission.READ_EXTERNAL_STORAGE"}, 201);
} else {
this.mCropImageView.setImageUriAsync(this.mCropImageUri);
}
}
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
setResultCancel();
}
@Override
@SuppressLint({"NewApi"})
public void onCreate(Bundle bundle) {
CharSequence charSequence;
super.onCreate(bundle);
setContentView(i.crop_image_activity);
this.mCropImageView = (CropImageView) findViewById(h.cropImageView);
Bundle bundleExtra = getIntent().getBundleExtra("CROP_IMAGE_EXTRA_BUNDLE");
this.mCropImageUri = (Uri) bundleExtra.getParcelable("CROP_IMAGE_EXTRA_SOURCE");
this.mOptions = (CropImageOptions) bundleExtra.getParcelable("CROP_IMAGE_EXTRA_OPTIONS");
if (bundle == null) {
Uri uri = this.mCropImageUri;
if (uri == null || uri.equals(Uri.EMPTY)) {
if (CropImage.j(this)) {
requestPermissions(new String[]{"android.permission.CAMERA"}, 2011);
} else {
CropImage.m(this);
}
} else if (CropImage.k(this, this.mCropImageUri)) {
requestPermissions(new String[]{"android.permission.READ_EXTERNAL_STORAGE"}, 201);
} else {
this.mCropImageView.setImageUriAsync(this.mCropImageUri);
}
}
androidx.appcompat.app.a supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
CropImageOptions cropImageOptions = this.mOptions;
supportActionBar.x((cropImageOptions == null || (charSequence = cropImageOptions.O) == null || charSequence.length() <= 0) ? getResources().getString(k.crop_image_activity_title) : this.mOptions.O);
supportActionBar.q(true);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(j.crop_image_menu, menu);
CropImageOptions cropImageOptions = this.mOptions;
if (!cropImageOptions.Z) {
menu.removeItem(h.crop_image_menu_rotate_left);
menu.removeItem(h.crop_image_menu_rotate_right);
} else if (cropImageOptions.f5941b0) {
menu.findItem(h.crop_image_menu_rotate_left).setVisible(true);
}
if (!this.mOptions.f5939a0) {
menu.removeItem(h.crop_image_menu_flip);
}
if (this.mOptions.f5949f0 != null) {
menu.findItem(h.crop_image_menu_crop).setTitle(this.mOptions.f5949f0);
}
Drawable drawable = null;
try {
int i2 = this.mOptions.f5951g0;
if (i2 != 0) {
drawable = androidx.core.content.a.e(this, i2);
menu.findItem(h.crop_image_menu_crop).setIcon(drawable);
}
} catch (Exception e2) {
Log.w("AIC", "Failed to read menu crop drawable", e2);
}
int i3 = this.mOptions.P;
if (i3 != 0) {
updateMenuItemIconColor(menu, h.crop_image_menu_rotate_left, i3);
updateMenuItemIconColor(menu, h.crop_image_menu_rotate_right, this.mOptions.P);
updateMenuItemIconColor(menu, h.crop_image_menu_flip, this.mOptions.P);
if (drawable != null) {
updateMenuItemIconColor(menu, h.crop_image_menu_crop, this.mOptions.P);
}
}
return true;
}
@Override
public void onCropImageComplete(CropImageView cropImageView, CropImageView.b bVar) {
setResult(bVar.g(), bVar.c(), bVar.f());
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == h.crop_image_menu_crop) {
cropImage();
return true;
}
if (menuItem.getItemId() == h.crop_image_menu_rotate_left) {
rotateImage(-this.mOptions.f5943c0);
return true;
}
if (menuItem.getItemId() == h.crop_image_menu_rotate_right) {
rotateImage(this.mOptions.f5943c0);
return true;
}
if (menuItem.getItemId() == h.crop_image_menu_flip_horizontally) {
this.mCropImageView.flipImageHorizontally();
return true;
}
if (menuItem.getItemId() == h.crop_image_menu_flip_vertically) {
this.mCropImageView.flipImageVertically();
return true;
}
if (menuItem.getItemId() != 16908332) {
return super.onOptionsItemSelected(menuItem);
}
setResultCancel();
return true;
}
@Override
public void onRequestPermissionsResult(int i2, String[] strArr, int[] iArr) {
if (i2 == 201) {
Uri uri = this.mCropImageUri;
if (uri == null || iArr.length <= 0 || iArr[0] != 0) {
Toast.makeText(this, k.crop_image_activity_no_permissions, 1).show();
setResultCancel();
} else {
this.mCropImageView.setImageUriAsync(uri);
}
}
if (i2 == 2011) {
CropImage.m(this);
}
}
@Override
public void onSetImageUriComplete(CropImageView cropImageView, Uri uri, Exception exc) {
if (exc != null) {
setResult(null, exc, 1);
return;
}
Rect rect = this.mOptions.X;
if (rect != null) {
this.mCropImageView.setCropRect(rect);
}
int i2 = this.mOptions.Y;
if (i2 > -1) {
this.mCropImageView.setRotatedDegrees(i2);
}
}
@Override
protected void onStart() {
super.onStart();
this.mCropImageView.setOnSetImageUriCompleteListener(this);
this.mCropImageView.setOnCropImageCompleteListener(this);
}
@Override
protected void onStop() {
super.onStop();
this.mCropImageView.setOnSetImageUriCompleteListener(null);
this.mCropImageView.setOnCropImageCompleteListener(null);
}
protected void rotateImage(int i2) {
this.mCropImageView.rotateImage(i2);
}
protected void setResult(Uri uri, Exception exc, int i2) {
setResult(exc == null ? -1 : 204, getResultIntent(uri, exc, i2));
finish();
}
protected void setResultCancel() {
setResult(0);
finish();
}
}