diff --git a/src/main/kotlin/com/looker/droidify/content/Preferences.kt b/src/main/kotlin/com/looker/droidify/content/Preferences.kt index 21a36139..0200d40c 100644 --- a/src/main/kotlin/com/looker/droidify/content/Preferences.kt +++ b/src/main/kotlin/com/looker/droidify/content/Preferences.kt @@ -16,8 +16,17 @@ object Preferences { private val subject = PublishSubject.create>() private val keys = sequenceOf( - Key.AutoSync, Key.IncompatibleVersions, Key.ProxyHost, Key.ProxyPort, Key.ProxyType, - Key.RootPermission, Key.SortOrder, Key.Theme, Key.UpdateNotify, Key.UpdateUnstable + Key.AutoSync, + Key.IncompatibleVersions, + Key.ListAnimation, + Key.ProxyHost, + Key.ProxyPort, + Key.ProxyType, + Key.RootPermission, + Key.SortOrder, + Key.Theme, + Key.UpdateNotify, + Key.UpdateUnstable ).map { Pair(it.name, it) }.toMap() fun init(context: Context) { @@ -117,6 +126,9 @@ object Preferences { object IncompatibleVersions : Key("incompatible_versions", Value.BooleanValue(false)) + object ListAnimation : + Key("list_animation", Value.BooleanValue(true)) + object ProxyHost : Key("proxy_host", Value.StringValue("localhost")) object ProxyPort : Key("proxy_port", Value.IntValue(9050)) object ProxyType : Key( diff --git a/src/main/kotlin/com/looker/droidify/screen/ProductsAdapter.kt b/src/main/kotlin/com/looker/droidify/screen/ProductsAdapter.kt index c286da2f..35779d6b 100644 --- a/src/main/kotlin/com/looker/droidify/screen/ProductsAdapter.kt +++ b/src/main/kotlin/com/looker/droidify/screen/ProductsAdapter.kt @@ -14,6 +14,7 @@ import androidx.recyclerview.widget.RecyclerView import coil.transform.RoundedCornersTransformation import com.google.android.material.imageview.ShapeableImageView import com.looker.droidify.R +import com.looker.droidify.content.Preferences import com.looker.droidify.database.Database import com.looker.droidify.entity.ProductItem import com.looker.droidify.entity.Repository @@ -131,7 +132,9 @@ class ProductsAdapter(private val onClick: (ProductItem) -> Unit) : override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) { super.onViewDetachedFromWindow(holder) - holder.itemView.clearAnimation() + if (Preferences[Preferences.Key.ListAnimation]) { + holder.itemView.clearAnimation() + } } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { @@ -197,12 +200,17 @@ class ProductsAdapter(private val onClick: (ProductItem) -> Unit) : holder.text.text = emptyText } }::class + if (Preferences[Preferences.Key.ListAnimation]) { + setAnimation(holder.itemView, holder.adapterPosition) + } + } + private fun setAnimation(itemView: View, position: Int) { val animation = AnimationUtils.loadAnimation( - holder.itemView.context, + itemView.context, if (position > lastPosition) R.anim.slide_up else R.anim.slide_down ) - holder.itemView.startAnimation(animation) - lastPosition = holder.adapterPosition + itemView.startAnimation(animation) + lastPosition = position } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/looker/droidify/screen/SettingsFragment.kt b/src/main/kotlin/com/looker/droidify/screen/SettingsFragment.kt index ada45dfa..15cf8de6 100644 --- a/src/main/kotlin/com/looker/droidify/screen/SettingsFragment.kt +++ b/src/main/kotlin/com/looker/droidify/screen/SettingsFragment.kt @@ -114,6 +114,10 @@ class SettingsFragment : ScreenFragment() { is Preferences.Theme.Amoled -> getString(R.string.amoled) } } + addSwitch( + Preferences.Key.ListAnimation, getString(R.string.list_animation), + getString(R.string.list_animation_description) + ) } preferences.addCategory(getString(R.string.install_types)) { addSwitch( diff --git a/src/main/res/values-es/strings.xml b/src/main/res/values-es/strings.xml index bd909a8f..e7b23f9c 100644 --- a/src/main/res/values-es/strings.xml +++ b/src/main/res/values-es/strings.xml @@ -75,6 +75,8 @@ Claro Link copiado al portapapeles Links + Lista de animaciones + "Habilitar la animación de lista en la página principal " Uniendo %s Nombre Error de red. diff --git a/src/main/res/values-it/strings.xml b/src/main/res/values-it/strings.xml index 05a1643b..14d0a83f 100644 --- a/src/main/res/values-it/strings.xml +++ b/src/main/res/values-it/strings.xml @@ -79,6 +79,8 @@ Chiaro Link copiato sulla clipboard Links + Elenco animazioni + Abilita l\'animazione dell\'elenco nella pagina principale Unione %s Nome Errore di rete. diff --git a/src/main/res/values-pt-rBR/strings.xml b/src/main/res/values-pt-rBR/strings.xml index 80c86145..cf3e64ba 100644 --- a/src/main/res/values-pt-rBR/strings.xml +++ b/src/main/res/values-pt-rBR/strings.xml @@ -79,6 +79,8 @@ Claro Link copiado para a área de transferência Links + Listar animações + Habilitar animação de lista na página principal Incorporando %s Nome Erro da rede. diff --git a/src/main/res/values-zh-rCN/strings.xml b/src/main/res/values-zh-rCN/strings.xml index 54aebff7..73317d2b 100644 --- a/src/main/res/values-zh-rCN/strings.xml +++ b/src/main/res/values-zh-rCN/strings.xml @@ -79,6 +79,8 @@ 亮色 链接已复制到剪贴板 链接 + 列出动画 + 在主页上启用列表动画 合并 %s 名称 网络错误. diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 368a6a85..a50b0964 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -80,6 +80,8 @@ Light Link copied to clipboard Links + List Animations + Enable List Animation on Main Page Merging %s Name Network error.