Skip to content

Commit

Permalink
add voter declaration
Browse files Browse the repository at this point in the history
add disclosure agreement
version bump
  • Loading branch information
Aaron Huttner authored and Aaron Huttner committed Aug 24, 2016
1 parent 27f1baf commit 4e0edc6
Show file tree
Hide file tree
Showing 13 changed files with 276 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Manifest version information!
def versionMajor = 1
def versionMinor = 0
def versionPatch = 3
def versionPatch = 4
def versionBuild = 0 // bump for dogfood builds, public betas, etc.

apply plugin: 'com.android.application'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import static com.rockthevote.grommet.data.db.model.RockyRequest.Status.ABANDONED;
import static com.rockthevote.grommet.data.db.model.RockyRequest.Status.FORM_COMPLETE;
import static com.rockthevote.grommet.data.db.model.RockyRequest.Status.IN_PROGRESS;
import static com.rockthevote.grommet.data.db.model.RockyRequest.Status.REGISTER_CLIENT_FAILURE;
import static com.rockthevote.grommet.data.db.model.RockyRequest.Status.REGISTER_SERVER_FAILURE;
import static com.rockthevote.grommet.data.db.model.RockyRequest.Status.REGISTER_SUCCESS;
import static java.util.Map.Entry;
Expand Down Expand Up @@ -163,6 +164,14 @@ private void doWork(final RockyRequest rockyRequest) {
.status(status)
.build(),
RockyRequest._ID + " = ? ", String.valueOf(rockyRequest.id()));
},
throwable -> {
// mark the row for removal if the data is corrupt
db.update(RockyRequest.TABLE,
new RockyRequest.Builder()
.status(REGISTER_CLIENT_FAILURE)
.build(),
RockyRequest._ID + " = ? ", String.valueOf(rockyRequest.id()));
}
);
}
Expand All @@ -181,6 +190,7 @@ private void cleanup() {
+ STATUS + " IN ("
+ "'" + ABANDONED + "', "
+ "'" + REGISTER_SERVER_FAILURE + "',"
+ "'" + REGISTER_CLIENT_FAILURE + "',"
+ "'" + REGISTER_SUCCESS + "'"
+ ")";

Expand Down Expand Up @@ -270,8 +280,11 @@ private ApiRockyRequestWrapper zipRockyRequest(RockyRequest rockyRequest,
EnumMap<VoterId.Type, VoterId> voterIds,
EnumMap<AdditionalInfo.Type, AdditionalInfo> additionalInfo) {


// Get address info objects
/*
* Get address info objects, this is a bit "mucky" because of the way I collect the data
* there will still be an address object even if the user didn't check the box for
* that type
*/
ApiAddress apiRegAddress = ApiAddress.fromAddress(addresses.get(REGISTRATION_ADDRESS));
ApiAddress apiMailAddress = rockyRequest.hasMailingAddress() ?
ApiAddress.fromAddress(addresses.get(MAILING_ADDRESS)) : null;
Expand Down Expand Up @@ -345,7 +358,6 @@ private ApiRockyRequestWrapper zipRockyRequest(RockyRequest rockyRequest,
return ApiRockyRequestWrapper.builder().apiRockyRequest(apiRockyRequest).build();
}


@Nullable
@Override
public IBinder onBind(Intent intent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public static ApiVoterRegistration fromDb(RockyRequest rockyRequest,
List<ApiContactMethod> contactMethods,
List<ApiAdditionalInfo> additionalInfo,
ApiRegistrationHelper registrationHelper) {

return builder()
.dateOfBirth(Dates.formatAsISO8601_ShortDate(rockyRequest.dateOfBirth()))
.mailingAddress(mailingAddress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import rx.functions.Func1;

@AutoValue
@SuppressWarnings("mutable")
public abstract class RockyRequest implements Parcelable, BaseColumns {
public static final String TABLE = "rocky_request";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class AdditionalInfoFragment extends BaseRegistrationFragment {

@BindView(R.id.does_not_have_penn_dot_checkbox) CheckBox noPennDOTCheckbox;

@NotEmpty(messageResId = R.string.error_penn_dot)
@Length(min = 8, max = 8, messageResId = R.string.error_penn_dot)
@BindView(R.id.til_penn_dot) TextInputLayout pennDOTTIL;

@BindView(R.id.penn_dot_edit_text) EditText pennDOTEditText;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.rockthevote.grommet.ui.registration;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.text.Html;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.rockthevote.grommet.R;
import com.rockthevote.grommet.util.ListTagHandler;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DisclosureAgreementDialogFragment extends DialogFragment {

@BindView(R.id.text_content) TextView content;

private DisclosureListener listener;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
setCancelable(false);
View v = inflater.inflate(R.layout.dialog_disclosure_agreement, container);
ButterKnife.bind(this, v);

Spanned result;

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
result = Html.fromHtml(getString(R.string.disclosure_agreement),
Html.FROM_HTML_MODE_LEGACY, null, new ListTagHandler());
} else {
result = Html.fromHtml(getString(R.string.disclosure_agreement),
null, new ListTagHandler());
}

content.setText(result);
content.setMovementMethod(LinkMovementMethod.getInstance());
return v;
}

public void setListener(DisclosureListener listener) {
this.listener = listener;
}

@OnClick(R.id.disclosure_decline_button)
public void onDeclineClick(View v) {
if (null != listener) {
listener.onDeclineClick();
}
}

@OnClick(R.id.disclosure_accept_button)
public void onAcceptClick(View v) {
if (null != listener) {
listener.onAcceptClick();
}
}

public interface DisclosureListener {

void onDeclineClick();

void onAcceptClick();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

import com.f2prateek.rx.preferences.Preference;
import com.jakewharton.rxbinding.widget.RxCompoundButton;
import com.mobsandgeeks.saripaar.annotation.Checked;
import com.rockthevote.grommet.R;
import com.rockthevote.grommet.data.db.model.RockyRequest;
import com.rockthevote.grommet.data.db.model.VoterClassification;
import com.rockthevote.grommet.data.prefs.CurrentRockyRequestId;
import com.rockthevote.grommet.ui.misc.ObservableValidator;
import com.rockthevote.grommet.ui.views.AddressView;
import com.squareup.sqlbrite.BriteDatabase;

Expand All @@ -33,6 +35,9 @@

public class PersonalInfoFragment extends BaseRegistrationFragment {

@Checked(value = false, messageResId = R.string.error_no_address)
@BindView(R.id.no_address_checkbox) CheckBox noAddress;

@BindView(R.id.home_address) AddressView homeAddress;

@BindView(R.id.mailing_address) AddressView mailingAddress;
Expand All @@ -55,6 +60,8 @@ public class PersonalInfoFragment extends BaseRegistrationFragment {

private CompositeSubscription subscriptions;

private ObservableValidator validator;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand All @@ -66,6 +73,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
validator = new ObservableValidator(this, getActivity());
}

@Override
Expand Down Expand Up @@ -125,17 +133,9 @@ public Observable<Boolean> verify() {
Observable<Boolean> changedAddObs = previousAddress.verify()
.flatMap(val -> Observable.just(addressChanged.isChecked() ? val : true));

return homeAddress.verify()
.concatWith(mailingAddressObs)
.concatWith(changedAddObs)
.toList()
.flatMap(list -> {
Boolean ret = true;
for (Boolean val : list) {
ret = ret && val;
}

return Observable.just(ret);
});
return Observable.zip(homeAddress.verify(), mailingAddressObs,
changedAddObs, validator.validate(),
(home, mail, change, other) -> home && mail && change && other);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

import com.f2prateek.rx.preferences.Preference;
Expand Down Expand Up @@ -65,6 +66,8 @@ public class ReviewAndConfirmFragment extends BaseRegistrationFragment implement
@BindView(R.id.signature_pad_error) TextView signaturePadError;
@BindView(R.id.button_register) Button buttonRegister;

@BindView(R.id.checkbox_agreement) CheckBox confirmCheckbox;

@Inject @EventRegTotal Preference<Integer> eventRegTotal;
@Inject @AppRegTotal Preference<Integer> appRegTotal;

Expand All @@ -73,6 +76,7 @@ public class ReviewAndConfirmFragment extends BaseRegistrationFragment implement
@Inject BriteDatabase db;

private CompositeSubscription subscriptions;
private DisclosureAgreementDialogFragment dialog;

@Nullable
@Override
Expand All @@ -85,11 +89,28 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);

dialog = new DisclosureAgreementDialogFragment();
dialog.setCancelable(false);
}

@Override
public void onResume() {
super.onResume();
dialog.setListener(new DisclosureAgreementDialogFragment.DisclosureListener() {
@Override
public void onDeclineClick() {
confirmCheckbox.setChecked(false);
dialog.dismiss();
}

@Override
public void onAcceptClick() {
buttonRegister.setEnabled(true);
dialog.dismiss();
}
});

subscriptions = new CompositeSubscription();

signaturePad.setOnSignedListener(this);
Expand Down Expand Up @@ -155,6 +176,7 @@ public void onPause() {
super.onPause();
subscriptions.unsubscribe();
signaturePad.setOnSignedListener(null);
dialog.setListener(null);
}

@OnClick(R.id.clear_signature)
Expand All @@ -164,7 +186,9 @@ public void onClearSignatureClick(View v) {

@OnCheckedChanged(R.id.checkbox_agreement)
public void onCheckChanged(boolean checked) {
buttonRegister.setEnabled(checked);
if (checked) {
dialog.show(getFragmentManager(), "disclosure_dialog");
}
}

@Override
Expand Down Expand Up @@ -192,7 +216,7 @@ public void onClear() {
RockyRequest._ID + " = ? ", String.valueOf(rockyRequestRowId.get()));
}

// the default value is set in the datamodule
// the default value is set in the data module
@SuppressWarnings("ConstantConditions")
@OnClick(R.id.button_register)
public void onRegisterClick(View v) {
Expand Down
52 changes: 52 additions & 0 deletions app/src/main/res/layout/dialog_disclosure_agreement.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingEnd="24dp"
android:paddingStart="24dp"
android:paddingTop="24dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="@dimen/content_area_padding"
android:text="@string/disclosure_agreement_title"
android:textAppearance="@android:style/TextAppearance.Material.DialogWindowTitle"/>


<TextView
android:id="@+id/text_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="24dp"
android:paddingTop="8dp"
tools:text="@string/disclosure_agreement"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="end"
android:orientation="horizontal"
android:paddingBottom="8dp">

<Button
android:id="@+id/disclosure_decline_button"
style="@android:style/Widget.Material.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_decline"
/>

<Button
android:id="@+id/disclosure_accept_button"
style="@android:style/Widget.Material.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_accept"
/>
</LinearLayout>


</LinearLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/layout/fragment_additional_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label_drivers_license_id"
android:digits="0123456789"
android:inputType="number"
android:maxLength="8"
android:maxLines="1"/>

</android.support.design.widget.TextInputLayout>
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/res/layout/fragment_assistant_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
android:columnCount="2"
android:useDefaultMargins="true"
android:visibility="gone"
tools:visibility="gone"
tools:visibility="visible"
>

<View
Expand Down Expand Up @@ -123,6 +123,16 @@

</android.support.design.widget.TextInputLayout>

<TextView
android:layout_width="wrap_content"
android:layout_columnSpan="2"
android:paddingBottom="@dimen/content_area_padding"
android:paddingTop="@dimen/content_area_padding"
android:layout_marginStart="@dimen/content_margin"
android:layout_marginEnd="@dimen/content_margin"
android:textStyle="bold"
android:text="@string/label_assistant_declaration"/>

<CheckBox
android:id="@+id/checkbox_assistant_affirmation"
style="@style/GrommetContentArea"
Expand Down
Loading

0 comments on commit 4e0edc6

Please sign in to comment.