Skip to content

Commit

Permalink
Merge pull request #9 from MaxAstin/dev
Browse files Browse the repository at this point in the history
1.5.2
  • Loading branch information
MaxAstin committed Apr 4, 2024
2 parents 3780988 + 3fc3b7d commit 5865beb
Show file tree
Hide file tree
Showing 36 changed files with 467 additions and 76 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "com.bunbeauty.fakelivestream"
minSdk = 27
targetSdk = 34
versionCode = 140
versionName = "1.4.0"
versionCode = 152
versionName = "1.5.2"
multiDexEnabled = true

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -27,7 +27,7 @@ android {

buildTypes {
release {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ private const val STREAM_DURATION_PARAM = "stream_duration"
private const val FEEDBACK_POSITIVE_EVENT = "feedback_positive"
private const val FEEDBACK_NEGATIVE_EVENT = "feedback_negative"

private const val SHARE_EVENT = "share"

@Singleton
class AnalyticsManager @Inject constructor(
private val firebaseAnalytics: FirebaseAnalytics
Expand Down Expand Up @@ -55,4 +57,8 @@ class AnalyticsManager @Inject constructor(
}
}

fun trackShare() {
firebaseAnalytics.logEvent(SHARE_EVENT) {}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ private const val IMAGE_URI_KEY = "image uri"
private const val USERNAME_KEY = "username"
private const val VIEWER_COUNT_INDEX_KEY = "viewer count index"
private const val SHOULD_ASK_FEEDBACK_KEY = "should ask feedback"
private const val IS_INTRO_VIEWED = "is intro viewed"

class SharedPreferencesStorage @Inject constructor(
@ApplicationContext private val context: Context
Expand Down Expand Up @@ -46,6 +47,12 @@ class SharedPreferencesStorage @Inject constructor(
}
}

override suspend fun saveIsIntroViewed(isIntroViewed: Boolean) {
sharedPreferences.edit {
putBoolean(IS_INTRO_VIEWED, isIntroViewed)
}
}

override fun getImageUriFlow(): Flow<String?> {
return mutableImageUriFlow.asStateFlow()
}
Expand All @@ -62,6 +69,10 @@ class SharedPreferencesStorage @Inject constructor(
return sharedPreferences.getBoolean(SHOULD_ASK_FEEDBACK_KEY, defaultValue)
}

override suspend fun getIsIntroViewed(defaultValue: Boolean): Boolean {
return sharedPreferences.getBoolean(IS_INTRO_VIEWED, defaultValue)
}

private fun getImageUri(): String? {
return sharedPreferences.getString(IMAGE_URI_KEY, null)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ interface KeyValueStorage {
suspend fun saveUsername(username: String)
suspend fun saveViewerCountIndex(index: Int)
suspend fun saveShouldAskFeedback(shouldAsk: Boolean)
suspend fun saveIsIntroViewed(isIntroViewed: Boolean)

fun getImageUriFlow(): Flow<String?>
suspend fun getUsername(): String?
suspend fun getViewerCountIndex(defaultValue: Int): Int
suspend fun getShouldAskFeedback(defaultValue: Boolean): Boolean
suspend fun getIsIntroViewed(defaultValue: Boolean): Boolean

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bunbeauty.fakelivestream.common.navigation

object NavigationDestinations {
const val INTRO = "intro"
const val PREPARATION = "preparation"
const val STREAM = "stream"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import com.bunbeauty.fakelivestream.common.ui.theme.FakeLiveStreamTheme

@Composable
fun PrimaryButton(
onClick: () -> Unit,
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Button(
modifier = modifier,
shape = RoundedCornerShape(32.dp),
shape = RoundedCornerShape(6.dp),
colors = ButtonDefaults.buttonColors(containerColor = FakeLiveStreamTheme.colors.interactive),
onClick = onClick,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ data class FakeLiveStreamTypography(
fontSize = 14.sp,
lineHeight = 20.sp
),
// val action: TextStyle = TextStyle(
// fontFamily = FontFamily(Font(R.font.roboto_medium)),
// fontWeight = FontWeight.W500,
// fontSize = 14.sp,
// lineHeight = 20.sp
// ),
)
val bodyLarge: TextStyle = TextStyle(
fontFamily = FontFamily(Font(R.font.roboto_regular)),
fontWeight = FontWeight.W400,
fontSize = 16.sp,
lineHeight = 22.sp
),
)

val TextStyle.bold: TextStyle
get() {
return copy(fontWeight = FontWeight.Bold)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.bunbeauty.fakelivestream.common.util

import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.provider.Settings
import com.google.android.play.core.review.ReviewManagerFactory

fun Activity.launchInAppReview() {
val reviewManager = ReviewManagerFactory.create(this)
val request = reviewManager.requestReviewFlow()
request.addOnCompleteListener { task ->
if (task.isSuccessful) {
reviewManager.launchReviewFlow(this, task.result)
}
}
}

fun Activity.openSettings() {
startActivity(
Intent().apply {
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
data = Uri.fromParts("package", packageName, null)
}
)
}

fun Activity.openSharing(text: String): Boolean {
return try {
val intent = Intent().apply {
action = Intent.ACTION_SEND
type = "text/plain"
putExtra(Intent.EXTRA_TEXT, text)
}
val chooser = Intent.createChooser(intent, null)
startActivity(chooser)
true
} catch (exception: Exception) {
false
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.bunbeauty.fakelivestream.features.intro.domain

import com.bunbeauty.fakelivestream.common.domain.KeyValueStorage
import javax.inject.Inject

class CheckIsIntroViewedUseCase @Inject constructor(
private val keyValueStorage: KeyValueStorage
) {

suspend operator fun invoke(): Boolean {
return keyValueStorage.getIsIntroViewed( defaultValue = false)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.bunbeauty.fakelivestream.features.intro.domain

import com.bunbeauty.fakelivestream.common.domain.KeyValueStorage
import javax.inject.Inject

class SaveIsIntroSeenUseCase @Inject constructor(
private val keyValueStorage: KeyValueStorage
) {

suspend operator fun invoke(isIntroViewed: Boolean) {
return keyValueStorage.saveIsIntroViewed(isIntroViewed = isIntroViewed)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.bunbeauty.fakelivestream.features.intro.presentation

import com.bunbeauty.fakelivestream.common.presentation.Base

interface Intro {

data class State(
val isChecked: Boolean
) : Base.State

sealed interface Action : Base.Action {
data object NextClick : Action
}

sealed interface Event : Base.Event {
data object OpenPreparation : Event
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.bunbeauty.fakelivestream.features.intro.presentation

import androidx.lifecycle.viewModelScope
import com.bunbeauty.fakelivestream.common.presentation.BaseViewModel
import com.bunbeauty.fakelivestream.features.intro.domain.CheckIsIntroViewedUseCase
import com.bunbeauty.fakelivestream.features.intro.domain.SaveIsIntroSeenUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class IntroViewModel @Inject constructor(
private val checkIsIntroViewedUseCase: CheckIsIntroViewedUseCase,
private val saveIsIntroSeenUseCase: SaveIsIntroSeenUseCase,
) : BaseViewModel<Intro.State, Intro.Action, Intro.Event>(
initState = {
Intro.State(isChecked = false)
}
) {

init {
viewModelScope.launch {
if (checkIsIntroViewedUseCase()) {
sendEvent(Intro.Event.OpenPreparation)
} else {
setState {
copy(isChecked = true)
}
}
}
}

override fun onAction(action: Intro.Action) {
when (action) {
Intro.Action.NextClick -> {
viewModelScope.launch {
saveIsIntroSeenUseCase(isIntroViewed = true)
sendEvent(Intro.Event.OpenPreparation)
}
}
}
}

}
Loading

0 comments on commit 5865beb

Please sign in to comment.