mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 03:12:15 +00:00
Improve: Remove "Installed" Notification after 5 seconds
Improve: Scrolling performance in AppDetail
This commit is contained in:
parent
26902110f1
commit
6eb3b96a83
@ -93,6 +93,8 @@ class InstallerService : Service() {
|
|||||||
Common.NOTIFICATION_ID_DOWNLOADING,
|
Common.NOTIFICATION_ID_DOWNLOADING,
|
||||||
notification
|
notification
|
||||||
)
|
)
|
||||||
|
Thread.sleep(5000)
|
||||||
|
notificationManager.cancel(notificationTag, Common.NOTIFICATION_ID_DOWNLOADING)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PackageInstaller.STATUS_FAILURE_ABORTED -> {
|
PackageInstaller.STATUS_FAILURE_ABORTED -> {
|
||||||
|
@ -256,71 +256,88 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
|
|||||||
updateButtons(ProductPreferences[packageName])
|
updateButtons(ProductPreferences[packageName])
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun updateButtons(preference: ProductPreference) {
|
private suspend fun updateButtons(preference: ProductPreference) =
|
||||||
val installed = installed
|
withContext(Dispatchers.Default) {
|
||||||
val product = Product.findSuggested(products, installed?.installedItem) { it.first }?.first
|
val installed = installed
|
||||||
val compatible = product != null && product.selectedReleases.firstOrNull()
|
val product =
|
||||||
.let { it != null && it.incompatibilities.isEmpty() }
|
Product.findSuggested(products, installed?.installedItem) { it.first }?.first
|
||||||
val canInstall = product != null && installed == null && compatible
|
val compatible = product != null && product.selectedReleases.firstOrNull()
|
||||||
val canUpdate =
|
.let { it != null && it.incompatibilities.isEmpty() }
|
||||||
product != null && compatible && product.canUpdate(installed?.installedItem) &&
|
val canInstall = product != null && installed == null && compatible
|
||||||
!preference.shouldIgnoreUpdate(product.versionCode)
|
val canUpdate =
|
||||||
val canUninstall = product != null && installed != null && !installed.isSystem
|
product != null && compatible && product.canUpdate(installed?.installedItem) &&
|
||||||
val canLaunch =
|
!preference.shouldIgnoreUpdate(product.versionCode)
|
||||||
product != null && installed != null && installed.launcherActivities.isNotEmpty()
|
val canUninstall = product != null && installed != null && !installed.isSystem
|
||||||
val canShare = product != null && products[0].second.name == "F-Droid"
|
val canLaunch =
|
||||||
|
product != null && installed != null && installed.launcherActivities.isNotEmpty()
|
||||||
|
val canShare = product != null && products[0].second.name == "F-Droid"
|
||||||
|
|
||||||
val actions = mutableSetOf<Action>()
|
val actions = mutableSetOf<Action>()
|
||||||
if (canInstall) {
|
launch {
|
||||||
actions += Action.INSTALL
|
if (canInstall) {
|
||||||
}
|
actions += Action.INSTALL
|
||||||
if (canUpdate) {
|
}
|
||||||
actions += Action.UPDATE
|
}
|
||||||
}
|
launch {
|
||||||
if (canLaunch) {
|
if (canUpdate) {
|
||||||
actions += Action.LAUNCH
|
actions += Action.UPDATE
|
||||||
}
|
}
|
||||||
if (installed != null) {
|
}
|
||||||
actions += Action.DETAILS
|
launch {
|
||||||
}
|
if (canLaunch) {
|
||||||
if (canUninstall) {
|
actions += Action.LAUNCH
|
||||||
actions += Action.UNINSTALL
|
}
|
||||||
}
|
}
|
||||||
if (canShare) {
|
launch {
|
||||||
actions += Action.SHARE
|
if (installed != null) {
|
||||||
}
|
actions += Action.DETAILS
|
||||||
val primaryAction = when {
|
}
|
||||||
canUpdate -> Action.UPDATE
|
}
|
||||||
canLaunch -> Action.LAUNCH
|
launch {
|
||||||
canInstall -> Action.INSTALL
|
if (canUninstall) {
|
||||||
installed != null -> Action.DETAILS
|
actions += Action.UNINSTALL
|
||||||
canShare -> Action.SHARE
|
}
|
||||||
else -> null
|
}
|
||||||
}
|
launch {
|
||||||
|
if (canShare) {
|
||||||
|
actions += Action.SHARE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val primaryAction = when {
|
||||||
|
canUpdate -> Action.UPDATE
|
||||||
|
canLaunch -> Action.LAUNCH
|
||||||
|
canInstall -> Action.INSTALL
|
||||||
|
installed != null -> Action.DETAILS
|
||||||
|
canShare -> Action.SHARE
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
val adapterAction =
|
launch(Dispatchers.Main) {
|
||||||
if (downloading) AppDetailAdapter.Action.CANCEL else primaryAction?.adapterAction
|
val adapterAction =
|
||||||
(recyclerView?.adapter as? AppDetailAdapter)?.setAction(adapterAction)
|
if (downloading) AppDetailAdapter.Action.CANCEL else primaryAction?.adapterAction
|
||||||
|
(recyclerView?.adapter as? AppDetailAdapter)?.setAction(adapterAction)
|
||||||
for (action in sequenceOf(
|
for (action in sequenceOf(
|
||||||
Action.INSTALL,
|
Action.INSTALL,
|
||||||
Action.SHARE,
|
Action.SHARE,
|
||||||
Action.UPDATE,
|
Action.UPDATE,
|
||||||
Action.UNINSTALL
|
Action.UNINSTALL
|
||||||
)) {
|
)) {
|
||||||
toolbar.menu.findItem(action.id).isEnabled = !downloading
|
toolbar.menu.findItem(action.id).isEnabled = !downloading
|
||||||
|
}
|
||||||
|
}
|
||||||
|
launch { this@AppDetailFragment.actions = Pair(actions, primaryAction) }
|
||||||
|
launch(Dispatchers.Main) { updateToolbarButtons() }
|
||||||
}
|
}
|
||||||
this.actions = Pair(actions, primaryAction)
|
|
||||||
withContext(Dispatchers.Main) { updateToolbarButtons() }
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun updateToolbarTitle() {
|
private suspend fun updateToolbarTitle() {
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
val showPackageName = recyclerView
|
val showPackageName = recyclerView
|
||||||
?.let { (it.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() != 0 } == true
|
?.let { (it.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() != 0 } == true
|
||||||
collapsingToolbar.title =
|
launch {
|
||||||
if (showPackageName) products[0].first.name.trimAfter(' ', 2)
|
collapsingToolbar.title =
|
||||||
else getString(R.string.application)
|
if (showPackageName) products[0].first.name.trimAfter(' ', 2)
|
||||||
|
else getString(R.string.application)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,11 +347,15 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
|
|||||||
val showPrimaryAction = recyclerView
|
val showPrimaryAction = recyclerView
|
||||||
?.let { (it.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() != 0 } == true
|
?.let { (it.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() != 0 } == true
|
||||||
val displayActions = actions.toMutableSet()
|
val displayActions = actions.toMutableSet()
|
||||||
if (!showPrimaryAction && primaryAction != null) {
|
launch {
|
||||||
displayActions -= primaryAction
|
if (!showPrimaryAction && primaryAction != null) {
|
||||||
|
displayActions -= primaryAction
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (displayActions.size >= 4 && resources.configuration.screenWidthDp < 400) {
|
launch {
|
||||||
displayActions -= Action.DETAILS
|
if (displayActions.size >= 4 && resources.configuration.screenWidthDp < 400) {
|
||||||
|
displayActions -= Action.DETAILS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
launch(Dispatchers.Main) {
|
launch(Dispatchers.Main) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user