mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Merge pull request #457 from alexbakker/rename-slides
Rename the security slides of the intro
This commit is contained in:
commit
2ab698c2d3
5 changed files with 27 additions and 27 deletions
|
@ -8,8 +8,8 @@ import androidx.fragment.app.Fragment;
|
||||||
import com.beemdevelopment.aegis.AegisApplication;
|
import com.beemdevelopment.aegis.AegisApplication;
|
||||||
import com.beemdevelopment.aegis.Preferences;
|
import com.beemdevelopment.aegis.Preferences;
|
||||||
import com.beemdevelopment.aegis.R;
|
import com.beemdevelopment.aegis.R;
|
||||||
import com.beemdevelopment.aegis.ui.slides.CustomAuthenticatedSlide;
|
import com.beemdevelopment.aegis.ui.slides.SecuritySetupSlide;
|
||||||
import com.beemdevelopment.aegis.ui.slides.CustomAuthenticationSlide;
|
import com.beemdevelopment.aegis.ui.slides.SecurityPickerSlide;
|
||||||
import com.beemdevelopment.aegis.vault.Vault;
|
import com.beemdevelopment.aegis.vault.Vault;
|
||||||
import com.beemdevelopment.aegis.vault.VaultFile;
|
import com.beemdevelopment.aegis.vault.VaultFile;
|
||||||
import com.beemdevelopment.aegis.vault.VaultFileCredentials;
|
import com.beemdevelopment.aegis.vault.VaultFileCredentials;
|
||||||
|
@ -23,8 +23,8 @@ import com.github.appintro.model.SliderPage;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class IntroActivity extends AppIntro2 {
|
public class IntroActivity extends AppIntro2 {
|
||||||
private CustomAuthenticatedSlide _authenticatedSlide;
|
private SecuritySetupSlide securitySetupSlide;
|
||||||
private CustomAuthenticationSlide _authenticationSlide;
|
private SecurityPickerSlide _securityPickerSlide;
|
||||||
private Fragment _endSlide;
|
private Fragment _endSlide;
|
||||||
|
|
||||||
private AegisApplication _app;
|
private AegisApplication _app;
|
||||||
|
@ -56,12 +56,12 @@ public class IntroActivity extends AppIntro2 {
|
||||||
homeSliderPage.setBackgroundColor(getResources().getColor(R.color.colorSecondary));
|
homeSliderPage.setBackgroundColor(getResources().getColor(R.color.colorSecondary));
|
||||||
addSlide(AppIntroFragment.newInstance(homeSliderPage));
|
addSlide(AppIntroFragment.newInstance(homeSliderPage));
|
||||||
|
|
||||||
_authenticationSlide = new CustomAuthenticationSlide();
|
_securityPickerSlide = new SecurityPickerSlide();
|
||||||
_authenticationSlide.setBgColor(getResources().getColor(R.color.colorSecondary));
|
_securityPickerSlide.setBgColor(getResources().getColor(R.color.colorSecondary));
|
||||||
addSlide(_authenticationSlide);
|
addSlide(_securityPickerSlide);
|
||||||
_authenticatedSlide = new CustomAuthenticatedSlide();
|
securitySetupSlide = new SecuritySetupSlide();
|
||||||
_authenticatedSlide.setBgColor(getResources().getColor(R.color.colorSecondary));
|
securitySetupSlide.setBgColor(getResources().getColor(R.color.colorSecondary));
|
||||||
addSlide(_authenticatedSlide);
|
addSlide(securitySetupSlide);
|
||||||
|
|
||||||
SliderPage endSliderPage = new SliderPage();
|
SliderPage endSliderPage = new SliderPage();
|
||||||
endSliderPage.setTitle(getString(R.string.setup_completed));
|
endSliderPage.setTitle(getString(R.string.setup_completed));
|
||||||
|
@ -74,10 +74,10 @@ public class IntroActivity extends AppIntro2 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSlideChanged(Fragment oldFragment, Fragment newFragment) {
|
public void onSlideChanged(Fragment oldFragment, Fragment newFragment) {
|
||||||
if (oldFragment == _authenticationSlide && newFragment != _endSlide) {
|
if (oldFragment == _securityPickerSlide && newFragment != _endSlide) {
|
||||||
// skip to the last slide if no encryption will be used
|
// skip to the last slide if no encryption will be used
|
||||||
int cryptType = getIntent().getIntExtra("cryptType", CustomAuthenticationSlide.CRYPT_TYPE_INVALID);
|
int cryptType = getIntent().getIntExtra("cryptType", SecurityPickerSlide.CRYPT_TYPE_INVALID);
|
||||||
if (cryptType == CustomAuthenticationSlide.CRYPT_TYPE_NONE) {
|
if (cryptType == SecurityPickerSlide.CRYPT_TYPE_NONE) {
|
||||||
// TODO: no magic indices
|
// TODO: no magic indices
|
||||||
goToNextSlide(false);
|
goToNextSlide(false);
|
||||||
}
|
}
|
||||||
|
@ -90,14 +90,14 @@ public class IntroActivity extends AppIntro2 {
|
||||||
public void onDonePressed(Fragment currentFragment) {
|
public void onDonePressed(Fragment currentFragment) {
|
||||||
super.onDonePressed(currentFragment);
|
super.onDonePressed(currentFragment);
|
||||||
|
|
||||||
int cryptType = _authenticatedSlide.getCryptType();
|
int cryptType = securitySetupSlide.getCryptType();
|
||||||
VaultFileCredentials creds = _authenticatedSlide.getCredentials();
|
VaultFileCredentials creds = securitySetupSlide.getCredentials();
|
||||||
|
|
||||||
Vault vault = new Vault();
|
Vault vault = new Vault();
|
||||||
VaultFile vaultFile = new VaultFile();
|
VaultFile vaultFile = new VaultFile();
|
||||||
try {
|
try {
|
||||||
JSONObject obj = vault.toJson();
|
JSONObject obj = vault.toJson();
|
||||||
if (cryptType == CustomAuthenticationSlide.CRYPT_TYPE_NONE) {
|
if (cryptType == SecurityPickerSlide.CRYPT_TYPE_NONE) {
|
||||||
vaultFile.setContent(obj);
|
vaultFile.setContent(obj);
|
||||||
} else {
|
} else {
|
||||||
vaultFile.setContent(obj, creds);
|
vaultFile.setContent(obj, creds);
|
||||||
|
@ -110,7 +110,7 @@ public class IntroActivity extends AppIntro2 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cryptType == CustomAuthenticationSlide.CRYPT_TYPE_NONE) {
|
if (cryptType == SecurityPickerSlide.CRYPT_TYPE_NONE) {
|
||||||
_app.initVaultManager(vault, null);
|
_app.initVaultManager(vault, null);
|
||||||
} else {
|
} else {
|
||||||
_app.initVaultManager(vault, creds);
|
_app.initVaultManager(vault, creds);
|
||||||
|
|
|
@ -16,7 +16,7 @@ import com.beemdevelopment.aegis.helpers.BiometricsHelper;
|
||||||
import com.github.appintro.SlidePolicy;
|
import com.github.appintro.SlidePolicy;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
public class CustomAuthenticationSlide extends Fragment implements SlidePolicy, RadioGroup.OnCheckedChangeListener {
|
public class SecurityPickerSlide extends Fragment implements SlidePolicy, RadioGroup.OnCheckedChangeListener {
|
||||||
public static final int CRYPT_TYPE_INVALID = 0;
|
public static final int CRYPT_TYPE_INVALID = 0;
|
||||||
public static final int CRYPT_TYPE_NONE = 1;
|
public static final int CRYPT_TYPE_NONE = 1;
|
||||||
public static final int CRYPT_TYPE_PASS = 2;
|
public static final int CRYPT_TYPE_PASS = 2;
|
||||||
|
@ -27,7 +27,7 @@ public class CustomAuthenticationSlide extends Fragment implements SlidePolicy,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.fragment_authentication_slide, container, false);
|
final View view = inflater.inflate(R.layout.fragment_security_picker_slide, container, false);
|
||||||
_buttonGroup = view.findViewById(R.id.rg_authenticationMethod);
|
_buttonGroup = view.findViewById(R.id.rg_authenticationMethod);
|
||||||
_buttonGroup.setOnCheckedChangeListener(this);
|
_buttonGroup.setOnCheckedChangeListener(this);
|
||||||
onCheckedChanged(_buttonGroup, _buttonGroup.getCheckedRadioButtonId());
|
onCheckedChanged(_buttonGroup, _buttonGroup.getCheckedRadioButtonId());
|
|
@ -32,7 +32,7 @@ import com.google.android.material.snackbar.Snackbar;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
|
|
||||||
public class CustomAuthenticatedSlide extends Fragment implements SlidePolicy, SlideSelectionListener {
|
public class SecuritySetupSlide extends Fragment implements SlidePolicy, SlideSelectionListener {
|
||||||
private int _bgColor;
|
private int _bgColor;
|
||||||
private EditText _textPassword;
|
private EditText _textPassword;
|
||||||
private EditText _textPasswordConfirm;
|
private EditText _textPasswordConfirm;
|
||||||
|
@ -43,7 +43,7 @@ public class CustomAuthenticatedSlide extends Fragment implements SlidePolicy, S
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.fragment_authenticated_slide, container, false);
|
final View view = inflater.inflate(R.layout.fragment_security_setup_slide, container, false);
|
||||||
_textPassword = view.findViewById(R.id.text_password);
|
_textPassword = view.findViewById(R.id.text_password);
|
||||||
_textPasswordConfirm = view.findViewById(R.id.text_password_confirm);
|
_textPasswordConfirm = view.findViewById(R.id.text_password_confirm);
|
||||||
_checkPasswordVisibility = view.findViewById(R.id.check_toggle_visibility);
|
_checkPasswordVisibility = view.findViewById(R.id.check_toggle_visibility);
|
||||||
|
@ -94,8 +94,8 @@ public class CustomAuthenticatedSlide extends Fragment implements SlidePolicy, S
|
||||||
@Override
|
@Override
|
||||||
public void onSlideSelected() {
|
public void onSlideSelected() {
|
||||||
Intent intent = getActivity().getIntent();
|
Intent intent = getActivity().getIntent();
|
||||||
_cryptType = intent.getIntExtra("cryptType", CustomAuthenticationSlide.CRYPT_TYPE_INVALID);
|
_cryptType = intent.getIntExtra("cryptType", SecurityPickerSlide.CRYPT_TYPE_INVALID);
|
||||||
if (_cryptType != CustomAuthenticationSlide.CRYPT_TYPE_NONE) {
|
if (_cryptType != SecurityPickerSlide.CRYPT_TYPE_NONE) {
|
||||||
_creds = new VaultFileCredentials();
|
_creds = new VaultFileCredentials();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,14 +108,14 @@ public class CustomAuthenticatedSlide extends Fragment implements SlidePolicy, S
|
||||||
@Override
|
@Override
|
||||||
public boolean isPolicyRespected() {
|
public boolean isPolicyRespected() {
|
||||||
switch (_cryptType) {
|
switch (_cryptType) {
|
||||||
case CustomAuthenticationSlide.CRYPT_TYPE_NONE:
|
case SecurityPickerSlide.CRYPT_TYPE_NONE:
|
||||||
return true;
|
return true;
|
||||||
case CustomAuthenticationSlide.CRYPT_TYPE_BIOMETRIC:
|
case SecurityPickerSlide.CRYPT_TYPE_BIOMETRIC:
|
||||||
if (!_creds.getSlots().has(BiometricSlot.class)) {
|
if (!_creds.getSlots().has(BiometricSlot.class)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// intentional fallthrough
|
// intentional fallthrough
|
||||||
case CustomAuthenticationSlide.CRYPT_TYPE_PASS:
|
case SecurityPickerSlide.CRYPT_TYPE_PASS:
|
||||||
if (EditTextHelper.areEditTextsEqual(_textPassword, _textPasswordConfirm)) {
|
if (EditTextHelper.areEditTextsEqual(_textPassword, _textPasswordConfirm)) {
|
||||||
return _creds.getSlots().has(PasswordSlot.class);
|
return _creds.getSlots().has(PasswordSlot.class);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ public class CustomAuthenticatedSlide extends Fragment implements SlidePolicy, S
|
||||||
Snackbar snackbar = Snackbar.make(view, message, Snackbar.LENGTH_LONG);
|
Snackbar snackbar = Snackbar.make(view, message, Snackbar.LENGTH_LONG);
|
||||||
snackbar.show();
|
snackbar.show();
|
||||||
}
|
}
|
||||||
} else if (_cryptType != CustomAuthenticationSlide.CRYPT_TYPE_BIOMETRIC) {
|
} else if (_cryptType != SecurityPickerSlide.CRYPT_TYPE_BIOMETRIC) {
|
||||||
deriveKey();
|
deriveKey();
|
||||||
} else if (!_creds.getSlots().has(BiometricSlot.class)) {
|
} else if (!_creds.getSlots().has(BiometricSlot.class)) {
|
||||||
showBiometricPrompt();
|
showBiometricPrompt();
|
Loading…
Add table
Add a link
Reference in a new issue