Skip to content

Commit a5c4cac

Browse files
committed
Merge remote-tracking branch 'origin/develop' into public
# Conflicts: # wearapp/build.gradle # wearapp/src/main/java/com/thewizrd/simpleweather/App.kt # wearapp/src/nongms/java/com/thewizrd/simpleweather/extras/Extras.kt
2 parents 2012bdc + ed9b32d commit a5c4cac

File tree

67 files changed

+1385
-792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1385
-792
lines changed

app/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ android {
1515
minSdkVersion rootProject.minSdkVersion
1616
targetSdkVersion rootProject.targetSdkVersion
1717
// NOTE: Version Code Format (TargetSDK, Version Name, Build Number, Variant Code (Android: 0, WearOS: 1)
18-
versionCode 345100100
19-
versionName "5.10.3"
18+
// ex) 345100131 = (34, 5.10, 013, 0)
19+
versionCode 345100190
20+
versionName "5.10.4"
2021

2122
vectorDrawables {
2223
useSupportLibrary true

app/src/main/java/com/thewizrd/simpleweather/preferences/BaseSettingsFragment.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import android.content.Intent
44
import android.os.Build
55
import android.os.Bundle
66
import android.text.format.DateFormat
7-
import androidx.activity.result.ActivityResultLauncher
8-
import androidx.activity.result.contract.ActivityResultContracts
97
import androidx.preference.Preference
108
import com.google.android.material.timepicker.MaterialTimePicker
119
import com.google.android.material.timepicker.TimeFormat
@@ -18,22 +16,19 @@ import com.thewizrd.simpleweather.preferences.timepickerpreference.TimePickerPre
1816
import com.thewizrd.simpleweather.services.UpdaterUtils
1917
import com.thewizrd.simpleweather.services.WeatherUpdaterWorker
2018
import com.thewizrd.simpleweather.snackbar.Snackbar
21-
import java.util.*
19+
import java.util.Locale
2220

2321
abstract class BaseSettingsFragment : ToolbarPreferenceFragmentCompat() {
2422
// Intent queue
2523
private val intentQueue = mutableSetOf<Intent.FilterComparison>()
2624

2725
protected lateinit var locationPermissionLauncher: LocationPermissionLauncher
28-
protected lateinit var notificationPermissionLauncher: ActivityResultLauncher<String>
2926

3027
override fun onCreate(savedInstanceState: Bundle?) {
3128
super.onCreate(savedInstanceState)
3229

3330
locationPermissionLauncher =
3431
LocationPermissionLauncher(this, locationCallback = ::onLocationPermissionCallback)
35-
notificationPermissionLauncher =
36-
registerForActivityResult(ActivityResultContracts.RequestPermission()) {}
3732
}
3833

3934
protected open fun onLocationPermissionCallback(granted: Boolean) {

app/src/main/java/com/thewizrd/simpleweather/preferences/SettingsFragment.kt

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import androidx.recyclerview.widget.RecyclerView
4141
import com.google.android.material.dialog.MaterialAlertDialogBuilder
4242
import com.thewizrd.common.helpers.ListChangedArgs
4343
import com.thewizrd.common.helpers.OnListChangedListener
44+
import com.thewizrd.common.helpers.PermissionLauncher
4445
import com.thewizrd.common.helpers.backgroundLocationPermissionEnabled
4546
import com.thewizrd.common.helpers.getBackgroundLocationRationale
4647
import com.thewizrd.common.helpers.locationPermissionEnabled
@@ -1257,9 +1258,21 @@ class SettingsFragment : BaseSettingsFragment(),
12571258
private lateinit var dailyNotifPref: SwitchPreferenceCompat
12581259
private lateinit var dailyNotifTimePref: TimePickerPreference
12591260

1261+
private lateinit var onGoingNotifPermissionLauncher: PermissionLauncher
1262+
12601263
override val titleResId: Int
12611264
get() = R.string.pref_title_onnotification
12621265

1266+
override fun onCreate(savedInstanceState: Bundle?) {
1267+
super.onCreate(savedInstanceState)
1268+
onGoingNotifPermissionLauncher = PermissionLauncher(this) { results ->
1269+
val isChecked = results.all { it.value }
1270+
if (onGoingNotification.callChangeListener(isChecked)) {
1271+
onGoingNotification.isChecked = isChecked
1272+
}
1273+
}
1274+
}
1275+
12631276
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
12641277
setPreferencesFromResource(R.xml.pref_weathernotification, rootKey)
12651278

@@ -1272,7 +1285,7 @@ class SettingsFragment : BaseSettingsFragment(),
12721285
if (newValue as Boolean) {
12731286
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
12741287
if (!preference.context.notificationPermissionEnabled()) {
1275-
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
1288+
onGoingNotifPermissionLauncher.requestPermission(Manifest.permission.POST_NOTIFICATIONS)
12761289
return@OnPreferenceChangeListener false
12771290
}
12781291
}
@@ -1343,9 +1356,28 @@ class SettingsFragment : BaseSettingsFragment(),
13431356
private lateinit var alertNotification: SwitchPreferenceCompat
13441357
private lateinit var popChanceNotifPref: SwitchPreferenceCompat
13451358

1359+
private lateinit var alertNotifPermissionLauncher: PermissionLauncher
1360+
private lateinit var popChanceNotifPermissionLauncher: PermissionLauncher
1361+
13461362
override val titleResId: Int
13471363
get() = R.string.label_nav_alerts
13481364

1365+
override fun onCreate(savedInstanceState: Bundle?) {
1366+
super.onCreate(savedInstanceState)
1367+
alertNotifPermissionLauncher = PermissionLauncher(this) { results ->
1368+
val isChecked = results.all { it.value }
1369+
if (alertNotification.callChangeListener(isChecked)) {
1370+
alertNotification.isChecked = isChecked
1371+
}
1372+
}
1373+
popChanceNotifPermissionLauncher = PermissionLauncher(this) { results ->
1374+
val isChecked = results.all { it.value }
1375+
if (popChanceNotifPref.callChangeListener(isChecked)) {
1376+
popChanceNotifPref.isChecked = isChecked
1377+
}
1378+
}
1379+
}
1380+
13491381
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
13501382
setPreferencesFromResource(R.xml.pref_alerts, rootKey)
13511383

@@ -1358,7 +1390,7 @@ class SettingsFragment : BaseSettingsFragment(),
13581390
if (newValue as Boolean) {
13591391
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
13601392
if (!preference.context.notificationPermissionEnabled()) {
1361-
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
1393+
alertNotifPermissionLauncher.requestPermission(Manifest.permission.POST_NOTIFICATIONS)
13621394
return@OnPreferenceChangeListener false
13631395
}
13641396
}
@@ -1393,7 +1425,7 @@ class SettingsFragment : BaseSettingsFragment(),
13931425
if (newValue as Boolean) {
13941426
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
13951427
if (!preference.context.notificationPermissionEnabled()) {
1396-
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
1428+
popChanceNotifPermissionLauncher.requestPermission(Manifest.permission.POST_NOTIFICATIONS)
13971429
return@OnPreferenceChangeListener false
13981430
}
13991431
}

app/src/main/java/com/thewizrd/simpleweather/setup/SetupSettingsFragment.kt

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ import android.os.Bundle
88
import android.view.LayoutInflater
99
import android.view.View
1010
import android.view.ViewGroup
11-
import androidx.activity.result.ActivityResultLauncher
12-
import androidx.activity.result.contract.ActivityResultContracts
13-
import androidx.annotation.NonNull
1411
import androidx.core.text.util.LocalePreferences
1512
import androidx.preference.ListPreference
1613
import androidx.preference.SwitchPreferenceCompat
1714
import com.google.android.material.snackbar.BaseTransientBottomBar
1815
import com.google.android.material.transition.MaterialSharedAxis
1916
import com.thewizrd.common.helpers.LocationPermissionLauncher
17+
import com.thewizrd.common.helpers.PermissionLauncher
2018
import com.thewizrd.common.helpers.backgroundLocationPermissionEnabled
2119
import com.thewizrd.common.helpers.getBackgroundLocationRationale
2220
import com.thewizrd.common.helpers.notificationPermissionEnabled
@@ -34,7 +32,15 @@ import com.thewizrd.simpleweather.snackbar.SnackbarManager
3432
class SetupSettingsFragment : CustomPreferenceFragmentCompat() {
3533
private lateinit var binding: FragmentSetupSettingsBinding
3634
private lateinit var locationPermissionLauncher: LocationPermissionLauncher
37-
private lateinit var notificationPermissionLauncher: ActivityResultLauncher<String>
35+
private lateinit var onGoingNotifPermissionLauncher: PermissionLauncher
36+
private lateinit var alertNotifPermissionLauncher: PermissionLauncher
37+
38+
// Preferences
39+
private lateinit var unitPref: SwitchPreferenceCompat
40+
private lateinit var intervalPref: ListPreference
41+
private lateinit var notIconPref: ListPreference
42+
private lateinit var onGoingPref: SwitchPreferenceCompat
43+
private lateinit var alertsPref: SwitchPreferenceCompat
3844

3945
override fun onCreate(savedInstanceState: Bundle?) {
4046
super.onCreate(savedInstanceState)
@@ -43,11 +49,20 @@ class SetupSettingsFragment : CustomPreferenceFragmentCompat() {
4349
returnTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
4450

4551
locationPermissionLauncher = LocationPermissionLauncher(this)
46-
notificationPermissionLauncher =
47-
registerForActivityResult(ActivityResultContracts.RequestPermission()) {}
52+
onGoingNotifPermissionLauncher = PermissionLauncher(this) { results ->
53+
val isChecked = results.all { it.value }
54+
if (onGoingPref.callChangeListener(isChecked)) {
55+
onGoingPref.isChecked = isChecked
56+
}
57+
}
58+
alertNotifPermissionLauncher = PermissionLauncher(this) { results ->
59+
val isChecked = results.all { it.value }
60+
if (alertsPref.callChangeListener(isChecked)) {
61+
alertsPref.isChecked = isChecked
62+
}
63+
}
4864
}
4965

50-
@NonNull
5166
override fun createSnackManager(activity: Activity): SnackbarManager {
5267
val mStepperNavBar = activity.findViewById<View>(R.id.bottom_nav_bar)
5368

@@ -78,12 +93,11 @@ class SetupSettingsFragment : CustomPreferenceFragmentCompat() {
7893
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
7994
setPreferencesFromResource(R.xml.pref_setup, rootKey)
8095

81-
val unitPref = findPreference<SwitchPreferenceCompat>(SettingsManager.KEY_USECELSIUS)!!
82-
val intervalPref = findPreference<ListPreference>(SettingsManager.KEY_REFRESHINTERVAL)!!
83-
val notIconPref = findPreference<ListPreference>(SettingsManager.KEY_NOTIFICATIONICON)!!
84-
val onGoingPref =
85-
findPreference<SwitchPreferenceCompat>(SettingsManager.KEY_ONGOINGNOTIFICATION)!!
86-
val alertsPref = findPreference<SwitchPreferenceCompat>(SettingsManager.KEY_USEALERTS)!!
96+
unitPref = findPreference(SettingsManager.KEY_USECELSIUS)!!
97+
intervalPref = findPreference(SettingsManager.KEY_REFRESHINTERVAL)!!
98+
notIconPref = findPreference(SettingsManager.KEY_NOTIFICATIONICON)!!
99+
onGoingPref = findPreference(SettingsManager.KEY_ONGOINGNOTIFICATION)!!
100+
alertsPref = findPreference(SettingsManager.KEY_USEALERTS)!!
87101

88102
if (LocalePreferences.getTemperatureUnit() == LocalePreferences.TemperatureUnit.CELSIUS) {
89103
unitPref.setDefaultValue(true)
@@ -102,7 +116,7 @@ class SetupSettingsFragment : CustomPreferenceFragmentCompat() {
102116

103117
if (value && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
104118
if (!preference.context.notificationPermissionEnabled()) {
105-
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
119+
onGoingNotifPermissionLauncher.requestPermission(Manifest.permission.POST_NOTIFICATIONS)
106120
return@setOnPreferenceChangeListener false
107121
}
108122
}
@@ -133,7 +147,7 @@ class SetupSettingsFragment : CustomPreferenceFragmentCompat() {
133147

134148
if (value && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
135149
if (!preference.context.notificationPermissionEnabled()) {
136-
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
150+
alertNotifPermissionLauncher.requestPermission(Manifest.permission.POST_NOTIFICATIONS)
137151
return@setOnPreferenceChangeListener false
138152
}
139153
}

app/src/main/java/com/thewizrd/simpleweather/viewmodels/WeatherNowViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.thewizrd.common.controls.toUiModel
1313
import com.thewizrd.common.helpers.locationPermissionEnabled
1414
import com.thewizrd.common.location.LocationProvider
1515
import com.thewizrd.common.location.LocationResult
16+
import com.thewizrd.common.performance.PerfTrace
1617
import com.thewizrd.common.utils.ErrorMessage
1718
import com.thewizrd.common.wearable.WearableSettings
1819
import com.thewizrd.common.weatherdata.WeatherDataLoader
@@ -32,7 +33,6 @@ import com.thewizrd.shared_resources.weatherdata.model.LocationType
3233
import com.thewizrd.shared_resources.weatherdata.model.WeatherAlert
3334
import com.thewizrd.simpleweather.R
3435
import com.thewizrd.simpleweather.controls.ImageDataViewModel
35-
import com.thewizrd.simpleweather.performance.PerfTrace
3636
import com.thewizrd.weather_api.weatherModule
3737
import kotlinx.coroutines.Dispatchers
3838
import kotlinx.coroutines.flow.MutableStateFlow

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
kotlinx_version = '1.9.0'
1111
ksp_version = '1.9.25-1.0.20'
1212

13-
desugar_version = '2.1.3'
13+
desugar_version = '2.1.4'
1414

1515
firebase_version = '33.7.0'
1616
gms_location_version = '21.3.0'
@@ -27,8 +27,8 @@ buildscript {
2727
arch_core_runtime_version = '2.2.0'
2828
fragment_version = '1.8.5'
2929
lifecycle_version = '2.8.7'
30-
nav_version = '2.8.4'
31-
paging_version = '3.3.4'
30+
nav_version = '2.8.5'
31+
paging_version = '3.3.5'
3232
preference_version = '1.2.1'
3333
recyclerview_version = '1.3.2'
3434
room_version = '2.6.1'
@@ -46,12 +46,12 @@ buildscript {
4646
material_version = '1.12.0'
4747

4848
compose_compiler_version = '1.5.15'
49-
compose_bom_version = '2024.11.00'
49+
compose_bom_version = '2024.12.01'
5050
wear_compose_version = '1.4.0'
5151
wear_tiles_version = '1.4.1'
5252
wear_watchface_version = '1.2.1'
53-
horologist_version = '0.6.21'
54-
accompanist_version = '0.36.0'
53+
horologist_version = '0.6.22'
54+
accompanist_version = '0.37.0'
5555

5656
glide_version = '4.16.0'
5757
icu4j_version = '76.1'
@@ -68,7 +68,7 @@ buildscript {
6868
}
6969

7070
dependencies {
71-
classpath 'com.android.tools.build:gradle:8.7.3'
71+
classpath 'com.android.tools.build:gradle:8.8.0'
7272
classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$ksp_version"
7373
classpath 'com.google.gms:google-services:4.4.2'
7474
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2'

common/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ dependencies {
8383
implementation "com.github.bumptech.glide:glide:$glide_version"
8484
implementation "com.ibm.icu:icu4j:$icu4j_version"
8585

86+
// Firebase
87+
fullgmsImplementation platform("com.google.firebase:firebase-bom:$firebase_version")
88+
fullgmsImplementation 'com.google.firebase:firebase-perf'
89+
8690
fullgmsImplementation "com.google.android.gms:play-services-basement:$gms_basement_version"
8791
fullgmsImplementation "com.google.android.gms:play-services-tasks:$gms_tasks_version"
8892
fullgmsImplementation "com.google.android.gms:play-services-location:$gms_location_version"

app/src/fullgms/java/com/thewizrd/simpleweather/performance/PerfTrace.kt renamed to common/src/fullgms/java/com/thewizrd/common/performance/PerfTrace.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@file:JvmMultifileClass
22
@file:JvmName("PerfTrace")
33

4-
package com.thewizrd.simpleweather.performance
4+
package com.thewizrd.common.performance
55

66
import com.google.firebase.perf.metrics.Trace
77

common/src/main/java/com/thewizrd/common/controls/AirQualityViewModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class AirQualityViewModel {
3636
private Integer pm10Index;
3737
private Integer coIndex;
3838

39-
public AirQualityViewModel(AirQuality aqi) {
39+
public AirQualityViewModel(@NonNull AirQuality aqi) {
4040
final Context context = SharedModuleKt.getSharedDeps().getContext();
4141
this.airQuality = new DetailItemViewModel(aqi);
4242
this.index = this.progress = NumberUtils.getValueOrDefault(aqi.getIndex(), 0);

common/src/main/java/com/thewizrd/common/controls/BeaufortViewModel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.graphics.Color;
44

55
import androidx.annotation.ColorInt;
6+
import androidx.annotation.NonNull;
67

78
import com.thewizrd.shared_resources.utils.Colors;
89
import com.thewizrd.shared_resources.weatherdata.model.Beaufort;
@@ -14,7 +15,7 @@ public class BeaufortViewModel {
1415
private @ColorInt
1516
int progressColor;
1617

17-
public BeaufortViewModel(Beaufort beaufort) {
18+
public BeaufortViewModel(@NonNull Beaufort beaufort) {
1819
this.beaufort = new DetailItemViewModel(beaufort.getScale());
1920
progressMax = 12;
2021

0 commit comments

Comments
 (0)