Create group on first launch
This commit is contained in:
parent
9265a2f0ff
commit
a1570a17d9
@ -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.DialogUtil;
|
||||||
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
|
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
|
||||||
import com.cringe_studios.cringe_authenticator.util.OTPDatabase;
|
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.StyledDialogBuilder;
|
||||||
import com.cringe_studios.cringe_authenticator.util.ThemeUtil;
|
import com.cringe_studios.cringe_authenticator.util.ThemeUtil;
|
||||||
import com.cringe_studios.cringe_authenticator_library.OTPType;
|
import com.cringe_studios.cringe_authenticator_library.OTPType;
|
||||||
import com.google.mlkit.vision.common.InputImage;
|
import com.google.mlkit.vision.common.InputImage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MainActivity extends BaseActivity {
|
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);
|
OTPDatabase.promptLoadDatabase(this, this::launchApp, this::finishAffinity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +176,15 @@ public class SettingsUtil {
|
|||||||
return ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getBoolean("hideCodes", false);
|
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) {
|
public static void setTheme(Context ctx, Theme theme) {
|
||||||
SharedPreferences prefs = ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE);
|
SharedPreferences prefs = ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE);
|
||||||
prefs.edit().putString("theme", theme.name()).apply();
|
prefs.edit().putString("theme", theme.name()).apply();
|
||||||
|
Loading…
Reference in New Issue
Block a user