Skip to content

Commit

Permalink
Merge branch 'development' of github.com:projectNEWM/newm-mobile into…
Browse files Browse the repository at this point in the history
… MOBILE-220-Fix-filter-for-Songs-Under-30-Seconds

* 'development' of github.com:projectNEWM/newm-mobile:
  Aab action flow (#324)
  Modify string for when a user shares a song (#322)
  Introduced Automatic Versioning with Manual Control Over Major Versions (#318)
  Add client header (#321)
  Migrate upload artifact to v4 (#320)
  Display app and build version (#319)
  Update repeat button color states (#317)
  Share button implementation (#316)
  Mobile 220 fix filter for songs under 30 seconds (#315)
  • Loading branch information
martyu committed Sep 29, 2024
2 parents b2a7aae + fcb5edf commit 8967399
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-preview-branch-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: apk
path: ${{steps.sign_app.outputs.signedReleaseFile}}
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/android-release-bundle-ontag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Create AAB Release Bundle
on:
release:
types: [published]
jobs:
build_android_release_artifacts:
if: ${{ startsWith(github.event.release.tag_name, 'androidRelease') }}
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v2

- name: set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

- name: Setup build tool version variable
run: |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
echo Last build tool version is: $BUILD_TOOL_VERSION
- name: Setup local.properties
run: |
echo STAGING_URL="${{ vars.STAGING_URL }}" >> ./local.properties
echo PRODUCTION_URL="${{ vars.PRODUCTION_URL }}" >> ./local.properties
echo GOOGLE_AUTH_CLIENT_ID="${{ vars.GOOGLE_AUTH_CLIENT_ID }}" >> ./local.properties
echo "RECAPTCHA_SITE_KEY=${{ secrets.RECAPTCHA_SITE_KEY }}" >> ./local.properties
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> ./local.properties
echo "ANDROID_SENTRY_DSN=${{ secrets.ANDROID_SENTRY_DSN }}" >> ./local.properties
echo "auth.token=${{ secrets.ANDROID_SENTRY_AUTH_TOKEN}}" >> ./sentry.properties
- name: create google-services.json
env:
GOOGLE_SERVICES_JSON: ${{ vars.GOOGLE_SERVICES_JSON }}
run: echo $GOOGLE_SERVICES_JSON > ./android/app-newm/google-services.json

- name: build android apk
run: ./gradlew :android:app-newm:assembleProductionRelease

- name: build bundle production
run: ./gradlew :android:app-newm:bundleProduction

- uses: r0adkll/sign-android-release@v1
name: Sign app APK
# ID used to access action output
id: sign_app
with:
releaseDirectory: android/app-newm/build/outputs/apk/production/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}

- uses: r0adkll/sign-android-release@v1
name: Sing app bundle
# ID used to access action output
id: sign_aab
with:
releaseDirectory: android/app-newm/build/outputs/bundle/productionRelease
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}

- uses: actions/upload-artifact@v4
with:
name: apk
path: ${{steps.sign_app.outputs.signedReleaseFile}}

- uses: actions/upload-artifact@v4
with:
name: aab
path: ${{steps.sign_aab.outputs.signedReleaseFile}}

- name: Upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{secrets.FIREBASE_ANDROID_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: newm-team
file: ${{steps.sign_app.outputs.signedReleaseFile}}
62 changes: 58 additions & 4 deletions android/app-newm/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import java.text.SimpleDateFormat
import java.util.Date

apply(from = "../../gradle_include/compose.gradle")
apply(from = "../../gradle_include/circuit.gradle")
apply(from = "../../gradle_include/flipper.gradle")

plugins {
id("com.android.application")
id( "com.google.gms.google-services")
id("com.google.gms.google-services")
id("kotlin-parcelize")
kotlin("android")
kotlin("kapt")
Expand All @@ -23,8 +25,8 @@ android {
applicationId = "io.newm"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 5
versionName = "0.3.0"
versionCode = getCurrentDateTimeVersionCode()
versionName = getCustomVersionName(major = 1)
testInstrumentationRunner = "io.newm.NewmAndroidJUnitRunner"
testApplicationId = "io.newm.test"
}
Expand Down Expand Up @@ -60,7 +62,11 @@ android {
dimension = "version"
}
all {
resValue("string", "account_type", "$applicationId${applicationIdSuffix.orEmpty()}.account")
resValue(
"string",
"account_type",
"$applicationId${applicationIdSuffix.orEmpty()}.account"
)
}
}

Expand Down Expand Up @@ -124,3 +130,51 @@ sentry {
includeSourceContext.set(true)
telemetry.set(true)
}


/**
* Generates a version code based on the current date and time in the format `yyMMddHH`.
*
* The version code is an integer composed of:
* - `yy`: The last two digits of the current year.
* - `MM`: The current month.
* - `dd`: The current day of the month.
* - `HH`: The current hour (24-hour format).
*
* The function formats the current date and time using `SimpleDateFormat`,
* converts it into a string, and then parses it as an integer.
*
* @return An integer representing the current date and time in the format `yyMMddHH`.
*/
fun getCurrentDateTimeVersionCode(): Int {
val dateFormat = SimpleDateFormat("yyMMddHH")
return dateFormat.format(Date()).toInt()
}

/**
* 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:
* - `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.
*
* The function retrieves the current date and time using `SimpleDateFormat` to format each component.
*
* @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`.
*/
fun getCustomVersionName(major: Int): String {
val yearFormat = SimpleDateFormat("yyyy")
val monthDayFormat = SimpleDateFormat("MMdd")
val hourFormat = SimpleDateFormat("HH")
val minuteFormat = SimpleDateFormat("mm")

val year = yearFormat.format(Date())
val monthDay = monthDayFormat.format(Date())
val hour = hourFormat.format(Date())
val minute = minuteFormat.format(Date())

return "$major.$year.$monthDay$hour$minute"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material.Divider
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetState
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.font.FontWeight
import androidx.compose.ui.unit.dp
import io.newm.BuildConfig
import io.newm.core.resources.R
import io.newm.core.theme.Black90
import io.newm.core.theme.Gray400
import io.newm.core.ui.buttons.PrimaryButton
import io.newm.core.ui.buttons.SecondaryButton
import io.newm.core.ui.text.versionTextStyle
import io.newm.shared.public.analytics.NewmAppEventLogger
import io.newm.shared.public.analytics.events.AppScreens

Expand Down Expand Up @@ -71,11 +77,34 @@ fun ProfileBottomSheetLayout(
text = stringResource(id = R.string.user_account_logout),
onClick = onLogout
)
Spacer(modifier = Modifier.height(32.dp))
Spacer(modifier = Modifier.height(16.dp))
AppVersion()
}
}
},
scrimColor = Black90,
content = content
)
}

@Composable
private fun AppVersion(){
Column {
Text(
modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
.fillMaxWidth()
.wrapContentWidth(Alignment.CenterHorizontally),
text = "Version " + BuildConfig.VERSION_NAME,
style = versionTextStyle.copy(fontWeight = FontWeight.Bold)
)
Text(
modifier = Modifier
.padding(horizontal = 16.dp)
.fillMaxWidth()
.wrapContentWidth(Alignment.CenterHorizontally),
text = "Build: " + BuildConfig.VERSION_CODE,
style = versionTextStyle
)
}
}
16 changes: 16 additions & 0 deletions android/core/resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<string name="newm_connect_wallet_instruction_1">1. Open your Cardano supported web3 wallet app</string>
<string name="newm_connect_wallet_instruction_2">2. Use this URL to connect your wallet</string>
<string name="newm_connect_wallet_instruction_title">how to connect</string>
<string name="newm_download_app_landing_page" translatable="false">"https://newm.io/app/"</string>
<string name="newm_tools_connect_wallet_url">https://tools.newm.io/wallet-connect</string>
<string name="newm_tools_url">https://tools.newm.io</string>
<string name="next">Next</string>
Expand Down Expand Up @@ -79,6 +80,21 @@
<string name="reset_password_new_password">Your new password</string>
<string name="search">Search</string>
<string name="second_fragment_label">Second Fragment</string>
<string name="share_phrase_1">Tune in to %1$s by %2$s on NEWM app! \n👉 Discover your next favorite song: %3$s</string>
<string name="share_phrase_10">Find your rhythm with %1$s by %2$s on NEWM app. \n👉 Download NEWM app to start listening: %3$s</string>
<string name="share_phrase_11">Bless your ears with %1$s by %2$s on NEWM app! \n👉 Download NEWM app to start listening: %3$s</string>
<string name="share_phrase_12">%1$s by %2$s is the track you didn’t know you needed on NEWM app. \n👉 Download NEWM app to discover &amp; listen: %3$s</string>
<string name="share_phrase_13">Ready to refresh your playlist? %1$s by %2$s is live on NEWM app! \n👉 Check it out: %3$s</string>
<string name="share_phrase_14">%1$s by %2$s is perfect for your next playlist. Stream it on NEWM app! \n👉 Discover it here: %3$s</string>
<string name="share_phrase_15">If you\'re not listening to %1$s by %2$s, you\'re missing out! \n👉 Download NEWM app to discover &amp; listen: %3$s</string>
<string name="share_phrase_2">%1$s by %2$s is a whole vibe on NEWM app! \n👉 Discover your next playlist-worthy track: %3$s</string>
<string name="share_phrase_3">Ready for a new vibe? %1$s by %2$s is waiting for you on NEWM app! \n👉 Discover more music on NEWM app: %3$s</string>
<string name="share_phrase_4">Can\'t stop playing %1$s by %2$s? Stream it on NEWM app now! \n👉 Discover more: %3$s</string>
<string name="share_phrase_5">Lose yourself in %1$s by %2$s! Download the NEWM app and start listening now. \n👉 Explore more music: %3$s</string>
<string name="share_phrase_6">Welcome to your next music obsession – %1$s by %2$s! \nDownload the NEWM app and start listening now. \n👉 %3$s</string>
<string name="share_phrase_7">Explore %1$s by %2$s on NEWM app and level-up your playlist! \n👉 Download NEWM app to discover &amp; listen: %3$s</string>
<string name="share_phrase_8">Love discovering new music? Start with %1$s by %2$s on NEWM app. \n👉 Download NEWM app to discover &amp; listen: %3$s</string>
<string name="share_phrase_9">Looking for fresh tracks? %1$s by %2$s is a must-listen on NEWM app! \n👉 Download NEWM app to discover &amp; listen: %3$s</string>
<string name="stars">Stars</string>
<string name="subtitle_this_week_earnings">Earnings</string>
<string name="subtitle_this_week_followers">Followers this week</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ val formEmailStyle = TextStyle(
color = Gray100
)

val versionTextStyle = TextStyle(
fontSize = 12.sp,
fontFamily = inter,
fontWeight = FontWeight.Light,
color = Gray100
)

object TextFieldWithLabelDefaults {
object KeyboardOptions {
@Stable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.newm.feature.musicplayer

import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import androidx.compose.animation.animateColorAsState
Expand Down Expand Up @@ -47,7 +49,6 @@ import io.newm.core.resources.R
import io.newm.core.theme.Black
import io.newm.core.theme.DarkPink
import io.newm.core.theme.DarkViolet
import io.newm.core.theme.Gray23
import io.newm.core.theme.Gray500
import io.newm.core.theme.GraySuit
import io.newm.core.theme.White
Expand All @@ -61,6 +62,7 @@ import io.newm.feature.musicplayer.models.PlaybackRepeatMode
import io.newm.feature.musicplayer.models.PlaybackState
import io.newm.feature.musicplayer.models.PlaybackStatus
import io.newm.feature.musicplayer.models.Track
import io.newm.feature.musicplayer.share.ShareButton
import io.newm.feature.musicplayer.viewmodel.PlaybackUiEvent
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -254,8 +256,10 @@ fun PlaybackControlPanel(
modifier = Modifier.padding(horizontal = 12.dp),
onClick = { onEvent(PlaybackUiEvent.Next) })
Spacer(modifier = Modifier.weight(1f))
// TODO: Implement share functionality
//ShareButton(onClick = {})
ShareButton(
songTitle = playbackStatus.track?.title,
songArtist = playbackStatus.track?.artist
)
}
}
}
Expand Down Expand Up @@ -338,16 +342,6 @@ fun NextTrackButton(onClick: () -> Unit, modifier: Modifier = Modifier) {
}
}

@Composable
fun ShareButton(onClick: () -> Unit, modifier: Modifier = Modifier) {
IconButton(modifier = modifier, onClick = onClick) {
Icon(
painter = painterResource(id = R.drawable.ic_share),
contentDescription = "Share Song",
tint = Color.White
)
}
}

@Composable
fun RepeatButton(
Expand All @@ -364,7 +358,7 @@ fun RepeatButton(
Icon(
painter = painterResource(id = imageRes),
contentDescription = "Repeat",
tint = if (repeatMode == PlaybackRepeatMode.REPEAT_OFF) Gray23 else White
tint = if (repeatMode == PlaybackRepeatMode.REPEAT_OFF) White else DarkViolet
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.newm.feature.musicplayer.share

import android.content.Context
import io.newm.core.resources.R

fun Context.getRandomSharePhrase(songTitle: String, songArtist: String, url: String): String {
val phraseIds = listOf(
R.string.share_phrase_1,
R.string.share_phrase_2,
R.string.share_phrase_3,
R.string.share_phrase_4,
R.string.share_phrase_5,
R.string.share_phrase_6,
R.string.share_phrase_7,
R.string.share_phrase_8,
R.string.share_phrase_9,
R.string.share_phrase_10,
R.string.share_phrase_11,
R.string.share_phrase_12,
R.string.share_phrase_13,
R.string.share_phrase_14,
R.string.share_phrase_15
)
return this.getString(phraseIds.random(), songTitle, songArtist, url)
}
Loading

0 comments on commit 8967399

Please sign in to comment.