UpdatesFragment: Restore update all button as action button
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -101,37 +101,6 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
|
||||
updateController(map)
|
||||
viewModel.updateAllEnqueued =
|
||||
map?.values?.all { it?.isRunning == true } ?: false
|
||||
|
||||
if (!map.isNullOrEmpty()) {
|
||||
binding.updateFab.apply {
|
||||
visibility = View.VISIBLE
|
||||
if (viewModel.updateAllEnqueued) {
|
||||
setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
requireContext(),
|
||||
R.drawable.ic_cancel
|
||||
)
|
||||
)
|
||||
} else {
|
||||
setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
requireContext(),
|
||||
R.drawable.ic_installation
|
||||
)
|
||||
)
|
||||
}
|
||||
setOnClickListener {
|
||||
if (viewModel.updateAllEnqueued) {
|
||||
cancelAll()
|
||||
} else {
|
||||
map.keys.forEach { updateSingle(it, true) }
|
||||
}
|
||||
binding.recycler.requestModelBuild()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binding.updateFab.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +114,10 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
|
||||
binding.swipeRefreshLayout.setOnRefreshListener {
|
||||
viewModel.fetchUpdates()
|
||||
}
|
||||
|
||||
binding.searchFab.setOnClickListener {
|
||||
findNavController().navigate(R.id.searchSuggestionFragment)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateController(appList: Map<Update, Download?>?) {
|
||||
@@ -179,9 +152,20 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
|
||||
else
|
||||
getString(R.string.updates_available)
|
||||
)
|
||||
.action(getString(R.string.action_manage))
|
||||
.action(
|
||||
if (viewModel.updateAllEnqueued) {
|
||||
getString(R.string.action_cancel)
|
||||
} else {
|
||||
getString(R.string.action_update_all)
|
||||
}
|
||||
)
|
||||
.click { _ ->
|
||||
findNavController().navigate(R.id.blacklistFragment)
|
||||
if (viewModel.updateAllEnqueued) {
|
||||
cancelAll()
|
||||
} else {
|
||||
appList.keys.forEach { updateSingle(it, true) }
|
||||
}
|
||||
requestModelBuild()
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -52,17 +52,14 @@
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/update_fab"
|
||||
android:id="@+id/search_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_margin="@dimen/margin_large"
|
||||
android:contentDescription="@string/action_search"
|
||||
android:text="@string/action_update_all"
|
||||
android:textColor="@color/colorWhite"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="?colorAccent"
|
||||
app:srcCompat="@drawable/ic_installation"
|
||||
app:srcCompat="@drawable/ic_round_search"
|
||||
app:tint="@color/colorWhite" />
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -51,13 +51,11 @@
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_action"
|
||||
style="@style/Widget.Material3.Button.TextButton.Dialog.Flush"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/icon_size_category"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/margin_small"
|
||||
android:layout_marginEnd="@dimen/margin_small"
|
||||
android:padding="@dimen/padding_xsmall"
|
||||
android:text="@string/action_manage" />
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginHorizontal="@dimen/margin_small"
|
||||
android:layout_marginVertical="@dimen/margin_xsmall"
|
||||
android:text="@string/action_update_all" />
|
||||
</RelativeLayout>
|
||||
|
||||
Reference in New Issue
Block a user