Skip to content

Commit

Permalink
Pre Release Fixes (#326)
Browse files Browse the repository at this point in the history
* Pre Release Fixes

* Update screenshots
  • Loading branch information
cristhianescobar authored Oct 2, 2024
1 parent 5e5c52e commit de90bea
Show file tree
Hide file tree
Showing 18 changed files with 203 additions and 59 deletions.
17 changes: 10 additions & 7 deletions android/app-newm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,22 @@ fun getCurrentDateTimeVersionCode(): Int {
/**
* Generates a custom version name based on the provided major version and the current date and time.
*
* The version name follows the format: `major.YYYY.MMDDHHmm`, where:
* The version name follows the format: `major.yyMMdd.HHmm`, where:
* - `major`: The major version number passed as a parameter.
* - `YYYY`: The current year.
* - `MMDD`: The current month and day.
* - `HHmm`: The current hour and minute.
* - `yy`: The current two-digit year.
* - `MMdd`: The current month and day.
* - `HH`: The current hour in 24-hour format.
* - `mm`: The current minute.
*
* The function retrieves the current date and time using `SimpleDateFormat` to format each component.
*
* Example output for `major = 1` on October 1st, 2024 at 13:45 would be: `1.241001.1345`.
*
* @param major The major version number to be used as the first part of the version name.
* @return A custom version name string in the format: `major.YYYY.MMDDHHmm`.
* @return A custom version name string in the format: `major.yyMMdd.HHmm`.
*/
fun getCustomVersionName(major: Int): String {
val yearFormat = SimpleDateFormat("yyyy")
val yearFormat = SimpleDateFormat("yy")
val monthDayFormat = SimpleDateFormat("MMdd")
val hourFormat = SimpleDateFormat("HH")
val minuteFormat = SimpleDateFormat("mm")
Expand All @@ -176,5 +179,5 @@ fun getCustomVersionName(major: Int): String {
val hour = hourFormat.format(Date())
val minute = minuteFormat.format(Date())

return "$major.$year.$monthDay$hour$minute"
return "$major.$year$monthDay.$hour$minute"
}
6 changes: 3 additions & 3 deletions android/app-newm/src/main/java/io/newm/screens/Screen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ sealed class Screen(val screenName: String) : CircuitScreen {

data object ForceAppUpdate : Screen(screenName = AppScreens.ForceUpdateScreen.name)

data object TermsAndConditions : Screen(screenName = AppScreens.TermsAndConditionsScreen.name), WebBrowserScreen {
data object TermsOfService : Screen(screenName = AppScreens.TermsOfServiceScreen.name), WebBrowserScreen {
@IgnoredOnParcel
override val url: String = "https://newm.io/terms-and-conditions"
override val url: String = "https://newm.io/app-tos"
}

data object PrivacyPolicy : Screen(screenName = AppScreens.PrivacyPolicyScreen.name), WebBrowserScreen {
@IgnoredOnParcel
override val url: String = "https://newm.io/privacy-policy"
override val url: String = "https://newm.io/app-privacy"

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,8 @@ class NFTLibraryPresenter(
}
}.collectAsRetainedState(initial = emptyList())

val streamTracks by remember(isWalletConnected) {
if (isWalletConnected == true) {
walletNFTTracksUseCase.getAllStreamTokensFlow()
} else {
flowOf()
}
}.collectAsRetainedState(initial = emptyList())
// Do not show stream tokens in the library
val streamTracks = emptyList<NFTTrack>()

var filters: NFTLibraryFilters by rememberRetained {
mutableStateOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,31 @@ import android.widget.Toast
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import io.newm.core.resources.R
import io.newm.core.theme.GraySuit
import io.newm.core.theme.White
import io.newm.core.theme.inter
import io.newm.core.ui.permissions.AppPermission
import io.newm.core.ui.permissions.doWithPermission
import io.newm.core.ui.permissions.rememberRequestPermissionIntent
Expand All @@ -39,8 +54,10 @@ fun LinkWalletScreen(
// Handle the returned result here
val data = result.data
// Do something with the data
val newmWalletConnectionId = data?.getStringExtra(BarcodeScannerActivity.NEWM_WALLET_CONNECTION_ID).orEmpty()
Toast.makeText(context, "Wallet connected $newmWalletConnectionId", Toast.LENGTH_SHORT).show()
val newmWalletConnectionId =
data?.getStringExtra(BarcodeScannerActivity.NEWM_WALLET_CONNECTION_ID).orEmpty()
Toast.makeText(context, "Wallet connected $newmWalletConnectionId", Toast.LENGTH_SHORT)
.show()
onConnectWallet(newmWalletConnectionId)
}
}
Expand Down Expand Up @@ -70,17 +87,43 @@ fun LinkWalletScreen(
.padding(vertical = 16.dp)
.defaultMinSize(minHeight = 200.dp)
.testTag(TAG_NFT_LIBRARY_SCREEN),
contentAlignment = Alignment.BottomCenter
contentAlignment = Alignment.Center
) {
ConnectWalletPanel(onButtonClick = {
context.run {
doWithPermission(
onGranted = { onRequestPermissionGranted.invoke() },
requestPermissionLauncher = requestPermission,
appPermission = AppPermission.CAMERA
)
}
})
Column(
modifier = modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.weight(1f))
Text(
text = stringResource(id = R.string.welcome_to_newm),
textAlign = TextAlign.Center,
fontFamily = inter,
fontWeight = FontWeight.Bold,
fontSize = 24.sp,
color = White
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = stringResource(id = R.string.library_no_wallet_connected_subtitle),
textAlign = TextAlign.Center,
fontFamily = inter,
fontWeight = FontWeight.Normal,
fontSize = 14.sp,
color = GraySuit
)
Spacer(modifier = Modifier.weight(1f))

ConnectWalletPanel(onButtonClick = {
context.run {
doWithPermission(
onGranted = { onRequestPermissionGranted.invoke() },
requestPermissionLauncher = requestPermission,
appPermission = AppPermission.CAMERA
)
}
})
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.newm.feature.login.screen.TextFieldState
import io.newm.feature.login.screen.password.isPasswordValid
import io.newm.feature.login.screen.password.passwordValidationError
import io.newm.screens.Screen.PrivacyPolicy
import io.newm.screens.Screen.TermsAndConditions
import io.newm.screens.Screen.TermsOfService
import io.newm.screens.profile.OnBack
import io.newm.screens.profile.OnConnectWallet
import io.newm.screens.profile.OnLogout
Expand Down Expand Up @@ -169,7 +169,7 @@ class ProfileEditPresenter(
}
OnShowTermsAndConditions -> {
eventLogger.logClickEvent(AppScreens.AccountScreen.TERMS_AND_CONDITIONS_BUTTON)
navigator.goTo(TermsAndConditions)
navigator.goTo(TermsOfService)
}
OnShowPrivacyPolicy -> {
eventLogger.logClickEvent(AppScreens.AccountScreen.PRIVACY_POLICY_BUTTON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.slack.circuit.runtime.presenter.Presenter
import io.newm.Logout
import io.newm.screens.Screen.EditProfile
import io.newm.screens.Screen.PrivacyPolicy
import io.newm.screens.Screen.TermsAndConditions
import io.newm.screens.Screen.TermsOfService
import io.newm.screens.profile.OnConnectWallet
import io.newm.screens.profile.OnDisconnectWallet
import io.newm.screens.profile.OnEditProfile
Expand Down Expand Up @@ -82,7 +82,7 @@ class ProfilePresenter(
}
OnShowTermsAndConditions -> {
eventLogger.logClickEvent(AppScreens.AccountScreen.TERMS_AND_CONDITIONS_BUTTON)
navigator.goTo(TermsAndConditions)
navigator.goTo(TermsOfService)
}
OnShowPrivacyPolicy -> {
eventLogger.logClickEvent(AppScreens.AccountScreen.PRIVACY_POLICY_BUTTON)
Expand Down
1 change: 1 addition & 0 deletions android/core/resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<string name="library_empty_content_title">Your library is empty.</string>
<string name="library_filter_songs">Filter Songs Under</string>
<string name="library_filter_songs_under_30">30 seconds</string>
<string name="library_no_wallet_connected_subtitle">Get started by connecting your Cardano wallet to unlock your NFT music library! 🎶</string>
<string name="library_search">Search</string>
<string name="library_sort_by_artist">Artist (A to Z)</string>
<string name="library_sort_by_length">Length (Shortest to Longest)</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package io.newm.core.ui

import androidx.compose.foundation.text.ClickableText
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.sp

@Composable
fun PrivacyPolicyAndTermsSection(
modifier: Modifier = Modifier,
onPrivacyPolicyClicked: () -> Unit,
onTermsOfServiceClicked: () -> Unit
) {
val annotatedText = buildAnnotatedString {
append("By continuing, I agree to NEWM's\n")

pushStringAnnotation(tag = "privacy", annotation = "privacy_policy")
withStyle(
style = SpanStyle(
color = MaterialTheme.colors.primary,
textDecoration = TextDecoration.Underline
)
) {
append("Privacy Policy")
}
pop()

append(" and ")

pushStringAnnotation(tag = "terms", annotation = "terms_of_service")
withStyle(
style = SpanStyle(
color = MaterialTheme.colors.primary,
textDecoration = TextDecoration.Underline
)
) {
append("Terms of Service")
}
pop()
}

ClickableText(
text = annotatedText,
style = MaterialTheme.typography.body2.copy(
fontSize = 12.sp,
color = MaterialTheme.colors.onBackground
),
modifier = modifier,
onClick = { offset ->
annotatedText.getStringAnnotations(tag = "privacy", start = offset, end = offset)
.firstOrNull()?.let {
onPrivacyPolicyClicked()
}

annotatedText.getStringAnnotations(tag = "terms", start = offset, end = offset)
.firstOrNull()?.let {
onTermsOfServiceClicked()
}
}
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.newm.feature.login.screen.welcome

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.Log
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.ActivityResult
Expand All @@ -11,6 +13,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.common.api.ApiException
Expand Down Expand Up @@ -44,25 +47,42 @@ class WelcomeScreenPresenter(
@Composable
override fun present(): WelcomeScreenUiState {
val launchGoogleSignIn = rememberGoogleSignInLauncher()

val context = LocalContext.current
return WelcomeScreenUiState { event ->
when (event) {
WelcomeScreenUiEvent.CreateAccountClicked -> {
analyticsTracker.logClickEvent(AppScreens.WelcomeScreen.CREATE_ACCOUNT_BUTTON)
navigator.goTo(CreateAccountScreen)
}

WelcomeScreenUiEvent.LoginClicked -> {
analyticsTracker.logClickEvent(AppScreens.WelcomeScreen.LOGIN_WITH_EMAIL_BUTTON)
navigator.goTo(LoginScreen)
}

WelcomeScreenUiEvent.OnGoogleSignInClicked -> {
analyticsTracker.logClickEvent(AppScreens.WelcomeScreen.LOGIN_WITH_GOOGLE_BUTTON)
launchGoogleSignIn()
}

WelcomeScreenUiEvent.OnTermsOfServiceClicked -> {
analyticsTracker.logClickEvent(AppScreens.AccountScreen.TERMS_AND_CONDITIONS_BUTTON)
context.launchUrl("https://newm.io/app-tos")
}

WelcomeScreenUiEvent.OnPrivacyPolicyClicked -> {
analyticsTracker.logClickEvent(AppScreens.AccountScreen.PRIVACY_POLICY_BUTTON)
context.launchUrl("https://newm.io/app-privacy")
}
}
}
}

private fun Context.launchUrl(url: String) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}

@Composable
private fun rememberGoogleSignInLauncher(): () -> Unit {
var result by remember { mutableStateOf<Task<GoogleSignInAccount>?>(null) }
Expand All @@ -82,8 +102,8 @@ class WelcomeScreenPresenter(
)
navigator.goTo(HomeScreen)
}.onFailure {
Log.e("WelcomeScreenPresenter", "Recaptcha failed", it)
}
Log.e("WelcomeScreenPresenter", "Recaptcha failed", it)
}
} catch (e: ApiException) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@ package io.newm.feature.login.screen.welcome

import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.ClickableText
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import io.newm.core.resources.R
import io.newm.core.theme.NewmTheme
import io.newm.core.theme.inter
import io.newm.core.ui.PrivacyPolicyAndTermsSection
import io.newm.core.ui.buttons.PrimaryButton
import io.newm.core.ui.buttons.SecondaryButton
import io.newm.feature.login.screen.LoginPageMainImage
Expand Down Expand Up @@ -81,10 +87,18 @@ fun WelcomeScreenUi(
iconResId = R.drawable.ic_google_g
)
}

PrivacyPolicyAndTermsSection(
modifier = Modifier
.padding(vertical = 32.dp, horizontal = 16.dp),
onPrivacyPolicyClicked = { onEvent(WelcomeScreenUiEvent.OnPrivacyPolicyClicked) },
onTermsOfServiceClicked = { onEvent(WelcomeScreenUiEvent.OnTermsOfServiceClicked) }
)
}
}
}


@Preview
@Composable
private fun DefaultLightWelcomePreview() {
Expand Down
Loading

0 comments on commit de90bea

Please sign in to comment.