Skip to content

Commit

Permalink
v1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenwinch committed Dec 9, 2023
1 parent a6fb6ea commit 92bf832
Show file tree
Hide file tree
Showing 99 changed files with 1,688 additions and 920 deletions.
14 changes: 14 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

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

17 changes: 5 additions & 12 deletions .idea/deploymentTargetDropDown.xml

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

5 changes: 2 additions & 3 deletions .idea/gradle.xml

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

19 changes: 11 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
// Version
def versionMajor = 1
def versionMinor = 3
def versionPatch = 0
def versionPatch = 1
def versionBuild = 0
def applicationName = "Flixclusive"

Expand Down Expand Up @@ -81,20 +81,20 @@ android {
dependencies {
def tvCompose = '1.0.0-alpha09'
def composeUi = '1.6.0-alpha04'
def googleMaterial = "1.9.0"
def googleMaterial = "1.10.0"
def material3 = "1.1.2"
def media3 = "1.1.1"
def media3 = "1.2.0"
def splashScreen = "1.0.1"
def hilt = "2.48"
def hiltNavigation = "1.1.0"
def retrofit2 = "2.9.0"
def composeDestination = '1.9.53'
def lifecycleRuntime = "2.6.2"
def room = "2.6.0"
def room = "2.6.1"
def dataStore = "1.0.0"
def coreKtx = "1.12.0"
def serialization = '1.6.0'
def activityCompose = "1.8.0"
def activityCompose = "1.8.1"
def constraintLayout = "1.0.1"
def gson = "2.10.1"
def coil = "2.4.0"
Expand All @@ -105,6 +105,9 @@ dependencies {
def androidXTestRunner = "1.5.2"
def androidXTestRules = "1.5.0"
def accompanistPermission = "0.32.0"
def conscrypt = "2.5.2"

implementation "org.conscrypt:conscrypt-android:$conscrypt"

implementation(project(path: ":providers"))

Expand Down Expand Up @@ -189,9 +192,9 @@ dependencies {
androidTestImplementation "androidx.test:rules:$androidXTestRules"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$composeUi"

testImplementation "junit:junit:$jUnit4"
testImplementation "io.mockk:mockk:$mock"
testImplementation project(path: ':providers')
androidTestImplementation "junit:junit:$jUnit4"
androidTestImplementation "io.mockk:mockk:$mock"
androidTestImplementation project(path: ':providers')
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesTest"
}

Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 13000,
"versionName": "1.3.0",
"versionCode": 13100,
"versionName": "1.3.1",
"outputFile": "app-release.apk"
}
],
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/java/com/flixclusive/FlixclusiveApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@ package com.flixclusive
import android.app.Application
import android.content.Context
import androidx.datastore.dataStore
import coil.ImageLoader
import coil.ImageLoaderFactory
import com.flixclusive.domain.config.ConfigurationProvider
import com.flixclusive.domain.preferences.AppSettingsManager
import com.flixclusive.domain.preferences.AppSettingsSerializer
import com.flixclusive.presentation.mobile.screens.crash.GlobalCrashHandler
import dagger.hilt.android.HiltAndroidApp
import okhttp3.OkHttpClient
import javax.inject.Inject


val Context.appSettingsDataStore by dataStore("app-preferences.json", AppSettingsSerializer)

@HiltAndroidApp
class FlixclusiveApplication : Application() {
class FlixclusiveApplication : Application(), ImageLoaderFactory {
@Inject
lateinit var configurationProvider: ConfigurationProvider
@Inject
lateinit var appSettingsManager: AppSettingsManager
@Inject
lateinit var client: OkHttpClient

override fun newImageLoader(): ImageLoader {
return ImageLoader.Builder(this)
.okHttpClient(client)
.build()
}

override fun onCreate() {
super.onCreate()
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/flixclusive/common/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ object Constants {
const val FINISH_THRESHOLD = 95.0
const val FILM_TV_SHOW_TITLE_FORMAT = "S%d E%d: %s"
const val APP_DATABASE = "app_database"
const val GITHUB_REPOSITORY = "https://github.com/rhenwinch/Flixclusive/releases/latest"
const val GITHUB_REPOSITORY = "https://github.com/rhenwinch/Flixclusive"
const val GITHUB_LATEST_RELEASE = "$GITHUB_REPOSITORY/releases/latest"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.flixclusive.data.api

import com.flixclusive.domain.model.config.AppConfig
import com.flixclusive.domain.model.config.HomeCategoriesConfig
import com.flixclusive.domain.model.config.ProviderStatus
import com.flixclusive.domain.model.config.SearchCategoriesConfig
import retrofit2.http.GET

Expand All @@ -14,4 +15,7 @@ interface GithubConfigService {

@GET("rhenwinch/flixclusive-config/main/app.json")
suspend fun getAppConfig(): AppConfig

@GET("rhenwinch/flixclusive-config/main/providers_config.json")
suspend fun getProvidersStatus(): List<ProviderStatus>
}
10 changes: 1 addition & 9 deletions app/src/main/java/com/flixclusive/data/api/TMDBApiService.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.flixclusive.data.api

import android.os.Build
import com.flixclusive.data.dto.tmdb.TMDBMovieDto
import com.flixclusive.data.dto.tmdb.TMDBTvShowDto
import com.flixclusive.data.dto.tmdb.common.TMDBImagesResponseDto
Expand All @@ -13,8 +12,6 @@ import retrofit2.http.Path
import retrofit2.http.Query
import retrofit2.http.Url
import java.text.SimpleDateFormat
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.util.Date
import java.util.Locale

Expand Down Expand Up @@ -61,17 +58,12 @@ interface TMDBApiService {
@Path("media_type") mediaType: String, // movie, tv
@Query("api_key") apiKey: String,
@Query("page") page: Int,
@Query("vote_count.gte") minVoteCount: String = "300",
@Query("sort_by") sortBy: String = "vote_average.desc",
@Query("with_genres") genres: String = "",
@Query("with_companies") companies: String = "",
@Query("with_networks") networks: String = "",
@Query("watch_region") watchRegion: String = "US",
@Query("without_genres") withoutGenres: String = "10763", // news genre
@Query("release_date.lte") releasedDate: String = when(Build.VERSION.SDK_INT) {
Build.VERSION_CODES.O -> LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
else -> SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(Date())
},
@Query("release_date.lte") releasedDate: String = SimpleDateFormat("yyyy-MM-dd", Locale.US).format(Date()),
@Query("with_original_language") withOriginalLanguage: String = "en",
): TMDBPageResponse<TMDBSearchItem>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import com.flixclusive.domain.config.ConfigurationProvider
import com.flixclusive.domain.config.RemoteConfigStatus
import com.flixclusive.domain.model.config.AppConfig
import com.flixclusive.domain.model.config.HomeCategoriesConfig
import com.flixclusive.domain.model.config.ProviderStatus
import com.flixclusive.domain.model.config.SearchCategoriesConfig
import com.flixclusive.domain.preferences.AppSettingsManager
import com.flixclusive.domain.preferences.ProviderConfiguration
import com.flixclusive.domain.repository.ProvidersRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
Expand All @@ -20,6 +24,8 @@ private const val MAX_RETRIES = 5

class ConfigurationProviderImpl @Inject constructor(
private val githubConfigService: GithubConfigService,
private val providersRepository: ProvidersRepository,
private val appSettingsManager: AppSettingsManager,
private val ioScope: CoroutineScope
): ConfigurationProvider {

Expand All @@ -30,6 +36,7 @@ class ConfigurationProviderImpl @Inject constructor(
override var homeCategoriesConfig: HomeCategoriesConfig? = null
override var searchCategoriesConfig: SearchCategoriesConfig? = null
override var appConfig: AppConfig? = null
override var providersStatus: List<ProviderStatus>? = null

override fun initialize() {
ioScope.launch {
Expand All @@ -38,6 +45,10 @@ class ConfigurationProviderImpl @Inject constructor(

try {
appConfig = githubConfigService.getAppConfig()
providersStatus = githubConfigService.getProvidersStatus()

initializeProviders()

homeCategoriesConfig = githubConfigService.getHomeCategoriesConfig()
searchCategoriesConfig = githubConfigService.getSearchCategoriesConfig()
_remoteStatus.update { RemoteConfigStatus.Success }
Expand All @@ -51,4 +62,47 @@ class ConfigurationProviderImpl @Inject constructor(
}
}
}

private suspend fun initializeProviders() {
val appSettings = appSettingsManager.localAppSettings
val providersConfigurations = appSettings.providers.toMutableList()

val isConfigEmpty = providersConfigurations.isEmpty()

if(providersRepository.providers.size == providersStatus!!.size)
return

for (i in providersStatus!!.indices) {
val provider = if(!isConfigEmpty) {
providersStatus!!.find {
it.name.equals(
other = providersConfigurations[i].name,
ignoreCase = true
)
}
} else providersStatus!![i]

val isIgnored = if(isConfigEmpty)
false
else providersConfigurations[i].isIgnored

providersRepository.populate(
name = provider!!.name,
isMaintenance = provider.isMaintenance,
isIgnored = isIgnored
)

if(isConfigEmpty) {
providersConfigurations.add(
ProviderConfiguration(name = provider.name)
)

appSettingsManager.updateData(
appSettings.copy(
providers = providersConfigurations.toList()
)
)
}
}
}
}
Loading

0 comments on commit 92bf832

Please sign in to comment.