diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java index 6efa59a..75ff044 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java @@ -31,12 +31,14 @@ import com.cringe_studios.cringe_authenticator.scanner.QRScannerContract; import com.cringe_studios.cringe_authenticator.util.DialogUtil; import com.cringe_studios.cringe_authenticator.util.NavigationUtil; import com.cringe_studios.cringe_authenticator.util.OTPDatabase; +import com.cringe_studios.cringe_authenticator.util.SettingsUtil; import com.cringe_studios.cringe_authenticator.util.StyledDialogBuilder; import com.cringe_studios.cringe_authenticator.util.ThemeUtil; import com.cringe_studios.cringe_authenticator_library.OTPType; import com.google.mlkit.vision.common.InputImage; import java.io.IOException; +import java.util.UUID; public class MainActivity extends BaseActivity { @@ -129,6 +131,11 @@ public class MainActivity extends BaseActivity { } }); + if(SettingsUtil.isFirstLaunch(this) && SettingsUtil.getGroups(this).isEmpty()) { + SettingsUtil.addGroup(this, UUID.randomUUID().toString(), "My Codes"); + SettingsUtil.setFirstLaunch(this, false); + } + OTPDatabase.promptLoadDatabase(this, this::launchApp, this::finishAffinity); } diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java index e74460c..01c42d5 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java @@ -176,6 +176,15 @@ public class SettingsUtil { return ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getBoolean("hideCodes", false); } + public static void setFirstLaunch(Context ctx, boolean firstLaunch) { + SharedPreferences prefs = ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE); + prefs.edit().putBoolean("firstLaunch", firstLaunch).apply(); + } + + public static boolean isFirstLaunch(Context ctx) { + return ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getBoolean("firstLaunch", true); + } + public static void setTheme(Context ctx, Theme theme) { SharedPreferences prefs = ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE); prefs.edit().putString("theme", theme.name()).apply();