Skip to content

Commit

Permalink
Merge pull request #7 from clemenceroumy/refresh-games
Browse files Browse the repository at this point in the history
Refresh games
  • Loading branch information
clemenceroumy authored Sep 3, 2023
2 parents 64b6395 + 9bfd8e3 commit a535eba
Show file tree
Hide file tree
Showing 56 changed files with 212 additions and 96 deletions.
14 changes: 7 additions & 7 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 21 additions & 19 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ plugins {
id("org.jetbrains.kotlin.android")
id("kotlin-android")
id("kotlin-kapt")
id("com.google.devtools.ksp")
id("com.google.dagger.hilt.android")
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
}

android {
val appVersionCode = 2
val appVersionName = "2.0.0"
val appVersionName = "2.0.1"

namespace = "com.croumy.hltbwearos"
compileSdk = 34
Expand All @@ -31,6 +32,9 @@ android {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
debug {
applicationIdSuffix = ".debug"
}
applicationVariants.all {
outputs.forEach { output ->
if (output is com.android.build.gradle.internal.api.BaseVariantOutputImpl) {
Expand Down Expand Up @@ -62,48 +66,48 @@ android {


dependencies {
val composeVersion = "1.5.0-alpha04"
val wearComposeVersion = "1.1.2"
val composeVersion = "1.5.0"
val wearComposeVersion = "1.2.0"
val hiltVersion = "2.46"
val hiltCoreVersion = "1.0.0"
val workVersion = "2.8.1"
val klockVersion = "2.2.0"
val klockVersion = "3.4.0"
val roomVersion = "2.5.2"
val kotlinxVersion = "1.7.3"

// CORE
implementation("androidx.lifecycle:lifecycle-service:2.6.1")
implementation("androidx.percentlayout:percentlayout:1.0.0")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.recyclerview:recyclerview:1.3.0")
implementation("androidx.recyclerview:recyclerview:1.3.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.compose.ui:ui-tooling-preview:$composeVersion")
implementation("androidx.core:core-ktx:1.10.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.7.3")
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinxVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$kotlinxVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxVersion")

// WEAR OS
implementation("androidx.wear:wear:1.2.0")
implementation("androidx.wear:wear:1.3.0")
implementation("androidx.wear:wear-ongoing:1.0.0")
implementation("androidx.wear:wear-remote-interactions:1.0.0")
implementation("androidx.wear:wear-remote-interactions:1.0.0")
implementation("com.google.android.gms:play-services-wearable:18.0.0")

// COMPOSE
implementation("androidx.activity:activity-compose:1.7.1")
debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion")
debugImplementation("androidx.compose.ui:ui-test-manifest:$composeVersion")
implementation("androidx.compose.ui:ui-tooling-preview:$composeVersion")
implementation("androidx.activity:activity-compose:1.7.2")
implementation("androidx.compose.ui:ui:$composeVersion")
implementation("androidx.compose.material:material:$composeVersion")
implementation("androidx.compose.material:material-icons-extended:${composeVersion}")
implementation("androidx.wear.compose:compose-material:$wearComposeVersion")
implementation("androidx.wear.compose:compose-foundation:$wearComposeVersion")
implementation("androidx.wear.compose:compose-navigation:1.2.0-rc01")
implementation("androidx.navigation:navigation-compose:2.6.0")
implementation("androidx.wear.compose:compose-navigation:$wearComposeVersion")
implementation("androidx.navigation:navigation-compose:2.7.1")
implementation("androidx.compose.animation:animation:${composeVersion}")


implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2")

//HILT
kapt("com.google.dagger:hilt-android-compiler:$hiltVersion")
kapt("com.google.dagger:hilt-compiler:$hiltVersion")
Expand All @@ -123,7 +127,7 @@ dependencies {
// ROOM
implementation("androidx.room:room-runtime:$roomVersion")
annotationProcessor("androidx.room:room-compiler:$roomVersion")
kapt("androidx.room:room-compiler:$roomVersion")
ksp("androidx.room:room-compiler:$roomVersion")

//Picture
implementation("io.coil-kt:coil-compose:2.3.0")
Expand All @@ -136,8 +140,6 @@ dependencies {

// Tests
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion")
debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion")
debugImplementation("androidx.compose.ui:ui-test-manifest:$composeVersion")
}

kapt {
Expand Down
Binary file added app/src/debug/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/src/debug/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
5 changes: 5 additions & 0 deletions app/src/debug/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file added app/src/debug/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app/src/debug/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app/src/debug/res/mipmap-xhdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app/src/debug/res/mipmap-xxhdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app/src/debug/res/mipmap-xxxhdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions app/src/debug/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#000000</color>
</resources>
Original file line number Diff line number Diff line change
@@ -1,49 +1,46 @@
package com.croumy.hltb_wearos.presentation

import android.annotation.SuppressLint
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.fragment.app.FragmentActivity
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavHostController
import androidx.wear.compose.material.SwipeToDismissBoxState
import androidx.wear.compose.material.rememberSwipeToDismissBoxState
import androidx.wear.compose.navigation.rememberSwipeDismissableNavController
import androidx.wear.compose.navigation.rememberSwipeDismissableNavHostState
import androidx.wear.remote.interactions.RemoteActivityHelper
import androidx.wear.widget.ConfirmationOverlay
import androidx.work.await
import com.croumy.hltb_wearos.presentation.data.AppService
import com.croumy.hltb_wearos.presentation.data.HLTBService
import com.croumy.hltb_wearos.presentation.data.PreferencesService
import com.croumy.hltb_wearos.presentation.models.Constants
import com.croumy.hltb_wearos.presentation.models.Constants.Companion.DATA_LAYER_TOKEN_CHANNEL
import com.croumy.hltb_wearos.presentation.models.Constants.Companion.PREFERENCES
import com.croumy.hltb_wearos.presentation.navigation.NavGraph
import com.croumy.hltb_wearos.presentation.theme.HLTBwearosTheme
import com.google.android.gms.wearable.CapabilityClient
import com.google.android.gms.wearable.DataClient
import com.google.android.gms.wearable.MessageClient
import com.google.android.gms.wearable.MessageEvent
import com.google.android.gms.wearable.Wearable
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.coroutines.tasks.await
import javax.inject.Inject
import kotlin.coroutines.cancellation.CancellationException

val LocalNavController = staticCompositionLocalOf<NavHostController> { error("No SwipeDismissableNavHostState found!") }
val LocalNavSwipeBox = staticCompositionLocalOf<SwipeToDismissBoxState> { error("No SwipeToDismissBoxState found!") }

@AndroidEntryPoint
class MainActivity : FragmentActivity(), MessageClient.OnMessageReceivedListener {
class MainActivity : ComponentActivity(), MessageClient.OnMessageReceivedListener {

// CREATING AN INSTANCE OF THE SERVICE WHEN APP STARTS
@Inject
lateinit var appService: AppService

@Inject
lateinit var hltbService: HLTBService

@Inject
lateinit var preferencesService: PreferencesService

Expand All @@ -58,9 +55,11 @@ class MainActivity : FragmentActivity(), MessageClient.OnMessageReceivedListener
val swipeBoxState = rememberSwipeToDismissBoxState()
val navState = rememberSwipeDismissableNavHostState(swipeBoxState)


HLTBwearosTheme {
NavGraph(navController = navController, navState = navState)
CompositionLocalProvider(
LocalNavController provides navController,
LocalNavSwipeBox provides swipeBoxState
) { NavGraph(navController = navController, navState = navState) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ fun GameItem(game: Game, isRunning: Boolean, onClick: () -> Unit, modifier: Modi
maxLines = 3,
overflow = TextOverflow.Ellipsis,
)
Spacer(Modifier.width(Dimensions.xsPadding))
Text(game.platform, style = MaterialTheme.typography.body2)
if(game.platform.isNotEmpty()) {
Spacer(Modifier.width(Dimensions.xsPadding))
Text(game.platform, style = MaterialTheme.typography.body2)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class AppService @Inject constructor(
submitRequest.value = null
}


fun startTimer() {
timer.value = timer.value.copy(state = TimerState.STARTED)
timer.value = timer.value.copy(time = timer.value.time.plus(10.milliseconds))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.croumy.hltb_wearos.presentation.helpers

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper

fun Context.findActivity(): Activity {
var context = this
while (context is ContextWrapper) {
if (context is Activity) return context
context = context.baseContext
}
throw IllegalStateException("no activity")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.croumy.hltb_wearos.presentation.helpers
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.Log
import androidx.wear.remote.interactions.RemoteActivityHelper
import com.croumy.hltb_wearos.presentation.models.Constants
import kotlinx.coroutines.guava.await
Expand All @@ -14,12 +15,16 @@ class Launcher {
link: String,
context: Context
) {
// LAUNCH PHONE APP (WHICH WILL SEND BACK THE TOKEN AND USERID)
val intent = Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse(link))
try {
// LAUNCH PHONE APP (WHICH WILL SEND BACK THE TOKEN AND USERID)
val intent = Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse(link))

RemoteActivityHelper(context).startRemoteActivity(intent).await()
RemoteActivityHelper(context).startRemoteActivity(intent).await()
} catch (throwable: RemoteActivityHelper.RemoteIntentException) {
Log.i("Launcher.launchRemoteActivity", "Error opening remote app : $throwable")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.croumy.hltb_wearos.presentation.models

import com.croumy.hltbwearos.BuildConfig

class Constants {
companion object {
const val CHANNEL_ID = "TimerChannel"
const val NOTIFICATION_ID = 1

const val DEEPLINK_PHONE = "app://com.croumy.hltbwearos"
const val DEEPLINK_PHONE = "app://${BuildConfig.APPLICATION_ID}"
const val GITHUB_REPO = "https://github.com/clemenceroumy/HLTB-wearOS/releases"
const val PHONE_CAPABILITY = "verify_remote_example_phone_app"

Expand All @@ -15,5 +17,8 @@ class Constants {
const val PREFERENCES = "com.croumy.hltbwearos_preferences"
const val PREFERENCES_TOKEN = "hltb_token"
const val PREFERENCES_USER_ID = "user_id"

const val HOME_NEED_REFRESH = "needRefresh"
const val HOME_PREVIOUS_GAME_ID = "previousGameId"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ fun NavGraph(navController: NavHostController, navState: SwipeDismissableNavHost
) {
composable(NavRoutes.StartApp.route) {
StartApp(
navigateToHome = { actions.navigateToHome()}
navigateToHome = { actions.navigateToHome() }
)
}

composable(NavRoutes.Home.route) {
HomeScreen(
navigateToGame = { actions.navigateToGameDetails(it)}
navigateToGame = { actions.navigateToGameDetails(it) }
)
}

Expand All @@ -41,9 +41,7 @@ fun NavGraph(navController: NavHostController, navState: SwipeDismissableNavHost
uriPattern = "app://${BuildConfig.APPLICATION_ID}/${NavRoutes.GameDetails.routeWithArgs}"
}),
) {
GameDetails(
onBack = { actions.navigateToHome() },
)
GameDetails()
}
}
}
Loading

0 comments on commit a535eba

Please sign in to comment.