Author: Adam Evyčędo <git@apiote.xyz>
fade switch of newly-configured feeds
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedChooserActivity.kt b/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedChooserActivity.kt index 13fd5163f5b2f5f7313d89cea0289946670e810c..cb78842e2a9225db4ddfa84fdfeb454ec7d434cf 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedChooserActivity.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedChooserActivity.kt @@ -13,6 +13,8 @@ import androidx.appcompat.content.res.AppCompatResources import androidx.core.content.edit import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.LinearLayoutManager +import androidx.transition.TransitionManager +import com.google.android.material.transition.MaterialFade import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch import xyz.apiote.bimba.czwek.R @@ -63,6 +65,11 @@ feeds, viewModel.settings.value ?: FeedsSettings(mutableMapOf()) ) { settings -> if (settings != null) { + val fade = MaterialFade().apply { + addTarget(R.id.feed_switch_container) + duration = 500L + } + TransitionManager.beginDelayedTransition(binding.root, fade) viewModel.setSettings(feedID, settings) updateItems(null, viewModel.settings.value, false) adapter.notifyItemChanged(adapter.getItemPosition(feedID)) diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedInfos.kt b/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedInfos.kt index c2ba176fd6e1bc6518d7eeb418e2f52703c87bb6..e65c86b1e92f3ea79cce05fe58b20c7836bdd8ea 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedInfos.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedInfos.kt @@ -11,10 +11,10 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetDialogFragment -import com.google.android.material.divider.MaterialDivider import com.google.android.material.materialswitch.MaterialSwitch import com.google.android.material.textview.MaterialTextView import xyz.apiote.bimba.czwek.R @@ -26,7 +26,7 @@ class BimbaFeedInfoViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { val root: View = itemView.findViewById(R.id.feed) val switch: MaterialSwitch = itemView.findViewById(R.id.feed_switch) val name: TextView = itemView.findViewById(R.id.feed_name) - val divider: MaterialDivider = itemView.findViewById(R.id.divider) + val switchContainer: ConstraintLayout = itemView.findViewById(R.id.feed_switch_container) companion object { fun bind( @@ -52,9 +52,8 @@ onClickListener(feed.id) } holder?.name?.text = feed.name if (feedSettings != null) { - holder?.divider?.visibility = View.VISIBLE + holder?.switchContainer?.visibility = View.VISIBLE holder?.switch?.apply { - visibility = View.VISIBLE isChecked = feedSettings.enabled setOnCheckedChangeListener { _, isChecked -> onCheckedChangeListener(feed.id, isChecked) diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedsViewModel.kt b/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedsViewModel.kt index c341d3731557418d14eb0f19234aed2a88454af0..95c79d3f824816a88d119ecb66bdb0bad3d23d0b 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedsViewModel.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/settings/feeds/FeedsViewModel.kt @@ -5,7 +5,6 @@ package xyz.apiote.bimba.czwek.settings.feeds import android.content.Context -import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel @@ -22,7 +21,6 @@ fun setSettings(feedID: String, feedSettings: FeedSettings) { val feedsSettings = _settings.value ?: FeedsSettings(mutableMapOf()) feedsSettings.settings[feedID] = feedSettings _settings.value = feedsSettings - Log.i("Settings", "${_settings.value}") } fun setEnabled(feedID: String, enabled: Boolean) { diff --git a/app/src/main/res/layout/feedinfo.xml b/app/src/main/res/layout/feedinfo.xml index 57d1b22fb8aa55e6da9dd91c87f6d22761b9517a..56725393291d0a9a2c6d80f314ceb9c35c26a87d 100644 --- a/app/src/main/res/layout/feedinfo.xml +++ b/app/src/main/res/layout/feedinfo.xml @@ -22,34 +22,44 @@ android:layout_marginTop="16dp" android:layout_marginBottom="16dp" android:textAppearance="@style/TextAppearance.Material3.HeadlineMedium" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@+id/divider" + app:layout_constraintEnd_toStartOf="@+id/feed_switch_container" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" tool:text="Gravity Falls CBT" /> - <com.google.android.material.materialswitch.MaterialSwitch - android:id="@+id/feed_switch" + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/feed_switch_container" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:visibility="invisible" - android:layout_marginEnd="16dp" - android:layout_marginBottom="16dp" - android:text="" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + android:visibility="invisible" + app:layout_constraintTop_toTopOf="parent"> - <com.google.android.material.divider.MaterialDivider - android:id="@+id/divider" - android:layout_width="1dp" - android:visibility="invisible" - android:layout_height="0dp" - android:layout_marginTop="16dp" - android:layout_marginEnd="8dp" - android:layout_marginBottom="16dp" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@+id/feed_switch" - app:layout_constraintTop_toTopOf="parent" /> + <com.google.android.material.materialswitch.MaterialSwitch + android:id="@+id/feed_switch" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:layout_marginEnd="16dp" + android:layout_marginBottom="16dp" + android:text="" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <com.google.android.material.divider.MaterialDivider + android:id="@+id/divider" + android:layout_width="1dp" + android:layout_height="0dp" + android:layout_marginTop="16dp" + android:layout_marginEnd="8dp" + android:layout_marginBottom="16dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/feed_switch" + app:layout_constraintTop_toTopOf="parent" /> + + + </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file