add fancy context menu in detail view

add toggle password visibility feedback
pull/8/head
Felix Prahl-Kamps 2019-10-06 20:08:01 +02:00
parent 21af9e1307
commit 31e4ed56fd
9 changed files with 206 additions and 29 deletions

View File

@ -262,34 +262,6 @@ public class SyncInfoDetailActivity extends AppCompatActivity {
dataLocallyChanged = true;
});
// CheckBox allowSelfSigned = findViewById(R.id.checkbox_self_signed);
// allowSelfSigned.setChecked(syncInformation.getRemote().getServer().getSelfSigned());
// allowSelfSigned.setOnCheckedChangeListener((compoundButton, b) -> {
// syncInformation.getRemote().getServer().setSelfSigned(b);
// dataLocallyChanged = true;
// });
// CheckBox push = findViewById(R.id.checkbox_push);
// push.setChecked(syncInformation.getRemote().getServer().getPush());
// push.setOnCheckedChangeListener((compoundButton, b) -> {
// syncInformation.getRemote().getServer().setPush(b);
// dataLocallyChanged = true;
// });
//
// CheckBox pull = findViewById(R.id.checkbox_pull);
// pull.setChecked(syncInformation.getRemote().getServer().getPull());
// pull.setOnCheckedChangeListener((compundButton, b) -> {
// syncInformation.getRemote().getServer().setPull(b);
// dataLocallyChanged = true;
// });
//
// CheckBox cache = findViewById(R.id.checkbox_cache);
// cache.setChecked(syncInformation.getRemote().getServer().getCachingEnabled());
// cache.setOnCheckedChangeListener((compoundButton, b) -> {
// syncInformation.getRemote().getServer().setCachingEnabled(b);
// dataLocallyChanged = true;
// });
// credentials
MaterialPreferenceText email = findViewById(R.id.email);

View File

@ -3,6 +3,7 @@ package lu.circl.mispbump.customViews;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.text.method.PasswordTransformationMethod;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@ -38,11 +39,19 @@ public class MaterialPasswordView extends ConstraintLayout {
passwordView.setText(password);
ImageButton visibleToggle = findViewById(R.id.visibleToggle);
AnimatedVectorDrawable lookAway = (AnimatedVectorDrawable) context.getDrawable(R.drawable.animated_eye_to_up);
AnimatedVectorDrawable lookCenter = (AnimatedVectorDrawable) context.getDrawable(R.drawable.animated_eye_to_center);
visibleToggle.setOnClickListener(v -> {
if (passwordView.getTransformationMethod() == null) {
passwordView.setTransformationMethod(new PasswordTransformationMethod());
visibleToggle.setImageDrawable(lookCenter);
lookCenter.start();
} else {
passwordView.setTransformationMethod(null);
visibleToggle.setImageDrawable(lookAway);
lookAway.start();
}
});
}

View File

@ -0,0 +1,44 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="group"
android:pivotX="12"
android:pivotY="12">
<path
android:name="cloud"
android:pathData="M 19.35 10.04 C 18.67 6.59 15.64 4 12 4 C 9.11 4 6.6 5.64 5.35 8.04 C 2.34 8.36 0 10.91 0 14 C 0 17.31 2.69 20 6 20 L 19 20 C 21.76 20 24 17.76 24 15 C 24 12.36 21.95 10.22 19.35 10.04 Z M 19 18 L 6 18 C 3.79 18 2 16.21 2 14 C 2 11.79 3.79 10 6 10 L 6.71 10 C 7.37 7.69 9.48 6 12 6 C 15.04 6 17.5 8.46 17.5 11.5 L 17.5 12 L 19 12 C 20.66 12 22 13.34 22 15 C 22 16.66 20.66 18 19 18 Z"
android:fillColor="#000"
android:strokeWidth="1" />
</group>
</vector>
</aapt:attr>
<target android:name="cloud">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="300"
android:valueFrom="M 14.588 4.459 C 15.395 4.755 16.136 5.187 16.785 5.726 C 17.434 6.266 17.99 6.913 18.427 7.641 C 18.863 8.369 19.18 9.178 19.35 10.04 C 19.35 10.04 19.35 10.04 19.35 10.04 C 21.95 10.22 24 12.36 24 15 C 24 17.76 21.76 20 19 20 C 14.667 20 10.333 20 6 20 C 2.69 20 0 17.31 0 14 C 0 10.91 2.34 8.36 5.35 8.04 C 6.6 5.64 9.11 4 12 4 C 12.91 4 13.782 4.162 14.588 4.459 M 6.71 10 L 6 10 C 3.79 10 2 11.79 2 14 C 2 16.21 3.79 18 6 18 L 19 18 L 19 18 C 20.66 18 22 16.66 22 15 C 22 13.34 20.66 12 19 12 L 17.5 12 L 17.5 11.5 C 17.5 8.46 15.04 6 12 6 C 9.48 6 7.37 7.69 6.71 10"
android:valueTo="M 8.12 9.29 C 9.413 10.583 10.707 11.877 12 13.17 C 13.293 11.877 14.587 10.583 15.88 9.29 C 16.27 8.9 16.9 8.9 17.29 9.29 C 17.68 9.68 17.68 10.31 17.29 10.7 C 16.525 11.465 15.76 12.23 14.995 12.995 C 14.23 13.76 13.465 14.525 12.7 15.29 C 12.31 15.68 11.68 15.68 11.29 15.29 C 9.76 13.76 8.23 12.23 6.7 10.7 C 6.31 10.31 6.31 9.68 6.7 9.29 C 7.09 8.91 7.73 8.9 8.12 9.29 C 8.12 9.29 8.12 9.29 8.12 9.29 M 11.75 12.75 L 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 L 11.75 12.75 L 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 L 11.75 12.75 L 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
</aapt:attr>
</target>
<target android:name="group">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="rotation"
android:duration="300"
android:valueFrom="0"
android:valueTo="360"
android:valueType="floatType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,44 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="group"
android:pivotX="12"
android:pivotY="12">
<path
android:name="cloud"
android:pathData="M 19.35 10.04 C 18.67 6.59 15.64 4 12 4 C 9.11 4 6.6 5.64 5.35 8.04 C 2.34 8.36 0 10.91 0 14 C 0 17.31 2.69 20 6 20 L 19 20 C 21.76 20 24 17.76 24 15 C 24 12.36 21.95 10.22 19.35 10.04 Z M 19 18 L 6 18 C 3.79 18 2 16.21 2 14 C 2 11.79 3.79 10 6 10 L 6.71 10 C 7.37 7.69 9.48 6 12 6 C 15.04 6 17.5 8.46 17.5 11.5 L 17.5 12 L 19 12 C 20.66 12 22 13.34 22 15 C 22 16.66 20.66 18 19 18 Z"
android:fillColor="#000"
android:strokeWidth="1" />
</group>
</vector>
</aapt:attr>
<target android:name="cloud">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="400"
android:valueFrom="M 17.29 9.29 C 16.9 8.9 16.27 8.9 15.88 9.29 C 14.587 10.583 13.293 11.877 12 13.17 C 10.707 11.877 9.413 10.583 8.12 9.29 C 8.12 9.29 8.12 9.29 8.12 9.29 C 7.73 8.9 7.09 8.91 6.7 9.29 C 6.31 9.68 6.31 10.31 6.7 10.7 C 8.23 12.23 9.76 13.76 11.29 15.29 C 11.68 15.68 12.31 15.68 12.7 15.29 C 13.465 14.525 14.23 13.76 14.995 12.995 C 15.76 12.23 16.525 11.465 17.29 10.7 C 17.68 10.31 17.68 9.68 17.29 9.29 M 11.75 12.75 L 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 L 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 L 11.75 12.75 L 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 C 11.75 12.75 11.75 12.75 11.75 12.75 L 11.75 12.75"
android:valueTo="M 19.35 10.04 C 19.18 9.178 18.863 8.369 18.427 7.641 C 17.99 6.913 17.434 6.266 16.785 5.726 C 16.136 5.187 15.395 4.755 14.588 4.459 C 13.782 4.162 12.91 4 12 4 C 9.11 4 6.6 5.64 5.35 8.04 C 2.34 8.36 0 10.91 0 14 C 0 17.31 2.69 20 6 20 C 10.333 20 14.667 20 19 20 C 21.76 20 24 17.76 24 15 C 24 12.36 21.95 10.22 19.35 10.04 C 19.35 10.04 19.35 10.04 19.35 10.04 M 19 18 L 6 18 C 3.79 18 2 16.21 2 14 C 2 11.79 3.79 10 6 10 L 6.71 10 C 7.37 7.69 9.48 6 12 6 C 15.04 6 17.5 8.46 17.5 11.5 L 17.5 12 L 19 12 C 20.66 12 22 13.34 22 15 C 22 16.66 20.66 18 19 18 L 19 18"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
</aapt:attr>
</target>
<target android:name="group">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="rotation"
android:duration="400"
android:valueFrom="0"
android:valueTo="0"
android:valueType="floatType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,27 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="down"
android:pathData="M 8.12 9.29 L 12 13.17 L 15.88 9.29 C 16.27 8.9 16.9 8.9 17.29 9.29 C 17.68 9.68 17.68 10.31 17.29 10.7 L 12.7 15.29 C 12.31 15.68 11.68 15.68 11.29 15.29 L 6.7 10.7 C 6.31 10.31 6.31 9.68 6.7 9.29 C 7.09 8.91 7.73 8.9 8.12 9.29 Z"
android:fillColor="#FF000000" />
</vector>
</aapt:attr>
<target android:name="down">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="250"
android:valueFrom="M 8.12 9.29 L 12 13.17 L 15.88 9.29 C 16.27 8.9 16.9 8.9 17.29 9.29 C 17.68 9.68 17.68 10.31 17.29 10.7 L 12.7 15.29 C 12.31 15.68 11.68 15.68 11.29 15.29 L 6.7 10.7 C 6.31 10.31 6.31 9.68 6.7 9.29 C 7.09 8.91 7.73 8.9 8.12 9.29 Z"
android:valueTo="M 8.12 14.71 L 12 10.83 L 15.88 14.71 C 16.27 15.1 16.9 15.1 17.29 14.71 C 17.68 14.32 17.68 13.69 17.29 13.3 L 12.7 8.71 C 12.31 8.32 11.68 8.32 11.29 8.71 L 6.7 13.3 C 6.31 13.69 6.31 14.32 6.7 14.71 C 7.09 15.09 7.73 15.1 8.12 14.71 Z"
android:valueType="pathType"
android:interpolator="@android:anim/accelerate_decelerate_interpolator" />
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,27 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="down"
android:pathData="M 8.12 9.29 L 12 13.17 L 15.88 9.29 C 16.27 8.9 16.9 8.9 17.29 9.29 C 17.68 9.68 17.68 10.31 17.29 10.7 L 12.7 15.29 C 12.31 15.68 11.68 15.68 11.29 15.29 L 6.7 10.7 C 6.31 10.31 6.31 9.68 6.7 9.29 C 7.09 8.91 7.73 8.9 8.12 9.29 Z"
android:fillColor="#FF000000" />
</vector>
</aapt:attr>
<target android:name="down">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="250"
android:valueFrom="M 8.12 14.71 L 12 10.83 L 15.88 14.71 C 16.27 15.1 16.9 15.1 17.29 14.71 C 17.68 14.32 17.68 13.69 17.29 13.3 L 12.7 8.71 C 12.31 8.32 11.68 8.32 11.29 8.71 L 6.7 13.3 C 6.31 13.69 6.31 14.32 6.7 14.71 C 7.09 15.09 7.73 15.1 8.12 14.71 Z"
android:valueTo="M 8.12 9.29 L 12 13.17 L 15.88 9.29 C 16.27 8.9 16.9 8.9 17.29 9.29 C 17.68 9.68 17.68 10.31 17.29 10.7 L 12.7 15.29 C 12.31 15.68 11.68 15.68 11.29 15.29 L 6.7 10.7 C 6.31 10.31 6.31 9.68 6.7 9.29 C 7.09 8.91 7.73 8.9 8.12 9.29 Z"
android:valueType="pathType"
android:interpolator="@android:anim/accelerate_decelerate_interpolator" />
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,27 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="eye_visible"
android:pathData="M 12 4.5 C 7 4.5 2.73 7.61 1 12 C 2.73 16.39 7 19.5 12 19.5 C 17 19.5 21.27 16.39 23 12 C 21.27 7.61 17 4.5 12 4.5 Z M 12 17 C 9.24 17 7 14.76 7 12 C 7 9.24 9.24 7 12 7 C 14.76 7 17 9.24 17 12 C 17 14.76 14.76 17 12 17 Z M 12 9 C 10.34 9 9 10.34 9 12 C 9 13.66 10.34 15 12 15 C 13.66 15 15 13.66 15 12 C 15 10.34 13.66 9 12 9 Z"
android:fillColor="#FF000000" />
</vector>
</aapt:attr>
<target android:name="eye_visible">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="300"
android:valueFrom="M 12 4.5 C 7 4.5 2.73 7.61 1 12 C 2.73 16.39 7 19.5 12 19.5 C 17 19.5 21.27 16.39 23 12 C 21.27 7.61 17 4.5 12 4.5 Z M 12 17 C 9.24 17 7 14.76 7 12 C 7 9.24 9.24 7 12 7 C 14.76 7 17 9.24 17 12 C 17 14.76 14.76 17 12 17 Z M 14.411 6.703 C 12.751 6.703 11.411 8.043 11.411 9.703 C 11.411 11.363 12.751 12.703 14.411 12.703 C 16.071 12.703 17.411 11.363 17.411 9.703 C 17.411 8.043 16.071 6.703 14.411 6.703 Z"
android:valueTo="M 12 4.5 C 7 4.5 2.73 7.61 1 12 C 2.73 16.39 7 19.5 12 19.5 C 17 19.5 21.27 16.39 23 12 C 21.27 7.61 17 4.5 12 4.5 Z M 12 17 C 9.24 17 7 14.76 7 12 C 7 9.24 9.24 7 12 7 C 14.76 7 17 9.24 17 12 C 17 14.76 14.76 17 12 17 Z M 12 9 C 10.34 9 9 10.34 9 12 C 9 13.66 10.34 15 12 15 C 13.66 15 15 13.66 15 12 C 15 10.34 13.66 9 12 9 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,27 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="eye_visible"
android:pathData="M 12 4.5 C 7 4.5 2.73 7.61 1 12 C 2.73 16.39 7 19.5 12 19.5 C 17 19.5 21.27 16.39 23 12 C 21.27 7.61 17 4.5 12 4.5 Z M 12 17 C 9.24 17 7 14.76 7 12 C 7 9.24 9.24 7 12 7 C 14.76 7 17 9.24 17 12 C 17 14.76 14.76 17 12 17 Z M 12 9 C 10.34 9 9 10.34 9 12 C 9 13.66 10.34 15 12 15 C 13.66 15 15 13.66 15 12 C 15 10.34 13.66 9 12 9 Z"
android:fillColor="#FF000000" />
</vector>
</aapt:attr>
<target android:name="eye_visible">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="300"
android:valueFrom="M 12 4.5 C 7 4.5 2.73 7.61 1 12 C 2.73 16.39 7 19.5 12 19.5 C 17 19.5 21.27 16.39 23 12 C 21.27 7.61 17 4.5 12 4.5 Z M 12 17 C 9.24 17 7 14.76 7 12 C 7 9.24 9.24 7 12 7 C 14.76 7 17 9.24 17 12 C 17 14.76 14.76 17 12 17 Z M 12 9 C 10.34 9 9 10.34 9 12 C 9 13.66 10.34 15 12 15 C 13.66 15 15 13.66 15 12 C 15 10.34 13.66 9 12 9 Z"
android:valueTo="M 12 4.5 C 7 4.5 2.73 7.61 1 12 C 2.73 16.39 7 19.5 12 19.5 C 17 19.5 21.27 16.39 23 12 C 21.27 7.61 17 4.5 12 4.5 Z M 12 17 C 9.24 17 7 14.76 7 12 C 7 9.24 9.24 7 12 7 C 14.76 7 17 9.24 17 12 C 17 14.76 14.76 17 12 17 Z M 14.411 6.703 C 12.751 6.703 11.411 8.043 11.411 9.703 C 11.411 11.363 12.751 12.703 14.411 12.703 C 16.071 12.703 17.411 11.363 17.411 9.703 C 17.411 8.043 16.071 6.703 14.411 6.703 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
</aapt:attr>
</target>
</animated-vector>

View File

@ -18,7 +18,7 @@
android:layout_width="48dp"
android:layout_height="0dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_eye"
android:src="@drawable/animated_eye_to_up"
android:tint="@color/colorIconDark"
app:layout_constraintBottom_toBottomOf="@+id/material_password"
app:layout_constraintEnd_toEndOf="parent"