正在查看: Hyouka private v5.8.9 应用的 ScreenChooseBackground.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Hyouka private v5.8.9 应用的 ScreenChooseBackground.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.beint.project.screens.sms;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import com.beint.project.adapter.ChooseBackgroundImageListAdapter;
import com.beint.project.core.model.sms.Conversation;
import com.beint.project.core.services.ConversationBackgroundServiceDelegate;
import com.beint.project.core.services.impl.BackgroundServiceImpl;
import com.beint.project.core.services.impl.PathManager;
import com.beint.project.core.services.impl.StorageService;
import com.beint.project.core.services.impl.ZangiConfigurationService;
import com.beint.project.core.utils.Constants;
import com.beint.project.core.utils.Log;
import com.beint.project.core.utils.NotificationCenter;
import com.beint.project.core.utils.ZangiEngineUtils;
import com.beint.project.core.utils.ZangiFileUtils;
import com.beint.project.databinding.ScreenChooseBackgroundBinding;
import com.beint.project.items.BackgroundItem;
import com.beint.project.screens.ConversationManager;
import com.beint.project.screens.utils.ImageLoader;
import com.beint.project.utils.ProgressDialogUtils;
import com.beint.project.utils.ProjectUtils;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
import java.util.ArrayList;
public final class ScreenChooseBackground extends AppModeNotifierActivity implements ConversationBackgroundServiceDelegate {
public static final Companion Companion = new Companion(null);
private static final int GALLERY_KITKAT_INTENT_CALLED = 21233;
private static final int RESULT_LOAD_IMAGE = 1;
private final String CLASS_NAME;
private String backgroundImagePath;
private ScreenChooseBackgroundBinding binding;
private Conversation conversation;
private final ChooseBackgroundImageListAdapter gridAdapter;
private final ArrayList<BackgroundItem> gridArray = new ArrayList<>();
private String userJid;
private String version;
public static final class Companion {
private Companion() {
}
public Companion(kotlin.jvm.internal.g gVar) {
this();
}
}
public ScreenChooseBackground() {
String canonicalName = ScreenChooseBackground.class.getCanonicalName();
this.CLASS_NAME = canonicalName == null ? "ScreenChooseBackground" : canonicalName;
this.gridAdapter = new ChooseBackgroundImageListAdapter();
this.version = "-1";
}
private final void addObservers() {
NotificationCenter.INSTANCE.addObserver(this, NotificationCenter.NotificationType.CONVERSATION_BACKGROUND_FINISH_DOWNLOAD, new ScreenChooseBackground$addObservers$1(this));
}
private final void backgroundVersionOnReceivers(String str) {
if (str == null) {
ZangiConfigurationService zangiConfigurationService = ZangiConfigurationService.INSTANCE;
String str2 = Constants.BACKGROUNDS_VERSION_LOCALE_VALUE;
kotlin.jvm.internal.k.e(str2, "BACKGROUNDS_VERSION_LOCALE_VALUE");
str = zangiConfigurationService.getString(str2, "-1");
}
this.version = str;
ZangiConfigurationService zangiConfigurationService2 = ZangiConfigurationService.INSTANCE;
String str3 = Constants.BACKGROUNDS_VERSION_LOCALE_VALUE;
kotlin.jvm.internal.k.e(str3, "BACKGROUNDS_VERSION_LOCALE_VALUE");
ScreenChooseBackgroundBinding screenChooseBackgroundBinding = null;
if (!kotlin.jvm.internal.k.b(str, zangiConfigurationService2.getString(str3, "-1"))) {
String backgroundsBucketDestination = ZangiFileUtils.getBackgroundsBucketDestination();
BackgroundServiceImpl.Companion companion = BackgroundServiceImpl.Companion;
BackgroundServiceImpl companion2 = companion.getInstance();
kotlin.jvm.internal.k.e(backgroundsBucketDestination, "screenDestination");
companion2.loadBackgroundByScreenDestination(backgroundsBucketDestination);
companion.getInstance().loadBackgroundThumbnails();
ScreenChooseBackgroundBinding screenChooseBackgroundBinding2 = this.binding;
if (screenChooseBackgroundBinding2 == null) {
kotlin.jvm.internal.k.q("binding");
} else {
screenChooseBackgroundBinding = screenChooseBackgroundBinding2;
}
FrameLayout frameLayout = screenChooseBackgroundBinding.progressLayout;
if (frameLayout == null) {
return;
}
frameLayout.setVisibility(0);
return;
}
this.gridArray.clear();
ArrayList<BackgroundItem> defaultThumbs = getDefaultThumbs();
if (!defaultThumbs.isEmpty()) {
BackgroundItem customThumbForUser = getCustomThumbForUser(this.userJid);
if (customThumbForUser != null) {
this.gridArray.add(customThumbForUser);
}
this.gridArray.addAll(defaultThumbs);
this.gridAdapter.setData(this.gridArray);
return;
}
BackgroundServiceImpl.Companion companion3 = BackgroundServiceImpl.Companion;
BackgroundServiceImpl companion4 = companion3.getInstance();
String backgroundsBucketDestination2 = ZangiFileUtils.getBackgroundsBucketDestination();
kotlin.jvm.internal.k.e(backgroundsBucketDestination2, "getBackgroundsBucketDestination()");
companion4.loadBackgroundByScreenDestination(backgroundsBucketDestination2);
companion3.getInstance().loadBackgroundThumbnails();
ScreenChooseBackgroundBinding screenChooseBackgroundBinding3 = this.binding;
if (screenChooseBackgroundBinding3 == null) {
kotlin.jvm.internal.k.q("binding");
} else {
screenChooseBackgroundBinding = screenChooseBackgroundBinding3;
}
FrameLayout frameLayout2 = screenChooseBackgroundBinding.progressLayout;
if (frameLayout2 == null) {
return;
}
frameLayout2.setVisibility(0);
}
static void backgroundVersionOnReceivers$default(ScreenChooseBackground screenChooseBackground, String str, int i, Object obj) {
if ((i & 1) != 0) {
str = null;
}
screenChooseBackground.backgroundVersionOnReceivers(str);
}
public final void changeBackground(String str) {
Conversation conversation;
if (!zb.f.y(str, "a007", false, 2, (Object) null) && BackgroundServiceImpl.Companion.getInstance().downloadBackgroundImageIfNeeded(str)) {
ProgressDialogUtils.showDialog(this, getResources().getString(2131886496), getResources().getString(2131887172), true);
return;
}
if (ImageLoader.getImageCache() != null) {
ImageLoader.getImageCache().clearCache();
}
String str2 = this.userJid;
if (!(str2 == null || str2.length() == 0) && (conversation = this.conversation) != null) {
kotlin.jvm.internal.k.c(conversation);
String backgroundPath = conversation.getBackgroundPath();
if (backgroundPath == null) {
backgroundPath = "";
}
Conversation conversation2 = this.conversation;
kotlin.jvm.internal.k.c(conversation2);
conversation2.setBackgroundPath(str);
ConversationManager conversationManager = ConversationManager.INSTANCE;
Conversation currentConversation = conversationManager.getCurrentConversation();
if (currentConversation != null) {
currentConversation.setBackgroundPath(str);
}
StorageService.INSTANCE.updateConversation(this.conversation);
conversationManager.removeExistBg(str);
Conversation conversation3 = this.conversation;
kotlin.jvm.internal.k.c(conversation3);
conversationManager.loadChatBackground(conversation3, null);
Conversation conversation4 = this.conversation;
kotlin.jvm.internal.k.c(conversation4);
conversationManager.updateBackgroundPath(backgroundPath, conversation4.getConversationJid());
} else if (kotlin.jvm.internal.k.b(this.userJid, ZangiEngineUtils.getCurrentRegisteredUserId("customBackground"))) {
StorageService.INSTANCE.setSettings("DEFAULT_BACKGROUND_PATH", str);
ConversationManager.INSTANCE.loadDefaultBackgroundRunnable();
}
this.gridAdapter.setSelectedItemPath(new File(str).getName());
this.gridAdapter.notifyDataSetChanged();
}
private final void deleteCustomBg() {
String str = this.userJid;
if (str == null || str.length() == 0) {
return;
}
String str2 = this.userJid + ".jpg";
StringBuilder sb = new StringBuilder();
PathManager pathManager = PathManager.INSTANCE;
sb.append(pathManager.getCUSTOM_THUMB_DIR());
sb.append(str2);
File file = new File(sb.toString());
if (file.exists()) {
file.delete();
}
File file2 = new File(pathManager.getBACKGROUNDS_DIR() + ZangiFileUtils.getBackgroundsBucketDestination() + '/' + str2);
if (file2.exists()) {
file2.delete();
}
}
private final void deleteRecursive(File file) {
if (file.isDirectory()) {
File[] listFiles = file.listFiles();
kotlin.jvm.internal.k.e(listFiles, "fileOrDirectory.listFiles()");
for (File file2 : listFiles) {
kotlin.jvm.internal.k.e(file2, "child");
deleteRecursive(file2);
}
}
file.delete();
}
public static final void downloadCompeted$lambda$7(ScreenChooseBackground screenChooseBackground) {
kotlin.jvm.internal.k.f(screenChooseBackground, "this$0");
screenChooseBackground.refreshBackgrounds();
}
public static final void downloadFailed$lambda$8(ScreenChooseBackground screenChooseBackground) {
kotlin.jvm.internal.k.f(screenChooseBackground, "this$0");
screenChooseBackground.refreshBackgrounds();
}
private final void galleryButtonHandler() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction("android.intent.action.OPEN_DOCUMENT");
intent.addCategory("android.intent.category.OPENABLE");
try {
startActivityForResult(intent, GALLERY_KITKAT_INTENT_CALLED);
} catch (ActivityNotFoundException unused) {
Log.i("START_ACTIVITY_ERROR", "No Intent available to handle action");
}
}
private final Bitmap getBitmapFromUri(Uri uri) throws IOException {
ParcelFileDescriptor openFileDescriptor = getContentResolver().openFileDescriptor(uri, "r");
if (openFileDescriptor == null || openFileDescriptor.getFileDescriptor() == null) {
return null;
}
FileDescriptor fileDescriptor = openFileDescriptor.getFileDescriptor();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
int min = Math.min(1636, ProjectUtils.getHeight(this));
int calculateInSampleSize = ZangiFileUtils.calculateInSampleSize(options.outWidth, options.outHeight, min, min);
options.inJustDecodeBounds = false;
options.inSampleSize = calculateInSampleSize;
Bitmap decodeFileDescriptor = BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
openFileDescriptor.close();
return decodeFileDescriptor;
}
private final BackgroundItem getCustomThumbForUser(String str) {
if (str == null || str.length() == 0) {
return null;
}
File file = new File(new File(PathManager.INSTANCE.getCUSTOM_THUMB_DIR()).getAbsolutePath() + '/' + str + ".jpg");
if (!file.exists() || file.isDirectory()) {
return null;
}
return new BackgroundItem(file.getAbsolutePath(), file.getName());
}
private final ArrayList<BackgroundItem> getDefaultThumbs() {
File file = new File(PathManager.INSTANCE.getTHUMB_BACKGROUNDS_DIR());
ArrayList<BackgroundItem> arrayList = new ArrayList<>();
if (file.exists() && file.listFiles() != null) {
File[] listFiles = file.listFiles();
kotlin.jvm.internal.k.e(listFiles, "tumbDir.listFiles()");
if (!(listFiles.length == 0)) {
File[] listFiles2 = file.listFiles();
kotlin.jvm.internal.k.e(listFiles2, "tumbDir.listFiles()");
for (File file2 : listFiles2) {
if (!file2.isDirectory()) {
String absolutePath = file2.getAbsolutePath();
kotlin.jvm.internal.k.e(absolutePath, "thumb.absolutePath");
String lowerCase = absolutePath.toLowerCase();
kotlin.jvm.internal.k.e(lowerCase, "this as java.lang.String).toLowerCase()");
if (zb.f.j(lowerCase, ".jpg", false, 2, (Object) null)) {
arrayList.add(new BackgroundItem(file2.getAbsolutePath(), file2.getName()));
}
}
}
}
}
arrayList.isEmpty();
return arrayList;
}
private final void hideShadowAfterLollipop() {
ScreenChooseBackgroundBinding screenChooseBackgroundBinding = this.binding;
if (screenChooseBackgroundBinding == null) {
kotlin.jvm.internal.k.q("binding");
screenChooseBackgroundBinding = null;
}
screenChooseBackgroundBinding.toolbarShadow.setVisibility(8);
}
public static final void onCreate$lambda$0(ScreenChooseBackground screenChooseBackground, int i) {
kotlin.jvm.internal.k.f(screenChooseBackground, "this$0");
ScreenChooseBackgroundBinding screenChooseBackgroundBinding = screenChooseBackground.binding;
if (screenChooseBackgroundBinding == null) {
kotlin.jvm.internal.k.q("binding");
screenChooseBackgroundBinding = null;
}
screenChooseBackgroundBinding.noneBackCheck.setVisibility(8);
try {
screenChooseBackground.gridArray.get(i).getPath();
String path = screenChooseBackground.gridArray.get(i).getPath();
kotlin.jvm.internal.k.e(path, "gridArray[position].path");
screenChooseBackground.changeBackground(path);
} catch (Exception e) {
Log.e(screenChooseBackground.CLASS_NAME, e.getMessage());
}
}
public static final void onCreate$lambda$1(ScreenChooseBackground screenChooseBackground, View view) {
kotlin.jvm.internal.k.f(screenChooseBackground, "this$0");
screenChooseBackground.galleryButtonHandler();
}
public static final void onCreate$lambda$2(ScreenChooseBackground screenChooseBackground, View view) {
kotlin.jvm.internal.k.f(screenChooseBackground, "this$0");
ScreenChooseBackgroundBinding screenChooseBackgroundBinding = screenChooseBackground.binding;
if (screenChooseBackgroundBinding == null) {
kotlin.jvm.internal.k.q("binding");
screenChooseBackgroundBinding = null;
}
screenChooseBackgroundBinding.noneBackCheck.setVisibility(0);
screenChooseBackground.deleteCustomBg();
screenChooseBackground.changeBackground("def");
backgroundVersionOnReceivers$default(screenChooseBackground, null, 1, null);
}
private static final void onCreate$lambda$3(ScreenChooseBackground screenChooseBackground, View view) {
kotlin.jvm.internal.k.f(screenChooseBackground, "this$0");
ScreenChooseBackgroundBinding screenChooseBackgroundBinding = screenChooseBackground.binding;
if (screenChooseBackgroundBinding == null) {
kotlin.jvm.internal.k.q("binding");
screenChooseBackgroundBinding = null;
}
screenChooseBackgroundBinding.noneBackCheck.setVisibility(8);
try {
screenChooseBackground.changeBackground("a007.jpg");
} catch (Exception e) {
Log.e(screenChooseBackground.CLASS_NAME, e.getMessage());
}
}
private final void refreshBackgrounds() {
this.gridArray.clear();
ArrayList<BackgroundItem> defaultThumbs = getDefaultThumbs();
BackgroundItem customThumbForUser = getCustomThumbForUser(this.userJid);
if (customThumbForUser != null) {
this.gridArray.add(customThumbForUser);
}
this.gridArray.addAll(defaultThumbs);
this.gridAdapter.setData(this.gridArray);
ScreenChooseBackgroundBinding screenChooseBackgroundBinding = this.binding;
if (screenChooseBackgroundBinding == null) {
kotlin.jvm.internal.k.q("binding");
screenChooseBackgroundBinding = null;
}
screenChooseBackgroundBinding.progressLayout.setVisibility(8);
}
private final String saveBitmap(Bitmap bitmap) {
if (bitmap == null) {
return "";
}
String str = this.userJid + ".jpg";
StringBuilder sb = new StringBuilder();
PathManager pathManager = PathManager.INSTANCE;
sb.append(pathManager.getCUSTOM_THUMB_DIR());
sb.append(str);
File file = new File(sb.toString());
File file2 = new File(pathManager.getBACKGROUNDS_DIR() + ZangiFileUtils.getBackgroundsBucketDestination() + '/' + str);
try {
if (file.exists()) {
deleteRecursive(file);
}
if (file2.exists()) {
deleteRecursive(file2);
}
ZangiFileUtils.writeBitmapToFile(pathManager.getCUSTOM_THUMB_DIR() + str, bitmap, false);
ZangiFileUtils.checkFolderExistingAndCreateIfNeeded(pathManager.getBACKGROUNDS_DIR() + ZangiFileUtils.getBackgroundsBucketDestination());
ZangiFileUtils.writeBitmapToFile(pathManager.getBACKGROUNDS_DIR() + ZangiFileUtils.getBackgroundsBucketDestination() + '/' + str, bitmap, true);
return pathManager.getBACKGROUNDS_DIR() + ZangiFileUtils.getBackgroundsBucketDestination() + '/' + str;
} catch (IOException e) {
Log.e(this.CLASS_NAME, "e = " + e);
return "";
}
}
private final String saveImage(String str) {
if (str.length() == 0) {
return "";
}
try {
return saveBitmap(ZangiFileUtils.scaleImage(str, Math.min(1636, ProjectUtils.getHeight(this))));
} catch (IOException e) {
Log.e(this.CLASS_NAME, e.getMessage());
return "";
}
}
public static final void versionCheckFinished$lambda$6(ScreenChooseBackground screenChooseBackground, String str) {
kotlin.jvm.internal.k.f(screenChooseBackground, "this$0");
screenChooseBackground.backgroundVersionOnReceivers(str);
}
public void downloadCompeted() {
if (kotlin.jvm.internal.k.b(this.version, "-1")) {
return;
}
ZangiConfigurationService zangiConfigurationService = ZangiConfigurationService.INSTANCE;
String str = Constants.BACKGROUNDS_VERSION_LOCALE_VALUE;
kotlin.jvm.internal.k.e(str, "BACKGROUNDS_VERSION_LOCALE_VALUE");
zangiConfigurationService.putString(str, this.version);
runOnUiThread(new Runnable() {
@Override
public final void run() {
ScreenChooseBackground.downloadCompeted$lambda$7(ScreenChooseBackground.this);
}
});
}
public void downloadFailed() {
runOnUiThread(new Runnable() {
@Override
public final void run() {
ScreenChooseBackground.downloadFailed$lambda$8(ScreenChooseBackground.this);
}
});
}
@android.annotation.SuppressLint({"NewApi"})
public void onActivityResult(int r11, int r12, android.content.Intent r13) {
throw new UnsupportedOperationException("Method not decompiled: com.beint.project.screens.sms.ScreenChooseBackground.onActivityResult(int, int, android.content.Intent):void");
}
@Override
@android.annotation.SuppressLint({"RestrictedApi"})
protected void onCreate(android.os.Bundle r13) {
throw new UnsupportedOperationException("Method not decompiled: com.beint.project.screens.sms.ScreenChooseBackground.onCreate(android.os.Bundle):void");
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
kotlin.jvm.internal.k.f(menuItem, "item");
if (menuItem.getItemId() == 16908332) {
finish();
}
return super/*android.app.Activity*/.onOptionsItemSelected(menuItem);
}
public void versionCheckFinished(final String str) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
ScreenChooseBackground.versionCheckFinished$lambda$6(ScreenChooseBackground.this, str);
}
});
}
}