Skip to content

Commit 8c75c44

Browse files
committed
Merge branch 'main' into pr/53
2 parents 62ff819 + aa8288c commit 8c75c44

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

.github/workflows/build_and_test.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ jobs:
4242
env:
4343
DEBUG_GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.DEBUG_GOOGLE_SERVICES_JSON_BASE64 }}
4444
run: |
45-
echo $DEBUG_GOOGLE_SERVICES_JSON_BASE64 | base64 --decode > app/google-services.json
45+
if [ -z "$DEBUG_GOOGLE_SERVICES_JSON_BASE64" ]; then
46+
echo "DEBUG_GOOGLE_SERVICES_JSON_BASE64 is empty. Copying test-google-services.json."
47+
cp test-google-services.json app/google-services.json
48+
else
49+
echo "Decoding DEBUG_GOOGLE_SERVICES_JSON_BASE64."
50+
echo $DEBUG_GOOGLE_SERVICES_JSON_BASE64 | base64 --decode > app/google-services.json
51+
fi
4652
4753
- name: Apply Spotless
4854
run: ./gradlew spotlessApply
@@ -131,7 +137,13 @@ jobs:
131137
env:
132138
DEBUG_GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.DEBUG_GOOGLE_SERVICES_JSON_BASE64 }}
133139
run: |
134-
echo $DEBUG_GOOGLE_SERVICES_JSON_BASE64 | base64 --decode > app/google-services.json
140+
if [ -z "$DEBUG_GOOGLE_SERVICES_JSON_BASE64" ]; then
141+
echo "DEBUG_GOOGLE_SERVICES_JSON_BASE64 is empty. Copying test-google-services.json."
142+
cp test-google-services.json app/google-services.json
143+
else
144+
echo "Decoding DEBUG_GOOGLE_SERVICES_JSON_BASE64."
145+
echo $DEBUG_GOOGLE_SERVICES_JSON_BASE64 | base64 --decode > app/google-services.json
146+
fi
135147
136148
- name: Build
137149
run: ./gradlew assembleDebug assembleDebugAndroidTest

app/src/main/java/com/android/developers/androidify/MainActivity.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ import com.android.developers.androidify.navigation.MainNavigation
3333
import com.android.developers.androidify.theme.AndroidifyTheme
3434
import com.android.developers.androidify.util.LocalOcclusion
3535
import dagger.hilt.android.AndroidEntryPoint
36+
import java.util.function.Consumer
3637

3738
@ExperimentalMaterial3ExpressiveApi
3839
@AndroidEntryPoint
3940
class MainActivity : ComponentActivity() {
4041

4142
private val isWindowOccluded = mutableStateOf(false)
43+
private val presentationListener = Consumer<Boolean> { isMinFractionRendered ->
44+
isWindowOccluded.value = !isMinFractionRendered
45+
}
4246

4347
override fun onCreate(savedInstanceState: Bundle?) {
4448
super.onCreate(savedInstanceState)
@@ -76,8 +80,17 @@ class MainActivity : ComponentActivity() {
7680
windowManager.registerTrustedPresentationListener(
7781
window.decorView.windowToken,
7882
presentationThreshold,
79-
mainExecutor
80-
) { isMinFractionRendered -> isWindowOccluded.value = !isMinFractionRendered }
83+
mainExecutor,
84+
presentationListener
85+
)
86+
}
87+
}
88+
89+
override fun onDetachedFromWindow() {
90+
super.onDetachedFromWindow()
91+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
92+
val windowManager = getSystemService(WINDOW_SERVICE) as WindowManager
93+
windowManager.unregisterTrustedPresentationListener(presentationListener)
8194
}
8295
}
8396

test-google-services.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"project_info": {
3+
"project_number": "abc",
4+
"project_id": "YourProjectId",
5+
"storage_bucket": "abc"
6+
},
7+
"client": [
8+
{
9+
"client_info": {
10+
"mobilesdk_app_id": "APlaceholderAPIKeyWith-ThirtyNineCharsX",
11+
"android_client_info": {
12+
"package_name": "com.android.developers.androidify"
13+
}
14+
},
15+
"oauth_client": [],
16+
"api_key": [
17+
{
18+
"current_key": "APlaceholderAPIKeyWith-ThirtyNineCharsX"
19+
}
20+
],
21+
"services": {
22+
"appinvite_service": {
23+
"other_platform_oauth_client": []
24+
}
25+
}
26+
}
27+
],
28+
"configuration_version": "1"
29+
}

0 commit comments

Comments
 (0)