Commit e2a708a
authored
Refactor: Move GutenbergKit configuration logic to appropriate locations (#22172)
* refactor: Move GutenbergKit configuration logic to appropriate locations
Continues the refactoring effort to reduce GutenbergKitActivity responsibilities
by moving fragment configuration logic closer to where it belongs.
Changes:
- Add companion object factory methods to SiteConfig.fromSiteModel() and PostConfig.fromPostModel()
- Move buildAuthorizationData() method from activity to GutenbergKitSettingsBuilder
- Add newInstanceWithBuilder() factory method to GutenbergKitEditorFragment
- Consolidate configuration parameters into GutenbergKitConfig wrapper object
- Remove duplicate configuration building methods from activity
- Clean up unused imports
The activity now delegates configuration building to the appropriate classes
rather than handling detailed fragment setup logic itself. This improves
separation of concerns and makes the fragment more self-contained.
* refactor: Restore FeatureConfig data class and embed in AppConfig
Maintains better separation of concerns by keeping feature-related
configuration grouped together instead of scattering individual
feature flags throughout AppConfig.
Changes:
- Restore FeatureConfig data class with feature flags
- Add featureConfig property to AppConfig instead of individual flags
- Update buildSettings method to use appConfig.featureConfig
- Update activity to create FeatureConfig separately
This preserves logical grouping while still consolidating parameters.
* refactor: Keep FeatureConfig as separate parameter in buildSettings
Restores the original API design where FeatureConfig remains a separate
parameter to buildSettings method instead of being embedded in AppConfig.
Changes:
- Remove featureConfig from AppConfig data class
- Restore featureConfig parameter to buildSettings method
- Add featureConfig to GutenbergKitConfig wrapper
- Update fragment to pass featureConfig separately
- Update activity to create separate featureConfig
This maintains better separation of concerns and preserves the logical
grouping of related configuration parameters.
* refactor: Simplify fromSiteModel to use single parameter
Remove redundant siteId parameter and use SiteModel.siteId directly.
This simplifies the factory method while maintaining the same functionality.
* fix: Restore original webEditor and selfHostedSiteId logic
Fixes logical changes in buildAuthorizationData to match original implementation:
- Add webEditor and selfHostedSiteId fields to SiteConfig
- Use original siteModel.selfHostedSiteId instead of calculated value
- Use original siteModel.webEditor instead of empty string
This ensures the authorization data matches the original behavior exactly.
* fix: Use processed username/password in buildAuthorizationData
Corrects the final logical difference to match original implementation:
- Add apiRestUsernameProcessed and apiRestPasswordProcessed fields to SiteConfig
- Use siteModel.getUserNameProcessed() and getPasswordProcessed() in factory
- Update buildAuthorizationData to use processed versions
This now exactly matches the original createGutenbergWebViewAuthorizationData method.
* fix: Update test helper methods for new data class parameters
Add missing required parameters to SiteConfig and AppConfig test helper methods
to fix compilation errors after consolidating configuration logic.
Changes:
- Add selfHostedSiteId, webEditor, and processed credentials to SiteConfig
- Add accountUserId, accountUserName, userAgent, and isJetpackSsoEnabled to AppConfig
- Update test cases to use the new parameter structure
* fix: Handle null context in UserAgent constructor
Make UserAgent constructor safe when called with null context by using
safe navigation operators and providing fallback values.
Changes:
- Use safe navigation for WebSettings.getDefaultUserAgent() call
- Provide empty string fallback for defaultUserAgent when context is null
- Use safe navigation for PackageUtils.getVersionName() call
- Provide "0" fallback for versionName when context is null
- Update test to use proper constructor parameters with import cleanup1 parent 8a31c31 commit e2a708a
File tree
5 files changed
+161
-68
lines changed- WordPress/src
- main/java/org/wordpress/android/ui/posts
- editor
- test/java/org/wordpress/android/ui/posts
- libs/fluxc/src/main/java/org/wordpress/android/fluxc/network
5 files changed
+161
-68
lines changedLines changed: 16 additions & 52 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
| |||
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
108 | | - | |
109 | | - | |
110 | 107 | | |
111 | 108 | | |
112 | 109 | | |
| |||
2212 | 2209 | | |
2213 | 2210 | | |
2214 | 2211 | | |
2215 | | - | |
2216 | | - | |
2217 | | - | |
| 2212 | + | |
2218 | 2213 | | |
2219 | | - | |
2220 | | - | |
2221 | | - | |
2222 | | - | |
2223 | | - | |
2224 | | - | |
2225 | | - | |
2226 | | - | |
2227 | | - | |
2228 | | - | |
2229 | | - | |
2230 | | - | |
2231 | | - | |
2232 | | - | |
2233 | | - | |
2234 | | - | |
2235 | | - | |
2236 | | - | |
2237 | | - | |
2238 | | - | |
2239 | | - | |
2240 | | - | |
2241 | | - | |
2242 | | - | |
2243 | | - | |
2244 | | - | |
2245 | | - | |
2246 | | - | |
2247 | | - | |
2248 | | - | |
2249 | | - | |
2250 | | - | |
2251 | | - | |
2252 | | - | |
2253 | | - | |
2254 | | - | |
2255 | | - | |
2256 | | - | |
2257 | | - | |
2258 | | - | |
2259 | | - | |
2260 | | - | |
2261 | | - | |
2262 | | - | |
| 2214 | + | |
| 2215 | + | |
2263 | 2216 | | |
2264 | 2217 | | |
2265 | 2218 | | |
| |||
2272 | 2225 | | |
2273 | 2226 | | |
2274 | 2227 | | |
2275 | | - | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
2276 | 2233 | | |
2277 | 2234 | | |
2278 | | - | |
| 2235 | + | |
2279 | 2236 | | |
2280 | 2237 | | |
2281 | 2238 | | |
2282 | 2239 | | |
2283 | 2240 | | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
2284 | 2248 | | |
2285 | 2249 | | |
2286 | 2250 | | |
| |||
Lines changed: 79 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
4 | 10 | | |
5 | 11 | | |
6 | 12 | | |
| |||
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
20 | | - | |
21 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
22 | 52 | | |
23 | 53 | | |
24 | 54 | | |
25 | 55 | | |
26 | 56 | | |
27 | 57 | | |
28 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
29 | 70 | | |
30 | 71 | | |
31 | 72 | | |
| |||
35 | 76 | | |
36 | 77 | | |
37 | 78 | | |
38 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
39 | 91 | | |
40 | 92 | | |
41 | 93 | | |
| |||
147 | 199 | | |
148 | 200 | | |
149 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
150 | 225 | | |
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
538 | 539 | | |
539 | 540 | | |
540 | 541 | | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
541 | 573 | | |
542 | 574 | | |
Lines changed: 21 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
393 | 394 | | |
394 | 395 | | |
395 | 396 | | |
396 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
397 | 402 | | |
398 | 403 | | |
399 | 404 | | |
| |||
441 | 446 | | |
442 | 447 | | |
443 | 448 | | |
444 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
445 | 454 | | |
446 | 455 | | |
447 | 456 | | |
| |||
601 | 610 | | |
602 | 611 | | |
603 | 612 | | |
604 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
605 | 618 | | |
606 | 619 | | |
607 | 620 | | |
| |||
623 | 636 | | |
624 | 637 | | |
625 | 638 | | |
626 | | - | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
627 | 644 | | |
628 | 645 | | |
629 | 646 | | |
| |||
Lines changed: 13 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
0 commit comments