Create group on first launch

This commit is contained in:
MrLetsplay 2023-09-27 21:47:21 +02:00
parent 9265a2f0ff
commit a1570a17d9
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
2 changed files with 16 additions and 0 deletions

View File

@ -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);
}

View File

@ -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();