Skip to content

Shortcut fixes #4354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 28, 2021
Merged

Shortcut fixes #4354

merged 8 commits into from
Oct 28, 2021

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Oct 27, 2021

Fixes #4168
Ensure pinned shortcuts are disabled (it is not possible to remove them) if the room is left. To repro:

  • Add a link to the home on a room, either by long pressing on the app icon then long pressing on a room, of from the room setting
  • Leave the room
    The shortcut is now disabled

There were another issue related to paged rooms, but now all the room are taken into account

Change in SDK is adding API to sort rooms, without any API break, but please review carefully 🙏

Fixes #4170 :
Remove shortcut as soon as a PIN code is set, for privacy.

I have one concern about performance, shortcut are computed each time any room summary is updated, it's probable possible to optimise that. I am open to ideas.


val session = activeSessionHolder.getSafeActiveSession() ?: return Disposables.empty()
pinCodeStore.addListener(this)
return session.getRoomSummariesLive(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getPagedRoomSummariesLive was used before, which was not correct, only the first 20 rooms was returned

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to know about all the rooms? the shortcut menu only holds a few entries~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because we have to check if a room has been left (so not in the list anymore) to disable any related shortcuts pinned to the home

val deadShortcutIds = ShortcutManagerCompat.getShortcuts(context, ShortcutManagerCompat.FLAG_MATCH_DYNAMIC)
.map { it.id }
.filter { !roomIds.contains(it) }
ShortcutManagerCompat.removeLongLivedShortcuts(context, deadShortcutIds)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disableShortcuts is also called now

}

@Singleton
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this to be able to add listener to this "object"

awaitPinCodeCallback<Boolean> {
PFSecurityManager.getInstance().pinCodeHelper.delete(it)
}
return@withContext
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was a bit useless to me (?)

@github-actions
Copy link

github-actions bot commented Oct 27, 2021

Unit Test Results

  60 files  ±0    60 suites  ±0   1m 7s ⏱️ +19s
117 tests ±0  117 ✔️ ±0  0 💤 ±0  0 ±0 
348 runs  ±0  348 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 34e8cf8. ± Comparison against base commit 54daee2.

♻️ This comment has been updated with latest results.

sortOrder = RoomSortOrder.PRIORITY_AND_ACTIVITY
)
.asObservable()
.doOnDispose {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: it could be easier to follow the listeners flow if they're added and removed within the pipeline

.doOnSubscribe { pinCodeStore.addListener(this)  }
.doFinally { pinCodeStore.removeListener(this) } // finally catches error, completes and disposed 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be aware the code will change with the Rx-Flow migration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I can do this small change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not so small since doOnDispose -> doFinally) 34e8cf8

private fun createShortcuts(rooms: List<RoomSummary>) {
if (hasPinCode) {
// No shortcut in this case (privacy)
ShortcutManagerCompat.removeAllDynamicShortcuts(context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to double check my understanding, if there's a pin code set we don't allow shortcuts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not exactly true.
If a PIN code is set it will still be possible to pin (the term is the same :/) a room from the room profile screen, so inside the app, i.e. once the PIN code has been entered. But the limited list of shortcuts (room) that we can see when long pressing on the app icon will not be visible anymore.

So a PIN code prevent a few rooms (5 on my phone) to be disclosed without having to enter the PIN code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thanks for explaining!

Copy link
Contributor

@ouchadam ouchadam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@bmarty bmarty enabled auto-merge October 28, 2021 07:53
@bmarty bmarty merged commit 2ce4d8d into develop Oct 28, 2021
@bmarty bmarty deleted the feature/bma/shortcut_fixes branch October 28, 2021 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shortcuts dispose information Check code in ShortcutsHandler
3 participants