Commit 86f0f20
committed
feat: Implement purchase handling and status updates
This commit introduces a robust purchase handling mechanism for in-app donations. It ensures that user entitlements are correctly processed, acknowledged, and persisted.
Key changes include:
- **Purchase Handling:** The `DefaultSupportRepository` now processes purchase updates from the Google Play Billing library, acknowledging new purchases and handling revoked or refunded transactions.
- **Entitlement Persistence:** Granted product entitlements are now saved to `SharedPreferences` to maintain state across app sessions.
- **Status Updates:** The `SupportActivity` and `SupportViewModel` have been updated to observe purchase status changes (granted, restored, revoked) and display a corresponding message to the user via a `Toast`.
- **UseCases and DI:** New use cases (`RefreshPurchasesUseCase`, `SetPurchaseStatusListenerUseCase`) and their tests have been added and integrated into the Dagger dependency graph to manage purchase status listening and refreshing.
- **Localized Strings:** New strings for purchase status notifications (`support_purchase_thank_you`, `support_purchase_restored`, `support_purchase_revoked`) have been added and translated across multiple locales.
- **Lifecycle Awareness:** The app now refreshes purchases in `onResume` of the `SupportActivity` to ensure the UI reflects the latest entitlement status.1 parent 262253d commit 86f0f20
File tree
36 files changed
+411
-8
lines changed- app/src
- main
- java/com/d4rk/androidtutorials/java
- data/repository
- di
- domain/support
- ui/screens/support
- res
- values-ar-rEG
- values-bg-rBG
- values-bn-rBD
- values-de-rDE
- values-es-rGQ
- values-es-rMX
- values-fil-rPH
- values-fr-rFR
- values-hi-rIN
- values-hu-rHU
- values-in-rID
- values-it-rIT
- values-ja-rJP
- values-ko-rKR
- values-pl-rPL
- values-pt-rBR
- values-ro-rRO
- values-ru-rRU
- values-sv-rSE
- values-th-rTH
- values-tr-rTR
- values-uk-rUA
- values-ur-rPK
- values-vi-rVN
- values-zh-rTW
- values
- test/java/com/d4rk/androidtutorials/java/domain/support
36 files changed
+411
-8
lines changedLines changed: 142 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| 15 | + | |
13 | 16 | | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
| 27 | + | |
20 | 28 | | |
21 | 29 | | |
| 30 | + | |
22 | 31 | | |
23 | 32 | | |
24 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
25 | 37 | | |
26 | 38 | | |
| 39 | + | |
| 40 | + | |
27 | 41 | | |
| 42 | + | |
28 | 43 | | |
29 | 44 | | |
30 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
31 | 49 | | |
32 | 50 | | |
33 | 51 | | |
34 | 52 | | |
35 | 53 | | |
36 | 54 | | |
37 | 55 | | |
| 56 | + | |
38 | 57 | | |
39 | 58 | | |
40 | | - | |
41 | | - | |
42 | | - | |
| 59 | + | |
43 | 60 | | |
44 | 61 | | |
45 | 62 | | |
| |||
53 | 70 | | |
54 | 71 | | |
55 | 72 | | |
| 73 | + | |
56 | 74 | | |
57 | 75 | | |
58 | 76 | | |
| |||
72 | 90 | | |
73 | 91 | | |
74 | 92 | | |
| 93 | + | |
75 | 94 | | |
76 | 95 | | |
77 | 96 | | |
| |||
114 | 133 | | |
115 | 134 | | |
116 | 135 | | |
117 | | - | |
118 | 136 | | |
119 | 137 | | |
120 | 138 | | |
| 139 | + | |
121 | 140 | | |
122 | 141 | | |
123 | 142 | | |
| |||
146 | 165 | | |
147 | 166 | | |
148 | 167 | | |
149 | | - | |
150 | 168 | | |
151 | 169 | | |
152 | 170 | | |
153 | 171 | | |
| 172 | + | |
154 | 173 | | |
155 | 174 | | |
156 | 175 | | |
157 | 176 | | |
158 | 177 | | |
159 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
26 | 36 | | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
252 | 264 | | |
253 | 265 | | |
254 | 266 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| |||
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
84 | 109 | | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments