Refactored tests for account setup and changing password.

This commit is contained in:
akwizgran
2017-11-14 11:05:52 +00:00
committed by Torsten Grote
parent 5dcd5f79dc
commit 0f1c9f4fe2
15 changed files with 276 additions and 242 deletions

View File

@@ -33,9 +33,8 @@ public class AuthorNameFragment extends SetupFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getActivity().setTitle(getString(R.string.setup_title));
View v =
inflater.inflate(R.layout.fragment_setup_author_name, container,
false);
View v = inflater.inflate(R.layout.fragment_setup_author_name,
container, false);
authorNameWrapper =
(TextInputLayout) v.findViewById(R.id.nickname_entry_wrapper);
authorNameInput =
@@ -43,7 +42,6 @@ public class AuthorNameFragment extends SetupFragment {
nextButton = (Button) v.findViewById(R.id.next);
authorNameInput.addTextChangedListener(this);
nextButton.setOnClickListener(this);
return v;

View File

@@ -35,8 +35,7 @@ public class DozeFragment extends SetupFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getActivity().setTitle(getString(R.string.setup_doze_title));
View v =
inflater.inflate(R.layout.fragment_setup_doze, container,
View v = inflater.inflate(R.layout.fragment_setup_doze, container,
false);
dozeButton = (Button) v.findViewById(R.id.dozeButton);
progressBar = (ProgressBar) v.findViewById(R.id.progress);

View File

@@ -91,7 +91,7 @@ public class PasswordControllerImpl extends ConfigControllerImpl
return StringUtils.fromHexString(hex);
}
// Call inside cryptoExecutor
@CryptoExecutor
String encryptDatabaseKey(SecretKey key, String password) {
long now = System.currentTimeMillis();
byte[] encrypted = crypto.encryptWithPassword(key.getBytes(), password);

View File

@@ -37,8 +37,7 @@ public class PasswordFragment extends SetupFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getActivity().setTitle(getString(R.string.setup_password_intro));
View v =
inflater.inflate(R.layout.fragment_setup_password, container,
View v = inflater.inflate(R.layout.fragment_setup_password, container,
false);
strengthMeter = (StrengthMeter) v.findViewById(R.id.strength_meter);

View File

@@ -42,18 +42,20 @@ abstract class SetupFragment extends BaseFragment implements TextWatcher,
protected abstract String getHelpText();
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1,
int i2) {
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// noop
}
@Override
public void onTextChanged(CharSequence authorName, int i, int i1, int i2) {
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// noop
}
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
public boolean onEditorAction(TextView textView, int actionId,
KeyEvent keyEvent) {
onClick(textView);
return true;
}

View File

@@ -192,11 +192,8 @@ public class NavDrawerActivity extends BriarActivity implements
drawerLayout.closeDrawer(START);
clearBackStack();
loadFragment(item.getItemId());
//Don't display the Settings Item as checked
if (item.getItemId() == R.id.nav_btn_settings) {
return false;
}
return true;
// Don't display the Settings item as checked
return item.getItemId() != R.id.nav_btn_settings;
}
@Override
@@ -214,7 +211,7 @@ public class NavDrawerActivity extends BriarActivity implements
getSupportFragmentManager()
.findFragmentByTag(ContactListFragment.TAG) == null) {
/*
* This Makes sure that the first fragment (ContactListFragment) the
* This makes sure that the first fragment (ContactListFragment) the
* user sees is the same as the last fragment the user sees before
* exiting. This models the typical Google navigation behaviour such
* as in Gmail/Inbox.

View File

@@ -172,8 +172,7 @@ public class UiUtils {
public static boolean needsDozeWhitelisting(Context ctx) {
if (Build.VERSION.SDK_INT < 23) return false;
PowerManager pm =
(PowerManager) ctx.getSystemService(POWER_SERVICE);
PowerManager pm = (PowerManager) ctx.getSystemService(POWER_SERVICE);
String packageName = ctx.getPackageName();
if (pm == null) throw new AssertionError();
return !pm.isIgnoringBatteryOptimizations(packageName);