discord-jadx/app/src/main/java/com/discord/screenshot_detection/ScreenshotDetector.java

125 lines
4.6 KiB
Java

package com.discord.screenshot_detection;
import android.app.Application;
import android.content.ContentResolver;
import android.content.SharedPreferences;
import android.net.Uri;
import androidx.core.app.NotificationCompat;
import c.a.s.b;
import c0.z.d.m;
import c0.z.d.o;
import com.discord.utilities.logging.Logger;
import kotlin.Unit;
import kotlin.jvm.functions.Function2;
import rx.subjects.PublishSubject;
/* compiled from: ScreenshotDetector.kt */
public final class ScreenshotDetector {
public static ScreenshotDetector a;
public final PublishSubject<Screenshot> b;
/* renamed from: c reason: collision with root package name */
public final b f2597c;
public final c.a.s.a d;
public boolean e;
public final Logger f;
public final SharedPreferences g;
/* compiled from: ScreenshotDetector.kt */
public static final class Screenshot {
public final Uri a;
public final String b;
public Screenshot(Uri uri, String str) {
m.checkNotNullParameter(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
m.checkNotNullParameter(str, "filename");
this.a = uri;
this.b = str;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Screenshot)) {
return false;
}
Screenshot screenshot = (Screenshot) obj;
return m.areEqual(this.a, screenshot.a) && m.areEqual(this.b, screenshot.b);
}
public int hashCode() {
Uri uri = this.a;
int i = 0;
int hashCode = (uri != null ? uri.hashCode() : 0) * 31;
String str = this.b;
if (str != null) {
i = str.hashCode();
}
return hashCode + i;
}
public String toString() {
StringBuilder O = c.d.b.a.a.O("Screenshot(uri=");
O.append(this.a);
O.append(", filename=");
return c.d.b.a.a.G(O, this.b, ")");
}
}
/* compiled from: ScreenshotDetector.kt */
public static final class a extends o implements Function2<Uri, String, Unit> {
public final /* synthetic */ ScreenshotDetector this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public a(ScreenshotDetector screenshotDetector) {
super(2);
this.this$0 = screenshotDetector;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
@Override // kotlin.jvm.functions.Function2
public Unit invoke(Uri uri, String str) {
Uri uri2 = uri;
String str2 = str;
m.checkNotNullParameter(uri2, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
m.checkNotNullParameter(str2, "filename");
ScreenshotDetector screenshotDetector = this.this$0;
if (screenshotDetector.e) {
PublishSubject<Screenshot> publishSubject = screenshotDetector.b;
publishSubject.j.onNext(new Screenshot(uri2, str2));
}
return Unit.a;
}
}
public ScreenshotDetector(Application application, Logger logger, SharedPreferences sharedPreferences) {
m.checkNotNullParameter(application, "applicationContext");
m.checkNotNullParameter(logger, "logger");
m.checkNotNullParameter(sharedPreferences, "cache");
this.f = logger;
this.g = sharedPreferences;
PublishSubject<Screenshot> k0 = PublishSubject.k0();
m.checkNotNullExpressionValue(k0, "PublishSubject.create()");
this.b = k0;
ContentResolver contentResolver = application.getContentResolver();
m.checkNotNullExpressionValue(contentResolver, "applicationContext.contentResolver");
b bVar = new b(logger, contentResolver, null, new a(this), 4);
this.f2597c = bVar;
c.a.s.a aVar = new c.a.s.a(bVar);
this.d = aVar;
a(sharedPreferences.getBoolean("screenshot_detection_enabled", false));
application.registerActivityLifecycleCallbacks(aVar);
aVar.a(this.e);
}
public final void a(boolean z2) {
this.e = z2;
SharedPreferences.Editor edit = this.g.edit();
m.checkNotNullExpressionValue(edit, "editor");
edit.putBoolean("screenshot_detection_enabled", z2);
edit.apply();
this.d.a(z2);
}
}