正在查看: SpeedCash v6.5.1482 应用的 Imagery.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: SpeedCash v6.5.1482 应用的 Imagery.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.bm.sc.util.android;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.app.PendingIntent;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.ExifInterface;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Base64OutputStream;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.RecyclerView;
import com.bm.sc.bebasbayar.R;
import com.bm.sc.bebasbayar.handler.FirebaseProcessor;
import com.bm.sc.bebasbayar.helper.Affinity;
import com.bm.sc.bebasbayar.helper.FileHelper;
import com.bm.sc.bebasbayar.iface.BBCallback;
import com.bm.sc.bebasbayar.setting.ApiConfig;
import com.bm.sc.bebasbayar.ui.activity.info.ImageChooserActivity;
import com.bm.sc.util.android.Imagery;
import com.bm.sc.util.common.Var;
import com.bm.sc.util.zoomimageview.ZoomInImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.channels.FileChannel;
import java.nio.channels.spi.AbstractInterruptibleChannel;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
public class Imagery {
public static final String DOCUMENT = "document";
public static final String IMAGE = "image";
public static final String TEMP = "temp";
public class a implements MediaScannerConnection.OnScanCompletedListener {
@Override
public void onScanCompleted(String str, Uri uri) {
}
}
public class b extends SimpleTarget<Bitmap> {
public final Context d;
public final String e;
public final String f;
public final ImageView g;
public b(Context context, String str, String str2, ImageView imageView) {
this.d = context;
this.e = str;
this.f = str2;
this.g = imageView;
}
public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
Imagery.deleteCache(this.d);
this.g.setImageBitmap(bitmap);
}
public void onLoadFailed(@Nullable Drawable drawable) {
Handler handler = new Handler();
final Context context = this.d;
final String str = this.e;
final String str2 = this.f;
final ImageView imageView = this.g;
handler.postDelayed(new Runnable() {
@Override
public final void run() {
Imagery.e(context, str, str2, imageView);
}
}, 500L);
}
}
public class c extends SimpleTarget<Bitmap> {
public final Context d;
public final String e;
public final String f;
public final ZoomInImageView g;
public c(Context context, String str, String str2, ZoomInImageView zoomInImageView) {
this.d = context;
this.e = str;
this.f = str2;
this.g = zoomInImageView;
}
public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
Imagery.deleteCache(this.d);
this.g.setImageBitmap(bitmap);
}
public void onLoadFailed(@Nullable Drawable drawable) {
Handler handler = new Handler();
final Context context = this.d;
final String str = this.e;
final String str2 = this.f;
final ZoomInImageView zoomInImageView = this.g;
handler.postDelayed(new Runnable() {
@Override
public final void run() {
Imagery.e(context, str, str2, zoomInImageView);
}
}, 500L);
}
}
public static class saveImg extends AsyncTask<Bitmap, Void, Boolean> {
public final WeakReference<File> a;
public final WeakReference<createImgeListener> b;
public interface createImgeListener {
void onDone(boolean z);
}
public saveImg(File file, createImgeListener createimgelistener) {
this.a = new WeakReference<>(file);
this.b = new WeakReference<>(createimgelistener);
}
@Override
public Boolean doInBackground(Bitmap... bitmapArr) {
File file = this.a.get();
if (file != null) {
try {
if (file.createNewFile()) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmapArr[0].compress(Bitmap.CompressFormat.PNG, 0, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(byteArray);
fileOutputStream.flush();
fileOutputStream.close();
}
} catch (IOException e) {
if (ApiConfig.isLoggable()) {
e.printStackTrace();
}
return Boolean.FALSE;
}
}
return Boolean.TRUE;
}
@Override
public void onPostExecute(Boolean bool) {
createImgeListener createimgelistener = this.b.get();
if (createimgelistener != null) {
createimgelistener.onDone(bool.booleanValue());
}
}
}
public static void copyFile(FileInputStream fileInputStream, FileOutputStream fileOutputStream, File file, View view) throws IOException {
FileChannel fileChannel;
AbstractInterruptibleChannel abstractInterruptibleChannel;
FileChannel fileChannel2;
try {
try {
fileChannel = fileInputStream.getChannel();
} catch (Throwable th) {
th = th;
}
} catch (IOException e) {
e = e;
fileChannel = null;
fileChannel2 = null;
} catch (Throwable th2) {
th = th2;
fileChannel = null;
abstractInterruptibleChannel = null;
}
try {
fileChannel2 = fileOutputStream.getChannel();
try {
fileChannel.transferTo(0L, fileChannel.size(), fileChannel2);
try {
fileChannel.close();
MediaScannerConnection.scanFile(view.getContext(), new String[]{file.getAbsolutePath()}, null, new a());
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setDataAndType(Uri.fromFile(file), "image/*");
int currentTimeMillis = (int) System.currentTimeMillis();
FirebaseProcessor.sendNotification(view.getContext(), Build.VERSION.SDK_INT >= 31 ? PendingIntent.getActivity(view.getContext(), 0, intent, 1140850688) : PendingIntent.getActivity(view.getContext(), 0, intent, 1140850688), currentTimeMillis, view.getContext().getString(R.string.title_download_invoice), view.getContext().getString(R.string.info_download_finished, file.getName()), false);
view.getContext().startActivity(Intent.createChooser(intent, "Buka gambar..."));
} finally {
if (fileChannel2 != null) {
fileChannel2.close();
}
}
} catch (IOException e2) {
e = e2;
StringBuilder sb = new StringBuilder();
sb.append("copyFile: ");
sb.append(e);
e.printStackTrace();
if (fileChannel != null) {
try {
fileChannel.close();
MediaScannerConnection.scanFile(view.getContext(), new String[]{file.getAbsolutePath()}, null, new a());
Intent intent2 = new Intent();
intent2.setAction("android.intent.action.VIEW");
intent2.setDataAndType(Uri.fromFile(file), "image/*");
int currentTimeMillis2 = (int) System.currentTimeMillis();
FirebaseProcessor.sendNotification(view.getContext(), Build.VERSION.SDK_INT >= 31 ? PendingIntent.getActivity(view.getContext(), 0, intent2, 1140850688) : PendingIntent.getActivity(view.getContext(), 0, intent2, 1140850688), currentTimeMillis2, view.getContext().getString(R.string.title_download_invoice), view.getContext().getString(R.string.info_download_finished, file.getName()), false);
view.getContext().startActivity(Intent.createChooser(intent2, "Buka gambar..."));
} finally {
}
}
if (fileChannel2 == null) {
}
}
} catch (IOException e3) {
e = e3;
fileChannel2 = null;
} catch (Throwable th3) {
th = th3;
abstractInterruptibleChannel = null;
if (fileChannel != null) {
try {
fileChannel.close();
MediaScannerConnection.scanFile(view.getContext(), new String[]{file.getAbsolutePath()}, null, new a());
Intent intent3 = new Intent();
intent3.setAction("android.intent.action.VIEW");
intent3.setDataAndType(Uri.fromFile(file), "image/*");
int currentTimeMillis3 = (int) System.currentTimeMillis();
FirebaseProcessor.sendNotification(view.getContext(), Build.VERSION.SDK_INT >= 31 ? PendingIntent.getActivity(view.getContext(), 0, intent3, 1140850688) : PendingIntent.getActivity(view.getContext(), 0, intent3, 1140850688), currentTimeMillis3, view.getContext().getString(R.string.title_download_invoice), view.getContext().getString(R.string.info_download_finished, file.getName()), false);
view.getContext().startActivity(Intent.createChooser(intent3, "Buka gambar..."));
} finally {
if (abstractInterruptibleChannel != null) {
abstractInterruptibleChannel.close();
}
}
}
throw th;
}
}
public static String createBase64FromBitmap(Bitmap bitmap) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
return Base64.encodeToString(byteArrayOutputStream.toByteArray(), 0);
}
public static String createBase64FromFile(File file) throws IOException {
Path path;
InputStream newInputStream;
path = Paths.get(file.getAbsolutePath(), new String[0]);
newInputStream = Files.newInputStream(path, new OpenOption[0]);
byte[] bArr = new byte[FragmentTransaction.TRANSIT_EXIT_MASK];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Base64OutputStream base64OutputStream = new Base64OutputStream(byteArrayOutputStream, 0);
while (true) {
try {
int read = newInputStream.read(bArr);
if (read == -1) {
break;
}
base64OutputStream.write(bArr, 0, read);
} catch (IOException unused) {
}
}
base64OutputStream.close();
newInputStream.close();
return byteArrayOutputStream.toString();
}
public static Bitmap createBitmapFromBase64(String str) throws UnsupportedEncodingException {
byte[] decode = Base64.decode(URLDecoder.decode(str, "UTF-8"), 0);
return BitmapFactory.decodeByteArray(decode, 0, decode.length);
}
public static File createFileFromBase64(String str, String str2) throws IOException {
return createFileFromByte(Base64.decode(URLDecoder.decode(str, "UTF-8"), 0), str2);
}
public static File createFileFromByte(byte[] bArr, String str) throws IOException {
File externalStorageDirectory = Environment.getExternalStorageDirectory();
StringBuilder sb = new StringBuilder();
sb.append(externalStorageDirectory.getAbsolutePath());
String str2 = File.separator;
sb.append(str2);
sb.append(Environment.DIRECTORY_DOWNLOADS);
sb.append(str2);
sb.append(str);
File file = new File(sb.toString());
FileOutputStream fileOutputStream = new FileOutputStream(file, true);
fileOutputStream.write(bArr);
fileOutputStream.flush();
fileOutputStream.close();
return file;
}
public static void deleteCache(Context context) {
try {
File externalCacheDir = context.getExternalCacheDir();
if (externalCacheDir == null || !externalCacheDir.isDirectory()) {
return;
}
deleteDir(externalCacheDir);
} catch (Exception e) {
StringBuilder sb = new StringBuilder();
sb.append("deleteCache: ");
sb.append(e);
}
}
public static boolean deleteDir(File file) {
if (file == null || !file.isDirectory()) {
return false;
}
String[] list = file.list();
if (list != null) {
for (String str : list) {
if (!deleteDir(new File(file, str))) {
return false;
}
}
}
return file.delete();
}
public static Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
if (bitmapDrawable.getBitmap() != null) {
return bitmapDrawable.getBitmap();
}
}
Bitmap createBitmap = (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) ? Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888) : Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return createBitmap;
}
public static void e(Context context, String str, String str2, ImageView imageView) {
f(context, str, str2, imageView);
}
public static void f(Context context, String str, String str2, ImageView imageView) {
if (str != null && str.isEmpty()) {
str = str2;
}
try {
URLEncoder.encode(str, "UTF-8");
} catch (UnsupportedEncodingException unused) {
}
if (FileHelper.isValidContextForGlide(context)) {
Glide.with(context).load(Integer.valueOf(R.drawable.ic_jay_user_icon)).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).dontAnimate().placeholder(R.drawable.ic_jay_user_icon).error(R.drawable.ic_jay_user_icon)).apply(RequestOptions.circleCropTransform()).into(imageView);
}
}
@Nullable
public static Bitmap getBitmapFromUri(Context context, Uri uri) {
if (uri == null) {
return null;
}
String pathFromUri = getPathFromUri(context, uri);
if (pathFromUri == null) {
pathFromUri = uri.getPath();
}
if (pathFromUri == null) {
return null;
}
return BitmapFactory.decodeFile(pathFromUri);
}
public static Bitmap getBitmapReduceFromUri(Context context, Uri uri) {
if (uri == null) {
return null;
}
String realPathFromURI = getRealPathFromURI(context, uri);
if (realPathFromURI == null) {
realPathFromURI = uri.getPath();
}
return reduceBitmapSize(BitmapFactory.decodeFile(realPathFromURI));
}
public static Bitmap getCropBitmapFromBitmap(@NonNull Bitmap bitmap) {
if (bitmap == null) {
return bitmap;
}
return Bitmap.createBitmap(bitmap, 10, bitmap.getHeight() / 4, bitmap.getWidth() - 10, bitmap.getHeight() / 2);
}
public static java.lang.String getDataColumn(android.content.Context r8, android.net.Uri r9, java.lang.String r10, java.lang.String[] r11) {
throw new UnsupportedOperationException("Method not decompiled: com.bm.sc.util.android.Imagery.getDataColumn(android.content.Context, android.net.Uri, java.lang.String, java.lang.String[]):java.lang.String");
}
public static Uri getImageUri(Context context, Bitmap bitmap) {
File file;
try {
file = File.createTempFile(String.valueOf(System.currentTimeMillis()), ".jpg", context.getCacheDir());
} catch (IOException e) {
e.printStackTrace();
file = null;
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(byteArray);
fileOutputStream.flush();
fileOutputStream.close();
Objects.requireNonNull(file);
return Uri.parse(file.getPath());
} catch (FileNotFoundException e2) {
e2.printStackTrace();
return null;
} catch (IOException e3) {
e3.printStackTrace();
return null;
}
}
public static String getMimeType(String str) {
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
if (fileExtensionFromUrl != null) {
return MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtensionFromUrl);
}
return null;
}
public static Intent getPICK(Context context, View view) {
Bitmap createBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
view.draw(new Canvas(createBitmap));
File file = new File(view.getContext().getCacheDir(), "images");
try {
file.mkdirs();
File file2 = new File(file, "filename.jpg");
FileOutputStream fileOutputStream = new FileOutputStream(file2);
createBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
Uri uriForFile = FileProvider.getUriForFile(view.getContext(), "com.bm.sc.bebasbayar.provider", file2);
context.grantUriPermission(context.getPackageName(), uriForFile, 2);
Intent intent = new Intent("android.intent.action.PICK");
intent.putExtra("android.intent.extra.STREAM", uriForFile);
intent.addFlags(3);
intent.setType("image/jpeg");
return intent;
} catch (Throwable th) {
th.printStackTrace();
return null;
}
}
public static String getPathFromUri(Context context, Uri uri) {
String realPathFromURI = getRealPathFromURI(context, uri);
return realPathFromURI == null ? uri.getPath() : realPathFromURI;
}
public static void getPhotoProfile(Context context, String str, String str2, String str3, String str4, ImageView imageView) {
Glide.with(context).asBitmap().load(str + "profile/" + str2).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).dontAnimate().override(300, 300).placeholder(R.drawable.ic_jay_user_icon).error(R.drawable.ic_jay_user_icon)).apply(RequestOptions.circleCropTransform()).into(new b(context, str3, str4, imageView));
}
@SuppressLint({"NewApi"})
public static String getRealPathFromURI(Context context, Uri uri) {
Uri uri2 = null;
if (DocumentsContract.isDocumentUri(context, uri)) {
if (isExternalStorageDocument(uri)) {
String[] split = DocumentsContract.getDocumentId(uri).split(":");
if ("primary".equalsIgnoreCase(split[0])) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
} else if (isDownloadsDocument(uri)) {
String documentId = DocumentsContract.getDocumentId(uri);
if (!TextUtils.isEmpty(documentId)) {
if (documentId.startsWith("raw:")) {
return documentId.replaceFirst("raw:", "");
}
try {
return getDataColumn(context, ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(documentId).longValue()), null, null);
} catch (NumberFormatException e) {
return e.toString();
}
}
} else if (isMediaDocument(uri)) {
String[] split2 = DocumentsContract.getDocumentId(uri).split(":");
String str = split2[0];
if ("image".equals(str)) {
uri2 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(str)) {
uri2 = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(str)) {
uri2 = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
return getDataColumn(context, uri2, "_id=?", new String[]{split2[1]});
}
} else {
if ("content".equalsIgnoreCase(uri.getScheme())) {
return isGooglePhotosUri(uri) ? uri.getLastPathSegment() : getDataColumn(context, uri, null, null);
}
if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
}
return null;
}
@Nullable
public static Bitmap getRotatedBitmap(Context context, @NonNull Uri uri) {
Bitmap rotate;
Bitmap bitmapFromUri = getBitmapFromUri(context, uri);
if (bitmapFromUri == null) {
return null;
}
try {
String var = Var.toString(new ExifInterface(getPathFromUri(context, uri)).getAttribute("Orientation"), "");
if (var.equalsIgnoreCase("6")) {
rotate = rotate(bitmapFromUri, 90);
} else if (var.equalsIgnoreCase("8")) {
rotate = rotate(bitmapFromUri, 270);
} else {
if (!var.equalsIgnoreCase("3")) {
return bitmapFromUri;
}
rotate = rotate(bitmapFromUri, 180);
}
return rotate;
} catch (IOException unused) {
return bitmapFromUri;
}
}
public static Bitmap getRotatedBitmap2(Bitmap bitmap, @NonNull Uri uri) {
if (bitmap != null) {
try {
String path = uri.getPath();
Objects.requireNonNull(path);
String var = Var.toString(new ExifInterface(path).getAttribute("Orientation"), "");
if (var.equalsIgnoreCase("6")) {
bitmap = rotate(bitmap, 90);
} else if (var.equalsIgnoreCase("8")) {
bitmap = rotate(bitmap, 270);
} else if (var.equalsIgnoreCase("3")) {
bitmap = rotate(bitmap, 180);
}
} catch (IOException unused) {
}
}
return bitmap;
}
public static Bitmap getRotatedBitmapFromBitmap(Context context, @NonNull Bitmap bitmap, File file) {
if (bitmap == null) {
return bitmap;
}
try {
ExifInterface exifInterface = Build.VERSION.SDK_INT >= 29 ? new ExifInterface(file) : new ExifInterface(file.toString());
StringBuilder sb = new StringBuilder();
sb.append("exifInterface ");
sb.append(exifInterface);
int attributeInt = exifInterface.getAttributeInt("Orientation", 0);
StringBuilder sb2 = new StringBuilder();
sb2.append("rotation ");
sb2.append(attributeInt);
if (attributeInt != 1 && attributeInt != 0) {
return attributeInt == 6 ? rotate(bitmap, 90) : attributeInt == 8 ? rotate(bitmap, 270) : attributeInt == 3 ? rotate(bitmap, 180) : bitmap;
}
return bitmap;
} catch (IOException e) {
StringBuilder sb3 = new StringBuilder();
sb3.append("ignored ");
sb3.append(e);
return null;
}
}
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int i) {
Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
Paint paint = new Paint();
Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
RectF rectF = new RectF(rect);
float f = i;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(-12434878);
canvas.drawRoundRect(rectF, f, f, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return createBitmap;
}
public static File getSaveDirectory(String str, String str2, String str3) {
StringBuilder sb = new StringBuilder();
String str4 = File.separator;
sb.append(str4);
sb.append(Environment.DIRECTORY_DOWNLOADS);
String sb2 = sb.toString();
String str5 = sb2 + str4 + "BB ANDROID" + str4 + str;
File file = new File(Environment.getExternalStorageDirectory(), str5);
boolean mkdirs = !file.isDirectory() ? file.mkdirs() : true;
File externalStorageDirectory = Environment.getExternalStorageDirectory();
StringBuilder sb3 = new StringBuilder();
if (mkdirs) {
sb2 = str5;
}
sb3.append(sb2);
sb3.append(str4);
sb3.append(str2);
sb3.append("-");
sb3.append(System.currentTimeMillis());
sb3.append(".");
sb3.append(str3.toLowerCase());
return new File(externalStorageDirectory, sb3.toString());
}
public static void h(Context context, final Dialog dialog, View view) {
Affinity.launch((Activity) context, ImageChooserActivity.class);
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
dialog.dismiss();
}
}, 2000L);
}
public static boolean i(Dialog dialog, DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
if (i != 4 || keyEvent.isCanceled()) {
return false;
}
dialogInterface.cancel();
dialog.dismiss();
return true;
}
public static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
public static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
public static boolean isGooglePhotosUri(Uri uri) {
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
}
public static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
public static void popupImageview(final Context context, String str, String str2, String str3, String str4, boolean z) {
final Dialog dialog = new Dialog(context, android.R.style.Theme.Light);
dialog.requestWindowFeature(1);
dialog.setCancelable(false);
dialog.setContentView(R.layout.dialog_popup_image);
ZoomInImageView zoomInImageView = (ZoomInImageView) dialog.findViewById(R.id.popup_image);
TextView textView = (TextView) dialog.findViewById(R.id.btn_upload_profile);
LinearLayout linearLayout = (LinearLayout) dialog.findViewById(R.id.popup_container);
if (z) {
textView.setVisibility(0);
} else {
textView.setVisibility(8);
}
Glide.with(context).asBitmap().load(str + "profile/" + str2).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).dontAnimate().placeholder(R.drawable.ic_jay_user_icon).error(R.drawable.ic_jay_user_icon)).apply(RequestOptions.circleCropTransform()).into(new c(context, str3, str4, zoomInImageView));
textView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
Imagery.h(context, dialog, view);
}
});
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public final boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
boolean i2;
i2 = Imagery.i(dialog, dialogInterface, i, keyEvent);
return i2;
}
});
linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
public static Bitmap reduceBitmapSize(Bitmap bitmap) {
int i;
if (bitmap == null) {
return null;
}
float width = bitmap.getWidth() / bitmap.getHeight();
int i2 = 1000;
if (width > RecyclerView.G0) {
i = (int) (1000 / width);
} else {
i2 = (int) (1000 * width);
i = 1000;
}
return Bitmap.createScaledBitmap(bitmap, i2, i, false);
}
public static Bitmap rotate(Bitmap bitmap, int i) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Matrix matrix = new Matrix();
matrix.postRotate(i);
return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
}
public static Drawable scaleDrawable(Context context, Drawable drawable, int i, int i2) {
return new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(((BitmapDrawable) drawable).getBitmap(), i, i2, false));
}
public static void screenShot(View view, String str) {
Bitmap createBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
view.draw(new Canvas(createBitmap));
try {
Environment.getExternalStorageDirectory();
File file = new File(view.getContext().getCacheDir().toString() + "/" + str + ".jpg");
FileOutputStream fileOutputStream = new FileOutputStream(file);
createBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
if (Build.VERSION.SDK_INT >= 30) {
FileInputStream fileInputStream = new FileInputStream(view.getContext().getDatabasePath(file.toString()));
File file2 = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/" + str + ".jpg");
copyFile(fileInputStream, new FileOutputStream(file2), file2, view);
} else {
FileInputStream fileInputStream2 = new FileInputStream(view.getContext().getDatabasePath(file.toString()));
File file3 = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/" + str + ".jpg");
copyFile(fileInputStream2, new FileOutputStream(file3), file3, view);
}
} catch (Throwable th) {
th.printStackTrace();
}
}
public static void shareImageCache(View view, String str) {
Bitmap createBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
view.draw(new Canvas(createBitmap));
File file = new File(view.getContext().getCacheDir(), "images");
try {
file.mkdirs();
File file2 = new File(file, str + ".jpg");
FileOutputStream fileOutputStream = new FileOutputStream(file2);
createBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
Uri uriForFile = FileProvider.getUriForFile(view.getContext(), "com.bm.sc.bebasbayar.provider", file2);
Intent intent = new Intent("android.intent.action.SEND");
intent.putExtra("android.intent.extra.STREAM", uriForFile);
intent.addFlags(1);
intent.setType("image/png");
view.getContext().startActivity(intent);
} catch (Throwable th) {
th.printStackTrace();
}
}
public static void shareImageCacheUri(View view, String str, BBCallback<Uri> bBCallback) {
Bitmap createBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
view.draw(new Canvas(createBitmap));
File file = new File(view.getContext().getCacheDir(), "images");
try {
file.mkdirs();
File file2 = new File(file, str + ".jpg");
FileOutputStream fileOutputStream = new FileOutputStream(file2);
createBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
bBCallback.do_callback(0, FileProvider.getUriForFile(view.getContext(), "com.bm.sc.bebasbayar.provider", file2));
} catch (Throwable th) {
th.printStackTrace();
bBCallback.do_callback(0, null);
}
}
public static void shareImageDir(View view, String str) {
Bitmap createBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
view.draw(new Canvas(createBitmap));
try {
File externalStorageDirectory = Environment.getExternalStorageDirectory();
StringBuilder sb = new StringBuilder();
sb.append(externalStorageDirectory.getAbsolutePath());
String str2 = File.separator;
sb.append(str2);
sb.append(Environment.DIRECTORY_DOWNLOADS);
sb.append(str2);
sb.append(str);
sb.append(".jpg");
File file = new File(sb.toString());
FileOutputStream fileOutputStream = new FileOutputStream(file);
createBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
Uri fromFile = Uri.fromFile(file);
Intent intent = new Intent("android.intent.action.SEND");
intent.putExtra("android.intent.extra.STREAM", fromFile);
intent.addFlags(1);
intent.setType("image/png");
view.getContext().startActivity(intent);
} catch (Throwable th) {
th.printStackTrace();
}
}
public static void screenShot(Activity activity, String str) {
try {
File externalStorageDirectory = Environment.getExternalStorageDirectory();
StringBuilder sb = new StringBuilder();
sb.append(externalStorageDirectory.getAbsolutePath());
String str2 = File.separator;
sb.append(str2);
sb.append(Environment.DIRECTORY_DOWNLOADS);
sb.append(str2);
sb.append(str);
sb.append(".jpg");
File file = new File(sb.toString());
View rootView = activity.getWindow().getDecorView().getRootView();
rootView.setDrawingCacheEnabled(true);
Bitmap createBitmap = Bitmap.createBitmap(rootView.getDrawingCache());
rootView.setDrawingCacheEnabled(false);
FileOutputStream fileOutputStream = new FileOutputStream(file);
createBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setDataAndType(Uri.fromFile(file), "image/*");
activity.startActivity(Intent.createChooser(intent, "Buka gambar..."));
} catch (Throwable th) {
th.printStackTrace();
}
}
}