• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.photopicker.core.banners
18 
19 /**
20  * An registry of all supported [Banner]s in Photopicker. Any Banner that must be shown via
21  * [BannerManager] needs to first define itself in this class.
22  *
23  * Banners are essentially defined by three values, the id, if the banner can be dismissed by the
24  * user, and the strategy for tracking it's dismissal. Actual banner implementations rely on the
25  * [Banner] interface.
26  *
27  * @property id A unique (to this enum) string id of the banner
28  * @property dismissable Whether the banner is dismiss-able by the user
29  * @property dismissableStrategy How to track the banner's dismiss state.
30  * @see [Banner] for details for actually implementing a banner that can be displayed.
31  * @see [BannerDeclaration.DismissStrategy] for details about how dismiss state can be tracked.
32  */
33 enum class BannerDefinitions(
34     override val id: String,
35     override val dismissableStrategy: DismissStrategy,
36 ) : BannerDeclaration {
37 
38     // keep-sorted start
39     CLOUD_CHOOSE_ACCOUNT("cloud_choose_account", DismissStrategy.ONCE),
40     CLOUD_CHOOSE_PROVIDER("cloud_choose_provider", DismissStrategy.ONCE),
41     CLOUD_MEDIA_AVAILABLE("cloud_media_available", DismissStrategy.ONCE),
42     CLOUD_UPDATED_ACCOUNT("cloud_updated_account", DismissStrategy.ONCE),
43     PRIVACY_EXPLAINER("privacy_explainer", DismissStrategy.PER_UID),
44     SWITCH_PROFILE("switch_profile", DismissStrategy.PER_UID);
45 
46     // keep-sorted end
47 
48     override val dismissable: Boolean =
49         when (dismissableStrategy) {
50             DismissStrategy.ONCE,
51             DismissStrategy.PER_UID,
52             DismissStrategy.SESSION -> true
53             DismissStrategy.NONE -> false
54         }
55 }
56