summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTyler Nijmeh <tylernij@gmail.com>2021-03-31 00:40:16 -0700
committerTyler Nijmeh <tylernij@gmail.com>2021-03-31 00:40:16 -0700
commit9ce17e0dc3e17c3a640363247667409e67ca68ae (patch)
treecb23d8c4ac9d726642fd1c8610015e9c662b65ee /app
parent633e1baf2be1e3eb4bc7cf8d1066416d0bd8c69e (diff)
Animate profile application
Signed-off-by: Tyler Nijmeh <tylernij@gmail.com>
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/draco/buoy/recyclers/BatterySaverProfileRecyclerAdapter.kt7
-rw-r--r--app/src/main/java/com/draco/buoy/views/MainActivity.kt2
-rw-r--r--app/src/main/res/anim/press.xml11
-rw-r--r--app/src/main/res/layout/recycler_item_profile.xml1
4 files changed, 17 insertions, 4 deletions
diff --git a/app/src/main/java/com/draco/buoy/recyclers/BatterySaverProfileRecyclerAdapter.kt b/app/src/main/java/com/draco/buoy/recyclers/BatterySaverProfileRecyclerAdapter.kt
index 0957ee7..fe22e4c 100644
--- a/app/src/main/java/com/draco/buoy/recyclers/BatterySaverProfileRecyclerAdapter.kt
+++ b/app/src/main/java/com/draco/buoy/recyclers/BatterySaverProfileRecyclerAdapter.kt
@@ -1,9 +1,11 @@
package com.draco.buoy.recyclers
import android.content.ContentResolver
+import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.view.animation.AnimationUtils
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.draco.buoy.R
@@ -11,7 +13,7 @@ import com.draco.buoy.repositories.BatterySaverConstantsConfigProfiles
import com.draco.buoy.utils.BatterySaverManager
class BatterySaverProfileRecyclerAdapter(
- contentResolver: ContentResolver
+ private val context: Context
) : RecyclerView.Adapter<BatterySaverProfileRecyclerAdapter.ViewHolder>() {
private val batterySaverProfiles = arrayOf(
null, /* Reset */
@@ -21,7 +23,7 @@ class BatterySaverProfileRecyclerAdapter(
BatterySaverConstantsConfigProfiles.EXTREME,
)
- private val batterySaverManager = BatterySaverManager(contentResolver)
+ private val batterySaverManager = BatterySaverManager(context.contentResolver)
class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) {
val title = itemView.findViewById<TextView>(R.id.title)
@@ -64,6 +66,7 @@ class BatterySaverProfileRecyclerAdapter(
}
holder.itemView.setOnClickListener {
+ it.startAnimation(AnimationUtils.loadAnimation(context, R.anim.press))
if (profile == null) {
batterySaverManager.resetConstants()
batterySaverManager.setLowPower(false)
diff --git a/app/src/main/java/com/draco/buoy/views/MainActivity.kt b/app/src/main/java/com/draco/buoy/views/MainActivity.kt
index b8f1fc2..90e06e8 100644
--- a/app/src/main/java/com/draco/buoy/views/MainActivity.kt
+++ b/app/src/main/java/com/draco/buoy/views/MainActivity.kt
@@ -22,7 +22,7 @@ class MainActivity : AppCompatActivity() {
recycler = findViewById(R.id.recycler_profile)
recycler.apply {
- adapter = BatterySaverProfileRecyclerAdapter(contentResolver)
+ adapter = BatterySaverProfileRecyclerAdapter(this@MainActivity)
layoutManager = LinearLayoutManager(this@MainActivity)
}
diff --git a/app/src/main/res/anim/press.xml b/app/src/main/res/anim/press.xml
new file mode 100644
index 0000000..6a7ab7a
--- /dev/null
+++ b/app/src/main/res/anim/press.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<scale xmlns:android="http://schemas.android.com/apk/res/android"
+ android:pivotY="50%"
+ android:pivotX="50%"
+ android:fromXScale="1.0"
+ android:fromYScale="1.0"
+ android:toXScale="0.9"
+ android:toYScale="0.9"
+ android:duration="150"
+ android:repeatMode="reverse"
+ android:repeatCount="1" /> \ No newline at end of file
diff --git a/app/src/main/res/layout/recycler_item_profile.xml b/app/src/main/res/layout/recycler_item_profile.xml
index 6db4ac0..65e66e1 100644
--- a/app/src/main/res/layout/recycler_item_profile.xml
+++ b/app/src/main/res/layout/recycler_item_profile.xml
@@ -5,7 +5,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginHorizontal="12dp"
android:layout_marginTop="12dp"
- app:cardCornerRadius="10dp"
app:cardBackgroundColor="@color/green">
<LinearLayout
android:layout_width="match_parent"