From e2cf6c1fce1603d4891828e7570fc6b0a0929ccd Mon Sep 17 00:00:00 2001 From: Aaron Huttner Date: Tue, 30 Aug 2016 11:49:04 -0400 Subject: [PATCH] add test to registration button. Force english phone format in spanish mode update activity transition --- app/build.gradle | 2 +- .../rockthevote/grommet/ui/MainActivity.java | 4 +- .../registration/AdditionalInfoFragment.java | 9 +- .../registration/AssistantInfoFragment.java | 7 +- .../ui/registration/RegistrationActivity.java | 19 +- .../main/res/drawable/register_to_vote.xml | 365 ++++++++++++++++++ app/src/main/res/layout/activity_main.xml | 3 +- app/src/main/res/values/strings.xml | 2 +- 8 files changed, 397 insertions(+), 14 deletions(-) create mode 100644 app/src/main/res/drawable/register_to_vote.xml diff --git a/app/build.gradle b/app/build.gradle index b0081904..b4229cd3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,7 @@ // Manifest version information! def versionMajor = 1 def versionMinor = 1 -def versionPatch = 1 +def versionPatch = 2 def versionBuild = 0 // bump for dogfood builds, public betas, etc. apply plugin: 'com.android.application' diff --git a/app/src/main/java/com/rockthevote/grommet/ui/MainActivity.java b/app/src/main/java/com/rockthevote/grommet/ui/MainActivity.java index 75ce372d..253bda74 100644 --- a/app/src/main/java/com/rockthevote/grommet/ui/MainActivity.java +++ b/app/src/main/java/com/rockthevote/grommet/ui/MainActivity.java @@ -1,6 +1,7 @@ package com.rockthevote.grommet.ui; import android.Manifest; +import android.app.ActivityOptions; import android.app.AlertDialog; import android.content.Intent; import android.content.pm.PackageManager; @@ -164,7 +165,8 @@ private void createNewVoterRecord() { long rockyRequestRowId = db.insert(RockyRequest.TABLE, builder.build()); currentRockyRequestId.set(rockyRequestRowId); - startActivity(new Intent(this, RegistrationActivity.class)); + startActivity(new Intent(this, RegistrationActivity.class), + ActivityOptions.makeSceneTransitionAnimation(this).toBundle()); }); } diff --git a/app/src/main/java/com/rockthevote/grommet/ui/registration/AdditionalInfoFragment.java b/app/src/main/java/com/rockthevote/grommet/ui/registration/AdditionalInfoFragment.java index 3c4c02f4..f130de7f 100644 --- a/app/src/main/java/com/rockthevote/grommet/ui/registration/AdditionalInfoFragment.java +++ b/app/src/main/java/com/rockthevote/grommet/ui/registration/AdditionalInfoFragment.java @@ -11,6 +11,7 @@ import android.widget.EditText; import com.f2prateek.rx.preferences.Preference; +import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.jakewharton.rxbinding.widget.RxCompoundButton; import com.jakewharton.rxbinding.widget.RxTextView; import com.mobsandgeeks.saripaar.Validator; @@ -192,10 +193,11 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { @Override public void onResume() { super.onResume(); - phoneFormatter = new PhoneNumberFormattingTextWatcher(); - phone.addTextChangedListener(phoneFormatter); subscriptions = new CompositeSubscription(); + phoneFormatter = new PhoneNumberFormattingTextWatcher("en"); + phone.addTextChangedListener(phoneFormatter); + subscriptions.add(RxTextView.afterTextChangeEvents(raceSpinner.getEditText()) .observeOn(Schedulers.io()) .skip(1) @@ -328,13 +330,14 @@ public void onResume() { .build(), RockyRequest._ID + " = ? ", String.valueOf(rockyRequestRowId.get())); })); + } @Override public void onPause() { super.onPause(); - phone.removeTextChangedListener(phoneFormatter); subscriptions.unsubscribe(); + phone.removeTextChangedListener(phoneFormatter); } /** diff --git a/app/src/main/java/com/rockthevote/grommet/ui/registration/AssistantInfoFragment.java b/app/src/main/java/com/rockthevote/grommet/ui/registration/AssistantInfoFragment.java index 4601bc97..8ad111e0 100644 --- a/app/src/main/java/com/rockthevote/grommet/ui/registration/AssistantInfoFragment.java +++ b/app/src/main/java/com/rockthevote/grommet/ui/registration/AssistantInfoFragment.java @@ -86,10 +86,11 @@ public void onViewCreated(View view, Bundle savedInstanceState) { @Override public void onResume() { super.onResume(); - phoneFormatter = new PhoneNumberFormattingTextWatcher(); + subscriptions = new CompositeSubscription(); + + phoneFormatter = new PhoneNumberFormattingTextWatcher("en"); phoneEditText.addTextChangedListener(phoneFormatter); - subscriptions = new CompositeSubscription(); subscriptions.add(RxTextView.afterTextChangeEvents(phoneEditText) .observeOn(Schedulers.io()) .debounce(DEBOUNCE, TimeUnit.MILLISECONDS) @@ -107,8 +108,8 @@ public void onResume() { @Override public void onPause() { super.onPause(); - phoneEditText.removeTextChangedListener(phoneFormatter); subscriptions.unsubscribe(); + phoneEditText.removeTextChangedListener(phoneFormatter); } @OnCheckedChanged(R.id.checkbox_has_assistant) diff --git a/app/src/main/java/com/rockthevote/grommet/ui/registration/RegistrationActivity.java b/app/src/main/java/com/rockthevote/grommet/ui/registration/RegistrationActivity.java index 55502677..2a78a3f1 100644 --- a/app/src/main/java/com/rockthevote/grommet/ui/registration/RegistrationActivity.java +++ b/app/src/main/java/com/rockthevote/grommet/ui/registration/RegistrationActivity.java @@ -5,10 +5,12 @@ import android.support.design.widget.AppBarLayout; import android.support.v4.view.ViewPager; import android.support.v7.widget.Toolbar; +import android.transition.Slide; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.Window; import android.widget.Button; import android.widget.LinearLayout; @@ -61,6 +63,11 @@ public RegistrationActivity() { @Override protected void onCreate(Bundle savedInstanceState) { + // inside your activity (if you did not enable transitions in your theme) + getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); + getWindow().setExitTransition(new Slide()); + getWindow().setEnterTransition(new Slide()); + super.onCreate(savedInstanceState); ViewGroup contentView = getContentView(); @@ -123,12 +130,16 @@ public boolean onOptionsItemSelected(MenuItem item) { showCancelDialog(); return true; case R.id.action_english: - LocaleUtils.setLocale(new Locale("en")); - recreate(); + if (!Locale.getDefault().equals(new Locale("en"))) { + LocaleUtils.setLocale(new Locale("en")); + recreate(); + } return true; case R.id.action_espanol: - LocaleUtils.setLocale(new Locale("es")); - recreate(); + if (!Locale.getDefault().equals(new Locale("es"))) { + LocaleUtils.setLocale(new Locale("es")); + recreate(); + } return true; default: return super.onOptionsItemSelected(item); diff --git a/app/src/main/res/drawable/register_to_vote.xml b/app/src/main/res/drawable/register_to_vote.xml new file mode 100644 index 00000000..473ef10b --- /dev/null +++ b/app/src/main/res/drawable/register_to_vote.xml @@ -0,0 +1,365 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 2f7568ad..fa595c1a 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -121,7 +121,8 @@ android:layout_gravity="bottom|end" android:layout_marginBottom="@dimen/content_margin" android:layout_marginEnd="@dimen/content_margin" - android:src="@drawable/ic_add_black_24dp" + android:src="@drawable/register_to_vote" + android:scaleType="centerInside" android:tint="@android:color/white" app:elevation="4dp" app:fabSize="auto" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0b6513a2..069346ac 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,7 +65,7 @@ City Zip Code State - Unit # + Unit Type & Number County I get my mail from a different address from the one above I have changed my address