正在查看: Atlys v4.8.7 应用的 PdfViewerActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Atlys v4.8.7 应用的 PdfViewerActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.rajat.pdfviewer;
import Hl.j;
import Oh.g;
import Ug.A;
import Ug.C;
import Ug.C0419a;
import Ug.E;
import Vg.a;
import Wg.c;
import Yo.i;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.graphics.pdf.PdfRenderer;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.widget.Toolbar;
import androidx.lifecycle.B;
import androidx.lifecycle.r0;
import androidx.lifecycle.w;
import bn.m;
import c2.h;
import com.rajat.pdfviewer.PdfViewerActivity;
import com.razorpay.R;
import h.b;
import h.d;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import k.k;
import kotlin.Metadata;
import kotlin.jvm.internal.l;
import kotlin.jvm.internal.z;
import wl.y;
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0007\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003¨\u0006\u0004"}, d2 = {"Lcom/rajat/pdfviewer/PdfViewerActivity;", "Lk/k;", "<init>", "()V", "pdfViewer_release"}, k = 1, mv = {1, 9, 0})
public final class PdfViewerActivity extends k {
public static boolean t1;
public static final boolean u1;
public String G;
public String I;
public String e1;
public String f1;
public String g1;
public String h1;
public String i1;
public String j1;
public String k1;
public String l1;
public String m1;
public String n1;
public C0419a o1;
public a p1;
public String q1;
public final d r1;
public final d s1;
static {
c[] cVarArr = c.b;
u1 = true;
}
public PdfViewerActivity() {
z.a.b(C.class);
final int i = 0;
d registerForActivityResult = registerForActivityResult(new g(10), new b(this) {
public final PdfViewerActivity b;
{
this.b = this;
}
public final void a(Object obj) {
Intent intent;
Uri data;
?? this$0 = this.b;
switch (i) {
case 0:
boolean booleanValue = ((Boolean) obj).booleanValue();
boolean z = PdfViewerActivity.t1;
kotlin.jvm.internal.l.h(this$0, "this$0");
if (booleanValue) {
this$0.m0();
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(this$0);
String str = this$0.h1;
if (str == null) {
kotlin.jvm.internal.l.o("permission_required_title");
throw null;
}
AlertDialog.Builder title = builder.setTitle(str);
String str2 = this$0.g1;
if (str2 == null) {
kotlin.jvm.internal.l.o("permission_required");
throw null;
}
AlertDialog.Builder message = title.setMessage(str2);
String str3 = this$0.k1;
if (str3 == null) {
kotlin.jvm.internal.l.o("pdf_viewer_grant");
throw null;
}
AlertDialog.Builder positiveButton = message.setPositiveButton(str3, new A(this$0, 0));
String str4 = this$0.l1;
if (str4 != null) {
positiveButton.setNegativeButton(str4, (DialogInterface.OnClickListener) null).show();
return;
} else {
kotlin.jvm.internal.l.o("pdf_viewer_cancel");
throw null;
}
default:
h.a aVar = (h.a) obj;
boolean z2 = PdfViewerActivity.t1;
kotlin.jvm.internal.l.h(this$0, "this$0");
if (aVar.a != -1 || (intent = aVar.b) == null || (data = intent.getData()) == null) {
return;
}
OutputStream openOutputStream = this$0.getContentResolver().openOutputStream(data);
if (openOutputStream != null) {
try {
String str5 = this$0.q1;
if (str5 != null) {
a.a.Y(new FileInputStream(new File(str5)), openOutputStream, 8192);
}
android.support.v4.media.session.b.c0(openOutputStream, (Throwable) null);
} catch (Throwable th2) {
try {
throw th2;
} catch (Throwable th3) {
android.support.v4.media.session.b.c0(openOutputStream, th2);
throw th3;
}
}
}
String str6 = this$0.e1;
if (str6 != null) {
Toast.makeText((Context) this$0, str6, 0).show();
return;
} else {
kotlin.jvm.internal.l.o("file_saved_successfully");
throw null;
}
}
}
});
l.g(registerForActivityResult, "registerForActivityResult(...)");
this.r1 = registerForActivityResult;
final int i2 = 1;
d registerForActivityResult2 = registerForActivityResult(new g(11), new b(this) {
public final PdfViewerActivity b;
{
this.b = this;
}
public final void a(Object obj) {
Intent intent;
Uri data;
?? this$0 = this.b;
switch (i2) {
case 0:
boolean booleanValue = ((Boolean) obj).booleanValue();
boolean z = PdfViewerActivity.t1;
kotlin.jvm.internal.l.h(this$0, "this$0");
if (booleanValue) {
this$0.m0();
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(this$0);
String str = this$0.h1;
if (str == null) {
kotlin.jvm.internal.l.o("permission_required_title");
throw null;
}
AlertDialog.Builder title = builder.setTitle(str);
String str2 = this$0.g1;
if (str2 == null) {
kotlin.jvm.internal.l.o("permission_required");
throw null;
}
AlertDialog.Builder message = title.setMessage(str2);
String str3 = this$0.k1;
if (str3 == null) {
kotlin.jvm.internal.l.o("pdf_viewer_grant");
throw null;
}
AlertDialog.Builder positiveButton = message.setPositiveButton(str3, new A(this$0, 0));
String str4 = this$0.l1;
if (str4 != null) {
positiveButton.setNegativeButton(str4, (DialogInterface.OnClickListener) null).show();
return;
} else {
kotlin.jvm.internal.l.o("pdf_viewer_cancel");
throw null;
}
default:
h.a aVar = (h.a) obj;
boolean z2 = PdfViewerActivity.t1;
kotlin.jvm.internal.l.h(this$0, "this$0");
if (aVar.a != -1 || (intent = aVar.b) == null || (data = intent.getData()) == null) {
return;
}
OutputStream openOutputStream = this$0.getContentResolver().openOutputStream(data);
if (openOutputStream != null) {
try {
String str5 = this$0.q1;
if (str5 != null) {
a.a.Y(new FileInputStream(new File(str5)), openOutputStream, 8192);
}
android.support.v4.media.session.b.c0(openOutputStream, (Throwable) null);
} catch (Throwable th2) {
try {
throw th2;
} catch (Throwable th3) {
android.support.v4.media.session.b.c0(openOutputStream, th2);
throw th3;
}
}
}
String str6 = this$0.e1;
if (str6 != null) {
Toast.makeText((Context) this$0, str6, 0).show();
return;
} else {
kotlin.jvm.internal.l.o("file_saved_successfully");
throw null;
}
}
}
});
l.g(registerForActivityResult2, "registerForActivityResult(...)");
this.s1 = registerForActivityResult2;
}
public static final void j0(PdfViewerActivity pdfViewerActivity, boolean z) {
a aVar = pdfViewerActivity.p1;
if (aVar != null) {
aVar.f.setVisibility(z ? 0 : 8);
} else {
l.o("binding");
throw null;
}
}
public final void k0() {
NetworkCapabilities networkCapabilities;
Bundle extras = getIntent().getExtras();
l.e(extras);
if (extras.containsKey("pdf_file_url")) {
Bundle extras2 = getIntent().getExtras();
l.e(extras2);
this.n1 = extras2.getString("pdf_file_url");
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
if (connectivityManager == null || (networkCapabilities = connectivityManager.getNetworkCapabilities(connectivityManager.getActiveNetwork())) == null || !(networkCapabilities.hasTransport(1) || networkCapabilities.hasTransport(0) || networkCapabilities.hasTransport(4))) {
String str = this.f1;
if (str == null) {
l.o("error_no_internet_connection");
throw null;
}
Toast.makeText((Context) this, (CharSequence) str, 0).show();
} else {
String str2 = this.n1;
if (TextUtils.isEmpty(str2)) {
l0("");
}
try {
a aVar = this.p1;
if (aVar == null) {
l.o("binding");
throw null;
}
PdfRendererView pdfRendererView = aVar.e;
l.e(str2);
C0419a c0419a = this.o1;
if (c0419a == null) {
l.o("headers");
throw null;
}
B i = r0.i(this);
w lifecycle = getLifecycle();
l.g(lifecycle, "<get-lifecycle>(...)");
pdfRendererView.d(str2, c0419a, i, lifecycle);
} catch (Exception e) {
l0(e.toString());
}
}
}
a aVar2 = this.p1;
if (aVar2 != null) {
aVar2.e.setStatusListener(new I2.a(this, 25));
} else {
l.o("binding");
throw null;
}
}
public final void l0(String str) {
Log.e("Pdf render error", str);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
String str2 = this.m1;
if (str2 == null) {
l.o("pdf_viewer_error");
throw null;
}
AlertDialog.Builder title = builder.setTitle(str2);
String str3 = this.i1;
if (str3 == null) {
l.o("error_pdf_corrupted");
throw null;
}
AlertDialog.Builder message = title.setMessage(str3);
String str4 = this.j1;
if (str4 == null) {
l.o("pdf_viewer_retry");
throw null;
}
AlertDialog.Builder positiveButton = message.setPositiveButton(str4, new A(this, 1));
String str5 = this.l1;
if (str5 != null) {
positiveButton.setNegativeButton(str5, (DialogInterface.OnClickListener) null).show();
} else {
l.o("pdf_viewer_cancel");
throw null;
}
}
public final void m0() {
y yVar;
String stringExtra = getIntent().getStringExtra("pdf_file_title");
if (stringExtra == null) {
stringExtra = "downloaded_file.pdf";
}
String str = this.q1;
if (str != null) {
if (u1) {
int i = Build.VERSION.SDK_INT;
if (i >= 29) {
ContentResolver contentResolver = getApplicationContext().getContentResolver();
l.e(contentResolver);
ContentValues contentValues = new ContentValues();
contentValues.put("_display_name", stringExtra);
contentValues.put("mime_type", "application/pdf");
if (i >= 29) {
contentValues.put("relative_path", Environment.DIRECTORY_DOCUMENTS);
}
Uri insert = contentResolver.insert(MediaStore.Files.getContentUri("external"), contentValues);
if (insert == null) {
throw new IOException("Failed to create new MediaStore record.");
}
OutputStream openOutputStream = contentResolver.openOutputStream(insert);
if (openOutputStream != null) {
try {
a.a.Y(new FileInputStream(new File(str)), openOutputStream, 8192);
android.support.v4.media.session.b.c0(openOutputStream, (Throwable) null);
} catch (Throwable th2) {
try {
throw th2;
} catch (Throwable th3) {
android.support.v4.media.session.b.c0(openOutputStream, th2);
throw th3;
}
}
}
String str2 = this.I;
if (str2 == null) {
l.o("file_saved_to_downloads");
throw null;
}
Toast.makeText((Context) this, (CharSequence) str2, 0).show();
} else {
j.C0(new File(str), new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), stringExtra), true, 4);
String str3 = this.I;
if (str3 == null) {
l.o("file_saved_to_downloads");
throw null;
}
Toast.makeText((Context) this, (CharSequence) str3, 0).show();
}
} else {
Intent intent = new Intent("android.intent.action.CREATE_DOCUMENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType("application/pdf");
intent.putExtra("android.intent.extra.TITLE", stringExtra);
this.s1.a(intent, (i) null);
}
yVar = y.a;
} else {
yVar = null;
}
if (yVar == null) {
String str4 = this.G;
if (str4 != null) {
Toast.makeText((Context) this, (CharSequence) str4, 0).show();
} else {
l.o("file_not_downloaded_yet");
throw null;
}
}
}
public final void onCreate(Bundle bundle) {
super/*androidx.fragment.app.K*/.onCreate(bundle);
View inflate = getLayoutInflater().inflate(2131558435, (ViewGroup) null, false);
int i = 2131362699;
FrameLayout frameLayout = (FrameLayout) m.F(2131362699, inflate);
if (frameLayout != null) {
i = 2131362771;
Toolbar F = m.F(2131362771, inflate);
if (F != null) {
LinearLayout linearLayout = (LinearLayout) inflate;
int i2 = 2131362862;
PdfRendererView pdfRendererView = (PdfRendererView) m.F(2131362862, inflate);
if (pdfRendererView != null) {
i2 = R.id.progressBar;
ProgressBar progressBar = (ProgressBar) m.F(R.id.progressBar, inflate);
if (progressBar != null) {
i2 = 2131363209;
TextView textView = (TextView) m.F(2131363209, inflate);
if (textView != null) {
this.p1 = new a(linearLayout, frameLayout, F, linearLayout, pdfRendererView, progressBar, textView);
setContentView(linearLayout);
TypedArray obtainStyledAttributes = getTheme().obtainStyledAttributes(E.c);
l.g(obtainStyledAttributes, "obtainStyledAttributes(...)");
try {
boolean z = obtainStyledAttributes.getBoolean(4, true);
Drawable drawable = obtainStyledAttributes.getDrawable(1);
obtainStyledAttributes.getColor(3, -1);
int color = obtainStyledAttributes.getColor(0, -1);
int resourceId = obtainStyledAttributes.getResourceId(5, -1);
a aVar = this.p1;
if (aVar == null) {
l.o("binding");
throw null;
}
aVar.c.setVisibility(z ? 0 : 8);
a aVar2 = this.p1;
if (aVar2 == null) {
l.o("binding");
throw null;
}
aVar2.c.setNavigationIcon(drawable);
if (resourceId != -1) {
a aVar3 = this.p1;
if (aVar3 == null) {
l.o("binding");
throw null;
}
View findViewById = aVar3.c.findViewById(2131363209);
l.f(findViewById, "null cannot be cast to non-null type android.widget.TextView");
((TextView) findViewById).setTextAppearance(this, resourceId);
}
if (color != -1) {
a aVar4 = this.p1;
if (aVar4 == null) {
l.o("binding");
throw null;
}
aVar4.c.setBackgroundColor(color);
}
obtainStyledAttributes.recycle();
Bundle extras = getIntent().getExtras();
l.e(extras);
String string = extras.getString("pdf_file_title", "PDF");
l.g(string, "getString(...)");
a aVar5 = this.p1;
if (aVar5 == null) {
l.o("binding");
throw null;
}
setSupportActionBar(aVar5.c);
k.b supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.p(true);
supportActionBar.r();
a aVar6 = this.p1;
if (aVar6 == null) {
l.o("binding");
throw null;
}
View findViewById2 = aVar6.c.findViewById(2131363209);
l.f(findViewById2, "null cannot be cast to non-null type android.widget.TextView");
((TextView) findViewById2).setText(string);
supportActionBar.s();
}
TypedArray obtainStyledAttributes2 = getTheme().obtainStyledAttributes(E.a);
l.g(obtainStyledAttributes2, "obtainStyledAttributes(...)");
try {
int color2 = obtainStyledAttributes2.getColor(0, h.getColor(getApplicationContext(), android.R.color.white));
a aVar7 = this.p1;
if (aVar7 == null) {
l.o("binding");
throw null;
}
aVar7.d.setBackgroundColor(color2);
int resourceId2 = obtainStyledAttributes2.getResourceId(10, -1);
if (resourceId2 != -1) {
Drawable drawable2 = h.getDrawable(this, resourceId2);
a aVar8 = this.p1;
if (aVar8 == null) {
l.o("binding");
throw null;
}
aVar8.f.setIndeterminateDrawable(drawable2);
}
obtainStyledAttributes2.recycle();
Bundle extras2 = getIntent().getExtras();
l.e(extras2);
t1 = extras2.getBoolean("enable_download", false);
C0419a c0419a = Build.VERSION.SDK_INT >= 33 ? (C0419a) Aa.h.A(getIntent()) : (C0419a) getIntent().getParcelableExtra("headers");
if (c0419a != null) {
this.o1 = c0419a;
}
Bundle extras3 = getIntent().getExtras();
l.e(extras3);
extras3.getBoolean("from_assests", false);
c[] cVarArr = c.b;
TypedArray obtainStyledAttributes3 = obtainStyledAttributes(E.b);
l.g(obtainStyledAttributes3, "obtainStyledAttributes(...)");
String string2 = obtainStyledAttributes3.getString(1);
if (string2 == null) {
string2 = getString(2132017353);
l.g(string2, "getString(...)");
}
this.i1 = string2;
String string3 = obtainStyledAttributes3.getString(0);
if (string3 == null) {
string3 = getString(2132017352);
l.g(string3, "getString(...)");
}
this.f1 = string3;
String string4 = obtainStyledAttributes3.getString(3);
if (string4 == null) {
string4 = getString(2132017422);
l.g(string4, "getString(...)");
}
this.e1 = string4;
String string5 = obtainStyledAttributes3.getString(4);
if (string5 == null) {
string5 = getString(2132017423);
l.g(string5, "getString(...)");
}
this.I = string5;
String string6 = obtainStyledAttributes3.getString(2);
if (string6 == null) {
string6 = getString(2132017421);
l.g(string6, "getString(...)");
}
this.G = string6;
String string7 = obtainStyledAttributes3.getString(9);
if (string7 == null) {
string7 = getString(2132017895);
l.g(string7, "getString(...)");
}
this.g1 = string7;
String string8 = obtainStyledAttributes3.getString(10);
if (string8 == null) {
string8 = getString(2132017896);
l.g(string8, "getString(...)");
}
this.h1 = string8;
String string9 = obtainStyledAttributes3.getString(6);
if (string9 == null) {
string9 = getString(2132017892);
l.g(string9, "getString(...)");
}
this.m1 = string9;
String string10 = obtainStyledAttributes3.getString(8);
if (string10 == null) {
string10 = getString(2132017894);
l.g(string10, "getString(...)");
}
this.j1 = string10;
String string11 = obtainStyledAttributes3.getString(5);
if (string11 == null) {
string11 = getString(2132017891);
l.g(string11, "getString(...)");
}
this.l1 = string11;
String string12 = obtainStyledAttributes3.getString(7);
if (string12 == null) {
string12 = getString(2132017893);
l.g(string12, "getString(...)");
}
this.k1 = string12;
k0();
return;
} catch (Throwable th2) {
obtainStyledAttributes2.recycle();
throw th2;
}
} catch (Throwable th3) {
obtainStyledAttributes.recycle();
throw th3;
}
}
}
}
i = i2;
}
}
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
}
public final boolean onCreateOptionsMenu(Menu menu) {
l.h(menu, "menu");
MenuInflater menuInflater = getMenuInflater();
l.g(menuInflater, "getMenuInflater(...)");
menuInflater.inflate(2131689478, menu);
MenuItem findItem = menu.findItem(2131362162);
TypedArray obtainStyledAttributes = getTheme().obtainStyledAttributes(E.c);
l.g(obtainStyledAttributes, "obtainStyledAttributes(...)");
try {
int color = obtainStyledAttributes.getColor(3, h.getColor(getApplicationContext(), android.R.color.white));
Drawable icon = findItem.getIcon();
if (icon != null) {
Drawable mutate = icon.mutate();
l.g(mutate, "mutate(...)");
g2.a.g(mutate, color);
findItem.setIcon(mutate);
}
obtainStyledAttributes.recycle();
findItem.setVisible(t1);
return true;
} catch (Throwable th2) {
obtainStyledAttributes.recycle();
throw th2;
}
}
public final void onDestroy() {
super.onDestroy();
a aVar = this.p1;
if (aVar == null) {
l.o("binding");
throw null;
}
PdfRendererView pdfRendererView = aVar.e;
if (pdfRendererView.i) {
R.d dVar = pdfRendererView.c;
if (dVar == null) {
l.o("pdfRendererCore");
throw null;
}
synchronized (dVar) {
try {
dVar.c();
if (dVar.a) {
PdfRenderer pdfRenderer = (PdfRenderer) dVar.d;
if (pdfRenderer != null) {
pdfRenderer.close();
}
dVar.a = false;
}
Sd.c cVar = (Sd.c) dVar.e;
((Ai.a) cVar.a).evictAll();
j.D0((File) cVar.b);
} catch (Throwable th2) {
throw th2;
}
}
pdfRendererView.i = false;
}
}
public final boolean onOptionsItemSelected(MenuItem item) {
l.h(item, "item");
int itemId = item.getItemId();
if (itemId != 2131362162) {
if (itemId != 16908332) {
return super/*android.app.Activity*/.onOptionsItemSelected(item);
}
finish();
return true;
}
if (Build.VERSION.SDK_INT >= 30) {
m0();
return true;
}
if (h.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
m0();
return true;
}
this.r1.a("android.permission.WRITE_EXTERNAL_STORAGE", (i) null);
return true;
}
}