Skip to content

Commit

Permalink
- baselineprofile enhancement
Browse files Browse the repository at this point in the history
- filter giveaways
- open links in customChromeTab
- delay splash screen
  • Loading branch information
MostafaMohamed2002 committed Nov 8, 2024
1 parent 33b7f29 commit f330331
Show file tree
Hide file tree
Showing 32 changed files with 25,386 additions and 15,635 deletions.
27 changes: 8 additions & 19 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ jobs:
runs-on: ubuntu-latest

steps:
# 🔍 Step 1: Check out the code
- name: 🛎️ Check out code
uses: actions/checkout@v3

# ☕ Step 2: Set up JDK 17 for Gradle
- name: ☕ Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

# 🏃‍♂️ Step 3: Cache Gradle dependencies to speed up builds
- name: 🗂️ Cache Gradle dependencies
uses: actions/cache@v3
with:
Expand All @@ -33,37 +29,30 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
# 🛠️ Step 4: Grant execute permissions for gradlew
- name: 🔑 Grant execute permission for gradlew
run: chmod +x ./gradlew

# 🏗️ Step 5: Build the project with Gradle
- name: 🏗️ Build with Gradle
run: ./gradlew assembleRelease --scan --no-daemon

# 🧪 Step 6: Run Unit Tests (Optional)
- name: 🧪 Run Unit Tests
run: ./gradlew test
# - name: 🧪 Run Unit Tests
# run: ./gradlew test
#
# - name: 📤 Upload Test Reports
# uses: actions/upload-artifact@v4
# with:
# name: test-report
# path: build/reports/tests/test

# 📝 Step 7: Upload Test Reports (Optional)
- name: 📤 Upload Test Reports
uses: actions/upload-artifact@v4
with:
name: test-report
path: build/reports/tests/test

# 🎨 Step 8: Run KtLint Code Style Check
- name: 🎨 Check Code Style with KtLint
run: ./gradlew ktlintCheck

# 📂 Step 9: Upload KtLint Reports
- name: 📤 Upload KtLint Reports
uses: actions/upload-artifact@v4
with:
name: ktlint-report
path: build/reports/ktlint/

# 📱 Step 10: Upload APK Artifact
- name: 📲 Upload APK
uses: actions/upload-artifact@v4
with:
Expand Down
11 changes: 6 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {

buildTypes {
release {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down Expand Up @@ -84,6 +84,7 @@ dependencies {
implementation(libs.volley)
implementation(libs.androidx.ui.text.google.fonts)
implementation(libs.androidx.profileinstaller)
implementation(libs.androidx.browser)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
Expand All @@ -94,7 +95,7 @@ dependencies {
debugImplementation(libs.androidx.ui.test.manifest)

// timber
implementation("com.jakewharton.timber:timber:5.0.1")
implementation(libs.timber)

// kotlin coroutines
implementation(libs.kotlinx.coroutines.android)
Expand All @@ -118,10 +119,10 @@ dependencies {
implementation(libs.androidx.hilt.navigation.compose)

// datastore
implementation("androidx.datastore:datastore-preferences:1.1.1")
implementation(libs.androidx.datastore.preferences)

implementation("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.compose.material:material:1.7.4")
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.material)
}
ksp {
arg("dagger.incremental", "true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ data class FreeGameDetailsEntity(
val screenshots: List<Screenshot>,
val shortDescription: String,
val thumbnail: String
) {
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ data class FreeGamesEntity(
val thumbnail: String,
@ColumnInfo(name = "title")
val title: String
) {
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interface CheapSharkApi {
@Query("storeID") storeId: String? = null,
@Query("lowerPrice") lowerPrice: Int? = null,
@Query("upperPrice") upperPrice: Int? = null,
@Query("onSale") onSale: Boolean? = null,
@Query("onSale") onSale: Int? = null,
@Query("sortBy") sortBy: String? = null,
@Query("desc") desc: Boolean? = null
@Query("desc") desc: Int? = null
): Response<List<DealsDTOItem>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ data class GameDTO(
val thumbnail: String,
@Json(name = "title")
val title: String
) {
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ interface GamePowerApi {

@GET("giveaways/")
suspend fun getGiveaways(
@Query("platform") platform: String = "pc",
@Query("sort-by") sortBy: String = "popularity",
@Query("type") type: String
@Query("platform") platform: String? = null,
@Query("sort-by") sortBy: String? = null,
@Query("type") type: String? = null
): List<GiveawayDtoItem>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.mostafadevo.freegames.data.remote.cheapshark.CheapSharkApi
import com.mostafadevo.freegames.data.remote.cheapshark.dto.DealsDTOItem
import com.mostafadevo.freegames.domain.repository.CheapSharkRepository
import com.mostafadevo.freegames.utils.ResultWrapper
import com.mostafadevo.freegames.utils.toInt
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
Expand Down Expand Up @@ -31,9 +32,9 @@ class CheapSharkRepositoryImpl @Inject constructor(
storeId = storeId,
lowerPrice = lowerPrice,
upperPrice = upperPrice,
onSale = onSale,
onSale = onSale?.toInt(),
sortBy = sortBy,
desc = desc
desc = desc?.toInt()
)
if (response.isSuccessful) {
emit(ResultWrapper.Success(response.body()!!))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ import kotlinx.coroutines.flow.flow
class GamePowerRepositoryImpl @Inject constructor(
private val gamePowerApi: GamePowerApi
) : GamePowerRepository {
override suspend fun getGiveaways(): Flow<ResultWrapper<List<Giveaway>>> {
override suspend fun getGiveaways(
platform: String?,
sortBy: String?,
type: String?
): Flow<ResultWrapper<List<Giveaway>>> {
return flow {
emit(ResultWrapper.Loading())
try {
val giveaways = gamePowerApi.getGiveaways(type = "game")
val giveaways = gamePowerApi.getGiveaways(
platform = platform,
sortBy = sortBy,
type = type
)
emit(ResultWrapper.Success(giveaways.map { it.toGiveaway() }))
} catch (e: Exception) {
emit(ResultWrapper.Error(message = e.message))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ data class GameDetails(
val screenshots: List<Screenshot>,
val shortDescription: String,
val thumbnail: String
) {
}
)
data class Screenshot(
val image: String
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ import com.mostafadevo.freegames.utils.ResultWrapper
import kotlinx.coroutines.flow.Flow

interface GamePowerRepository {
suspend fun getGiveaways(): Flow<ResultWrapper<List<Giveaway>>>
suspend fun getGiveaways(
platform: String?,
sortBy: String?,
type: String?
): Flow<ResultWrapper<List<Giveaway>>>
}
12 changes: 9 additions & 3 deletions app/src/main/java/com/mostafadevo/freegames/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
package com.mostafadevo.freegames.ui

import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.mostafadevo.freegames.domain.model.ThemePreference
Expand All @@ -21,8 +23,12 @@ import dagger.hilt.android.AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
WindowCompat.setDecorFitsSystemWindows(window, false)
installSplashScreen().apply {
Handler(Looper.getMainLooper()).postDelayed({
// Dismiss the splash screen after 1 second delay
}, 1000)
}
enableEdgeToEdge()
setContent {
val settingsViewModel = hiltViewModel<SettingsScreenViewModel>()
val themeState = settingsViewModel.themeState.collectAsStateWithLifecycle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.TileMode
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -54,6 +55,7 @@ fun FreeGameListItem(
)
Column(
modifier = Modifier
.testTag("FreeGameListItem")
.fillMaxWidth()
.padding(8.dp)
.clip(RoundedCornerShape(8.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,13 @@ fun GiveawayListItem(
.clip(RoundedCornerShape(8.dp))
) {
Text(
text = "End in ${
if (timeRemaining == "N/A") {
text = if (timeRemaining == "N/A") {
"N/A"
} else {
getTimeRemaining(
timeRemaining
)
}
}",
},
style = MaterialTheme.typography.labelSmall,
fontSize = 12.sp,
color = Color.White,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.TileMode
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -58,6 +59,7 @@ fun DealsListItem(
)
Column(
modifier = Modifier
.testTag("DealsListItem")
.fillMaxWidth()
.padding(8.dp)
.clip(RoundedCornerShape(8.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
Expand Down Expand Up @@ -67,7 +69,10 @@ fun NavHostScreen() {
startDestination = "/free",
modifier = Modifier
.padding(scaffoldPadding)
.consumeWindowInsets(scaffoldPadding),
.consumeWindowInsets(scaffoldPadding)
.semantics {
testTagsAsResourceId = true
},
enterTransition = { slideInHorizontally { it } + fadeIn() },
exitTransition = { slideOutHorizontally { -it } + fadeOut() },
popEnterTransition = { slideInHorizontally { -it } + fadeIn() },
Expand All @@ -78,7 +83,6 @@ fun NavHostScreen() {
val dealsAndGiveawayScreenViewModel = hiltViewModel<DealsAndGiveawayScreenViewModel>()
DealsScreen(
viewModel = dealsAndGiveawayScreenViewModel,
navController = navController
)
}
composable(route = "/free") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,23 @@ sealed class DealsAndGiveawayScreenUiEvent {

data object OnClearSearchBarDeals : DealsAndGiveawayScreenUiEvent()
data object OnApplyDealsFilters : DealsAndGiveawayScreenUiEvent()

// giveaways bottom sheet events
data class OnToggleGiveawaysBottomSheet(
val isVisible: Boolean
) : DealsAndGiveawayScreenUiEvent()

data class OnGiveawaysSortByFilterChanged(
val sortBy: String
) : DealsAndGiveawayScreenUiEvent()

data class OnGiveawaysTypeFilterChanged(
val type: String
) : DealsAndGiveawayScreenUiEvent()

data class OnGiveawaysPlatformFilterChanged(
val platform: String
) : DealsAndGiveawayScreenUiEvent()

data object OnApplyGiveawaysFilters : DealsAndGiveawayScreenUiEvent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ data class DealsAndGiveawayScreenUiState(
val filterOnSale: Boolean ? = false,
var filterSortBy: String ? = null,
val filterDesc: Boolean ? = false,
val searchHistoryLimit: Int = 5
val searchHistoryLimit: Int = 5,
val isGiveawaysBottomSheetVisible: Boolean = false,
val giveawaysFilterSortBy: String ? = null,
val giveawaysFilterType: String ? = null,
val giveawaysFilterPlatform: String ? = null
)
Loading

0 comments on commit f330331

Please sign in to comment.