203 lines
8.5 KiB
Java
203 lines
8.5 KiB
Java
package c.a.s;
|
|
|
|
import android.content.ContentResolver;
|
|
import android.database.ContentObserver;
|
|
import android.database.Cursor;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.provider.MediaStore;
|
|
import androidx.core.app.NotificationCompat;
|
|
import com.discord.utilities.logging.Logger;
|
|
import com.discord.utilities.time.Clock;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import com.discord.widgets.chat.input.MentionUtilsKt;
|
|
import d0.g0.t;
|
|
import d0.g0.w;
|
|
import d0.t.j;
|
|
import d0.z.d.m;
|
|
import java.util.Locale;
|
|
import java.util.Objects;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function2;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: ScreenshotContentObserver.kt */
|
|
public final class b extends ContentObserver {
|
|
public static final a a = new a(null);
|
|
public String b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final Logger f235c;
|
|
public final ContentResolver d;
|
|
public final Clock e;
|
|
public final Function2<Uri, String, Unit> f;
|
|
|
|
/* compiled from: ScreenshotContentObserver.kt */
|
|
public static final class a {
|
|
public a(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
}
|
|
|
|
/* compiled from: ScreenshotContentObserver.kt */
|
|
/* renamed from: c.a.s.b$b reason: collision with other inner class name */
|
|
public static final class C0044b {
|
|
public final String a;
|
|
public final long b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final String f236c;
|
|
public final String d;
|
|
public final Uri e;
|
|
public final long f;
|
|
|
|
public C0044b(long j, String str, String str2, Uri uri, long j2) {
|
|
m.checkNotNullParameter(str, "fileName");
|
|
m.checkNotNullParameter(str2, "relativePath");
|
|
m.checkNotNullParameter(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
|
|
this.b = j;
|
|
this.f236c = str;
|
|
this.d = str2;
|
|
this.e = uri;
|
|
this.f = j2;
|
|
this.a = str2 + MentionUtilsKt.SLASH_CHAR + str;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof C0044b)) {
|
|
return false;
|
|
}
|
|
C0044b bVar = (C0044b) obj;
|
|
return this.b == bVar.b && m.areEqual(this.f236c, bVar.f236c) && m.areEqual(this.d, bVar.d) && m.areEqual(this.e, bVar.e) && this.f == bVar.f;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int a = a0.a.a.b.a(this.b) * 31;
|
|
String str = this.f236c;
|
|
int i = 0;
|
|
int hashCode = (a + (str != null ? str.hashCode() : 0)) * 31;
|
|
String str2 = this.d;
|
|
int hashCode2 = (hashCode + (str2 != null ? str2.hashCode() : 0)) * 31;
|
|
Uri uri = this.e;
|
|
if (uri != null) {
|
|
i = uri.hashCode();
|
|
}
|
|
return a0.a.a.b.a(this.f) + ((hashCode2 + i) * 31);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder P = c.d.b.a.a.P("ScreenshotData(id=");
|
|
P.append(this.b);
|
|
P.append(", fileName=");
|
|
P.append(this.f236c);
|
|
P.append(", relativePath=");
|
|
P.append(this.d);
|
|
P.append(", uri=");
|
|
P.append(this.e);
|
|
P.append(", dateAdded=");
|
|
return c.d.b.a.a.A(P, this.f, ")");
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public b(Logger logger, ContentResolver contentResolver, Clock clock, Function2 function2, int i) {
|
|
super(null);
|
|
Clock clock2 = (i & 4) != 0 ? ClockFactory.get() : null;
|
|
m.checkNotNullParameter(logger, "logger");
|
|
m.checkNotNullParameter(contentResolver, "contentResolver");
|
|
m.checkNotNullParameter(clock2, "clock");
|
|
m.checkNotNullParameter(function2, "onScreenshot");
|
|
this.f235c = logger;
|
|
this.d = contentResolver;
|
|
this.e = clock2;
|
|
this.f = function2;
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:25:0x00b7, code lost:
|
|
r0 = move-exception;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:26:0x00b8, code lost:
|
|
d0.y.b.closeFinally(r2, r0);
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:27:0x00bc, code lost:
|
|
throw r0;
|
|
*/
|
|
/* JADX WARNING: Removed duplicated region for block: B:31:0x00c3 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:45:? A[RETURN, SYNTHETIC] */
|
|
public final void a(Uri uri) {
|
|
C0044b bVar;
|
|
String str;
|
|
ContentResolver contentResolver = this.d;
|
|
int i = Build.VERSION.SDK_INT;
|
|
Cursor query = contentResolver.query(uri, (String[]) j.plus(j.plus(new String[]{"_display_name", "date_added", "_id"}, i >= 29 ? new String[]{"is_pending", "relative_path"} : new String[0]), i >= 29 ? new String[]{"relative_path"} : new String[]{"_data"}), null, null, "date_added DESC");
|
|
if (query != null) {
|
|
if (query.moveToFirst()) {
|
|
if (i < 29 || query.getInt(query.getColumnIndex("is_pending")) != 1) {
|
|
if (i >= 29) {
|
|
str = query.getString(query.getColumnIndex("relative_path"));
|
|
} else {
|
|
String string = query.getString(query.getColumnIndex("_data"));
|
|
m.checkNotNullExpressionValue(string, "cursor.getString(cursor.…mages.ImageColumns.DATA))");
|
|
str = w.substringBeforeLast$default(string, (char) MentionUtilsKt.SLASH_CHAR, (String) null, 2, (Object) null);
|
|
}
|
|
long j = query.getLong(query.getColumnIndex("_id"));
|
|
String string2 = query.getString(query.getColumnIndex("_display_name"));
|
|
m.checkNotNullExpressionValue(string2, "cursor.getString(cursor.…ages.Media.DISPLAY_NAME))");
|
|
m.checkNotNullExpressionValue(str, "relativePath");
|
|
bVar = new C0044b(j, string2, str, uri, query.getLong(query.getColumnIndex("date_added")));
|
|
d0.y.b.closeFinally(query, null);
|
|
if (bVar != null) {
|
|
String str2 = this.b;
|
|
if (str2 == null || !t.equals$default(str2, bVar.a, false, 2, null)) {
|
|
String str3 = bVar.a;
|
|
Locale locale = Locale.getDefault();
|
|
m.checkNotNullExpressionValue(locale, "Locale.getDefault()");
|
|
Objects.requireNonNull(str3, "null cannot be cast to non-null type java.lang.String");
|
|
String lowerCase = str3.toLowerCase(locale);
|
|
m.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
|
|
if (w.contains$default((CharSequence) lowerCase, (CharSequence) "screenshots/", false, 2, (Object) null)) {
|
|
if (Math.abs((this.e.currentTimeMillis() / ((long) 1000)) - bVar.f) <= 10) {
|
|
this.b = bVar.a;
|
|
this.f.invoke(bVar.e, bVar.f236c);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
d0.y.b.closeFinally(query, null);
|
|
bVar = null;
|
|
if (bVar != null) {
|
|
}
|
|
}
|
|
}
|
|
d0.y.b.closeFinally(query, null);
|
|
bVar = null;
|
|
if (bVar != null) {
|
|
}
|
|
}
|
|
|
|
@Override // android.database.ContentObserver
|
|
public void onChange(boolean z2, Uri uri) {
|
|
super.onChange(z2, uri);
|
|
if (uri != null) {
|
|
String uri2 = uri.toString();
|
|
m.checkNotNullExpressionValue(uri2, "uri.toString()");
|
|
String uri3 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString();
|
|
m.checkNotNullExpressionValue(uri3, "MediaStore.Images.Media.…AL_CONTENT_URI.toString()");
|
|
if (t.startsWith$default(uri2, uri3, false, 2, null)) {
|
|
try {
|
|
a(uri);
|
|
} catch (Exception e) {
|
|
Logger.e$default(this.f235c, "Error processing screenshot", e, null, 4, null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|