Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23
以下内容为反编译后的 PhotoUploadOptionsActivity.java 源代码,内容仅作参考
package com.perm.kate;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioGroup;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.FileProvider;
import com.perm.utils.PhotoOrientationHelper;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
public class PhotoUploadOptionsActivity extends BaseActivity {
ImageView imageView;
RadioGroup resizeSpinner;
ArrayList uris;
int rotate = 0;
private final View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View view) {
String obj = ((EditText) PhotoUploadOptionsActivity.this.findViewById(R.id.caption)).getText().toString();
PhotoUploadOptionsActivity photoUploadOptionsActivity = PhotoUploadOptionsActivity.this;
int idToResize = photoUploadOptionsActivity.idToResize(photoUploadOptionsActivity.resizeSpinner.getCheckedRadioButtonId());
PhotoUploadOptionsActivity.this.saveResizeOption(idToResize);
Intent intent = new Intent();
intent.putExtra("uris", PhotoUploadOptionsActivity.this.uris);
intent.putExtra("caption", obj);
intent.putExtra("resize_option", idToResize);
intent.putExtra("rotate", PhotoUploadOptionsActivity.this.rotate);
PhotoUploadOptionsActivity.this.setResult(-1, intent);
PhotoUploadOptionsActivity.this.finish();
}
};
private final View.OnClickListener editListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = new Intent("android.intent.action.EDIT");
Uri uri = (Uri) PhotoUploadOptionsActivity.this.uris.get(0);
if (uri.getScheme().equals("file") && Build.VERSION.SDK_INT >= 24) {
uri = FileProvider.getUriForFile(PhotoUploadOptionsActivity.this, "com.perm.kate.provider", new File(uri.getPath()));
}
intent.setDataAndType(uri, "image/*");
PhotoUploadOptionsActivity.this.startActivityForResult(intent, 3);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
PhotoUploadOptionsActivity.this.showEditInfo();
}
}
};
private final View.OnClickListener editInfoClick = new View.OnClickListener() {
@Override
public void onClick(View view) {
PhotoUploadOptionsActivity.this.showEditInfo();
}
};
private Uri aviaryFix(Uri uri) {
String uri2 = uri.toString();
if (uri2.startsWith("/") && uri2.contains("AVIARY")) {
return Uri.parse("file://" + uri2);
}
return uri;
}
public static Bitmap getResampledImage(Uri uri, Context context, int i, int i2) {
InputStream inputStream;
InputStream inputStream2;
BitmapFactory.Options options;
try {
try {
inputStream2 = context.getContentResolver().openInputStream(uri);
try {
BitmapFactory.Options options2 = new BitmapFactory.Options();
int i3 = 1;
options2.inJustDecodeBounds = true;
BitmapFactory.decodeStream(inputStream2, null, options2);
Helper.closeStream(inputStream2);
int max = Math.max(options2.outWidth / i2, options2.outHeight / i2);
if (max != 0) {
i3 = max;
}
options = new BitmapFactory.Options();
options.inSampleSize = i3;
options.inPreferredConfig = Bitmap.Config.RGB_565;
inputStream = context.getContentResolver().openInputStream(uri);
} catch (FileNotFoundException e) {
e = e;
inputStream = null;
} catch (Throwable th) {
th = th;
inputStream = null;
}
} finally {
Helper.closeStream(inputStream2);
Helper.closeStream(uri);
}
} catch (FileNotFoundException e2) {
e = e2;
inputStream = null;
inputStream2 = null;
} catch (Throwable th2) {
th = th2;
inputStream = null;
inputStream2 = null;
}
try {
Bitmap decodeStream = BitmapFactory.decodeStream(inputStream, null, options);
Helper.closeStream(inputStream);
return PhotoOrientationHelper.fixOrientation(decodeStream, i);
} catch (FileNotFoundException e3) {
e = e3;
e.printStackTrace();
uri = inputStream;
return null;
} catch (Throwable th3) {
th = th3;
th.printStackTrace();
Helper.reportError(th);
uri = inputStream;
return null;
}
}
static int getResizeOption() {
return PreferenceManager.getDefaultSharedPreferences(KApplication.current).getInt("photo_resize_option1", 1);
}
public int idToResize(int i) {
return i == R.id.button3 ? 0 : 1;
}
public void lambda$onCreate$0(Bitmap bitmap) {
this.imageView.setImageBitmap(bitmap);
}
public void lambda$onCreate$1() {
try {
showProgressBar(true);
final Bitmap resampledImage = getResampledImage((Uri) this.uris.get(0), this, this.rotate, 600);
showProgressBar(false);
runOnUiThread(new Runnable() {
@Override
public final void run() {
PhotoUploadOptionsActivity.this.lambda$onCreate$0(resampledImage);
}
});
} catch (Throwable th) {
th.printStackTrace();
Helper.reportError(th);
}
}
public void openLink(String str) {
try {
startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
} catch (ActivityNotFoundException unused) {
}
}
private int resizeToId(int i) {
return i == 0 ? R.id.button3 : i == 1 ? R.id.button2 : R.id.button1;
}
public void saveResizeOption(int i) {
PreferenceManager.getDefaultSharedPreferences(KApplication.current).edit().putInt("photo_resize_option1", i).apply();
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
Uri data;
super.onActivityResult(i, i2, intent);
if (i == 3 && i2 == -1) {
try {
Log.i("Kate.PhotoUploadOptions", "REQUEST_EDIT OK");
Log.i("Kate.PhotoUploadOptions", "data=" + intent);
if (intent == null || (data = intent.getData()) == null) {
return;
}
Uri aviaryFix = aviaryFix(data);
this.uris.set(0, aviaryFix);
int orientation = PhotoOrientationHelper.getOrientation(aviaryFix);
this.rotate = orientation;
this.imageView.setImageBitmap(getResampledImage(aviaryFix, this, orientation, 600));
} catch (Throwable th) {
th.printStackTrace();
Helper.reportError(th);
}
}
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.photo_upload_options);
this.uris = (ArrayList) getIntent().getSerializableExtra("uris");
if (!getIntent().getBooleanExtra("show_caption", false) || this.uris.size() > 1) {
findViewById(R.id.caption).setVisibility(8);
}
Button button = (Button) findViewById(R.id.btn_save);
button.setText(R.string.upload);
button.setOnClickListener(this.listener);
findViewById(R.id.edit).setOnClickListener(this.editListener);
this.imageView = (ImageView) findViewById(R.id.preview);
if (this.uris.size() == 1) {
this.rotate = PhotoOrientationHelper.getOrientation((Uri) this.uris.get(0));
}
if (this.uris.size() == 1) {
new Thread(new Runnable() {
@Override
public final void run() {
PhotoUploadOptionsActivity.this.lambda$onCreate$1();
}
}).start();
} else {
this.imageView.setVisibility(8);
}
this.resizeSpinner = (RadioGroup) findViewById(R.id.radio);
this.resizeSpinner.check(resizeToId(getResizeOption()));
findViewById(R.id.edit_info).setOnClickListener(this.editInfoClick);
setButtonsBg();
if (this.uris.size() > 1) {
findViewById(R.id.fl_button_bg).setVisibility(8);
findViewById(R.id.fl_button_bg2).setVisibility(8);
}
}
protected void showEditInfo() {
View inflate = LayoutInflater.from(this).inflate(R.layout.photo_edit_info, (ViewGroup) null);
inflate.findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PhotoUploadOptionsActivity.this.openLink("http://market.android.com/details?id=com.shinycore.picsayfree");
}
});
inflate.findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PhotoUploadOptionsActivity.this.openLink("http://market.android.com/details?id=com.adobe.psmobile");
}
});
inflate.findViewById(R.id.button3).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PhotoUploadOptionsActivity.this.openLink("http://market.android.com/details?id=com.aviary.android.feather");
}
});
inflate.findViewById(R.id.button4).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PhotoUploadOptionsActivity.this.openLink("http://market.android.com/details?id=com.alensw.PicFolder");
}
});
new AlertDialog.Builder(this).setView(inflate).setPositiveButton("OK", (DialogInterface.OnClickListener) null).setTitle(R.string.label_edit).create().show();
}
}