Skip to content

Commit 69e7a10

Browse files
committed
Merge branch 'github/master'
2 parents cd39d2c + f96844e commit 69e7a10

8 files changed

Lines changed: 56 additions & 27 deletions

File tree

PlayCoreKtx/app/build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,26 @@ android {
3939
viewBinding = true
4040
}
4141

42+
signingConfigs {
43+
if (project.hasProperty("signing.storeFile")) {
44+
release {
45+
keyAlias project['signing.keyAlias']
46+
keyPassword project['signing.keyPassword']
47+
storeFile file(project['signing.storeFile'])
48+
storePassword project['signing.storePassword']
49+
}
50+
}
51+
}
52+
4253
buildTypes {
4354
debug {}
4455
release {
4556
minifyEnabled true
57+
signingConfig signingConfigs.release
4658
}
4759
}
4860

61+
4962
compileOptions {
5063
sourceCompatibility = '1.8'
5164
targetCompatibility = '1.8'
@@ -64,6 +77,7 @@ android {
6477

6578
play {
6679
serviceAccountCredentials = file("../play-key.json")
80+
updatePriority = 5
6781
}
6882

6983
dependencies {

PlayCoreKtx/app/src/main/java/com/google/android/samples/dynamicfeatures/state/ColorViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.android.samples.dynamicfeatures.state
1717

1818
import android.graphics.Color
19+
import androidx.annotation.Keep
1920
import androidx.lifecycle.ViewModel
2021
import androidx.lifecycle.viewModelScope
2122
import kotlinx.coroutines.ExperimentalCoroutinesApi

PlayCoreKtx/app/src/main/java/com/google/android/samples/dynamicfeatures/state/InstallViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.android.samples.dynamicfeatures.state
1717

1818
import android.util.Log
19+
import androidx.annotation.Keep
1920
import androidx.lifecycle.LiveData
2021
import androidx.lifecycle.ViewModel
2122
import androidx.lifecycle.ViewModelProvider
@@ -52,7 +53,7 @@ import kotlinx.coroutines.flow.map
5253
import kotlinx.coroutines.launch
5354

5455
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
55-
class InstallViewModel(private val manager: SplitInstallManager) : ViewModel() {
56+
class InstallViewModel @Keep constructor(private val manager: SplitInstallManager) : ViewModel() {
5657

5758
val pictureModuleStatus = getStatusLiveDataForModule(PICTURE_MODULE)
5859

PlayCoreKtx/app/src/main/java/com/google/android/samples/dynamicfeatures/state/ReviewViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.google.android.samples.dynamicfeatures.state
1717

18+
import androidx.annotation.Keep
1819
import androidx.annotation.MainThread
1920
import androidx.lifecycle.ViewModel
2021
import androidx.lifecycle.ViewModelProvider
@@ -28,7 +29,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
2829
import kotlinx.coroutines.async
2930
import kotlinx.coroutines.withContext
3031

31-
class ReviewViewModel(private val reviewManager: ReviewManager) : ViewModel() {
32+
class ReviewViewModel @Keep constructor(private val reviewManager: ReviewManager) : ViewModel() {
3233
/**
3334
* For this sample, we check if the user has been asked to review during this application session
3435
* already. Every time the app process starts fresh, it will be reset.

PlayCoreKtx/app/src/main/java/com/google/android/samples/dynamicfeatures/state/UpdateViewModel.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package com.google.android.samples.dynamicfeatures.state
1717

18+
import android.util.Log
19+
import androidx.annotation.Keep
1820
import androidx.lifecycle.ViewModel
1921
import androidx.lifecycle.ViewModelProvider
2022
import androidx.lifecycle.asLiveData
@@ -38,7 +40,7 @@ import kotlinx.coroutines.launch
3840
* ViewModel for InAppUpdates.
3941
*/
4042
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
41-
class UpdateViewModel(manager: AppUpdateManager) : ViewModel() {
43+
class UpdateViewModel @Keep constructor(manager: AppUpdateManager) : ViewModel() {
4244
val updateStatus = manager.requestUpdateFlow().catch {
4345
_events.send(Event.ToastEvent("Update info not available"))
4446
}.asLiveData()
@@ -53,6 +55,7 @@ class UpdateViewModel(manager: AppUpdateManager) : ViewModel() {
5355
}
5456
is AppUpdateResult.Available -> {
5557
with(updateResult.updateInfo) {
58+
Log.d(TAG, "Update priority: $updatePriority")
5659
if (isImmediateUpdateAllowed
5760
&&
5861
(clientVersionStalenessDays ?: 0 > 7
@@ -87,3 +90,5 @@ class UpdateViewModelProviderFactory(
8790
return modelClass.getConstructor(AppUpdateManager::class.java).newInstance(manager)
8891
}
8992
}
93+
94+
const val TAG = "UpdateViewModel"

PlayCoreKtx/app/src/main/java/com/google/android/samples/dynamicfeatures/ui/MainFragment.kt

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import android.os.Bundle
2121
import android.util.Log
2222
import android.view.View
2323
import android.widget.Toast
24+
import androidx.annotation.Keep
2425
import androidx.core.content.ContextCompat
2526
import androidx.fragment.app.Fragment
2627
import androidx.fragment.app.activityViewModels
@@ -59,10 +60,12 @@ import com.google.android.samples.dynamicfeatures.state.UpdateViewModel
5960
import com.google.android.samples.dynamicfeatures.state.UpdateViewModelProviderFactory
6061
import kotlinx.coroutines.ExperimentalCoroutinesApi
6162
import kotlinx.coroutines.flow.collect
63+
import kotlinx.coroutines.flow.drop
6264
import kotlinx.coroutines.flow.launchIn
6365
import kotlinx.coroutines.flow.onEach
6466

6567
@OptIn(ExperimentalCoroutinesApi::class)
68+
@Keep
6669
class MainFragment : Fragment(R.layout.fragment_main) {
6770

6871
private var bindings: FragmentMainBinding? = null
@@ -110,27 +113,31 @@ class MainFragment : Fragment(R.layout.fragment_main) {
110113
val colorBackgroundOff = ContextCompat.getColor(requireContext(), R.color.background)
111114
val drawable = btnToggleLight.drawable as AnimatedVectorDrawable
112115
viewLifecycleOwner.lifecycleScope.launchWhenResumed {
113-
colorViewModel.lightsOn.collect { lightsOn: Boolean ->
114-
if (lightsOn) {
115-
// The user has turned on the flashlight.
116-
drawable.start()
117-
view.setBackgroundColor(colorViewModel.backgroundColor.value)
118-
} else {
119-
// The user has turned off the flashlight. Reset the icon and color:
120-
drawable.reset()
121-
view.setBackgroundColor(colorBackgroundOff)
122-
// then check if the color was picked from a photo,
123-
// and launch a review if yes:
124-
if (colorViewModel.colorWasPicked) {
125-
colorViewModel.notifyPickedColorConsumed()
126-
val reviewInfo = reviewViewModel.obtainReviewInfo()
127-
if (reviewInfo != null) {
128-
reviewManager.launchReview(requireActivity(), reviewInfo)
129-
reviewViewModel.notifyAskedForReview()
116+
colorViewModel.lightsOn
117+
.onEach { lightsOn: Boolean ->
118+
if (lightsOn) {
119+
// The user has turned on the flashlight.
120+
drawable.start()
121+
view.setBackgroundColor(colorViewModel.backgroundColor.value)
122+
} else {
123+
// The user has turned off the flashlight. Reset the icon and color:
124+
drawable.reset()
125+
view.setBackgroundColor(colorBackgroundOff)
126+
}
127+
}
128+
.drop(1) // for launching the review ignore the starting value
129+
.collect { lightsOn ->
130+
// Check if the color was picked from a photo,
131+
// and launch a review if yes:
132+
if (!lightsOn && colorViewModel.colorWasPicked) {
133+
colorViewModel.notifyPickedColorConsumed()
134+
val reviewInfo = reviewViewModel.obtainReviewInfo()
135+
if (reviewInfo != null) {
136+
reviewManager.launchReview(requireActivity(), reviewInfo)
137+
reviewViewModel.notifyAskedForReview()
138+
}
130139
}
131140
}
132-
}
133-
}
134141
}
135142
}
136143

PlayCoreKtx/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ buildscript {
2424
'annotations' : '1.1.0',
2525
'appcompat' : '1.3.0-alpha01',
2626
'constraintLayout' : '1.1.3',
27-
'coroutines' : '1.3.8',
27+
'coroutines' : '1.3.9',
2828
'espresso' : '3.1.1',
2929
'extJunit' : '1.1.0',
3030
'fragment' : '1.3.0-alpha07',
31-
'kotlin' : '1.3.72',
31+
'kotlin' : '1.4.0',
3232
'lifecycle' : '2.3.0-alpha06',
3333
'material' : '1.2.0-rc01',
3434
'playcore' : '1.8.0',
@@ -54,7 +54,7 @@ buildscript {
5454
}
5555

5656
dependencies {
57-
classpath 'com.android.tools.build:gradle:4.1.0-beta05'
57+
classpath 'com.android.tools.build:gradle:4.1.0-rc01'
5858
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
5959
classpath("com.github.triplet.gradle:play-publisher:3.0.0-SNAPSHOT")
6060
}

PlayCoreKtx/buildSrc/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ repositories {
2626
}
2727

2828
dependencies {
29-
implementation("com.android.tools.build:gradle-api:4.1.0-beta05")
30-
implementation("com.android.tools.build:gradle:4.1.0-beta05")
29+
implementation("com.android.tools.build:gradle-api:4.1.0-rc01")
30+
implementation("com.android.tools.build:gradle:4.1.0-rc01")
3131
implementation(kotlin("stdlib"))
3232
gradleApi()
3333
}

0 commit comments

Comments
 (0)