Skip to content

Commit

Permalink
Merge pull request #48 from huttneab/reg_flow_rearrange
Browse files Browse the repository at this point in the history
Rearrange Registration Flow
  • Loading branch information
huttneab authored Aug 15, 2016
2 parents 8e0cb90 + cf3b0d3 commit 49d3767
Show file tree
Hide file tree
Showing 35 changed files with 667 additions and 510 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ dependencies {
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.googlecode.libphonenumber:libphonenumber:7.5.2'

apt 'com.squareup.dagger:dagger-compiler:1.2.2'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public enum ApiEndpoints {
PRODUCTION("Production", ApiModule.PRODUCTION_API_URL.toString()),
STAGING("Staging","https://staging.rocky.rockthevote.com/v3"),
STAGING("Staging","https://staging.rocky.rockthevote.com/v3/"),
MOCK_MODE("Mock Mode", "http://localhost/mock/");
public final String name;
public final String url;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
library = true
)
public final class ApiModule {
public static final HttpUrl PRODUCTION_API_URL = HttpUrl.parse("http://register.rockthevote.org/v3");
public static final HttpUrl PRODUCTION_API_URL = HttpUrl.parse("http://register.rockthevote.org/v3/");

@Provides @Singleton HttpUrl provideBaseUrl() {
return PRODUCTION_API_URL;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.rockthevote.grommet.ui.misc;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout;
import android.support.v7.widget.ListPopupWindow;
import android.util.AttributeSet;
import android.widget.AdapterView;
import android.widget.ListAdapter;

import com.rockthevote.grommet.R;


public class BetterSpinner extends TextInputLayout {

ListPopupWindow listPopupWindow;
ListAdapter listAdapter;
TextInputEditText editText;

public BetterSpinner(Context context) {
this(context, null);
}

public BetterSpinner(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}

public BetterSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);

editText = new TextInputEditText(context);
editText.setId(R.id.titleId);
editText.setHeight((int) getResources().getDimension(R.dimen.list_item_height));
editText.setFocusable(false);
editText.setMaxLines(1);
editText.setCursorVisible(false);
editText.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0,
R.drawable.drop_down_arrow, 0);

addView(editText, 0);
listPopupWindow = new ListPopupWindow(context);
listPopupWindow.setAnchorView(editText);
}

public void setAdapter(ListAdapter listAdapter) {
this.listAdapter = listAdapter;
listPopupWindow.setAdapter(listAdapter);
getEditText().setOnClickListener(view -> listPopupWindow.show());
}

public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
listPopupWindow.setOnItemClickListener(listener);
}

public void dismiss() {
listPopupWindow.dismiss();
}

/**
* set the height of the popup window in pixes
*/
public void setHeight(int height) {
listPopupWindow.setHeight(height);
}

@NonNull
@Override
public TextInputEditText getEditText() {
return editText;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.rockthevote.grommet.ui.misc;

import com.mobsandgeeks.saripaar.adapter.ViewDataAdapter;
import com.mobsandgeeks.saripaar.exception.ConversionException;

public class BetterSpinnerValidator implements ViewDataAdapter<BetterSpinner, String> {
@Override
public String getData(BetterSpinner view) throws ConversionException {
if (view.getEditText() != null) {
return view.getEditText().getText().toString();
} else {
return "";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final V ch
final View target, final int dxConsumed, final int dyConsumed,
final int dxUnconsumed, final int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
if (dyConsumed > 10 && child.getVisibility() != View.VISIBLE) {
if (dyConsumed > 0 && child.getVisibility() != View.VISIBLE) {
animateIn(child);
} else if (dyConsumed == 0 && dyUnconsumed > 0 && child.getVisibility() != View.VISIBLE) {
animateIn(child);
} else if (dyConsumed < 0 && !this.mIsAnimatingOut && child.getVisibility() == View.VISIBLE) {
animateOut(child);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class ObservableValidator {
public ObservableValidator(Object controller, Context context) {
Validator validator = new Validator(controller);
validator.registerAdapter(TextInputLayout.class, new TilStringValidator());
validator.registerAdapter(BetterSpinner.class, new BetterSpinnerValidator());
validator.setViewValidatedAction(new Validator.ViewValidatedAction() {
@Override
public void onAllRulesPassed(View view) {
Expand Down
Loading

0 comments on commit 49d3767

Please sign in to comment.