Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add identify-user support #3439

Merged
merged 44 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3a43e21
Remove Powermock from AuditEventLoggerTest
seadowg Nov 4, 2019
40caeb7
Move audit code into one package
seadowg Nov 5, 2019
89e0318
Add note to state of union about package restructuring
seadowg Nov 5, 2019
4b664e2
Remove test only helpers on AuditEventLogger
seadowg Nov 5, 2019
42d48b5
User is prompted to identify themselves when form has identify-user
seadowg Nov 6, 2019
01a8c24
Don't prompt the user to identify themselves when identify-user=false
seadowg Nov 7, 2019
41b6773
User identity is required to not be empty
seadowg Nov 7, 2019
b1f6cb1
Form is closed if user dismisses identity prompt
seadowg Nov 7, 2019
086d1c4
Set user on AuditEvent during logging
seadowg Nov 7, 2019
f719c4d
Log user to audit.csv
seadowg Nov 11, 2019
6bf2cf6
Add close button to identity prompt dialog
seadowg Nov 11, 2019
09371a3
Try to make FormEntryActivity code a little nicer
seadowg Nov 12, 2019
42041d8
Refactor to allow IdentityPromptViewModel to be initialized on Activi…
seadowg Nov 12, 2019
ff634ef
Test AsyncEventAuditEventWriter instead of task
seadowg Nov 12, 2019
edcefa8
Update upgrade path test for audit event writing
seadowg Nov 12, 2019
b4da96f
Account for null auditConfig in FormController
seadowg Nov 12, 2019
0bfcad8
Stop identity dialog closing on rotate and background
seadowg Nov 18, 2019
1a160a7
Add test for resuming form
seadowg Nov 18, 2019
7ecc006
Escape quotes and commas in audit log user
seadowg Nov 19, 2019
ec2eb39
Use existing escape code
seadowg Nov 19, 2019
4af585a
Use polyfill theme to fix input box colors
seadowg Nov 19, 2019
0020549
Make sure identity prompt works in landscape
seadowg Nov 19, 2019
91ace9e
Fix colors for identity prompt in dark theme
seadowg Nov 19, 2019
0ac57f8
Don't use primary background for identity prompt dialog
seadowg Nov 19, 2019
af32b80
Make sure keyboard opens for identity prompt
seadowg Nov 19, 2019
c21ad72
Prompt user for indentity when editing saved form
seadowg Nov 19, 2019
0cf338b
Remove unused menu
seadowg Nov 19, 2019
b461e7b
Add comment around path into form
seadowg Nov 19, 2019
157f077
Remove simplePressBack from DrawWidgetTest
seadowg Nov 20, 2019
22967e1
Remove simplePressBack
seadowg Nov 20, 2019
f7fe929
Correct dimension name
seadowg Nov 20, 2019
89c1374
Share rotation wait code
seadowg Nov 20, 2019
3c1d203
Fix background of identity prompt on lower API levels
seadowg Nov 20, 2019
0e18c08
Remvoe unneeded parameter form method
seadowg Nov 20, 2019
d26dc90
Add scrolling to form selection
seadowg Nov 20, 2019
c18e444
Rename view model
seadowg Nov 20, 2019
b548c9c
Use primitives instead of object types
seadowg Nov 20, 2019
e06739f
Account for moving backwards disabled setting
seadowg Nov 21, 2019
0ee4868
Don't allow whitespace users
seadowg Nov 25, 2019
6bba809
Make sure toolbar is visible on older API levels
seadowg Nov 25, 2019
9ca2a5c
Rename TextUtils to StringUtils
seadowg Nov 25, 2019
c8deaa7
Switch out CoordinatorLayout from full screen dialog
seadowg Nov 25, 2019
ed4a633
Remove background from dialog theme
seadowg Nov 25, 2019
7b69272
Make sure identity is persisted during rotations
seadowg Nov 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static ViewAction rotateToLandscape() {

public T waitForRotationToEnd() {
try {
Thread.sleep(2000);
Thread.sleep(3000);
} catch (InterruptedException e) {
Timber.i(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void openingForm_andEnteringBlankIdentity_remainsOnIdentityPrompt() {
new MainMenuPage(rule)
.clickFillBlankForm()
.clickOnFormWithIdentityPrompt("Identify User")
.enterIdentity("")
.enterIdentity(" ")
.clickKeyboardEnterWithValidationError();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import static org.odk.collect.android.utilities.StringUtils.isBlank;

public class IdentityPromptViewModel extends ViewModel {

private final MutableLiveData<Boolean> formEntryCancelled = new MutableLiveData<>(false);
Expand Down Expand Up @@ -43,9 +45,11 @@ public void promptClosing() {

private void updateRequiresIdentity() {
this.requiresIdentity.setValue(
auditEventLogger != null &&
auditEventLogger.isUserRequired() &&
(auditEventLogger.getUser() == null || auditEventLogger.getUser().isEmpty())
auditEventLogger != null && auditEventLogger.isUserRequired() && !userIsValid(auditEventLogger.getUser())
);
}

private static boolean userIsValid(String user) {
return user != null && !user.isEmpty() && !isBlank(user);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.odk.collect.android.utilities;

import static java.lang.Character.isWhitespace;

public class StringUtils {
seadowg marked this conversation as resolved.
Show resolved Hide resolved

private StringUtils() {
}

public static boolean isBlank(String string) {
char[] chars = string.toCharArray();

for (char character : chars) {
if (!isWhitespace(character)) {
return false;
}
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.odk.collect.android.utilities;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.odk.collect.android.utilities.StringUtils.isBlank;

public class StringUtilsTest {

@Test
public void whenStringIsJustWhitespace_returnsTrue() {
assertTrue(isBlank(" "));
}

@Test
public void whenStringContainsWhitespace_returnsFalse() {
assertFalse(isBlank(" hello "));
}
}