Skip to content

Commit

Permalink
Merge pull request #91 from SuddenH4X/release/2.7.0
Browse files Browse the repository at this point in the history
Release/2.7.0
  • Loading branch information
SuddenH4X authored Sep 3, 2023
2 parents f7bd30a + 9495166 commit 9138f45
Show file tree
Hide file tree
Showing 19 changed files with 327 additions and 210 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This library:
- uses AndroidX
- uses no third party dependencies
- is easy debuggable
- is Android 13 (API 33) ready
- is Android 14 (API 34) ready
- is easy to use

## How to use
Expand All @@ -42,7 +42,7 @@ The library supports API level 14 and higher. You can simply include it in your
```groovy
dependencies {
...
implementation 'com.suddenh4x.ratingdialog:awesome-app-rating:2.6.0'
implementation 'com.suddenh4x.ratingdialog:awesome-app-rating:2.7.0'
}
```

Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
buildscript {
ext.kotlin_version = '1.8.0'
ext.kotlin_version = '1.9.10'
repositories {
google()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'de.mannodermaus.gradle.plugins:android-junit5:1.8.2.1'
classpath 'org.jlleitschuh.gradle:ktlint-gradle:11.0.0'
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
classpath 'de.mannodermaus.gradle.plugins:android-junit5:1.9.3.0'
classpath 'org.jlleitschuh.gradle:ktlint-gradle:11.5.1'
classpath 'io.github.gradle-nexus:publish-plugin:1.3.0'
}
}

Expand All @@ -31,6 +31,6 @@ subprojects {
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
29 changes: 11 additions & 18 deletions exampleapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android'

android {
namespace 'com.suddenh4x.ratingdialog.exampleapp'
compileSdkVersion 33
compileSdk 34
defaultConfig {
applicationId "com.suddenh4x.ratingdialog.exampleapp"
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
versionCode 1
versionName "1.0.0"
}
Expand All @@ -24,30 +24,23 @@ android {
compose = true
}


kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
composeOptions {
kotlinCompilerExtensionVersion '1.5.3'
}

composeOptions {
kotlinCompilerExtensionVersion '1.4.0'
kotlin {
jvmToolchain 17
}
}

dependencies {
implementation project(':library')
implementation 'androidx.activity:activity-compose:1.6.1'
implementation 'androidx.compose.material:material:1.3.1'
implementation 'androidx.compose.ui:ui-tooling:1.3.3'
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'androidx.activity:activity-compose:1.7.2'
implementation 'androidx.compose.material3:material3:1.1.1'
implementation 'androidx.compose.ui:ui-tooling:1.5.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "com.google.android.material:compose-theme-adapter:1.2.1"
implementation 'com.google.android.material:material:1.7.0'
implementation 'com.google.android.material:material:1.9.0'
}

afterEvaluate {
Expand Down
2 changes: 1 addition & 1 deletion exampleapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</intent-filter>
</activity>
<activity
android:name="com.suddenh4x.ratingdialog.exampleapp.JetpackComposeActivity"
android:name="com.suddenh4x.ratingdialog.exampleapp.composeexample.ComposeExampleActivity"
android:exported="false" />
</application>
</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
import androidx.lifecycle.MutableLiveData
import com.suddenh4x.ratingdialog.AppRating
import com.suddenh4x.ratingdialog.exampleapp.composeexample.ComposeExampleActivity
import com.suddenh4x.ratingdialog.preferences.MailSettings
import com.suddenh4x.ratingdialog.preferences.RatingThreshold

Expand Down Expand Up @@ -152,7 +153,7 @@ class MainActivity : AppCompatActivity() {
}

fun onJetpackComposeButtonClicked(@Suppress("UNUSED_PARAMETER") view: View) {
val jetpackComposeIntent = Intent(this, JetpackComposeActivity::class.java)
val jetpackComposeIntent = Intent(this, ComposeExampleActivity::class.java)
startActivity(jetpackComposeIntent)
}

Expand Down
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()
}
}
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
}
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) }
}
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
}
}
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)
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,
)
Loading

0 comments on commit 9138f45

Please sign in to comment.