Merge branch 'doubletap_feedback' into 'master'
Doubletap feedback Closes #286 See merge request pixeldroid/PixelDroid!339
This commit is contained in:
commit
b7ce805e2c
|
@ -136,11 +136,11 @@ dependencies {
|
|||
implementation 'com.google.android.material:material:1.3.0'
|
||||
|
||||
//Dagger (dependency injection)
|
||||
implementation 'com.google.dagger:dagger-android:2.34.1'
|
||||
implementation 'com.google.dagger:dagger-android-support:2.34.1'
|
||||
implementation 'com.google.dagger:dagger-android:2.35.1'
|
||||
implementation 'com.google.dagger:dagger-android-support:2.35.1'
|
||||
// if you use the support libraries
|
||||
kapt 'com.google.dagger:dagger-android-processor:2.34.1'
|
||||
kapt 'com.google.dagger:dagger-compiler:2.34.1'
|
||||
kapt 'com.google.dagger:dagger-android-processor:2.35.1'
|
||||
kapt 'com.google.dagger:dagger-compiler:2.35.1'
|
||||
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.Manifest
|
|||
import android.app.AlertDialog
|
||||
import android.content.Intent
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.AnimatedVectorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.util.Log
|
||||
|
@ -14,6 +15,7 @@ import android.widget.*
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.LifecycleCoroutineScope
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.RequestBuilder
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
@ -472,6 +474,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
|||
// Button is inactive, like
|
||||
binding.liker.playAnimation()
|
||||
binding.liker.isChecked = true
|
||||
binding.likeAnimation.animateView()
|
||||
likePostCall(api)
|
||||
}
|
||||
} else {
|
||||
|
@ -484,6 +487,17 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
|||
}
|
||||
}
|
||||
}
|
||||
private fun ImageView.animateView() {
|
||||
visibility = View.VISIBLE
|
||||
when (val drawable = drawable) {
|
||||
is AnimatedVectorDrawableCompat -> {
|
||||
drawable.start()
|
||||
}
|
||||
is AnimatedVectorDrawable -> {
|
||||
drawable.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun likePostCall(api: PixelfedAPI) {
|
||||
//Call the api function
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<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="path"
|
||||
android:pathData="M 16.5 3 C 14.76 3 13.09 3.81 12 5.09 C 10.91 3.81 9.24 3 7.5 3 C 4.42 3 2 5.42 2 8.5 C 2 12.28 5.4 15.36 10.55 20.04 L 12 21.35 L 13.45 20.03 C 18.6 15.36 22 12.28 22 8.5 C 22 5.42 19.58 3 16.5 3 Z M 12.1 18.55 L 12 18.65 L 11.9 18.55 C 7.14 14.24 4 11.39 4 8.5 C 4 6.5 5.5 5 7.5 5 C 9.04 5 10.54 5.99 11.07 7.36 L 12.94 7.36 C 13.46 5.99 14.96 5 16.5 5 C 18.5 5 20 6.5 20 8.5 C 20 11.39 16.86 14.24 12.1 18.55 Z"
|
||||
android:fillColor="#000"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
<target android:name="path">
|
||||
<aapt:attr name="android:animation">
|
||||
<set>
|
||||
<objectAnimator
|
||||
android:propertyName="pathData"
|
||||
android:duration="170"
|
||||
android:valueFrom="M 12 12.1 C 12 12.1 12 12.1 12 12.1 C 12 12.1 12 12.1 12 12.1 C 12 12.1 12 12.1 12 12.1 C 12 12.1 12 12.1 12 12.1 L 12 12.1 L 12 12.1 L 12 12.1 C 12 12.1 12 12.1 12 12.1 C 12 12.1 12 12.1 12 12.1 C 12 12.1 12 12.1 12 12.1"
|
||||
android:valueTo="M 12 5.09 C 12.545 4.45 13.235 3.928 14.006 3.565 C 14.777 3.203 15.63 3 16.5 3 C 19.58 3 22 5.42 22 8.5 C 22 12.28 18.6 15.36 13.45 20.04 L 12 21.35 L 12 21.35 L 10.55 20.03 C 5.4 15.36 2 12.28 2 8.5 C 2 5.42 4.42 3 7.5 3 C 9.24 3 10.91 3.81 12 5.09"
|
||||
android:valueType="pathType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"/>
|
||||
<objectAnimator
|
||||
android:propertyName="fillColor"
|
||||
android:startOffset="94"
|
||||
android:duration="100"
|
||||
android:valueFrom="#000"
|
||||
android:valueTo="#ff0000"
|
||||
android:valueType="colorType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"/>
|
||||
<objectAnimator
|
||||
android:propertyName="fillAlpha"
|
||||
android:startOffset="300"
|
||||
android:duration="400"
|
||||
android:valueFrom="1"
|
||||
android:valueTo="0"
|
||||
android:valueType="floatType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"/>
|
||||
</set>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
|
@ -82,6 +82,19 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/like_animation"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:src="@drawable/heart_anim"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/postPagerHost"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/postPagerHost"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/post_fragment_image_popup_menu_anchor"
|
||||
android:layout_width="1dp"
|
||||
|
|
Loading…
Reference in New Issue