-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from SuddenH4X/release/2.7.0
Release/2.7.0
- Loading branch information
Showing
19 changed files
with
327 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 0 additions & 115 deletions
115
exampleapp/src/main/java/com/suddenh4x/ratingdialog/exampleapp/JetpackComposeActivity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
.../main/java/com/suddenh4x/ratingdialog/exampleapp/composeexample/ComposeExampleActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.suddenh4x.ratingdialog.exampleapp.composeexample | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.viewModels | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.platform.ComposeView | ||
import com.suddenh4x.ratingdialog.AppRating | ||
import com.suddenh4x.ratingdialog.exampleapp.R | ||
import com.suddenh4x.ratingdialog.exampleapp.composeexample.ui.ComposeExampleApp | ||
|
||
class ComposeExampleActivity : ComponentActivity() { | ||
private val viewModel: ComposeExampleViewModel by viewModels() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_jetpack_compose) | ||
AppRating.reset(this) | ||
|
||
val composeView = findViewById<ComposeView>(R.id.ComposeView) | ||
composeView.setContent { | ||
val uiState by viewModel.uiState.collectAsState() | ||
|
||
ComposeExampleApp( | ||
uiState = uiState, | ||
openGoogleInAppReview = ::openGoogleInAppReview, | ||
dismissSnackbar = viewModel::dismissSnackbar, | ||
finishActivity = ::finish | ||
) | ||
} | ||
} | ||
|
||
private fun openGoogleInAppReview() { | ||
AppRating.Builder(this) | ||
.useGoogleInAppReview() | ||
.setGoogleInAppReviewCompleteListener { successful -> | ||
viewModel.showSnackbar(successful) | ||
} | ||
.setDebug(true) | ||
.showIfMeetsConditions() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...c/main/java/com/suddenh4x/ratingdialog/exampleapp/composeexample/ComposeExampleUiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.suddenh4x.ratingdialog.exampleapp.composeexample | ||
|
||
sealed interface ComposeExampleUiState { | ||
|
||
data object NoSnackbar : ComposeExampleUiState | ||
|
||
data class Snackbar(val snackbarText: String) : ComposeExampleUiState | ||
} |
23 changes: 23 additions & 0 deletions
23
...main/java/com/suddenh4x/ratingdialog/exampleapp/composeexample/ComposeExampleViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.suddenh4x.ratingdialog.exampleapp.composeexample | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.SharingStarted | ||
import kotlinx.coroutines.flow.map | ||
import kotlinx.coroutines.flow.stateIn | ||
import kotlinx.coroutines.flow.update | ||
|
||
class ComposeExampleViewModel : ViewModel() { | ||
|
||
private val viewModelState = MutableStateFlow(ComposeExampleViewModelState()) | ||
|
||
val uiState = viewModelState.map(ComposeExampleViewModelState::toUiState) | ||
.stateIn(viewModelScope, SharingStarted.Eagerly, viewModelState.value.toUiState()) | ||
|
||
fun showSnackbar(successful: Boolean) = viewModelState.update { | ||
it.copy(snackbarText = "Google in-app review completed (successful: $successful)") | ||
} | ||
|
||
fun dismissSnackbar() = viewModelState.update { it.copy(snackbarText = null) } | ||
} |
9 changes: 9 additions & 0 deletions
9
...java/com/suddenh4x/ratingdialog/exampleapp/composeexample/ComposeExampleViewModelState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.suddenh4x.ratingdialog.exampleapp.composeexample | ||
|
||
data class ComposeExampleViewModelState(val snackbarText: String? = null) { | ||
|
||
fun toUiState(): ComposeExampleUiState = when { | ||
snackbarText != null -> ComposeExampleUiState.Snackbar(snackbarText) | ||
else -> ComposeExampleUiState.NoSnackbar | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...in/java/com/suddenh4x/ratingdialog/exampleapp/composeexample/composetheme/ComposeColor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.suddenh4x.ratingdialog.exampleapp.composeexample.composetheme | ||
|
||
import androidx.compose.ui.graphics.Color | ||
|
||
val md_theme_light_primary = Color(0xFF008577) | ||
val md_theme_light_onPrimary = Color(0xFFF4EFF4) | ||
|
||
val md_theme_dark_primary = Color(0xFF00574B) | ||
val md_theme_dark_onPrimary = Color(0xFFF4EFF4) |
13 changes: 13 additions & 0 deletions
13
...a/com/suddenh4x/ratingdialog/exampleapp/composeexample/composetheme/ComposeColorScheme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.suddenh4x.ratingdialog.exampleapp.composeexample.composetheme | ||
|
||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
|
||
internal val LightColorScheme = lightColorScheme( | ||
primary = md_theme_light_primary, | ||
onPrimary = md_theme_light_onPrimary, | ||
) | ||
internal val DarkColorScheme = darkColorScheme( | ||
primary = md_theme_dark_primary, | ||
onPrimary = md_theme_dark_onPrimary, | ||
) |
Oops, something went wrong.