UpdatesFragment: Move Update All button to FAB

* Also link BlacklistFragment in in it's place as requested by users

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-03-04 14:50:15 +05:30
parent 85226a8f41
commit 29ce733611
5 changed files with 57 additions and 15 deletions

View File

@@ -65,10 +65,14 @@ class BlacklistFragment : Fragment(R.layout.activity_generic_recycler) {
updateController(null)
}
override fun onPause() {
super.onPause()
blacklistProvider.save(VM.selected)
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
blacklistProvider.save(VM.selected)
}
private fun updateController(blackList: List<Black>?) {

View File

@@ -30,6 +30,7 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import com.aurora.Constants
import com.aurora.extensions.browse
import com.aurora.extensions.isRAndAbove
@@ -96,6 +97,37 @@ class UpdatesFragment : BaseFragment(R.layout.fragment_updates) {
updateController(map)
binding.swipeRefreshLayout.isRefreshing = false
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
}
}
}
@@ -156,19 +188,9 @@ class UpdatesFragment : BaseFragment(R.layout.fragment_updates) {
else
getString(R.string.updates_available)
)
.action(
if (viewModel.updateAllEnqueued)
getString(R.string.action_cancel)
else
getString(R.string.action_update_all)
)
.action(getString(R.string.action_manage))
.click { _ ->
if (viewModel.updateAllEnqueued) {
cancelAll()
} else {
appList.keys.forEach { updateSingle(it, true) }
}
requestModelBuild()
findNavController().navigate(R.id.blacklistFragment)
}
)

View File

@@ -40,4 +40,19 @@
app:stackFromEnd="false"
tools:listitem="@layout/view_app_list" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/update_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:tint="@color/colorWhite" />
</RelativeLayout>

View File

@@ -59,5 +59,5 @@
android:layout_marginStart="@dimen/margin_small"
android:layout_marginEnd="@dimen/margin_small"
android:padding="@dimen/padding_xsmall"
android:text="@string/action_update_all" />
android:text="@string/action_manage" />
</RelativeLayout>

View File

@@ -402,4 +402,5 @@
<string name="device_doze_description">Please, disable battery optimizations to allow background operations.</string>
<string name="device_doze_extra">Optionally you can choose to keep the optimizations enabled, but then you won\'t be able to take benefit of background downloads and automated updates, so choice is yours.</string>
<string name="failed_apk_export">Failed to export APKs</string>
<string name="action_manage">Manage</string>
</resources>