2020-02-20 01:01:14 -05:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
|
|
|
import org.thoughtcrime.securesms.insights.InsightsOptOut;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
|
|
|
import org.thoughtcrime.securesms.jobs.StickerPackDownloadJob;
|
|
|
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
2020-02-28 15:56:59 -05:00
|
|
|
import org.thoughtcrime.securesms.logging.Log;
|
2020-02-20 01:01:14 -05:00
|
|
|
import org.thoughtcrime.securesms.migrations.ApplicationMigrations;
|
|
|
|
import org.thoughtcrime.securesms.stickers.BlessedPacks;
|
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rule of thumb: if there's something you want to do on the first app launch that involves
|
|
|
|
* persisting state to the database, you'll almost certainly *also* want to do it post backup
|
|
|
|
* restore, since a backup restore will wipe the current state of the database.
|
|
|
|
*/
|
|
|
|
public final class AppInitialization {
|
|
|
|
|
2020-02-28 15:56:59 -05:00
|
|
|
private static final String TAG = Log.tag(AppInitialization.class);
|
|
|
|
|
2020-02-20 01:01:14 -05:00
|
|
|
private AppInitialization() {}
|
|
|
|
|
|
|
|
public static void onFirstEverAppLaunch(@NonNull Context context) {
|
2020-02-28 15:56:59 -05:00
|
|
|
Log.i(TAG, "onFirstEverAppLaunch()");
|
|
|
|
|
2020-02-20 01:01:14 -05:00
|
|
|
InsightsOptOut.userRequestedOptOut(context);
|
|
|
|
TextSecurePreferences.setAppMigrationVersion(context, ApplicationMigrations.CURRENT_VERSION);
|
|
|
|
TextSecurePreferences.setJobManagerVersion(context, JobManager.CURRENT_VERSION);
|
|
|
|
TextSecurePreferences.setLastExperienceVersionCode(context, Util.getCanonicalVersionCode());
|
|
|
|
TextSecurePreferences.setHasSeenStickerIntroTooltip(context, true);
|
|
|
|
ApplicationDependencies.getMegaphoneRepository().onFirstEverAppLaunch();
|
2020-02-10 13:42:43 -05:00
|
|
|
SignalStore.onFirstEverAppLaunch();
|
2020-02-20 01:01:14 -05:00
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.ZOZO.getPackId(), BlessedPacks.ZOZO.getPackKey(), false));
|
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.BANDIT.getPackId(), BlessedPacks.BANDIT.getPackKey(), false));
|
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forReference(BlessedPacks.SWOON_HANDS.getPackId(), BlessedPacks.SWOON_HANDS.getPackKey()));
|
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forReference(BlessedPacks.SWOON_FACES.getPackId(), BlessedPacks.SWOON_FACES.getPackKey()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void onPostBackupRestore(@NonNull Context context) {
|
2020-02-28 15:56:59 -05:00
|
|
|
Log.i(TAG, "onPostBackupRestore()");
|
|
|
|
|
2020-02-20 01:01:14 -05:00
|
|
|
ApplicationDependencies.getMegaphoneRepository().onFirstEverAppLaunch();
|
2020-02-10 13:42:43 -05:00
|
|
|
SignalStore.onFirstEverAppLaunch();
|
2020-02-20 01:01:14 -05:00
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.ZOZO.getPackId(), BlessedPacks.ZOZO.getPackKey(), false));
|
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.BANDIT.getPackId(), BlessedPacks.BANDIT.getPackKey(), false));
|
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forReference(BlessedPacks.SWOON_HANDS.getPackId(), BlessedPacks.SWOON_HANDS.getPackKey()));
|
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forReference(BlessedPacks.SWOON_FACES.getPackId(), BlessedPacks.SWOON_FACES.getPackKey()));
|
|
|
|
}
|
|
|
|
}
|