Commit 858c38b
committed
Refactor: Add manual location and temperature unit settings for weather
This commit introduces the ability for users to manually set their location for weather information and choose their preferred temperature unit (Celsius/Fahrenheit).
- Added `gpsLocation` boolean to `Prefs` to toggle between GPS and manual location.
- Added `tempUnit` (Celsius/Fahrenheit) to `Prefs`.
- Implemented `saveLocation`, `loadLocation`, and `loadLocationName` in `Prefs` to handle manual location data.
- Updated `WeatherHelper` to use GPS or saved manual location based on `prefs.gpsLocation`.
- Modified `WeatherReceiver` to fetch weather based on the selected temperature unit and added location search functionality using the Open-Meteo Geocoding API.
- Added UI elements in `SettingsFragment` for:
- Toggling GPS location.
- Selecting temperature unit.
- Navigating to a new `LocationSearchFragment` to set manual location if GPS is disabled.
- Created `LocationSearchFragment` with a `ListView` to display location search results and an `EditText` for user input.
- Added new string resources for the new settings and temperature units.
- Updated `nav_graph.xml` to include navigation to `LocationSearchFragment`.
- Moved `WeatherHelper` to the `helper` package.
- Updated weather API endpoint in `WeatherReceiver` to include temperature unit.
- Adjusted JSON parsing in `WeatherReceiver` for the updated API response.
Signed-off-by: CreativeCodeCat <[email protected]>1 parent 0ab929e commit 858c38b
File tree
10 files changed
+420
-71
lines changed- app/src/main
- java/com/github/droidworksstudio/mlauncher
- data
- helper
- receivers
- ui
- res
- layout
- values
10 files changed
+420
-71
lines changedLines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
474 | 495 | | |
475 | 496 | | |
476 | 497 | | |
| |||
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
| |||
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
140 | 147 | | |
141 | 148 | | |
142 | 149 | | |
| |||
534 | 541 | | |
535 | 542 | | |
536 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
537 | 548 | | |
538 | 549 | | |
539 | 550 | | |
| |||
674 | 685 | | |
675 | 686 | | |
676 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
677 | 694 | | |
678 | 695 | | |
679 | 696 | | |
| |||
962 | 979 | | |
963 | 980 | | |
964 | 981 | | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
965 | 1009 | | |
966 | 1010 | | |
967 | 1011 | | |
| |||
Lines changed: 68 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | | - | |
26 | | - | |
| 28 | + | |
27 | 29 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 42 | + | |
| 43 | + | |
46 | 44 | | |
47 | 45 | | |
48 | | - | |
49 | 46 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
56 | 55 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
62 | 61 | | |
63 | 62 | | |
64 | | - | |
65 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
66 | 69 | | |
67 | | - | |
68 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
69 | 101 | | |
70 | | - | |
71 | 102 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | 103 | | |
83 | 104 | | |
84 | 105 | | |
| |||
87 | 108 | | |
88 | 109 | | |
89 | 110 | | |
90 | | - | |
| 111 | + | |
91 | 112 | | |
92 | 113 | | |
93 | | - | |
| 114 | + | |
94 | 115 | | |
95 | 116 | | |
96 | 117 | | |
| |||
0 commit comments