Finish the initial intro screen
This commit is contained in:
parent
670bc31a54
commit
11f7d386b0
5 changed files with 74 additions and 6 deletions
|
@ -128,6 +128,7 @@ So make sure you have a **current backup** before switching!
|
|||
* [Apache Commons Codec](https://commons.apache.org/proper/commons-codec/)
|
||||
* [Expandable Layout](https://github.com/AAkira/ExpandableLayout)
|
||||
* [LicensesDialog](https://github.com/PSDev/LicensesDialog)
|
||||
* [material-intro](https://github.com/heinrichreimer/material-intro)
|
||||
* [MaterialProgressBar](https://github.com/DreaminginCodeZH/MaterialProgressBar)
|
||||
* [OpenPGP API library](https://github.com/open-keychain/openpgp-api)
|
||||
* [VNTNumberPickerPreference](https://github.com/vanniktech/VNTNumberPickerPreference)
|
||||
|
|
|
@ -30,10 +30,12 @@ import android.os.Bundle;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.TextInputEditText;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -45,6 +47,7 @@ import android.widget.EditText;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.heinrichreimersoftware.materialintro.app.IntroActivity;
|
||||
import com.heinrichreimersoftware.materialintro.app.OnNavigationBlockedListener;
|
||||
|
@ -63,6 +66,21 @@ public class IntroScreenActivity extends IntroActivity {
|
|||
private EncryptionFragment encryptionFragment;
|
||||
private AuthenticationFragment authenticationFragment;
|
||||
|
||||
private void saveSettings() {
|
||||
Constants.EncryptionType encryptionType = encryptionFragment.getEncryptionType();
|
||||
Constants.AuthMethod authMethod = authenticationFragment.getAuthMethod();
|
||||
|
||||
settings.setEncryption(encryptionType);
|
||||
settings.setAuthMethod(authMethod);
|
||||
|
||||
if (authMethod == Constants.AuthMethod.PASSWORD || authMethod == Constants.AuthMethod.PIN) {
|
||||
String password = authenticationFragment.getPassword();
|
||||
settings.setAuthCredentials(password);
|
||||
}
|
||||
|
||||
settings.setFirstTimeWarningShown(true);
|
||||
}
|
||||
|
||||
@Override protected void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
@ -75,7 +93,6 @@ public class IntroScreenActivity extends IntroActivity {
|
|||
@Override
|
||||
public void onEncryptionChanged(Constants.EncryptionType newEncryptionType) {
|
||||
authenticationFragment.updateEncryptionType(newEncryptionType);
|
||||
settings.setEncryption(newEncryptionType);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -84,7 +101,6 @@ public class IntroScreenActivity extends IntroActivity {
|
|||
addSlide(new SimpleSlide.Builder()
|
||||
.title(R.string.intro_slide1_title)
|
||||
.description(R.string.intro_slide1_desc)
|
||||
.image(R.mipmap.ic_launcher)
|
||||
.background(R.color.colorPrimary)
|
||||
.backgroundDark(R.color.colorPrimaryDark)
|
||||
.canGoBackward(false)
|
||||
|
@ -107,6 +123,15 @@ public class IntroScreenActivity extends IntroActivity {
|
|||
.build()
|
||||
);
|
||||
|
||||
addSlide(new SimpleSlide.Builder()
|
||||
.title(R.string.intro_slide4_title)
|
||||
.description(R.string.intro_slide4_desc)
|
||||
.background(R.color.colorPrimary)
|
||||
.backgroundDark(R.color.colorPrimaryDark)
|
||||
.scrollable(false)
|
||||
.build()
|
||||
);
|
||||
|
||||
addOnNavigationBlockedListener(new OnNavigationBlockedListener() {
|
||||
@Override
|
||||
public void onNavigationBlocked(int position, int direction) {
|
||||
|
@ -114,12 +139,27 @@ public class IntroScreenActivity extends IntroActivity {
|
|||
authenticationFragment.flashWarning();
|
||||
}
|
||||
});
|
||||
|
||||
addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
if (position == 3)
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (getCurrentSlidePosition() != 0)
|
||||
super.onBackPressed();
|
||||
// We don't want users to quit the intro screen and end up in an uninitialized state
|
||||
}
|
||||
|
||||
public static class EncryptionFragment extends SlideFragment {
|
||||
|
@ -145,6 +185,10 @@ public class IntroScreenActivity extends IntroActivity {
|
|||
selectionMapping.put(i, Constants.EncryptionType.valueOf(encValues[i].toUpperCase()));
|
||||
}
|
||||
|
||||
public Constants.EncryptionType getEncryptionType() {
|
||||
return selectionMapping.get(selection.getSelectedItemPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -258,6 +302,14 @@ public class IntroScreenActivity extends IntroActivity {
|
|||
}
|
||||
}
|
||||
|
||||
public Constants.AuthMethod getAuthMethod() {
|
||||
return selectionMapping.get(selection.getSelectedItemPosition());
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return passwordInput.getText().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
|
|
@ -220,6 +220,10 @@ public class Settings {
|
|||
return AuthMethod.valueOf(authString.toUpperCase());
|
||||
}
|
||||
|
||||
public void setAuthMethod(AuthMethod authMethod) {
|
||||
setString(R.string.settings_key_auth, authMethod.name().toLowerCase());
|
||||
}
|
||||
|
||||
public void removeAuthPasswordHash() {
|
||||
remove(R.string.settings_key_auth_password_hash);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
<copyright>Copyright (C) 2015 A.Akira</copyright>
|
||||
<license>Apache Software License 2.0</license>
|
||||
</notice>
|
||||
<notice>
|
||||
<name>material-intro</name>
|
||||
<url>https://github.com/heinrichreimer/material-intro</url>
|
||||
<copyright>Copyright (c) 2017 Jan Heinrich Reimer</copyright>
|
||||
<license>MIT License</license>
|
||||
</notice>
|
||||
<notice>
|
||||
<name>MaterialProgressBar</name>
|
||||
<url>https://github.com/DreaminginCodeZH/MaterialProgressBar</url>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="intro_slide1_title">Welcome to andOTP</string>
|
||||
<string name="intro_slide1_desc">This wizard will guide you through the initial setup.</string>
|
||||
<string name="intro_slide1_title">Let\'s get started</string>
|
||||
<string name="intro_slide1_desc">This wizard will guide you through the initial setup of andOTP.
|
||||
Don\'t worry, you can still change any of the options later in the <b>Settings</b>.</string>
|
||||
|
||||
<string name="intro_slide2_desc">To ensure the security of your accounts andOTP only stores them
|
||||
in encrypted data files. Here you can choose which method of encryption will be used.</string>
|
||||
|
@ -28,4 +29,8 @@
|
|||
<string name="intro_slide3_warn_no_pin">Please set a PIN to continue!</string>
|
||||
<string name="intro_slide3_warn_confirm_password">Please confirm your password to continue!</string>
|
||||
<string name="intro_slide3_warn_confirm_pin">Please confirm your PIN to continue!</string>
|
||||
|
||||
<string name="intro_slide4_title">Finished</string>
|
||||
<string name="intro_slide4_desc">Your settings have been saved, you are all set to use andOTP
|
||||
now!</string>
|
||||
</resources>
|
Loading…
Reference in a new issue