Skip to content

Commit

Permalink
Glimpse: Split ACTION_REVIEW from ACTION_REVIEW_SECURE
Browse files Browse the repository at this point in the history
Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/8233
Change-Id: Icaa5df7bef3ab74de1c85c655db11cfd4ea57860
  • Loading branch information
SebaUbuntu committed Feb 16, 2025
1 parent d47de86 commit a0ad138
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/org/lineageos/glimpse/ViewActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ class ViewActivity : AppCompatActivity(R.layout.activity_view) {
parsedIntent?.handle {
when (it) {
is ParsedIntent.ViewIntent,
is ParsedIntent.ReviewIntent -> {
is ParsedIntent.ReviewIntent,
is ParsedIntent.SecureReviewIntent -> {
viewModel.setParsedIntent(it)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ class IntentsViewModel(application: Application) : GlimpseViewModel(application)
*
* @param albumRequest The [AlbumViewModel.AlbumRequest] to show
* @param initialMedia The [Media] from which we should start
* @param secure Whether we can show item with a locked status
*/
class ReviewIntent(
val albumRequest: AlbumViewModel.AlbumRequest? = null,
val initialMedia: Media? = null,
val secure: Boolean = false,
) : ParsedIntent()

/**
* Review content securely.
*
* @param medias The list of [Media] to show
*/
class SecureReviewIntent(
val medias: List<Media>,
) : ParsedIntent()

/**
Expand Down Expand Up @@ -163,8 +170,7 @@ class IntentsViewModel(application: Application) : GlimpseViewModel(application)

Intent.ACTION_VIEW -> ParsedIntent.ViewIntent(mediaItems.filterIsInstance<Media>())

MediaStore.ACTION_REVIEW,
MediaStore.ACTION_REVIEW_SECURE -> ParsedIntent.ReviewIntent(
MediaStore.ACTION_REVIEW -> ParsedIntent.ReviewIntent(
AlbumViewModel.AlbumRequest(
intent.extras?.getSerializable(
ViewActivity.EXTRA_ALBUM_TYPE, AlbumType::class
Expand All @@ -187,7 +193,10 @@ class IntentsViewModel(application: Application) : GlimpseViewModel(application)
intent.extras?.getString(ViewActivity.EXTRA_MIME_TYPE),
),
mediaItems.filterIsInstance<Media>().firstOrNull(),
intent.action == MediaStore.ACTION_REVIEW_SECURE,
)

MediaStore.ACTION_REVIEW_SECURE -> ParsedIntent.SecureReviewIntent(
mediaItems.filterIsInstance<Media>(),
)

Intent.ACTION_GET_CONTENT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The LineageOS Project
* SPDX-FileCopyrightText: 2023-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -123,6 +123,10 @@ class LocalPlayerViewModel(

is IntentsViewModel.ParsedIntent.ReviewIntent -> album

is IntentsViewModel.ParsedIntent.SecureReviewIntent -> {
flowOf(RequestStatus.Success(it.medias))
}

else -> flowOf(RequestStatus.Loading())
}
}
Expand All @@ -140,7 +144,7 @@ class LocalPlayerViewModel(
val secure = parsedIntent
.mapLatest {
when (it) {
is IntentsViewModel.ParsedIntent.ReviewIntent -> it.secure
is IntentsViewModel.ParsedIntent.SecureReviewIntent -> true
else -> false
}
}
Expand All @@ -158,7 +162,8 @@ class LocalPlayerViewModel(
val readOnly = parsedIntent
.mapLatest {
when (it) {
is IntentsViewModel.ParsedIntent.ReviewIntent -> it.secure
is IntentsViewModel.ParsedIntent.ReviewIntent,
is IntentsViewModel.ParsedIntent.SecureReviewIntent -> false
else -> true
}
}
Expand Down

0 comments on commit a0ad138

Please sign in to comment.