Skip to content

Commit

Permalink
Deactivate vertical layout scrolling (e.g. due to very long passwords…
Browse files Browse the repository at this point in the history
…) during horizontal scrolling in a password field. Additional small adjustments in regard to the layout.
  • Loading branch information
tejado committed Dec 21, 2016
1 parent 45ab4d9 commit aa2b808
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.MotionEvent;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
Expand Down Expand Up @@ -222,7 +223,35 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
TypefaceUtils.setMonospace(itsPasswordCurrent, ctx);
itsPasswordInput = (TextInputLayout)
rootView.findViewById(R.id.password_input);


itsPassword = (TextView)rootView.findViewById(R.id.password);

// disable vertical scrolling if scrolling is already in progress in the TextView
// http://stackoverflow.com/a/22609646
// thanks to Hardik <http://stackoverflow.com/users/1135548/hardik>
itsPassword.setOnTouchListener(new TextView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow View to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;

case MotionEvent.ACTION_UP:
// Allow View to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}

// Handle HorizontalScrollView touch events.
v.onTouchEvent(event);
return true;
}
});

TypefaceUtils.setMonospace(itsPassword, ctx);
View passwordVisibility =
rootView.findViewById(R.id.password_visibility);
Expand All @@ -237,6 +266,29 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
rootView.findViewById(R.id.password_confirm_input);
itsPasswordConfirm = (TextView)
rootView.findViewById(R.id.password_confirm);
itsPasswordConfirm.setOnTouchListener(new TextView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow View to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;

case MotionEvent.ACTION_UP:
// Allow View to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}

// Handle HorizontalScrollView touch events.
v.onTouchEvent(event);
return true;
}
});


TypefaceUtils.setMonospace(itsPasswordConfirm, ctx);
itsValidator.registerTextView(itsPasswordConfirm);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
Expand Down
49 changes: 30 additions & 19 deletions authorizer/src/main/res/layout/fragment_passwdsafe_edit_record.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@
android:id="@+id/password_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="false">
app:passwordToggleEnabled="false"
android:layout_toLeftOf="@+id/password_visibility"
android:layout_toStartOf="@+id/password_visibility">
<android.support.design.widget.TextInputEditText
android:id="@+id/password"
android:layout_width="match_parent"
Expand All @@ -221,34 +223,43 @@
android:clickable="true"
android:contentDescription="@string/show_passwords"
android:longClickable="true"
android:src="?attr/drawableActionVisibility"/>
android:src="?attr/drawableActionVisibility"
android:tint="@color/colorPrimary"/>

</RelativeLayout>

<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="@+id/password_confirm_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="false"
android:layout_toLeftOf="@+id/password_generate"
android:layout_toStartOf="@+id/password_generate">
<android.support.design.widget.TextInputEditText
android:id="@+id/password_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/confirm"
android:inputType="textPassword"
android:singleLine="true"/>
</android.support.design.widget.TextInputLayout>

<ImageView android:id="@+id/password_generate"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_toLeftOf="@id/password_visibility"
android:layout_toStartOf="@id/password_visibility"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:clickable="true"
android:contentDescription="@string/generate_password"
android:longClickable="true"
android:src="?attr/drawableActionNewPassword"/>
</RelativeLayout>
android:src="?attr/drawableActionNewPassword"
android:tint="@color/colorPrimary"/>

<android.support.design.widget.TextInputLayout
android:id="@+id/password_confirm_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="false">
<android.support.design.widget.TextInputEditText
android:id="@+id/password_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/confirm"
android:inputType="textPassword"
android:singleLine="true"/>
</android.support.design.widget.TextInputLayout>
</RelativeLayout>

<!-- Password policy -->
<TextView android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<android.support.design.widget.TextInputLayout
android:id="@+id/passwd_input"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="@+id/passwd_edit"
Expand Down

0 comments on commit aa2b808

Please sign in to comment.