Skip to content

Commit 6f577d8

Browse files
committed
Do not show shortcuts if a PIN code is set
1 parent 3a81c10 commit 6f577d8

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

changelog.d/4170.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Do not show shortcuts if a PIN code is set

vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import android.os.Build
2222
import androidx.core.content.getSystemService
2323
import androidx.core.content.pm.ShortcutManagerCompat
2424
import im.vector.app.core.di.ActiveSessionHolder
25+
import im.vector.app.features.pin.PinCodeStore
2526
import io.reactivex.disposables.Disposable
2627
import io.reactivex.disposables.Disposables
2728
import org.matrix.android.sdk.api.session.room.RoomSortOrder
@@ -35,7 +36,8 @@ import javax.inject.Inject
3536
class ShortcutsHandler @Inject constructor(
3637
private val context: Context,
3738
private val shortcutCreator: ShortcutCreator,
38-
private val activeSessionHolder: ActiveSessionHolder
39+
private val activeSessionHolder: ActiveSessionHolder,
40+
private val pinCodeStore: PinCodeStore
3941
) {
4042

4143
fun observeRoomsAndBuildShortcuts(): Disposable {
@@ -61,7 +63,6 @@ class ShortcutsHandler @Inject constructor(
6163
}
6264
}
6365

64-
6566
private fun removeDeadShortcut(roomIds: List<String>) {
6667
val deadShortcutIds = ShortcutManagerCompat.getShortcuts(context, ShortcutManagerCompat.FLAG_MATCH_DYNAMIC)
6768
.map { it.id }
@@ -79,12 +80,17 @@ class ShortcutsHandler @Inject constructor(
7980
}
8081

8182
private fun createShortcuts(rooms: List<RoomSummary>) {
82-
val shortcuts = rooms.mapIndexed { index, room ->
83-
shortcutCreator.create(room, index)
84-
}
83+
if (pinCodeStore.getEncodedPin() != null) {
84+
// No shortcut in this case (privacy)
85+
ShortcutManagerCompat.removeAllDynamicShortcuts(context)
86+
} else {
87+
val shortcuts = rooms.mapIndexed { index, room ->
88+
shortcutCreator.create(room, index)
89+
}
8590

86-
shortcuts.forEach { shortcut ->
87-
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
91+
shortcuts.forEach { shortcut ->
92+
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
93+
}
8894
}
8995
}
9096

0 commit comments

Comments
 (0)