Migrate from password manager (#39)
* Update gradle Change .gitignore & clean project * Change password manager * Change password manager * Change password manager * Cleaned up imports. Fixed the backup screen. * Update securitypull/2/head
parent
07264d542b
commit
44850ed5ce
@ -0,0 +1,151 @@ |
||||
package com.wallet.crypto.trustapp.widget; |
||||
|
||||
import android.content.Context; |
||||
import android.content.res.ColorStateList; |
||||
import android.content.res.TypedArray; |
||||
import android.support.design.widget.TextInputLayout; |
||||
import android.support.v4.view.ViewCompat; |
||||
import android.support.v4.view.ViewPropertyAnimatorListenerAdapter; |
||||
import android.support.v4.view.animation.FastOutSlowInInterpolator; |
||||
import android.text.TextUtils; |
||||
import android.util.AttributeSet; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.view.animation.Interpolator; |
||||
import android.widget.EditText; |
||||
import android.widget.TextView; |
||||
|
||||
import com.wallet.crypto.trustapp.R; |
||||
|
||||
/** |
||||
* TextInputLayout temporary workaround for helper text showing |
||||
* https://gist.github.com/drstranges/1a86965f582f610244d6
|
||||
*/ |
||||
public class HelperTextInputLayout extends TextInputLayout { |
||||
|
||||
static final Interpolator FAST_OUT_SLOW_IN_INTERPOLATOR = new FastOutSlowInInterpolator(); |
||||
|
||||
private CharSequence mHelperText; |
||||
private ColorStateList mHelperTextColor; |
||||
private boolean mHelperTextEnabled = false; |
||||
private boolean mErrorEnabled = false; |
||||
private TextView mHelperView; |
||||
private int mHelperTextAppearance = R.style.HelperTextAppearance; |
||||
|
||||
public HelperTextInputLayout(Context _context) { |
||||
super(_context); |
||||
} |
||||
|
||||
public HelperTextInputLayout(Context _context, AttributeSet _attrs) { |
||||
super(_context, _attrs); |
||||
|
||||
final TypedArray a = getContext().obtainStyledAttributes( |
||||
_attrs, |
||||
R.styleable.HelperTextInputLayout,0,0); |
||||
try { |
||||
mHelperTextColor = a.getColorStateList(R.styleable.HelperTextInputLayout_helperTextColor); |
||||
mHelperText = a.getText(R.styleable.HelperTextInputLayout_helperText); |
||||
} finally { |
||||
a.recycle(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void addView(View child, int index, ViewGroup.LayoutParams params) { |
||||
super.addView(child, index, params); |
||||
if (child instanceof EditText) { |
||||
if (!TextUtils.isEmpty(mHelperText)) { |
||||
setHelperText(mHelperText); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public int getHelperTextAppearance() { |
||||
return mHelperTextAppearance; |
||||
} |
||||
|
||||
public void setHelperTextAppearance(int _helperTextAppearanceResId) { |
||||
mHelperTextAppearance = _helperTextAppearanceResId; |
||||
} |
||||
|
||||
public void setHelperTextColor(ColorStateList _helperTextColor) { |
||||
mHelperTextColor = _helperTextColor; |
||||
} |
||||
|
||||
public void setHelperTextEnabled(boolean _enabled) { |
||||
if (mHelperTextEnabled == _enabled) return; |
||||
if (_enabled && mErrorEnabled) { |
||||
setErrorEnabled(false); |
||||
} |
||||
if (this.mHelperTextEnabled != _enabled) { |
||||
if (_enabled) { |
||||
this.mHelperView = new TextView(this.getContext()); |
||||
this.mHelperView.setTextAppearance(this.getContext(), this.mHelperTextAppearance); |
||||
if (mHelperTextColor != null){ |
||||
this.mHelperView.setTextColor(mHelperTextColor); |
||||
} |
||||
this.mHelperView.setVisibility(INVISIBLE); |
||||
this.addView(this.mHelperView); |
||||
if (this.mHelperView != null) { |
||||
ViewCompat.setPaddingRelative( |
||||
this.mHelperView, |
||||
ViewCompat.getPaddingStart(getEditText()), |
||||
0, ViewCompat.getPaddingEnd(getEditText()), |
||||
getEditText().getPaddingBottom()); |
||||
} |
||||
} else { |
||||
this.removeView(this.mHelperView); |
||||
this.mHelperView = null; |
||||
} |
||||
|
||||
this.mHelperTextEnabled = _enabled; |
||||
} |
||||
} |
||||
|
||||
public void setHelperText(CharSequence _helperText) { |
||||
mHelperText = _helperText; |
||||
if (!this.mHelperTextEnabled) { |
||||
if (TextUtils.isEmpty(mHelperText)) { |
||||
return; |
||||
} |
||||
this.setHelperTextEnabled(true); |
||||
} |
||||
|
||||
if (!TextUtils.isEmpty(mHelperText)) { |
||||
this.mHelperView.setText(mHelperText); |
||||
this.mHelperView.setVisibility(VISIBLE); |
||||
ViewCompat.setAlpha(this.mHelperView, 0.0F); |
||||
ViewCompat.animate(this.mHelperView) |
||||
.alpha(1.0F).setDuration(200L) |
||||
.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR) |
||||
.setListener(null).start(); |
||||
} else if (this.mHelperView.getVisibility() == VISIBLE) { |
||||
ViewCompat.animate(this.mHelperView) |
||||
.alpha(0.0F).setDuration(200L) |
||||
.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR) |
||||
.setListener(new ViewPropertyAnimatorListenerAdapter() { |
||||
public void onAnimationEnd(View view) { |
||||
mHelperView.setText(null); |
||||
mHelperView.setVisibility(INVISIBLE); |
||||
} |
||||
}).start(); |
||||
} |
||||
this.sendAccessibilityEvent(2048); |
||||
} |
||||
|
||||
@Override |
||||
public void setErrorEnabled(boolean _enabled) { |
||||
if (mErrorEnabled == _enabled) return; |
||||
mErrorEnabled = _enabled; |
||||
if (_enabled && mHelperTextEnabled) { |
||||
setHelperTextEnabled(false); |
||||
} |
||||
|
||||
super.setErrorEnabled(_enabled); |
||||
|
||||
if (!(_enabled || TextUtils.isEmpty(mHelperText))) { |
||||
setHelperText(mHelperText); |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,26 +1,63 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
<FrameLayout |
||||
xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
tools:context="com.wallet.crypto.trustapp.views.ExportAccountActivity"> |
||||
|
||||
<android.support.design.widget.AppBarLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:theme="@style/AppTheme.AppBarOverlay"> |
||||
|
||||
<android.support.v7.widget.Toolbar |
||||
android:id="@+id/toolbar" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="?attr/actionBarSize" |
||||
android:title="@string/action_export" |
||||
android:background="?attr/colorPrimary" |
||||
app:popupTheme="@style/AppTheme.PopupOverlay" /> |
||||
|
||||
</android.support.design.widget.AppBarLayout> |
||||
|
||||
<include layout="@layout/content_export_account" /> |
||||
|
||||
</android.support.design.widget.CoordinatorLayout> |
||||
> |
||||
<android.support.v7.widget.Toolbar |
||||
android:id="@+id/toolbar" |
||||
android:title="@string/action_export" |
||||
android:background="?attr/colorPrimary" |
||||
app:popupTheme="@style/AppTheme.PopupOverlay" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="?attr/actionBarSize" |
||||
/> |
||||
<LinearLayout |
||||
android:orientation="vertical" |
||||
android:padding="16dp" |
||||
android:layout_marginTop="?actionBarSize" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
> |
||||
<com.wallet.crypto.trustapp.widget.HelperTextInputLayout |
||||
app:helperText="@string/backup_new_password_text" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
> |
||||
<EditText |
||||
android:id="@+id/password" |
||||
android:hint="@string/label_new_password" |
||||
android:imeActionLabel="@string/action_sign_in_short" |
||||
android:imeOptions="actionUnspecified" |
||||
android:maxLines="1" |
||||
android:singleLine="true" |
||||
android:inputType="textPassword" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
/> |
||||
</com.wallet.crypto.trustapp.widget.HelperTextInputLayout> |
||||
<android.support.design.widget.TextInputLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content"> |
||||
<EditText |
||||
android:id="@+id/confirm_password" |
||||
android:hint="@string/label_confirm_new_password" |
||||
android:imeActionLabel="@string/action_sign_in_short" |
||||
android:imeOptions="actionUnspecified" |
||||
android:inputType="textPassword" |
||||
android:maxLines="1" |
||||
android:singleLine="true" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
/> |
||||
</android.support.design.widget.TextInputLayout> |
||||
<Button |
||||
android:id="@+id/export_account_button" |
||||
android:text="@string/action_backup" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
/> |
||||
</LinearLayout> |
||||
</FrameLayout> |
||||
|
@ -1,63 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" |
||||
tools:context="com.wallet.crypto.trustapp.views.ExportAccountActivity" |
||||
tools:showIn="@layout/activity_export_account"> |
||||
|
||||
<LinearLayout |
||||
android:id="@+id/import_form" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:padding="16dp" |
||||
android:orientation="vertical"> |
||||
|
||||
<android.support.design.widget.TextInputLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content"> |
||||
|
||||
<EditText |
||||
android:id="@+id/export_password" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:hint="@string/label_new_password" |
||||
android:imeActionLabel="@string/action_sign_in_short" |
||||
android:imeOptions="actionUnspecified" |
||||
android:inputType="textPassword" |
||||
android:maxLines="1" |
||||
android:singleLine="true" /> |
||||
|
||||
</android.support.design.widget.TextInputLayout> |
||||
|
||||
<android.support.design.widget.TextInputLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content"> |
||||
|
||||
<EditText |
||||
android:id="@+id/confirm_password" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:hint="@string/label_confirm_new_password" |
||||
android:imeActionLabel="@string/action_sign_in_short" |
||||
android:imeOptions="actionUnspecified" |
||||
android:inputType="textPassword" |
||||
android:maxLines="1" |
||||
android:singleLine="true" /> |
||||
|
||||
</android.support.design.widget.TextInputLayout> |
||||
|
||||
<Button |
||||
android:id="@+id/export_account_button" |
||||
style="?android:textAppearanceSmall" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="16dp" |
||||
android:text="@string/action_backup" |
||||
android:textStyle="bold" /> |
||||
|
||||
</LinearLayout> |
||||
|
||||
</android.support.constraint.ConstraintLayout> |
@ -1,13 +1,17 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<color name="colorPrimary">#2e91db</color> |
||||
<color name="colorPrimaryDark">#1E76CE</color> |
||||
<color name="colorAccent">#2e91db</color> |
||||
<color name="green">#2fbb4f</color> |
||||
<color name="red">#f7506c</color> |
||||
<color name="colorWhite">#FFFFFFFF</color> |
||||
<color name="semitransparentWhite">#AAFFFFFF</color> |
||||
<color name="QRCodeBlackColor">#FF000000</color> |
||||
<color name="QRCodeWhiteColor">#FFFFFFFF</color> |
||||
<color name="black">#313849</color> |
||||
<color name="green">#2fbb4f</color> |
||||
<color name="red">#f7506c</color> |
||||
<color name="white">#FFFFFFFF</color> |
||||
<color name="black">#313849</color> |
||||
|
||||
<color name="colorPrimary">#2e91db</color> |
||||
<color name="colorPrimaryDark">#1E76CE</color> |
||||
<color name="colorAccent">#2e91db</color> |
||||
<color name="secondary_text">#40000000</color> |
||||
|
||||
<color name="semitransparentWhite">#AAFFFFFF</color> |
||||
|
||||
<color name="QRCodeBlackColor">#FF000000</color> |
||||
<color name="QRCodeWhiteColor">#FFFFFFFF</color> |
||||
</resources> |
||||
|
@ -0,0 +1,12 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
|
||||
<declare-styleable name="HelperTextInputLayout"> |
||||
<attr name="helperText" format="string"/> |
||||
<attr name="helperTextColor" format="color|reference"/> |
||||
</declare-styleable> |
||||
|
||||
<style name="HelperTextAppearance" parent="TextAppearance.Design.Error"> |
||||
<item name="android:textColor">@color/secondary_text</item> |
||||
</style> |
||||
</resources> |
Loading…
Reference in new issue