187 lines
9.2 KiB
Java
187 lines
9.2 KiB
Java
package com.discord.stores;
|
|
|
|
import android.app.Application;
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import c.q.a.k.a;
|
|
import com.discord.stores.StoreNotices;
|
|
import com.discord.utilities.string.StringUtilsKt;
|
|
import com.discord.utilities.time.Clock;
|
|
import com.discord.widgets.changelog.WidgetChangeLog;
|
|
import com.discord.widgets.changelog.WidgetChangeLogSpecial;
|
|
import d0.g0.t;
|
|
import d0.g0.w;
|
|
import d0.z.d.m;
|
|
import s.a.j0;
|
|
import s.a.w0;
|
|
/* compiled from: StoreChangeLog.kt */
|
|
public final class StoreChangeLog extends Store {
|
|
public Application app;
|
|
private final Clock clock;
|
|
private final Dispatcher dispatcher;
|
|
private final StoreExperiments experiments;
|
|
private final StoreNotices notices;
|
|
private final StoreUserSettingsSystem userSettingsSystem;
|
|
private final StoreUser users;
|
|
|
|
public StoreChangeLog(Clock clock, StoreNotices storeNotices, StoreUser storeUser, StoreUserSettingsSystem storeUserSettingsSystem, StoreExperiments storeExperiments, Dispatcher dispatcher) {
|
|
m.checkNotNullParameter(clock, "clock");
|
|
m.checkNotNullParameter(storeNotices, "notices");
|
|
m.checkNotNullParameter(storeUser, "users");
|
|
m.checkNotNullParameter(storeUserSettingsSystem, "userSettingsSystem");
|
|
m.checkNotNullParameter(storeExperiments, "experiments");
|
|
m.checkNotNullParameter(dispatcher, "dispatcher");
|
|
this.clock = clock;
|
|
this.notices = storeNotices;
|
|
this.users = storeUser;
|
|
this.userSettingsSystem = storeUserSettingsSystem;
|
|
this.experiments = storeExperiments;
|
|
this.dispatcher = dispatcher;
|
|
}
|
|
|
|
public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreChangeLog storeChangeLog) {
|
|
return storeChangeLog.dispatcher;
|
|
}
|
|
|
|
private final StoreNotices.Notice createChangeLogNotice() {
|
|
return new StoreNotices.Notice("CHANGE_LOG", null, 1337, 0, true, null, 0, false, 604800000, new StoreChangeLog$createChangeLogNotice$1(this), 226, null);
|
|
}
|
|
|
|
private final String getChangelogExperimentString(Context context, String str, String str2) {
|
|
int identifier = context.getResources().getIdentifier(str, "string", context.getPackageName());
|
|
if (identifier <= 0) {
|
|
return str2;
|
|
}
|
|
String string = context.getString(identifier);
|
|
m.checkNotNullExpressionValue(string, "context.getString(id)");
|
|
return string;
|
|
}
|
|
|
|
private final String getLastSeenChangeLogVersion() {
|
|
return getPrefs().getString("CACHE_KEY_VIEWED_CHANGE_LOG_VERSION", "");
|
|
}
|
|
|
|
private final boolean isTooYoung(long j) {
|
|
long firstUseTimestamp = this.notices.getFirstUseTimestamp() + 432000000;
|
|
long currentTimeMillis = this.clock.currentTimeMillis();
|
|
return currentTimeMillis < ((j >>> 22) + 1420070400000L) + 432000000 || currentTimeMillis < firstUseTimestamp;
|
|
}
|
|
|
|
public static /* synthetic */ void openChangeLog$default(StoreChangeLog storeChangeLog, Context context, boolean z2, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
z2 = false;
|
|
}
|
|
storeChangeLog.openChangeLog(context, z2);
|
|
}
|
|
|
|
private final void setLastSeenChangeLogVersion(String str) {
|
|
SharedPreferences.Editor edit = getPrefs().edit();
|
|
m.checkExpressionValueIsNotNull(edit, "editor");
|
|
edit.putString("CACHE_KEY_VIEWED_CHANGE_LOG_VERSION", str);
|
|
edit.apply();
|
|
}
|
|
|
|
private final boolean shouldShowChangelog(Context context, long j, String str, Integer num) {
|
|
String str2;
|
|
int identifier = (num != null && num.intValue() == 1) ? context.getResources().getIdentifier("change_log_md_experiment_body", "string", context.getPackageName()) : 2131887242;
|
|
CharSequence stringByLocale = StringUtilsKt.getStringByLocale(context, identifier, "en");
|
|
CharSequence stringByLocale2 = StringUtilsKt.getStringByLocale(context, identifier, str);
|
|
if ((!m.areEqual(str, "en")) && m.areEqual(stringByLocale, stringByLocale2)) {
|
|
return false;
|
|
}
|
|
if (num != null && num.intValue() == 1) {
|
|
String string = context.getString(2131887243);
|
|
m.checkNotNullExpressionValue(string, "context.getString(R.string.change_log_md_date)");
|
|
str2 = getChangelogExperimentString(context, "change_log_md_experiment_date", string);
|
|
} else {
|
|
str2 = context.getString(2131887243);
|
|
m.checkNotNullExpressionValue(str2, "context.getString(R.string.change_log_md_date)");
|
|
}
|
|
String lastSeenChangeLogVersion = getLastSeenChangeLogVersion();
|
|
if (!(lastSeenChangeLogVersion == null || t.isBlank(lastSeenChangeLogVersion)) && !isTooYoung(j)) {
|
|
return !m.areEqual(str2, getLastSeenChangeLogVersion());
|
|
}
|
|
markSeen(str2);
|
|
return false;
|
|
}
|
|
|
|
public final Application getApp() {
|
|
Application application = this.app;
|
|
if (application == null) {
|
|
m.throwUninitializedPropertyAccessException("app");
|
|
}
|
|
return application;
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handleConnectionOpen() {
|
|
a.G(w0.i, j0.a, null, new StoreChangeLog$handleConnectionOpen$1(this, null), 2, null);
|
|
}
|
|
|
|
@StoreThread
|
|
public final void handlePostConnectionOpen() {
|
|
String str = (String) w.split$default((CharSequence) this.userSettingsSystem.getLocale(), new String[]{"-"}, false, 0, 6, (Object) null).get(0);
|
|
long id2 = this.users.getMe().getId();
|
|
Application application = this.app;
|
|
if (application == null) {
|
|
m.throwUninitializedPropertyAccessException("app");
|
|
}
|
|
if (shouldShowChangelog(application, id2, str, null)) {
|
|
this.notices.requestToShow(createChangeLogNotice());
|
|
}
|
|
}
|
|
|
|
@StoreThread
|
|
public final void init(Application application) {
|
|
m.checkNotNullParameter(application, "app");
|
|
init((Context) application);
|
|
this.app = application;
|
|
}
|
|
|
|
public final void markSeen(String str) {
|
|
m.checkNotNullParameter(str, "currentVersion");
|
|
setLastSeenChangeLogVersion(str);
|
|
StoreNotices.markSeen$default(this.notices, "CHANGE_LOG", 0, 2, null);
|
|
}
|
|
|
|
public final void openChangeLog(Context context, boolean z2) {
|
|
m.checkNotNullParameter(context, "context");
|
|
String string = context.getString(2131887243);
|
|
m.checkNotNullExpressionValue(string, "context.getString(R.string.change_log_md_date)");
|
|
String changelogExperimentString = getChangelogExperimentString(context, "change_log_md_experiment_date", string);
|
|
String string2 = context.getString(2131887245);
|
|
m.checkNotNullExpressionValue(string2, "context.getString(R.string.change_log_md_revision)");
|
|
String changelogExperimentString2 = getChangelogExperimentString(context, "change_log_md_revision", string2);
|
|
String string3 = context.getString(2131887246);
|
|
m.checkNotNullExpressionValue(string3, "context.getString(R.string.change_log_md_video)");
|
|
String changelogExperimentString3 = getChangelogExperimentString(context, "change_log_md_experiment_video", string3);
|
|
String string4 = context.getString(2131887242);
|
|
m.checkNotNullExpressionValue(string4, "context.getString(R.string.change_log_md_body)");
|
|
String changelogExperimentString4 = getChangelogExperimentString(context, "change_log_md_experiment_body", string4);
|
|
String string5 = context.getString(2131886808);
|
|
m.checkNotNullExpressionValue(string5, "context.getString(R.string.back)");
|
|
String changelogExperimentString5 = getChangelogExperimentString(context, "change_log_md_experiment_template", string5);
|
|
WidgetChangeLogSpecial.Companion.ExitStyle exitStyle = z2 ? WidgetChangeLogSpecial.Companion.ExitStyle.BACK : WidgetChangeLogSpecial.Companion.ExitStyle.CLOSE;
|
|
if (m.areEqual(changelogExperimentString5, "special") && m.areEqual(null, 1)) {
|
|
WidgetChangeLogSpecial.Companion.launch(context, changelogExperimentString, changelogExperimentString2, changelogExperimentString3, changelogExperimentString4, exitStyle, true);
|
|
} else if (m.areEqual(null, 1)) {
|
|
WidgetChangeLog.Companion.launch(context, changelogExperimentString, changelogExperimentString2, changelogExperimentString3, changelogExperimentString4);
|
|
} else {
|
|
WidgetChangeLog.Companion companion = WidgetChangeLog.Companion;
|
|
String string6 = context.getString(2131887243);
|
|
m.checkNotNullExpressionValue(string6, "context.getString(R.string.change_log_md_date)");
|
|
String string7 = context.getString(2131887245);
|
|
m.checkNotNullExpressionValue(string7, "context.getString(R.string.change_log_md_revision)");
|
|
String string8 = context.getString(2131887246);
|
|
m.checkNotNullExpressionValue(string8, "context.getString(R.string.change_log_md_video)");
|
|
String string9 = context.getString(2131887242);
|
|
m.checkNotNullExpressionValue(string9, "context.getString(R.string.change_log_md_body)");
|
|
companion.launch(context, string6, string7, string8, string9);
|
|
}
|
|
}
|
|
|
|
public final void setApp(Application application) {
|
|
m.checkNotNullParameter(application, "<set-?>");
|
|
this.app = application;
|
|
}
|
|
}
|