Skip to content

Commit

Permalink
Merge pull request #187 from michaelbel/develop
Browse files Browse the repository at this point in the history
1.5.2
  • Loading branch information
michaelbel authored Nov 21, 2023
2 parents 786b865 + 756b070 commit fe9c8f9
Show file tree
Hide file tree
Showing 264 changed files with 2,654 additions and 1,106 deletions.
10 changes: 5 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.io.FileInputStream
import org.apache.commons.io.output.ByteArrayOutputStream
import org.jetbrains.kotlin.konan.properties.Properties
import java.io.FileInputStream

@Suppress("dsl_scope_violation")
plugins {
Expand All @@ -11,7 +11,6 @@ plugins {
alias(libs.plugins.firebase.appdistribution)
alias(libs.plugins.firebase.crashlytics)
alias(libs.plugins.palantir.git)
alias(libs.plugins.detekt)
id("movies-android-hilt")
}

Expand Down Expand Up @@ -91,14 +90,14 @@ android {
isShrinkResources = true
signingConfig = signingConfigs.getByName("release")
applicationIdSuffix = MoviesBuildType.RELEASE.applicationIdSuffix
manifestPlaceholders += mapOf("appName" to "@string/app_name")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
"retrofit2.pro",
"okhttp3.pro",
"coroutines.pro"
)

firebaseAppDistribution {
appId = "1:770317857182:android:876190afbc53df31"
artifactType = "APK"
Expand All @@ -113,6 +112,7 @@ android {
isMinifyEnabled = false
isShrinkResources = false
applicationIdSuffix = MoviesBuildType.DEBUG.applicationIdSuffix
manifestPlaceholders += mapOf("appName" to "@string/app_name_dev")
}
create("benchmark") {
initWith(getByName("release"))
Expand Down Expand Up @@ -153,11 +153,11 @@ android {
dependencies {
implementation(project(":core:analytics"))
implementation(project(":core:common"))
implementation(project(":core:domain"))
implementation(project(":core:interactor"))
implementation(project(":core:navigation"))
implementation(project(":core:notifications"))
implementation(project(":core:ui"))

implementation(project(":core:work"))
implementation(project(":feature:auth"))
implementation(project(":feature:account"))
implementation(project(":feature:details"))
Expand Down
3 changes: 0 additions & 3 deletions app/src/debug/res/values/strings.xml

This file was deleted.

50 changes: 41 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

<dist:module dist:instant="true" />

Expand All @@ -23,12 +24,13 @@
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:label="${appName}"
android:localeConfig="@xml/locale_config"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/Theme.Movies.Starting">
android:theme="@style/Theme.Movies.Starting"
android:icon="@mipmap/ic_launcher_red"
android:roundIcon="@mipmap/ic_launcher_red"
android:enableOnBackInvokedCallback="true">

<profileable
android:shell="true"
Expand All @@ -37,7 +39,7 @@
<activity
android:name="org.michaelbel.movies.MainActivity"
android:exported="true"
android:screenOrientation="portrait">
android:screenOrientation="fullUser">

<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
Expand Down Expand Up @@ -89,11 +91,41 @@
</activity>

<activity-alias
android:name=".DEFAULT"
android:name="org.michaelbel.movies.RedIcon"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher_red"
android:roundIcon="@mipmap/ic_launcher_red"
android:targetActivity="org.michaelbel.movies.MainActivity">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity-alias>

<activity-alias
android:name="org.michaelbel.movies.PurpleIcon"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_purple"
android:roundIcon="@mipmap/ic_launcher_purple"
android:targetActivity="org.michaelbel.movies.MainActivity">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity-alias>

<activity-alias
android:name="org.michaelbel.movies.BrownIcon"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_brown"
android:roundIcon="@mipmap/ic_launcher_brown"
android:targetActivity="org.michaelbel.movies.MainActivity">

<intent-filter>
Expand Down
12 changes: 4 additions & 8 deletions app/src/main/kotlin/org/michaelbel/movies/App.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
package org.michaelbel.movies

import android.app.Application
import android.util.Log
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import com.google.firebase.FirebaseApp
import dagger.hilt.android.HiltAndroidApp
import org.michaelbel.moviemade.BuildConfig
import javax.inject.Inject
import org.michaelbel.movies.ui.appicon.installLauncherIcon

@HiltAndroidApp
internal class App: Application(), Configuration.Provider {

@Inject lateinit var workerFactory: HiltWorkerFactory

override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder()
.setWorkerFactory(workerFactory)
.setMinimumLoggingLevel(if (BuildConfig.DEBUG) Log.DEBUG else Log.ERROR)
.build()
}
override val workManagerConfiguration: Configuration
get() = Configuration.Builder().setWorkerFactory(workerFactory).build()

override fun onCreate() {
super.onCreate()
installLauncherIcon()
FirebaseApp.initializeApp(this)
}
}
33 changes: 5 additions & 28 deletions app/src/main/kotlin/org/michaelbel/movies/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@ package org.michaelbel.movies

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.getValue
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import dagger.hilt.android.AndroidEntryPoint
import org.michaelbel.movies.common.theme.AppTheme
import org.michaelbel.movies.navigation.ktx.addOnDestinationChangedListener
import org.michaelbel.movies.ui.shortcuts.installShortcuts
import org.michaelbel.movies.ui.theme.MoviesTheme

/**
* Per-App Language depends on AppCompatActivity (not ComponentActivity).
Expand All @@ -26,29 +19,13 @@ internal class MainActivity: AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
enableEdgeToEdge()
super.onCreate(savedInstanceState)

/** Configure edge-to-edge display. */
WindowCompat.setDecorFitsSystemWindows(window, false)

installShortcuts()
setContent {
val currentTheme: AppTheme by viewModel.currentTheme.collectAsStateWithLifecycle()
val dynamicColors: Boolean by viewModel.dynamicColors.collectAsStateWithLifecycle()

val navHostController: NavHostController = rememberNavController().apply {
addOnDestinationChangedListener(viewModel::analyticsTrackDestination)
}

MoviesTheme(
theme = currentTheme,
dynamicColors = dynamicColors
) {
MainActivityContent(
navHostController = navHostController,
onStartUpdateFlow = { viewModel.startUpdateFlow(this) }
)
}
MainActivityContent(
onStartUpdateFlow = { viewModel.startUpdateFlow(this) }
)
}
}
}
74 changes: 45 additions & 29 deletions app/src/main/kotlin/org/michaelbel/movies/MainActivityContent.kt
Original file line number Diff line number Diff line change
@@ -1,54 +1,70 @@
package org.michaelbel.movies

import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import org.michaelbel.movies.auth.accountGraph
import org.michaelbel.movies.auth.authGraph
import org.michaelbel.movies.auth.navigateToAccount
import org.michaelbel.movies.auth.navigateToAuth
import org.michaelbel.movies.common.theme.AppTheme
import org.michaelbel.movies.details.detailsGraph
import org.michaelbel.movies.details.navigateToDetails
import org.michaelbel.movies.feed.FeedDestination
import org.michaelbel.movies.feed.feedGraph
import org.michaelbel.movies.gallery.galleryGraph
import org.michaelbel.movies.gallery.navigateToGallery
import org.michaelbel.movies.navigation.ktx.addOnDestinationChangedListener
import org.michaelbel.movies.settings.navigateToSettings
import org.michaelbel.movies.settings.settingsGraph
import org.michaelbel.movies.ui.theme.MoviesTheme

@Composable
internal fun MainActivityContent(
navHostController: NavHostController = rememberNavController(),
startDestination: String = FeedDestination.route,
onStartUpdateFlow: () -> Unit
onStartUpdateFlow: () -> Unit,
viewModel: MainViewModel = hiltViewModel()
) {
NavHost(
navController = navHostController,
startDestination = startDestination
val currentTheme: AppTheme by viewModel.currentTheme.collectAsStateWithLifecycle()
val dynamicColors: Boolean by viewModel.dynamicColors.collectAsStateWithLifecycle()
val navHostController: NavHostController = rememberNavController().apply {
addOnDestinationChangedListener(viewModel::analyticsTrackDestination)
}

MoviesTheme(
theme = currentTheme,
dynamicColors = dynamicColors
) {
authGraph(
navigateBack = navHostController::popBackStack
)
accountGraph(
navigateBack = navHostController::popBackStack
)
feedGraph(
navigateToAuth = navHostController::navigateToAuth,
navigateToAccount = navHostController::navigateToAccount,
navigateToSettings = navHostController::navigateToSettings,
navigateToDetails = navHostController::navigateToDetails,
onStartUpdateFlow = onStartUpdateFlow
)
detailsGraph(
navigateBack = navHostController::popBackStack,
navigateToGallery = navHostController::navigateToGallery
)
galleryGraph(
navigateBack = navHostController::popBackStack
)
settingsGraph(
navigateBack = navHostController::popBackStack
)
NavHost(
navController = navHostController,
startDestination = FeedDestination.route
) {
authGraph(
navigateBack = navHostController::popBackStack
)
accountGraph(
navigateBack = navHostController::popBackStack
)
feedGraph(
navigateToAuth = navHostController::navigateToAuth,
navigateToAccount = navHostController::navigateToAccount,
navigateToSettings = navHostController::navigateToSettings,
navigateToDetails = navHostController::navigateToDetails,
onStartUpdateFlow = onStartUpdateFlow
)
detailsGraph(
navigateBack = navHostController::popBackStack,
navigateToGallery = navHostController::navigateToGallery
)
galleryGraph(
navigateBack = navHostController::popBackStack
)
settingsGraph(
navigateBack = navHostController::popBackStack
)
}
}
}
14 changes: 7 additions & 7 deletions app/src/main/kotlin/org/michaelbel/movies/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.work.WorkManager
import androidx.work.workDataOf
import com.google.firebase.messaging.FirebaseMessaging
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.stateIn
Expand All @@ -17,18 +18,17 @@ import org.michaelbel.movies.common.inappupdate.di.InAppUpdate
import org.michaelbel.movies.common.ktx.printlnDebug
import org.michaelbel.movies.common.theme.AppTheme
import org.michaelbel.movies.common.viewmodel.BaseViewModel
import org.michaelbel.movies.domain.workers.AccountUpdateWorker
import org.michaelbel.movies.domain.workers.MoviesDatabaseWorker
import org.michaelbel.movies.interactor.Interactor
import javax.inject.Inject
import org.michaelbel.movies.work.AccountUpdateWorker
import org.michaelbel.movies.work.MoviesDatabaseWorker

@HiltViewModel
internal class MainViewModel @Inject constructor(
private val interactor: Interactor,
private val inAppUpdate: InAppUpdate,
private val workManager: WorkManager,
private val analytics: MoviesAnalytics,
private val firebaseMessaging: FirebaseMessaging
private val firebaseMessaging: FirebaseMessaging,
private val workManager: WorkManager
): BaseViewModel() {

val currentTheme: StateFlow<AppTheme> = interactor.currentTheme
Expand Down Expand Up @@ -84,7 +84,7 @@ internal class MainViewModel @Inject constructor(
workManager.enqueue(request)
}

private companion object {
private const val MOVIES_DATA_FILENAME = "movies.json"
companion object {
const val MOVIES_DATA_FILENAME = "movies.json"
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name" translatable="false">Movies</string>
<string name="app_name_dev" translatable="false">Movies Dev</string>
</resources>
Loading

0 comments on commit fe9c8f9

Please sign in to comment.