102 lines
3.5 KiB
Java
102 lines
3.5 KiB
Java
package com.discord.utilities.surveys;
|
|
|
|
import android.app.Application;
|
|
import android.content.pm.PackageManager;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import d0.z.d.m;
|
|
import j0.l.e.j;
|
|
import rx.Observable;
|
|
/* compiled from: SurveyUtils.kt */
|
|
public final class SurveyUtils {
|
|
public static final SurveyUtils INSTANCE = new SurveyUtils();
|
|
private static final long MIN_APP_INSTALL_TIME = 604800000;
|
|
private static Application applicationContext;
|
|
|
|
/* compiled from: SurveyUtils.kt */
|
|
public static class Survey {
|
|
private final String noticeKey;
|
|
private final String surveyBody;
|
|
private final String surveyId;
|
|
private final String surveyTitle;
|
|
private final String surveyURL;
|
|
|
|
/* compiled from: SurveyUtils.kt */
|
|
public static final class None extends Survey {
|
|
public static final None INSTANCE = new None();
|
|
|
|
private None() {
|
|
super("", "", "", "", "");
|
|
}
|
|
}
|
|
|
|
public Survey(String str, String str2, String str3, String str4, String str5) {
|
|
m.checkNotNullParameter(str, "surveyId");
|
|
m.checkNotNullParameter(str2, "surveyURL");
|
|
m.checkNotNullParameter(str3, "noticeKey");
|
|
m.checkNotNullParameter(str4, "surveyBody");
|
|
m.checkNotNullParameter(str5, "surveyTitle");
|
|
this.surveyId = str;
|
|
this.surveyURL = str2;
|
|
this.noticeKey = str3;
|
|
this.surveyBody = str4;
|
|
this.surveyTitle = str5;
|
|
}
|
|
|
|
public String getNoticeKey() {
|
|
return this.noticeKey;
|
|
}
|
|
|
|
public String getSurveyBody() {
|
|
return this.surveyBody;
|
|
}
|
|
|
|
public String getSurveyId() {
|
|
return this.surveyId;
|
|
}
|
|
|
|
public String getSurveyTitle() {
|
|
return this.surveyTitle;
|
|
}
|
|
|
|
public String getSurveyURL() {
|
|
return this.surveyURL;
|
|
}
|
|
}
|
|
|
|
private SurveyUtils() {
|
|
}
|
|
|
|
private final boolean isInstallOldEnough() {
|
|
try {
|
|
Application application = applicationContext;
|
|
if (application == null) {
|
|
m.throwUninitializedPropertyAccessException("applicationContext");
|
|
}
|
|
PackageManager packageManager = application.getPackageManager();
|
|
Application application2 = applicationContext;
|
|
if (application2 == null) {
|
|
m.throwUninitializedPropertyAccessException("applicationContext");
|
|
}
|
|
return ClockFactory.get().currentTimeMillis() - packageManager.getPackageInfo(application2.getPackageName(), 0).firstInstallTime >= 604800000;
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public final Observable<Survey> getSurveyToShow() {
|
|
if (!isInstallOldEnough()) {
|
|
j jVar = new j(Survey.None.INSTANCE);
|
|
m.checkNotNullExpressionValue(jVar, "Observable.just(Survey.None)");
|
|
return jVar;
|
|
}
|
|
Observable<R> F = StoreStream.Companion.getUserSurvey().observeUserSurvey().F(SurveyUtils$getSurveyToShow$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(F, "StoreStream\n .get… )\n }\n }");
|
|
return F;
|
|
}
|
|
|
|
public final void init(Application application) {
|
|
m.checkNotNullParameter(application, "applicationContext");
|
|
applicationContext = application;
|
|
}
|
|
}
|