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

UI Improvements: Bigger buttons/fields #314

Merged
merged 4 commits into from
Aug 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -160,7 +160,7 @@ public void configure(@Nullable Configuration configuration) {
}

private void showConfigurationMissingLayout(@StringRes int errorMessage) {
int horizontalMargin = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_horizontal_margin);
int horizontalMargin = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_horizontal_margin);
final LinearLayout errorLayout = new LinearLayout(getContext());
errorLayout.setOrientation(LinearLayout.VERTICAL);
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void setupBackground() {
Drawable bg = parent.getBackground();
GradientDrawable gd = bg == null ? new GradientDrawable() : (GradientDrawable) bg;
gd.setCornerRadius(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_corner_radius));
gd.setStroke((int) getResources().getDimension(R.dimen.com_auth0_lock_input_field_stroke_width), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal));
gd.setStroke(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_input_field_stroke_width), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal));
gd.setColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal));
ViewUtils.setBackground(parent, gd);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ private void init() {
}

private LinearLayout.LayoutParams defineFieldParams() {
int horizontalMargin = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_horizontal_margin);
int verticalMargin = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_vertical_margin_field);
int horizontalMargin = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_horizontal_margin);
int verticalMargin = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER_HORIZONTAL;
params.setMargins(horizontalMargin, verticalMargin / 2, horizontalMargin, verticalMargin / 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ private void init() {
showEnterprise = !lockWidget.getConfiguration().getEnterpriseStrategies().isEmpty();
boolean showModeSelection = showDatabase && lockWidget.getConfiguration().allowLogIn() && lockWidget.getConfiguration().allowSignUp();

int verticalMargin = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_vertical_margin_field);
int horizontalMargin = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_horizontal_margin);
int verticalMargin = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field);
int horizontalMargin = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_horizontal_margin);

if (showModeSelection) {
Log.v(TAG, "Showing the LogIn/SignUp tabs");
Expand Down Expand Up @@ -147,9 +147,9 @@ private void addSeparator() {
orSeparatorMessage.setTextColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_text));
orSeparatorMessage.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.com_auth0_lock_title_text));
orSeparatorMessage.setGravity(Gravity.CENTER);
int verticalPadding = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_vertical_margin_field);
int verticalPadding = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field);
orSeparatorMessage.setPadding(0, verticalPadding, 0, verticalPadding);
formsHolder.addView(orSeparatorMessage, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
formsHolder.addView(orSeparatorMessage, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* TextView that removes the extra padding added in pre Lollipop APIs when
* using the lineSpacingExtra attribute.
*/
public class LineSpacingTextView extends TextView {
class LineSpacingTextView extends TextView {

public LineSpacingTextView(Context context) {
super(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ private void init() {
}
addPasswordlessRequestCodeLayout();
}
final int verticalPadding = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field);
setPadding(0, verticalPadding, 0, verticalPadding);
}

private void addSocialLayout(boolean passwordlessAvailable) {
Expand Down Expand Up @@ -106,7 +108,7 @@ private void addSeparator() {
orSeparatorMessage.setTextColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_text));
orSeparatorMessage.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.com_auth0_lock_title_text));
orSeparatorMessage.setGravity(Gravity.CENTER);
int verticalPadding = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_vertical_margin_field);
int verticalPadding = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field);
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, verticalPadding, 0, verticalPadding);
addView(orSeparatorMessage, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ private void showContentLayout() {
HeaderView headerView = new HeaderView(getContext(), lockTheme);
addView(headerView, wrapHeightParams);

int horizontalMargin = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_horizontal_margin);
int verticalMargin = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field);
int horizontalMargin = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_horizontal_margin);
formLayout = new PasswordlessFormLayout(this);
LayoutParams formLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
formLayoutParams.setMargins(horizontalMargin, 0, horizontalMargin, 0);
formLayout.setPadding(horizontalMargin, verticalMargin, horizontalMargin, verticalMargin);
addView(formLayout, formLayoutParams);

boolean showPasswordless = configuration.getDefaultPasswordlessStrategy() != null;
Expand Down Expand Up @@ -119,7 +120,7 @@ public void configure(@Nullable Configuration configuration) {
}

private void showConfigurationMissingLayout(@StringRes int errorMessage) {
int horizontalMargin = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_horizontal_margin);
int horizontalMargin = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_horizontal_margin);
final LinearLayout errorLayout = new LinearLayout(getContext());
errorLayout.setOrientation(LinearLayout.VERTICAL);
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private Map<String, String> getCustomFieldValues() {
}

private LinearLayout.LayoutParams defineFieldParams() {
int verticalMargin = (int) getResources().getDimension(R.dimen.com_auth0_lock_widget_vertical_margin_field);
int verticalMargin = getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER_HORIZONTAL;
params.setMargins(0, verticalMargin, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.auth0.android.lock.R;
import com.auth0.android.lock.events.SocialConnectionEvent;
import com.auth0.android.lock.utils.json.Strategy;
import com.auth0.android.lock.views.interfaces.LockWidgetSocial;
Expand Down Expand Up @@ -59,14 +60,17 @@ private void init(boolean smallButtons) {
SocialViewAdapter adapter = new SocialViewAdapter(getContext(), socialStrategies);
adapter.setButtonSize(smallButtons);
adapter.setCallback(this);
LayoutManager lm = new GridLayoutManager(getContext(), 1, smallButtons ? HORIZONTAL : VERTICAL, false);
final int orientation = smallButtons ? HORIZONTAL : VERTICAL;
LayoutManager lm = new GridLayoutManager(getContext(), 1, orientation, false);
recycler.setLayoutManager(lm);
recycler.setHasFixedSize(true);
recycler.setAdapter(adapter);
recycler.setOverScrollMode(OVER_SCROLL_NEVER);
final SpacesItemDecoration spaceDecoration = new SpacesItemDecoration(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_social), orientation);
recycler.addItemDecoration(spaceDecoration);
LayoutParams recyclerParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
addView(recycler, recyclerParams);
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.auth0.android.lock.views;

import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;

class SpacesItemDecoration extends RecyclerView.ItemDecoration {
private final int orientation;
private final int space;

public SpacesItemDecoration(int space, @LinearLayoutCompat.OrientationMode int orientation) {
this.space = space;
this.orientation = orientation;
}

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
if (parent.getChildAdapterPosition(view) == 0) {
return;
}

if (orientation == RecyclerView.HORIZONTAL) {
outRect.left = space;
} else {
outRect.top = space;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ protected void updateBorder(boolean isValid) {
GradientDrawable gd = bg == null ? new GradientDrawable() : (GradientDrawable) bg;
gd.setCornerRadius(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_corner_radius));
int strokeColor = isValid ? R.color.com_auth0_lock_input_field_border_normal : R.color.com_auth0_lock_input_field_border_error;
gd.setStroke((int) getResources().getDimension(R.dimen.com_auth0_lock_input_field_stroke_width), ContextCompat.getColor(getContext(), strokeColor));
gd.setStroke(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_input_field_stroke_width), ContextCompat.getColor(getContext(), strokeColor));
gd.setColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal));
ViewUtils.setBackground(parent, gd);

Expand Down
4 changes: 1 addition & 3 deletions lib/src/main/res/layout/com_auth0_lock_btn_social_small.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@

<ImageView
android:id="@+id/com_auth0_lock_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
style="@style/Lock.Theme.Widget.Icon.Social"
tools:background="#FF3333"
tools:src="@drawable/com_auth0_lock_ic_social_auth0" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/com_auth0_lock_widget_vertical_margin_field"
android:layout_marginTop="@dimen/com_auth0_lock_widget_vertical_margin_field"
android:paddingBottom="@dimen/com_auth0_lock_widget_vertical_margin_field"
android:paddingTop="@dimen/com_auth0_lock_widget_vertical_margin_field"
android:gravity="center"
android:orientation="vertical">

Expand Down
9 changes: 6 additions & 3 deletions lib/src/main/res/layout/com_auth0_lock_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lock="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/com_auth0_lock_header_background"
android:layout_width="match_parent"
Expand All @@ -35,14 +36,16 @@
<ImageView
android:id="@+id/com_auth0_lock_header_logo"
style="@style/Lock.Theme.Widget.Logo"
android:layout_marginTop="@dimen/com_auth0_lock_header_vertical_margin"
android:fitsSystemWindows="false"
android:paddingTop="@dimen/com_auth0_lock_header_vertical_margin"
android:src="?attr/Auth0.HeaderLogo" />
lock:srcCompat="?attr/Auth0.HeaderLogo"
tools:ignore="MissingPrefix"
tools:srcCompat="@drawable/com_auth0_lock_header_logo" />

<TextView
android:id="@+id/com_auth0_lock_header_text"
style="@style/Lock.Theme.Text.Header"
android:layout_below="@id/com_auth0_lock_header_logo"
android:paddingBottom="@dimen/com_auth0_lock_header_vertical_margin"
android:layout_marginBottom="@dimen/com_auth0_lock_header_vertical_margin"
tools:text="Auth0" />
</RelativeLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/com_auth0_lock_widget_vertical_margin_field"
android:layout_marginLeft="@dimen/com_auth0_lock_widget_horizontal_margin"
android:layout_marginRight="@dimen/com_auth0_lock_widget_horizontal_margin"
android:layout_marginTop="@dimen/com_auth0_lock_widget_vertical_margin_field"
android:gravity="center"
android:orientation="vertical">
android:orientation="vertical"
android:paddingBottom="@dimen/com_auth0_lock_widget_vertical_margin_field"
android:paddingLeft="@dimen/com_auth0_lock_widget_horizontal_margin"
android:paddingRight="@dimen/com_auth0_lock_widget_horizontal_margin"
android:paddingTop="@dimen/com_auth0_lock_widget_vertical_margin_field">

<com.auth0.android.lock.views.LineSpacingTextView
android:id="@+id/com_auth0_lock_title"
Expand Down
78 changes: 0 additions & 78 deletions lib/src/main/res/values-long/dimens.xml

This file was deleted.

Loading