Skip to content

Commit 4b3978b

Browse files
committed
SimpleWeather: update for wear nongms build
1 parent d1d58d9 commit 4b3978b

File tree

34 files changed

+1011
-634
lines changed

34 files changed

+1011
-634
lines changed

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

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

app/src/nongms/java/com/thewizrd/simpleweather/performance/PerfTrace.kt renamed to common/src/nongms/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 androidx.tracing.Trace
77
import kotlin.random.Random

shared_resources/src/main/java/com/thewizrd/shared_resources/preferences/SettingsManager.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import androidx.annotation.StringDef
1212
import androidx.core.content.edit
1313
import androidx.preference.PreferenceManager
1414
import com.squareup.moshi.JsonReader
15+
import com.thewizrd.shared_resources.BuildConfig
1516
import com.thewizrd.shared_resources.R
1617
import com.thewizrd.shared_resources.appLib
1718
import com.thewizrd.shared_resources.database.LocationsDAO
@@ -460,6 +461,10 @@ class SettingsManager(context: Context) {
460461
// Android Wear specific members
461462
@RequiresApi(Build.VERSION_CODES.M)
462463
fun getDataSync(): WearableDataSync {
464+
if (BuildConfig.IS_NONGMS) {
465+
return WearableDataSync.OFF
466+
}
467+
463468
return WearableDataSync.valueOf(preferences.getString(KEY_DATASYNC, "0")!!.toInt())
464469
}
465470

wearapp/build.gradle

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'com.google.gms.google-services'
3-
apply plugin: 'com.google.firebase.crashlytics'
4-
apply plugin: 'com.google.firebase.firebase-perf'
52
apply plugin: 'kotlin-android'
63
apply plugin: 'kotlin-kapt'
74
apply plugin: 'com.google.devtools.ksp'
@@ -75,10 +72,24 @@ android {
7572
jvmToolchain(17)
7673
}
7774

75+
sourceSets {
76+
main {
77+
manifest.srcFile 'src/main/AndroidManifest.xml'
78+
}
79+
fullgms {
80+
manifest.srcFile 'src/fullgms/AndroidManifest.xml'
81+
}
82+
nongms {
83+
manifest.srcFile 'src/main/AndroidManifest.xml'
84+
}
85+
}
86+
7887
flavorDimensions 'gms'
7988
productFlavors {
8089
nongms {
8190
dimension 'gms'
91+
applicationIdSuffix ".foss"
92+
versionNameSuffix "-nongms"
8293
buildConfigField "boolean", "IS_NONGMS", "true"
8394
}
8495
fullgms {
@@ -138,13 +149,6 @@ dependencies {
138149

139150
implementation "com.google.android.material:material:$material_version"
140151

141-
implementation "com.google.android.gms:play-services-base:$gms_base_version"
142-
implementation "com.google.android.gms:play-services-location:$gms_location_version"
143-
144-
// WearOS
145-
implementation "com.google.android.gms:play-services-wearable:$gms_wearable_version"
146-
compileOnly 'com.google.android.wearable:wearable:2.9.0'
147-
148152
implementation 'androidx.wear:wear:1.3.0'
149153
implementation "androidx.wear:wear-input:1.2.0-alpha02"
150154
debugImplementation "androidx.wear:wear-input-testing:1.2.0-alpha02"
@@ -190,17 +194,28 @@ dependencies {
190194
androidTestImplementation "androidx.compose.ui:ui-test-junit4"
191195
debugImplementation "androidx.compose.ui:ui-tooling"
192196

193-
// Firebase
194-
implementation platform("com.google.firebase:firebase-bom:$firebase_version")
195-
implementation 'com.google.firebase:firebase-analytics'
196-
implementation 'com.google.firebase:firebase-crashlytics'
197-
implementation 'com.google.firebase:firebase-config'
198-
implementation 'com.google.firebase:firebase-perf'
199-
200197
implementation "com.jakewharton.timber:timber:$timber_version"
201198
implementation "com.ibm.icu:icu4j:$icu4j_version"
202199

203200
implementation "com.squareup.moshi:moshi-kotlin:$moshi_version"
204201
ksp "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
205202
implementation "com.squareup.moshi:moshi-adapters:$moshi_version"
203+
204+
// Firebase
205+
fullgmsImplementation platform("com.google.firebase:firebase-bom:$firebase_version")
206+
fullgmsImplementation 'com.google.firebase:firebase-analytics'
207+
fullgmsImplementation 'com.google.firebase:firebase-crashlytics'
208+
fullgmsImplementation 'com.google.firebase:firebase-config'
209+
fullgmsImplementation 'com.google.firebase:firebase-perf'
210+
211+
fullgmsImplementation "com.google.android.gms:play-services-base:$gms_base_version"
212+
fullgmsImplementation "com.google.android.gms:play-services-location:$gms_location_version"
213+
fullgmsImplementation "com.google.android.gms:play-services-wearable:$gms_wearable_version"
214+
fullgmsCompileOnly 'com.google.android.wearable:wearable:2.9.0'
215+
}
216+
217+
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Fullgms")) {
218+
apply plugin: 'com.google.gms.google-services'
219+
apply plugin: 'com.google.firebase.crashlytics'
220+
apply plugin: 'com.google.firebase.firebase-perf'
206221
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application tools:ignore="AllowBackup,MissingApplicationIcon">
6+
7+
<activity
8+
android:name=".setup.SetupSyncActivity"
9+
android:theme="@style/WearAppTheme" />
10+
11+
<service
12+
android:name=".wearable.WearableDataListenerService"
13+
android:enabled="true"
14+
android:exported="true">
15+
16+
<intent-filter>
17+
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
18+
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
19+
<action android:name="com.google.android.gms.wearable.CAPABILITY_CHANGED" />
20+
21+
<data
22+
android:scheme="wear"
23+
android:host="*" />
24+
</intent-filter>
25+
</service>
26+
27+
<uses-library
28+
android:name="com.google.android.wearable"
29+
android:required="false" />
30+
31+
<activity
32+
android:name="com.google.android.gms.common.api.GoogleApiActivity"
33+
android:theme="@android:style/Theme.Translucent.NoTitleBar"
34+
android:exported="false" />
35+
36+
<meta-data
37+
android:name="com.google.android.gms.version"
38+
android:value="@integer/google_play_services_version" />
39+
40+
<meta-data
41+
android:name="preloaded_fonts"
42+
android:resource="@array/preloaded_fonts" />
43+
44+
</application>
45+
</manifest>

wearapp/src/main/java/com/thewizrd/simpleweather/FirebaseConfigurator.kt renamed to wearapp/src/fullgms/java/com/thewizrd/simpleweather/FirebaseConfigurator.kt

File renamed without changes.

wearapp/src/main/java/com/thewizrd/simpleweather/extras/Extras.kt renamed to wearapp/src/fullgms/java/com/thewizrd/simpleweather/extras/Extras.kt

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@
33

44
package com.thewizrd.simpleweather.extras
55

6+
import android.content.Context
67
import android.content.Intent
78
import android.widget.Toast
89
import com.thewizrd.extras.extrasModule
910
import com.thewizrd.shared_resources.di.localBroadcastManager
11+
import com.thewizrd.simpleweather.FirebaseConfigurator
1012
import com.thewizrd.simpleweather.R
1113
import com.thewizrd.simpleweather.preferences.SettingsActivity
12-
import com.thewizrd.simpleweather.wearable.WearableListenerActivity
14+
import com.thewizrd.simpleweather.setup.SetupActivity
15+
import com.thewizrd.simpleweather.setup.SetupActivity.Companion.REQUEST_CODE_SYNC_ACTIVITY
16+
import com.thewizrd.simpleweather.setup.SetupSyncActivity
17+
import com.thewizrd.simpleweather.wearable.WearableListenerActions
18+
19+
fun initializeExtras() {
20+
extrasModule.initialize()
21+
}
22+
23+
fun initializeFirebase(context: Context) {
24+
FirebaseConfigurator.initialize(context)
25+
}
1326

1427
fun isIconPackSupported(packKey: String?): Boolean {
1528
return extrasModule.isIconPackSupported(packKey)
@@ -23,12 +36,19 @@ fun isPremiumWeatherAPI(api: String?): Boolean {
2336
return extrasModule.isPremiumWeatherAPI(api)
2437
}
2538

39+
fun SetupActivity.startSetupSyncActivity() {
40+
startActivityForResult(
41+
Intent(this, SetupSyncActivity::class.java),
42+
REQUEST_CODE_SYNC_ACTIVITY
43+
)
44+
}
45+
2646
fun SettingsActivity.SettingsFragment.navigateToPremiumFragment() {
2747
// Navigate to premium page
2848
showToast(R.string.message_premium_required, Toast.LENGTH_SHORT);
2949
localBroadcastManager.sendBroadcast(
30-
Intent(WearableListenerActivity.ACTION_OPENONPHONE)
31-
.putExtra(WearableListenerActivity.EXTRA_SHOWANIMATION, true)
50+
Intent(WearableListenerActions.ACTION_OPENONPHONE)
51+
.putExtra(WearableListenerActions.EXTRA_SHOWANIMATION, true)
3252
)
3353
return
3454
}
@@ -37,8 +57,12 @@ fun SettingsActivity.IconsFragment.navigateUnsupportedIconPack() {
3757
// Navigate to premium page
3858
showToast(R.string.message_premium_required, Toast.LENGTH_SHORT);
3959
localBroadcastManager.sendBroadcast(
40-
Intent(WearableListenerActivity.ACTION_OPENONPHONE)
41-
.putExtra(WearableListenerActivity.EXTRA_SHOWANIMATION, true)
60+
Intent(WearableListenerActions.ACTION_OPENONPHONE)
61+
.putExtra(WearableListenerActions.EXTRA_SHOWANIMATION, true)
4262
)
4363
return
64+
}
65+
66+
fun checkPremiumStatus() {
67+
extrasModule.checkPremiumStatus()
4468
}

0 commit comments

Comments
 (0)