127 lines
5.2 KiB
Java
127 lines
5.2 KiB
Java
|
package com.discord.utilities.bugreports;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.SharedPreferences;
|
||
|
import com.discord.screenshot_detection.ScreenshotDetector;
|
||
|
import com.discord.stores.StoreStream;
|
||
|
import com.discord.stores.StoreUser;
|
||
|
import com.discord.utilities.cache.SharedPreferencesProvider;
|
||
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
||
|
import com.discord.widgets.bugreports.WidgetBugReport;
|
||
|
import d0.g;
|
||
|
import d0.z.d.m;
|
||
|
import kotlin.Lazy;
|
||
|
import kotlin.jvm.functions.Function0;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
import rx.Observable;
|
||
|
/* compiled from: BugReportManager.kt */
|
||
|
public final class BugReportManager {
|
||
|
public static final Companion Companion = new Companion(null);
|
||
|
public static final String PREFS_SS_BUG_REPORTING_SETTINGS_ENABLED = "prefs_ss_bug_reporting_enabled";
|
||
|
private static BugReportManager bugReportManager;
|
||
|
private final SharedPreferences cache;
|
||
|
private boolean isStaff;
|
||
|
private final Lazy screenshotDetector$delegate;
|
||
|
private boolean settingsEnabled;
|
||
|
private final StoreUser storeUser;
|
||
|
|
||
|
/* compiled from: BugReportManager.kt */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
|
||
|
public final BugReportManager get() {
|
||
|
BugReportManager access$getBugReportManager$cp = BugReportManager.access$getBugReportManager$cp();
|
||
|
if (access$getBugReportManager$cp == null) {
|
||
|
m.throwUninitializedPropertyAccessException("bugReportManager");
|
||
|
}
|
||
|
return access$getBugReportManager$cp;
|
||
|
}
|
||
|
|
||
|
public final void init() {
|
||
|
BugReportManager.access$setBugReportManager$cp(new BugReportManager(SharedPreferencesProvider.INSTANCE.get(), null, 2, null));
|
||
|
BugReportManager access$getBugReportManager$cp = BugReportManager.access$getBugReportManager$cp();
|
||
|
if (access$getBugReportManager$cp == null) {
|
||
|
m.throwUninitializedPropertyAccessException("bugReportManager");
|
||
|
}
|
||
|
access$getBugReportManager$cp.setupSubscriptions();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public BugReportManager(SharedPreferences sharedPreferences, StoreUser storeUser) {
|
||
|
m.checkNotNullParameter(sharedPreferences, "cache");
|
||
|
m.checkNotNullParameter(storeUser, "storeUser");
|
||
|
this.cache = sharedPreferences;
|
||
|
this.storeUser = storeUser;
|
||
|
this.settingsEnabled = true;
|
||
|
this.screenshotDetector$delegate = g.lazy(BugReportManager$screenshotDetector$2.INSTANCE);
|
||
|
this.settingsEnabled = sharedPreferences.getBoolean(PREFS_SS_BUG_REPORTING_SETTINGS_ENABLED, true);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
||
|
public /* synthetic */ BugReportManager(SharedPreferences sharedPreferences, StoreUser storeUser, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this(sharedPreferences, (i & 2) != 0 ? StoreStream.Companion.getUsers() : storeUser);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ BugReportManager access$getBugReportManager$cp() {
|
||
|
return bugReportManager;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$setBugReportManager$cp(BugReportManager bugReportManager2) {
|
||
|
bugReportManager = bugReportManager2;
|
||
|
}
|
||
|
|
||
|
private final ScreenshotDetector getScreenshotDetector() {
|
||
|
return (ScreenshotDetector) this.screenshotDetector$delegate.getValue();
|
||
|
}
|
||
|
|
||
|
public final SharedPreferences getCache() {
|
||
|
return this.cache;
|
||
|
}
|
||
|
|
||
|
public final StoreUser getStoreUser() {
|
||
|
return this.storeUser;
|
||
|
}
|
||
|
|
||
|
public final boolean isBugReportSettingEnabled() {
|
||
|
return this.settingsEnabled;
|
||
|
}
|
||
|
|
||
|
public final boolean isEnabled() {
|
||
|
return this.isStaff && this.settingsEnabled;
|
||
|
}
|
||
|
|
||
|
public final void onScreenshot(Context context, ScreenshotDetector.Screenshot screenshot) {
|
||
|
m.checkNotNullParameter(context, "context");
|
||
|
m.checkNotNullParameter(screenshot, "screenshot");
|
||
|
if (isEnabled()) {
|
||
|
WidgetBugReport.Companion.launch(context, screenshot);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final void setBugReportingSettingEnabled(boolean z2) {
|
||
|
SharedPreferences.Editor edit = this.cache.edit();
|
||
|
m.checkExpressionValueIsNotNull(edit, "editor");
|
||
|
edit.putBoolean(PREFS_SS_BUG_REPORTING_SETTINGS_ENABLED, z2);
|
||
|
edit.apply();
|
||
|
this.settingsEnabled = z2;
|
||
|
getScreenshotDetector().a(isEnabled());
|
||
|
}
|
||
|
|
||
|
public final void setUserIsStaff(boolean z2) {
|
||
|
this.isStaff = z2;
|
||
|
getScreenshotDetector().a(isEnabled());
|
||
|
}
|
||
|
|
||
|
public final void setupSubscriptions() {
|
||
|
Observable r = this.storeUser.observeMe(true).F(BugReportManager$setupSubscriptions$1.INSTANCE).r();
|
||
|
m.checkNotNullExpressionValue(r, "storeUser.observeMe(emit… }.distinctUntilChanged()");
|
||
|
ObservableExtensionsKt.appSubscribe$default(r, BugReportManager.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new BugReportManager$setupSubscriptions$2(this), 62, (Object) null);
|
||
|
}
|
||
|
}
|