正在查看: Hyouka private v5.8.9 应用的 TakePhotoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Hyouka private v5.8.9 应用的 TakePhotoActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.beint.project.screens.sms;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import com.beint.project.MainApplication;
import com.beint.project.core.managers.OrientationManager;
import com.beint.project.core.services.impl.PathManager;
import com.beint.project.core.utils.Json;
import com.beint.project.core.utils.Log;
import com.beint.project.core.utils.ZangiFileUtils;
import com.beint.project.screens.sms.gallery.ZangiFileGalleryActivity;
import com.beint.project.screens.sms.gallery.enums.DestinationType;
import com.beint.project.screens.utils.ImageLoader;
import com.beint.project.utils.AlertDialogUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
public final class TakePhotoActivity extends AppModeNotifierActivity {
private static String mCurrentPhotoPath;
private Bitmap mImageBitmap;
private Uri mVideoUri;
private Uri photoURI;
private final long videoId;
public static final Companion Companion = new Companion(null);
private static WeakReference<TakePhotoActivity> thisWeak = new WeakReference<>(null);
private final int ACTION_TAKE_PHOTO_B = 1;
private final int ACTION_TAKE_PHOTO_S = 2;
private final int ACTION_TAKE_VIDEO = 3;
private final String BITMAP_STORAGE_KEY = "viewbitmap";
private final String IMAGEVIEW_VISIBILITY_STORAGE_KEY = "imageviewvisibility";
private final String VIDEO_STORAGE_KEY = "viewvideo";
private final String VIDEOVIEW_VISIBILITY_STORAGE_KEY = "videoviewvisibility";
private final String IMAGE_URI = "IMAGE_URI";
private final String JPEG_FILE_PREFIX = "IMG_";
private final String JPEG_FILE_SUFFIX = ".jpg";
private final String MOV__FILE_PREFIX = "MOV_";
private final String MOV_FILE_SUFFIX = ".mp4";
private final String TAG = TakePhotoActivity.class.getCanonicalName();
private String afterBackResult = "";
private final String mAlbumStorageDir = PathManager.INSTANCE.getINCOMING_DIR();
public static final class Companion {
private Companion() {
}
public Companion(kotlin.jvm.internal.g gVar) {
this();
}
public final synchronized TakePhotoActivity getInstance() {
return (TakePhotoActivity) TakePhotoActivity.thisWeak.get();
}
public final HashMap<String, Object> getStates() {
return Json.Companion.jsonObjectFromString(MainApplication.Companion.getMainContext().getSharedPreferences("takePhotoState", 0).getString("photoState", null));
}
public final void removeStates() {
MainApplication.Companion.getMainContext().getSharedPreferences("takePhotoState", 0).edit().remove("photoState").apply();
}
public final void saveStates(Intent intent) {
String str;
Bundle extras;
Bundle extras2;
SharedPreferences sharedPreferences = MainApplication.Companion.getMainContext().getSharedPreferences("takePhotoState", 0);
HashMap hashMap = new HashMap();
if (TakePhotoActivity.mCurrentPhotoPath != null) {
String str2 = TakePhotoActivity.mCurrentPhotoPath;
kotlin.jvm.internal.k.c(str2);
hashMap.put("path", str2);
}
if (intent == null || (extras2 = intent.getExtras()) == null || (str = extras2.getString("capture_from_camera")) == null) {
str = "";
}
String string = (intent == null || (extras = intent.getExtras()) == null) ? null : extras.getString("conversationId");
hashMap.put("conversationId", string != null ? string : "");
hashMap.put("result", str);
sharedPreferences.edit().putString("photoState", Json.Companion.jsonString(hashMap)).apply();
}
public final synchronized void setInstance(TakePhotoActivity takePhotoActivity) {
TakePhotoActivity.thisWeak = new WeakReference(takePhotoActivity);
}
}
private final void cameraVideoHandle(Intent intent) {
if (mCurrentPhotoPath != null) {
galleryAddPic();
}
}
private final void chooseAction() {
if (Companion.getStates() != null) {
return;
}
if (this.afterBackResult.length() <= 2) {
Intent intent = getIntent();
kotlin.jvm.internal.k.e(intent, "this.intent");
Bundle extras = intent.getExtras();
String valueOf = String.valueOf(extras != null ? extras.getString("capture_from_camera") : null);
if (kotlin.jvm.internal.k.b("photo", valueOf)) {
dispatchTakePictureIntent(this.ACTION_TAKE_PHOTO_S);
} else if (kotlin.jvm.internal.k.b("video", valueOf)) {
dispatchTakeVideoIntent();
}
} else if (kotlin.jvm.internal.k.b(this.afterBackResult, "photo")) {
dispatchTakePictureIntent(this.ACTION_TAKE_PHOTO_S);
} else if (kotlin.jvm.internal.k.b(this.afterBackResult, "video")) {
dispatchTakeVideoIntent();
}
if (ImageLoader.getImageCache() != null) {
ImageLoader.getImageCache().clearCache();
}
}
private final File creatMoveFile() throws IOException {
if (!ZangiFileUtils.checkFoldersExisting()) {
return null;
}
return File.createTempFile(this.MOV__FILE_PREFIX + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + '_', this.MOV_FILE_SUFFIX, getAlbumDir());
}
private final File createImageFile() throws IOException {
if (!ZangiFileUtils.checkFoldersExisting()) {
return null;
}
return File.createTempFile(this.JPEG_FILE_PREFIX + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + '_', this.JPEG_FILE_SUFFIX, getAlbumDir());
}
private final void dispatchTakePictureIntent(int i) {
if (ZangiFileUtils.checkFoldersExisting()) {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
try {
File upPhotoFile = setUpPhotoFile();
kotlin.jvm.internal.k.c(upPhotoFile);
mCurrentPhotoPath = upPhotoFile.getAbsolutePath();
Uri fromFile = Build.VERSION.SDK_INT <= 23 ? Uri.fromFile(upPhotoFile) : FileProvider.f(this, "com.beint.zangi.provider", upPhotoFile);
this.photoURI = fromFile;
intent.putExtra("output", fromFile);
} catch (IOException e) {
e.printStackTrace();
mCurrentPhotoPath = null;
}
Companion.saveStates(getIntent());
intent.putExtra("android.intent.extra.sizeLimit", 3568813L);
intent.addFlags(16777216);
intent.addFlags(8388608);
intent.putExtra("return-data", true);
try {
startActivityForResult(intent, i);
} catch (Exception e7) {
Log.e(this.TAG, "error -> " + e7.getMessage());
}
}
}
private final void dispatchTakeVideoIntent() {
if (ZangiFileUtils.checkFoldersExisting()) {
Companion.saveStates(getIntent());
Intent intent = new Intent("android.media.action.VIDEO_CAPTURE");
intent.putExtra("android.intent.extra.videoQuality", 1);
intent.putExtra("android.intent.extra.sizeLimit", 131428800L);
intent.addFlags(16777216);
intent.addFlags(131072);
try {
startActivityForResult(intent, this.ACTION_TAKE_VIDEO);
overridePendingTransition(0, 0);
} catch (Exception e) {
Log.e(this.TAG, "error -> " + e.getMessage());
}
}
}
private final void galleryAddPic() {
Intent intent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
intent.setData(Uri.fromFile(new File(mCurrentPhotoPath)));
sendBroadcast(intent);
}
private final File getAlbumDir() {
return new File(this.mAlbumStorageDir);
}
private final void handleBigCameraPhoto() {
if (mCurrentPhotoPath != null) {
galleryAddPic();
}
}
private final boolean isGroup(String str) {
if (str != null && zb.f.y(str, "gid", false, 2, (Object) null)) {
return true;
}
return str != null && zb.f.y(str, "pid", false, 2, (Object) null);
}
private final void sendFile() {
Log.i(this.TAG, "send file");
String str = mCurrentPhotoPath;
if (str == null) {
finish();
return;
}
if (str == null) {
return;
}
if (new File(str).length() / 1024 > 4000200) {
AlertDialogUtils.showAlertWithMessage((Context) this, 2131886570, false);
return;
}
Companion companion = Companion;
HashMap<String, Object> states = companion.getStates();
Object obj = states != null ? states.get("result") : null;
kotlin.jvm.internal.k.d(obj, "null cannot be cast to non-null type kotlin.String");
String str2 = (String) obj;
HashMap<String, Object> states2 = companion.getStates();
Object obj2 = states2 != null ? states2.get("conversationId") : null;
kotlin.jvm.internal.k.d(obj2, "null cannot be cast to non-null type kotlin.String");
String str3 = (String) obj2;
Log.i(this.TAG, "conversationId = " + str3 + " result = " + str2);
if (kotlin.jvm.internal.k.b("photo", str2)) {
Bundle bundle = new Bundle();
ZangiFileGalleryActivity.Companion companion2 = ZangiFileGalleryActivity.Companion;
bundle.putString(companion2.getTAKEN_MEDIA_PATH(), str);
bundle.putString(companion2.getDESTINATION_NUMBER_KEY(), str3);
bundle.putBoolean(companion2.getIS_FOR_GROUP(), isGroup(str3));
Log.i(this.TAG, "open photo");
getScreenService().openZangiFileGalleryActivity(this, DestinationType.ADD_DESCRIPTION_TO_IMAGE, bundle);
} else if (kotlin.jvm.internal.k.b("video", str2)) {
Bundle bundle2 = new Bundle();
bundle2.putInt("videoId", (int) this.videoId);
ZangiFileGalleryActivity.Companion companion3 = ZangiFileGalleryActivity.Companion;
bundle2.putString(companion3.getTAKEN_MEDIA_PATH(), str);
bundle2.putString(companion3.getDESTINATION_NUMBER_KEY(), str3);
bundle2.putBoolean(companion3.getIS_FOR_GROUP(), isGroup(str3));
Log.i(this.TAG, "open video");
getScreenService().openZangiFileGalleryActivity(this, DestinationType.ADD_DESCRIPTION_TO_VIDEO, bundle2);
}
this.afterBackResult = "";
finish();
}
private final File setUpPhotoFile() throws IOException {
File createImageFile = createImageFile();
mCurrentPhotoPath = createImageFile != null ? createImageFile.getAbsolutePath() : null;
return createImageFile;
}
private final File setUpVideoFile() throws IOException {
File creatMoveFile = creatMoveFile();
mCurrentPhotoPath = creatMoveFile != null ? creatMoveFile.getAbsolutePath() : null;
return creatMoveFile;
}
protected void onActivityResult(int i, int i7, Intent intent) {
super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i, i7, intent);
try {
HashMap<String, Object> states = Companion.getStates();
Object obj = states != null ? states.get("path") : null;
mCurrentPhotoPath = obj instanceof String ? (String) obj : null;
if (i == this.ACTION_TAKE_VIDEO && intent != null && intent.getData() != null) {
try {
ContentResolver contentResolver = getContentResolver();
Uri data = intent.getData();
kotlin.jvm.internal.k.c(data);
AssetFileDescriptor openAssetFileDescriptor = contentResolver.openAssetFileDescriptor(data, "r");
FileInputStream createInputStream = openAssetFileDescriptor != null ? openAssetFileDescriptor.createInputStream() : null;
if (createInputStream == null) {
return;
}
File upVideoFile = setUpVideoFile();
FileOutputStream fileOutputStream = new FileOutputStream(upVideoFile);
byte[] bArr = new byte[1024];
while (true) {
int read = createInputStream.read(bArr);
if (read <= 0) {
break;
} else {
fileOutputStream.write(bArr, 0, read);
}
}
createInputStream.close();
fileOutputStream.close();
kotlin.jvm.internal.k.c(upVideoFile);
mCurrentPhotoPath = upVideoFile.getAbsolutePath();
} catch (IOException unused) {
}
}
String str = mCurrentPhotoPath;
if (str == null) {
str = "";
}
File file = str != null ? new File(str) : null;
if (i7 != -1) {
if (file != null) {
file.delete();
}
Companion.removeStates();
mCurrentPhotoPath = null;
finish();
return;
}
Log.i(this.TAG, "!!!!!mCurrentPhotoPath=" + mCurrentPhotoPath);
String str2 = this.TAG;
StringBuilder sb = new StringBuilder();
sb.append("!!!!!mCurrentPhotoFile length=");
sb.append(file != null ? Long.valueOf(file.length()) : null);
Log.i(str2, sb.toString());
if (i == this.ACTION_TAKE_PHOTO_S) {
if (i7 == -1) {
this.afterBackResult = "photo";
handleBigCameraPhoto();
}
} else if (i == this.ACTION_TAKE_VIDEO && i7 == -1) {
this.afterBackResult = "video";
cameraVideoHandle(intent);
}
sendFile();
Companion.removeStates();
mCurrentPhotoPath = null;
finish();
} catch (Exception unused2) {
Companion.removeStates();
Log.e(this.TAG, "Error during capture from camera");
Toast.makeText(MainApplication.Companion.getMainContext(), 2131886271, 1).show();
finish();
}
}
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
Companion.setInstance(this);
if (OrientationManager.INSTANCE.isLeftHande()) {
setContentView(2131558521);
} else {
setContentView(2131558520);
}
View findViewById = findViewById(2131363849);
if (findViewById != null) {
findViewById.setVisibility(8);
}
setSupportActionBar(findViewById(2131363848));
androidx.appcompat.app.a supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.v(false);
}
androidx.appcompat.app.a supportActionBar2 = getSupportActionBar();
if (supportActionBar2 != null) {
supportActionBar2.q(true);
}
androidx.appcompat.app.a supportActionBar3 = getSupportActionBar();
if (supportActionBar3 != null) {
supportActionBar3.r(true);
}
androidx.appcompat.app.a supportActionBar4 = getSupportActionBar();
if (supportActionBar4 != null) {
supportActionBar4.w(2131887337);
}
this.mImageBitmap = null;
this.mVideoUri = null;
chooseAction();
}
public boolean onCreateOptionsMenu(Menu menu) {
return super/*android.app.Activity*/.onCreateOptionsMenu(menu);
}
@Override
protected void onDestroy() {
super.onDestroy();
Companion companion = Companion;
companion.setInstance(null);
companion.removeStates();
}
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (i == 4) {
onBackPressed();
}
return false;
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
kotlin.jvm.internal.k.f(menuItem, "item");
menuItem.getItemId();
return super/*android.app.Activity*/.onOptionsItemSelected(menuItem);
}
protected void onRestoreInstanceState(Bundle bundle) {
kotlin.jvm.internal.k.f(bundle, "savedInstanceState");
super/*android.app.Activity*/.onRestoreInstanceState(bundle);
this.mImageBitmap = (Bitmap) bundle.getParcelable(this.BITMAP_STORAGE_KEY);
this.mVideoUri = (Uri) bundle.getParcelable(this.VIDEO_STORAGE_KEY);
mCurrentPhotoPath = bundle.getString(this.IMAGE_URI);
}
protected void onSaveInstanceState(Bundle bundle) {
kotlin.jvm.internal.k.f(bundle, "outState");
bundle.putParcelable(this.BITMAP_STORAGE_KEY, this.mImageBitmap);
bundle.putParcelable(this.VIDEO_STORAGE_KEY, this.mVideoUri);
bundle.putParcelable(this.VIDEO_STORAGE_KEY, this.mVideoUri);
bundle.putBoolean(this.IMAGEVIEW_VISIBILITY_STORAGE_KEY, this.mImageBitmap != null);
bundle.putBoolean(this.VIDEOVIEW_VISIBILITY_STORAGE_KEY, this.mVideoUri != null);
bundle.putString(this.IMAGE_URI, mCurrentPhotoPath);
super/*androidx.activity.ComponentActivity*/.onSaveInstanceState(bundle);
}
}