2020-02-20 01:01:14 -05:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
2020-12-04 18:31:58 -05:00
|
|
|
import org.signal.core.util.logging.Log;
|
2020-02-20 01:01:14 -05:00
|
|
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
|
|
|
import org.thoughtcrime.securesms.insights.InsightsOptOut;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
2021-06-03 20:30:44 -04:00
|
|
|
import org.thoughtcrime.securesms.jobs.EmojiSearchIndexDownloadJob;
|
2020-02-20 01:01:14 -05:00
|
|
|
import org.thoughtcrime.securesms.jobs.StickerPackDownloadJob;
|
|
|
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
|
|
|
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);
|
2022-01-13 10:51:45 -05:00
|
|
|
TextSecurePreferences.setLastVersionCode(context, Util.getCanonicalVersionCode());
|
2020-02-20 01:01:14 -05:00
|
|
|
TextSecurePreferences.setHasSeenStickerIntroTooltip(context, true);
|
2020-11-18 19:36:48 -05:00
|
|
|
TextSecurePreferences.setPasswordDisabled(context, true);
|
|
|
|
TextSecurePreferences.setReadReceiptsEnabled(context, true);
|
|
|
|
TextSecurePreferences.setTypingIndicatorsEnabled(context, true);
|
|
|
|
TextSecurePreferences.setHasSeenWelcomeScreen(context, false);
|
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));
|
2021-01-21 00:11:50 -05:00
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.DAY_BY_DAY.getPackId(), BlessedPacks.DAY_BY_DAY.getPackKey(), false));
|
2020-02-20 01:01:14 -05:00
|
|
|
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();
|
2022-01-28 15:16:33 -05:00
|
|
|
SignalStore.onPostBackupRestore();
|
2020-02-10 13:42:43 -05:00
|
|
|
SignalStore.onFirstEverAppLaunch();
|
2021-01-08 23:00:41 -05:00
|
|
|
SignalStore.onboarding().clearAll();
|
2021-03-17 12:52:25 -04:00
|
|
|
TextSecurePreferences.onPostBackupRestore(context);
|
2022-02-14 12:01:46 -05:00
|
|
|
TextSecurePreferences.setPasswordDisabled(context, true);
|
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));
|
2021-01-21 00:11:50 -05:00
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.DAY_BY_DAY.getPackId(), BlessedPacks.DAY_BY_DAY.getPackKey(), false));
|
2020-02-20 01:01:14 -05:00
|
|
|
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()));
|
2021-06-03 20:30:44 -04:00
|
|
|
EmojiSearchIndexDownloadJob.scheduleImmediately();
|
2020-02-20 01:01:14 -05:00
|
|
|
}
|
2021-01-13 17:33:14 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Temporary migration method that does the safest bits of {@link #onFirstEverAppLaunch(Context)}
|
|
|
|
*/
|
|
|
|
public static void onRepairFirstEverAppLaunch(@NonNull Context context) {
|
|
|
|
Log.w(TAG, "onRepairFirstEverAppLaunch()");
|
|
|
|
|
|
|
|
InsightsOptOut.userRequestedOptOut(context);
|
|
|
|
TextSecurePreferences.setAppMigrationVersion(context, ApplicationMigrations.CURRENT_VERSION);
|
|
|
|
TextSecurePreferences.setJobManagerVersion(context, JobManager.CURRENT_VERSION);
|
2022-01-13 10:51:45 -05:00
|
|
|
TextSecurePreferences.setLastVersionCode(context, Util.getCanonicalVersionCode());
|
2021-01-13 17:33:14 -05:00
|
|
|
TextSecurePreferences.setHasSeenStickerIntroTooltip(context, true);
|
|
|
|
TextSecurePreferences.setPasswordDisabled(context, true);
|
|
|
|
ApplicationDependencies.getMegaphoneRepository().onFirstEverAppLaunch();
|
|
|
|
SignalStore.onFirstEverAppLaunch();
|
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.ZOZO.getPackId(), BlessedPacks.ZOZO.getPackKey(), false));
|
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.BANDIT.getPackId(), BlessedPacks.BANDIT.getPackKey(), false));
|
2021-01-21 00:11:50 -05:00
|
|
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.DAY_BY_DAY.getPackId(), BlessedPacks.DAY_BY_DAY.getPackKey(), false));
|
2021-01-13 17:33:14 -05:00
|
|
|
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()));
|
|
|
|
}
|
2020-02-20 01:01:14 -05:00
|
|
|
}
|