Skip to content

Commit

Permalink
🚀 added splash screen as the home in navigation graph.
Browse files Browse the repository at this point in the history
  • Loading branch information
it5prasoon committed Jan 6, 2022
1 parent 4a93415 commit 67e2304
Show file tree
Hide file tree
Showing 68 changed files with 174 additions and 131 deletions.
Binary file modified app/src/main/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.
4 changes: 3 additions & 1 deletion app/src/main/java/com/matrix/studyjournal/HostActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class HostActivity : AppCompatActivity(R.layout.activity_host) {


override fun onCreate(savedInstanceState: Bundle?) {
// setTheme(R.style.Theme_StudyJournal)
setupFragmentFactory()
super.onCreate(savedInstanceState)
setSupportActionBar(findViewById(R.id.toolbar))
Expand All @@ -24,7 +26,7 @@ class HostActivity : AppCompatActivity(R.layout.activity_host) {
private fun setupNavController() {
findViewById<Toolbar>(R.id.toolbar).setupWithNavController(
findNavController(),
AppBarConfiguration.Builder(R.id.mainFragment, R.id.timerFragment).build()
AppBarConfiguration.Builder(R.id.splashFragment, R.id.mainFragment, R.id.timerFragment).build()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.matrix.studyNote.ui.details.DetailsFragment
import com.matrix.studyNote.ui.note.NoteFragment
import com.matrix.studyNote.ui.sessionDialog.SessionDialogFragment
import com.matrix.core.di.FragmentKey
import com.matrix.main.ui.splashscreen.SplashFragment
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -20,6 +21,11 @@ import dagger.multibindings.IntoMap
@InstallIn(SingletonComponent::class)
interface InjectFactoryModule {

@Binds
@IntoMap
@FragmentKey(SplashFragment::class)
fun bindSplashFragment(fragment: SplashFragment): Fragment

@Binds
@IntoMap
@FragmentKey(MainFragment::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

package com.matrix.studyjournal.navigation

import androidx.navigation.NavDirections
import com.matrix.core.utils.navigation.GlobalDirections
import com.matrix.core.utils.navigation.models.Properties
import com.matrix.main.ui.MainFragmentDirections
import com.matrix.main.ui.splashscreen.SplashFragmentDirections
import com.matrix.timer.ui.TimerFragmentDirections
import com.matrix.studyNote.ui.sessionDialog.SessionDialogFragmentDirections
import javax.inject.Inject
Expand All @@ -12,6 +14,10 @@ import javax.inject.Inject
* Default implementation of [GlobalDirections] interface.
*/
class AppDirections @Inject constructor() : GlobalDirections {

override fun fromSplashToMain() =
SplashFragmentDirections.actionSplashFragmentToMainFragment()

override fun fromSessionDialogToTimer(properties: Properties) =
SessionDialogFragmentDirections.actionSessionFragmentToTimerFragment(properties)

Expand Down
31 changes: 0 additions & 31 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

74 changes: 0 additions & 74 deletions app/src/main/res/drawable/ic_launcher_background.xml

This file was deleted.

13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_splash_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:drawable="@color/blue_500"/>

<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher"/>
</item>

</layer-list>
4 changes: 2 additions & 2 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
4 changes: 2 additions & 2 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
19 changes: 17 additions & 2 deletions app/src/main/res/navigation/app_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/app_graph"
app:startDestination="@id/mainFragment">
app:startDestination="@id/splashFragment">
<fragment
android:id="@+id/mainFragment"
android:name="com.matrix.main.ui.MainFragment"
Expand All @@ -15,11 +15,26 @@
app:enterAnim="@anim/from_left"
app:exitAnim="@anim/to_right"
app:popEnterAnim="@anim/from_right"
app:popExitAnim="@anim/to_left">
app:popExitAnim="@anim/to_left"
>
<argument
android:name="properties"
app:argType="com.matrix.core.utils.navigation.models.Properties" />
</action>
</fragment>
<include app:graph="@navigation/study_note_graph" />
<fragment
android:id="@+id/splashFragment"
android:name="com.matrix.main.ui.splashscreen.SplashFragment"
android:label="SplashFragment">

<action
android:id="@+id/action_splashFragment_to_mainFragment"
app:destination="@id/mainFragment"
app:popUpTo="@id/splashFragment"
app:popUpToInclusive="true"
app:exitAnim="@anim/nav_default_exit_anim"
>
</action>
</fragment>
</navigation>
4 changes: 4 additions & 0 deletions app/src/main/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">#6D68FD</color>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/ic_splash_background</item>
</style>
</resources>
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
}
buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.matrix.core.utils.navigation.models.Properties
* Interface to perform intermodular navigation.
*/
interface GlobalDirections {
fun fromSplashToMain(): NavDirections
fun fromSessionDialogToTimer(properties: Properties): NavDirections
fun fromMainToStudyNote(properties: Properties): NavDirections
fun fromTimerToStudyNote(properties: Properties): NavDirections
Expand Down
Binary file added docs/ic_launcher/1024.png
Binary file added docs/ic_launcher/play_store_512.png
5 changes: 5 additions & 0 deletions docs/ic_launcher/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="@mipmap/ic_launcher_adaptive_back"/>
<foreground android:drawable="@mipmap/ic_launcher_adaptive_fore"/>
</adaptive-icon>
Binary file added docs/ic_launcher/res/mipmap-hdpi/ic_launcher.png
Binary file added docs/ic_launcher/res/mipmap-mdpi/ic_launcher.png
Binary file added docs/ic_launcher/res/mipmap-xhdpi/ic_launcher.png
2 changes: 2 additions & 0 deletions features/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
`android-library-convention`
kotlin("kapt")
id("dagger.hilt.android.plugin")
id("kotlin-android")
}

configuration(
Expand Down Expand Up @@ -39,6 +40,7 @@ dependencies {

implementation(project(":common:core"))
implementation(project(":common:core-ui"))
implementation("androidx.legacy:legacy-support-v4:1.0.0")

testImplementation(Libraries.jUnit)
androidTestImplementation(Libraries.androidXJunit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import java.util.Date
import javax.inject.Inject

/**
* Adds a new workout note to the database.
* Adds a new study note to the database.
*/
class AddNewWorkoutNoteUseCase @Inject constructor(
class AddNewStudyNoteUseCase @Inject constructor(
private val repository: CrudRepository
) {
suspend operator fun invoke() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import com.matrix.core.domain.models.StudyNote
import javax.inject.Inject

/**
* Deletes a workout note from the database.
* Deletes a study note from the database.
*/
class DeleteWorkoutNoteUseCase @Inject constructor(
class DeleteStudyNoteUseCase @Inject constructor(
private val repository: CrudRepository
) {
suspend operator fun invoke(studyNote: StudyNote) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.inject.Inject
/**
* Fetches study notes from the database.
*/
class FetchWorkoutNotesUseCase @Inject constructor(
class FetchStudyNotesUseCase @Inject constructor(
private val repository: CrudRepository
) {
operator fun invoke() = repository.fetchStudyNotes().map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.inject.Inject
/**
* Restores the last deleted workout note from the database.
*/
class RestoreWorkoutNoteUseCase @Inject constructor(private val repository: CrudRepository) {
class RestoreStudyNoteUseCase @Inject constructor(private val repository: CrudRepository) {
suspend operator fun invoke(workoutNote: StudyNote) =
repository.restoreStudyNote(workoutNote)
}
12 changes: 12 additions & 0 deletions features/main/src/main/java/com/matrix/main/ui/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.os.Bundle
import android.view.View
import androidx.appcompat.content.res.AppCompatResources
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import by.kirich1409.viewbindingdelegate.viewBinding
import com.google.android.material.tabs.TabLayoutMediator
import com.matrix.core.utils.navigation.GlobalDirections
Expand All @@ -14,8 +16,13 @@ import com.matrix.main.databinding.FragmentMainBinding
import com.matrix.main.ui.history.HistoryFragment
import com.matrix.main.ui.pager.ViewPagerAdapter
import com.matrix.main.ui.settings.SettingsFragment
import com.matrix.main.ui.splashscreen.SplashFragment
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import androidx.appcompat.app.AppCompatActivity




@AndroidEntryPoint
class MainFragment @Inject constructor(
Expand Down Expand Up @@ -44,4 +51,9 @@ class MainFragment @Inject constructor(
tab.icon = AppCompatResources.getDrawable(requireContext(), tabIcons[position])
}.attach()
}

override fun onResume() {
(activity as AppCompatActivity?)!!.supportActionBar!!.show()
super.onResume()
}
}
Loading

0 comments on commit 67e2304

Please sign in to comment.