package com.lt.app.a; import android.content.ClipData; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.media.ExifInterface; import android.net.Uri; import android.os.Build; import android.provider.MediaStore; import android.webkit.WebChromeClient; import android.widget.Toast; import com.a.a.a; import com.lt.app.App; import com.lt.app.c; import com.lt.plugin.IAudioRecorder; import com.lt.plugin.a; import com.lt.plugin.ac; import com.lt.plugin.as; import com.lt.plugin.au; import com.lt.plugin.b; import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import me.dhtv.app.R; public class e implements a.AbstractC0041a, a.b { /* renamed from: ˊ */ private static e f6047; /* renamed from: ʻ */ private final com.lt.plugin.a f6048; /* renamed from: ʼ */ private final int f6049; /* renamed from: ʽ */ private final Intent f6050; /* renamed from: ʾ */ private final String[] f6051; /* renamed from: ʿ */ private final a f6052; /* renamed from: ˆ */ private final ArrayList<Integer> f6053; /* renamed from: ˈ */ private Uri f6054; /* renamed from: ˉ */ private com.a.a.a f6055; public interface a { /* renamed from: ʻ reason: contains not printable characters */ void m8283(Uri[] uriArr); } /* renamed from: ʼ */ private Uri[] m8272(Uri[] uriArr) { return uriArr; } private e(com.lt.plugin.a aVar, int i, Intent intent, String[] strArr, a aVar2) { this.f6053 = new ArrayList<>(2); this.f6054 = null; this.f6048 = aVar; this.f6049 = i; this.f6050 = intent; this.f6051 = strArr; this.f6052 = aVar2; } /* renamed from: ʼ */ private void m8269() { ArrayList arrayList = new ArrayList(2); this.f6053.clear(); if ((this.f6049 & 2) == 2) { arrayList.add(Integer.valueOf((int) R.string.file_choose_capture)); this.f6053.add(2); } if ((this.f6049 & 8) == 8) { arrayList.add(Integer.valueOf((int) R.string.file_choose_capture_video)); this.f6053.add(8); } if ((this.f6049 & 4) == 4) { arrayList.add(Integer.valueOf((int) R.string.file_choose_capture_audio)); this.f6053.add(4); } if ((this.f6049 & 1) == 1 || arrayList.size() == 0) { arrayList.add(Integer.valueOf((int) R.string.file_choose_choose)); this.f6053.add(1); } int size = arrayList.size(); String[] strArr = new String[size]; for (int i = 0; i < size; i++) { strArr[i] = this.f6048.getString(((Integer) arrayList.get(i)).intValue()); } com.lt.plugin.a aVar = this.f6048; this.f6055 = com.a.a.a.m6208(aVar, aVar.m1697()).m6236(R.string.cancel).m6240(strArr).m6239(true).m6237(this).m6241(); } /* renamed from: ʻ */ private void m8268(Uri[] uriArr) { a aVar = this.f6052; if (aVar != null) { aVar.m8283(uriArr); } } @Override // com.a.a.a.AbstractC0041a /* renamed from: ʻ */ public void m8282(com.a.a.a aVar, boolean z) { f6047 = null; if (z) { m8268((Uri[]) null); } } @Override // com.a.a.a.AbstractC0041a /* renamed from: ʻ */ public void m8281(com.a.a.a aVar, int i) { int intValue = this.f6053.get(i).intValue(); if (intValue == 1) { m8273(); } else if (intValue == 2) { m8275(); } else if (intValue == 4) { m8277(); } else if (intValue == 8) { m8278(); } } /* JADX DEBUG: Multi-variable search result rejected for r1v1, resolved type: android.net.Uri[] */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r1v0, types: [java.io.OutputStream] */ /* JADX WARN: Type inference failed for: r1v3 */ /* JADX WARN: Type inference failed for: r1v4 */ /* JADX WARN: Type inference failed for: r1v14 */ /* JADX WARNING: Removed duplicated region for block: B:30:0x008b */ @Override // com.lt.plugin.a.b /* renamed from: ʻ */ public void m8280(int i, int i2, Intent intent) { Uri[] uriArr; int i3; Uri[] uriArr2 = 0; OutputStream outputStream = null; Uri[] uriArr3 = null; Uri[] uriArr4 = null; this.f6048.m8777((a.b) null); switch (i) { case 5173: case 5174: case 5175: case 5176: if (i2 != -1) { m8268((Uri[]) null); return; } if (i == 5174) { try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeStream(this.f6048.getContentResolver().openInputStream(this.f6054), null, options); options.inSampleSize = Math.max(options.outWidth, options.outHeight) / 1280; if (options.inSampleSize > 1) { if (Build.VERSION.SDK_INT >= 24) { try { InputStream openInputStream = this.f6048.getContentResolver().openInputStream(this.f6054); ExifInterface exifInterface = new ExifInterface(openInputStream); openInputStream.close(); int attributeInt = exifInterface.getAttributeInt("Orientation", 1); if (attributeInt == 3) { i3 = 180; } else if (attributeInt == 6) { i3 = 90; } else if (attributeInt == 8) { i3 = 270; } } catch (Exception e) { e.printStackTrace(); } options.inJustDecodeBounds = false; Bitmap decodeStream = BitmapFactory.decodeStream(this.f6048.getContentResolver().openInputStream(this.f6054), null, options); if (i3 > 0) { Matrix matrix = new Matrix(); matrix.postRotate((float) i3); decodeStream = Bitmap.createBitmap(decodeStream, 0, 0, decodeStream.getWidth(), decodeStream.getHeight(), matrix, true); } outputStream = this.f6048.getContentResolver().openOutputStream(this.f6054); decodeStream.compress(Bitmap.CompressFormat.JPEG, 80, outputStream); } i3 = 0; options.inJustDecodeBounds = false; Bitmap decodeStream2 = BitmapFactory.decodeStream(this.f6048.getContentResolver().openInputStream(this.f6054), null, options); if (i3 > 0) { } outputStream = this.f6048.getContentResolver().openOutputStream(this.f6054); decodeStream2.compress(Bitmap.CompressFormat.JPEG, 80, outputStream); } if (outputStream != null) { try { outputStream.flush(); outputStream.close(); } catch (Exception e2) { e2.printStackTrace(); } } } catch (Exception e3) { e3.printStackTrace(); if (0 != 0) { uriArr2.flush(); uriArr2.close(); } } catch (Throwable th) { if (0 != 0) { try { uriArr2.flush(); uriArr2.close(); } catch (Exception e4) { e4.printStackTrace(); } } throw th; } uriArr = new Uri[]{this.f6054}; } else if (i == 5176) { Uri data = intent.getData(); if (data != null) { uriArr3 = new Uri[]{data}; } uriArr = uriArr3; } else if (i == 5175) { ac r12 = as.m8895(); if (r12 != null) { uriArr4 = r12.m8793(intent); } m8264(intent, uriArr4); uriArr = m8272(uriArr4); } else { if (Build.VERSION.SDK_INT >= 21) { ClipData clipData = intent.getClipData(); if (clipData == null || clipData.getItemCount() <= 0) { uriArr2 = WebChromeClient.FileChooserParams.parseResult(i2, intent); } else { Uri[] uriArr5 = new Uri[clipData.getItemCount()]; for (int i4 = 0; i4 < clipData.getItemCount(); i4++) { uriArr5[i4] = clipData.getItemAt(i4).getUri(); } uriArr2 = uriArr5; } } else if (intent != null) { uriArr2 = new Uri[]{intent.getData()}; } m8264(intent, uriArr2); uriArr = m8272(uriArr2); } m8268(uriArr); return; default: return; } } /* renamed from: ʻ */ private void m8264(Intent intent, Uri[] uriArr) { if (!(intent == null || uriArr == null || uriArr.length == 0 || Build.VERSION.SDK_INT < 19)) { int flags = intent.getFlags() & 1; for (Uri uri : uriArr) { try { this.f6048.getContentResolver().takePersistableUriPermission(uri, flags); } catch (Exception e) { e.printStackTrace(); } } } } /* renamed from: ʽ */ private void m8273() { m8274(); } /* renamed from: ʾ */ private void m8274() { ac r3; this.f6048.m8777(this); try { if (this.f6050 != null) { this.f6048.startActivityForResult(this.f6050, 5173); return; } Intent r1 = c.m8485(this.f6050, this.f6051); if (this.f6048.getPackageManager().queryIntentActivities(r1, 65536).size() == 0) { r1.setType(""); } if (c.m8505(r1.getType()) != 1 || (r3 = as.m8895()) == null) { this.f6048.startActivityForResult(r1, 5173); } else { r3.m8792(this.f6048, r1.getBooleanExtra("android.intent.extra.ALLOW_MULTIPLE", false) ? 36 : 1, 5175); } } catch (Exception e) { e.printStackTrace(); m8268((Uri[]) null); Toast.makeText(this.f6048, (int) R.string.file_choose_fail, 1).show(); } } /* renamed from: ʿ */ private void m8275() { this.f6048.m8778(new a.d() { /* class com.lt.app.a.$$Lambda$e$YyLeckBJsyhjM0sf9Gi3XBRyQM8 */ @Override // com.lt.plugin.a.d public final void onResult(boolean z) { e.lambda$YyLeckBJsyhjM0sf9Gi3XBRyQM8(e.this, z); } }, R.string.file_choose_perm_capture_f, "android.permission.CAMERA", "android.permission.WRITE_EXTERNAL_STORAGE"); } /* access modifiers changed from: public */ /* renamed from: ʼ */ private /* synthetic */ void m8271(boolean z) { if (!z) { m8268((Uri[]) null); } else { m8276(); } } /* renamed from: ˆ */ private void m8276() { this.f6048.m8777(this); Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); intent.addCategory("android.intent.category.DEFAULT"); ContentValues contentValues = new ContentValues(2); contentValues.put("_display_name", System.currentTimeMillis() + ".jpg"); contentValues.put("mime_type", "image/jpeg"); Uri insert = this.f6048.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues); this.f6054 = insert; intent.putExtra("output", insert); this.f6048.startActivityForResult(intent, 5174); } /* renamed from: ˈ */ private void m8277() { if (!App.m8121(87, true)) { au.m8965(this.f6048, "没有选购录音插件"); return; } IAudioRecorder r0 = as.m8920(); if (r0 == null) { m8268((Uri[]) null); au.m8940((Context) this.f6048); return; } r0.m8756(this.f6048, new b() { /* class com.lt.app.a.$$Lambda$e$LHmXyMpoL6L5BP5MlnAW2C53Yw */ @Override // com.lt.plugin.b public final void callback(Object obj) { e.m8260lambda$LHmXyMpoL6L5BP5MlnAW2C53Yw(e.this, (File) obj); } }); } /* access modifiers changed from: public */ /* renamed from: ʻ */ private /* synthetic */ void m8266(File file) { if (file != null) { m8268(new Uri[]{au.m8931(this.f6048, file)}); return; } m8268((Uri[]) null); } /* renamed from: ˉ */ private void m8278() { this.f6048.m8778(new a.d() { /* class com.lt.app.a.$$Lambda$e$gepWRq8c6A_UX5IJL_p2xLpMKE */ @Override // com.lt.plugin.a.d public final void onResult(boolean z) { e.m8261lambda$gepWRq8c6A_UX5IJL_p2xLpMKE(e.this, z); } }, R.string.file_choose_perm_capture_v_f, "android.permission.CAMERA"); } /* access modifiers changed from: public */ /* renamed from: ʻ */ private /* synthetic */ void m8267(boolean z) { if (!z) { m8268((Uri[]) null); } else { m8279(); } } /* renamed from: ˊ */ private void m8279() { this.f6048.m8777(this); this.f6048.startActivityForResult(new Intent("android.media.action.VIDEO_CAPTURE"), 5176); } /* renamed from: ʻ */ public static synchronized void m8265(final com.lt.plugin.a aVar, final int i, final Intent intent, final String[] strArr, final a aVar2) { synchronized (e.class) { if (f6047 == null) { aVar.m8778(new a.d() { /* class com.lt.app.a.e.AnonymousClass1 */ @Override // com.lt.plugin.a.d public synchronized void onResult(boolean z) { if (z) { e unused = e.f6047 = new e(aVar, i, intent, strArr, aVar2); e.f6047.m8269(); } else if (aVar2 != null) { aVar2.m8283(null); } } }, R.string.perm_no_rw, "android.permission.READ_EXTERNAL_STORAGE"); } } } }