Commit 8ce374b
## Explanation
This PR fixes #5615 the issue where the scroll position in the policies
screen (Privacy Policy/Terms of Service) would reset after an
orientation change.
### **Changes Made:**
1. **Updated `PoliciesFragmentPresenter`:**
- Added a `scrollPosition` property to save and restore the scroll
state.
- Implemented `onSaveInstanceState` and `onRestoreInstanceState`
handling using a constant key.
- Ensured the scroll position is retained using
`ScrollView.viewTreeObserver` in `onGlobalLayoutListener`.
2. **Modified `PoliciesFragment`:**
- Delegated `onSaveInstanceState` calls to the presenter.
- Passed the saved instance state to the presenter during fragment view
creation.
### **Testing Performed:**
- Verified that scroll position is correctly retained:
- Across orientation changes (portrait ↔️ landscape).
- On both Privacy Policy and Terms of Service screens
---
## Essential Checklist
- [x] The PR title and explanation each start with "Fix #bugnum: ".
- [x] No unnecessary code changes or Android Studio formatting changes
are included.
- [x] The branch is **not** called "develop" and is up-to-date with
"develop".
- [x] Appropriate reviewers are assigned.
---
After Changes :
[Screen_recording_20241223_010758.webm](https://github.com/user-attachments/assets/f9648b03-5b27-4090-9eaa-82946214cd62)
---------
Co-authored-by: Adhiambo Peres <[email protected]>
1 parent 68f20cb commit 8ce374b
File tree
4 files changed
+66
-3
lines changed- app/src
- main
- java/org/oppia/android/app/policies
- res/layout
4 files changed
+66
-3
lines changedLines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
29 | | - | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | | - | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
36 | 47 | | |
37 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
38 | 53 | | |
39 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
40 | 62 | | |
41 | 63 | | |
42 | 64 | | |
| |||
86 | 108 | | |
87 | 109 | | |
88 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
89 | 115 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
304 | 306 | | |
305 | 307 | | |
306 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
307 | 337 | | |
308 | 338 | | |
309 | 339 | | |
| |||
0 commit comments