Skip to content

Commit 5f75d59

Browse files
committed
completed first phase...:rocket:
0 parents  commit 5f75d59

File tree

189 files changed

+5962
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+5962
-0
lines changed

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
*.iml
2+
*.apk
3+
*.aar
4+
*.ap_
5+
*.aab
6+
.gradle
7+
/local.properties
8+
/.idea
9+
/.idea/caches
10+
/.idea/libraries
11+
/.idea/modules.xml
12+
/.idea/workspace.xml
13+
/.idea/navEditor.xml
14+
/.idea/assetWizardSettings.xml
15+
.DS_Store
16+
/build
17+
/app/release
18+
/reports
19+
/captures
20+
.externalNativeBuild
21+
.cxx

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle.kts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import extensions.configuration
2+
import extensions.implementation
3+
4+
plugins {
5+
`android-app-convention`
6+
kotlin("kapt")
7+
id("dagger.hilt.android.plugin")
8+
id("androidx.navigation.safeargs.kotlin")
9+
}
10+
11+
configuration(
12+
applicationId = "com.matrix.studyjournal",
13+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
14+
)
15+
16+
dependencies {
17+
implementation(Libraries.room())
18+
implementation(Libraries.navigation())
19+
implementation(Libraries.daggerHilt())
20+
implementation(Libraries.preferences)
21+
22+
implementation(project(":common:core"))
23+
implementation(project(":common:core-ui"))
24+
implementation(project(":features:main"))
25+
implementation(project(":features:timer"))
26+
implementation(project(":features:study-note"))
27+
}
28+
29+
kapt {
30+
correctErrorTypes = true
31+
}

app/proguard-rules.pro

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.kts.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
-keepnames class * extends android.os.Parcelable

app/src/main/AndroidManifest.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.matrix.studyjournal">
4+
5+
<uses-permission android:name="android.permission.VIBRATE" />
6+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
7+
<uses-permission android:name="android.permission.WAKE_LOCK" />
8+
9+
<application
10+
android:name="com.matrix.studyjournal.App"
11+
android:allowBackup="true"
12+
android:fullBackupOnly="true"
13+
android:icon="@mipmap/ic_launcher"
14+
android:label="@string/app_name"
15+
android:roundIcon="@mipmap/ic_launcher_round"
16+
android:supportsRtl="true"
17+
android:theme="@style/Theme.StudyJournal">
18+
<activity
19+
android:name="com.matrix.studyjournal.HostActivity"
20+
android:exported="true"
21+
android:launchMode="singleTask"
22+
android:windowSoftInputMode="adjustPan"
23+
android:screenOrientation="nosensor">
24+
<intent-filter>
25+
<action android:name="android.intent.action.MAIN" />
26+
<category android:name="android.intent.category.LAUNCHER" />
27+
</intent-filter>
28+
</activity>
29+
<service android:name="com.matrix.timer.data.services.TimerService" />
30+
</application>
31+
32+
</manifest>
40.3 KB
Loading
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* Android with clean and multi module architecture */
2+
package com.matrix.studyjournal
3+
4+
import android.app.Application
5+
import android.app.NotificationChannel
6+
import android.app.NotificationManager
7+
import android.os.Build
8+
import com.matrix.core.utils.NotificationChannel.NOTIFICATION_CHANNEL_ID
9+
import com.matrix.core.utils.NotificationChannel.NOTIFICATION_CHANNEL_NAME
10+
import dagger.hilt.android.HiltAndroidApp
11+
12+
@HiltAndroidApp
13+
class App : Application() {
14+
override fun onCreate() {
15+
super.onCreate()
16+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
17+
val serviceChannel = NotificationChannel(
18+
NOTIFICATION_CHANNEL_ID,
19+
NOTIFICATION_CHANNEL_NAME,
20+
NotificationManager.IMPORTANCE_HIGH
21+
)
22+
val manager = getSystemService(NotificationManager::class.java)
23+
manager.createNotificationChannel(serviceChannel)
24+
}
25+
}
26+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* Android with clean and multi module architecture */
2+
3+
package com.matrix.studyjournal
4+
5+
import android.os.Bundle
6+
import androidx.appcompat.app.AppCompatActivity
7+
import androidx.appcompat.widget.Toolbar
8+
import androidx.navigation.fragment.NavHostFragment
9+
import androidx.navigation.ui.AppBarConfiguration
10+
import androidx.navigation.ui.setupWithNavController
11+
import com.matrix.core.di.setupFragmentFactory
12+
import dagger.hilt.android.AndroidEntryPoint
13+
14+
@AndroidEntryPoint
15+
class HostActivity : AppCompatActivity(R.layout.activity_host) {
16+
17+
override fun onCreate(savedInstanceState: Bundle?) {
18+
setupFragmentFactory()
19+
super.onCreate(savedInstanceState)
20+
setSupportActionBar(findViewById(R.id.toolbar))
21+
setupNavController()
22+
}
23+
24+
private fun setupNavController() {
25+
findViewById<Toolbar>(R.id.toolbar).setupWithNavController(
26+
findNavController(),
27+
AppBarConfiguration.Builder(R.id.mainFragment, R.id.timerFragment).build()
28+
)
29+
}
30+
31+
private fun findNavController() = (supportFragmentManager
32+
.findFragmentById(R.id.navHostFragment) as NavHostFragment)
33+
.navController
34+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/* Android with clean and multi module architecture */
2+
3+
package com.matrix.studyjournal.di
4+
5+
import android.app.Notification
6+
import android.app.PendingIntent
7+
import android.content.Context
8+
import android.content.Intent
9+
import android.content.SharedPreferences
10+
import androidx.core.app.NotificationCompat
11+
import androidx.preference.PreferenceManager
12+
import androidx.room.Room
13+
import com.matrix.core.data.db.AppDatabase
14+
import com.matrix.core.di.DefaultSharedPreferences
15+
import com.matrix.core.di.UserInputSharedPreferences
16+
import com.matrix.core.utils.NotificationChannel.NOTIFICATION_CHANNEL_ID
17+
import com.matrix.core.utils.navigation.GlobalNavHost
18+
import com.matrix.studyjournal.BuildConfig
19+
import com.matrix.studyjournal.HostActivity
20+
import com.matrix.studyjournal.R
21+
import dagger.Module
22+
import dagger.Provides
23+
import dagger.hilt.InstallIn
24+
import dagger.hilt.android.qualifiers.ApplicationContext
25+
import dagger.hilt.components.SingletonComponent
26+
import javax.inject.Singleton
27+
28+
@Module
29+
@InstallIn(SingletonComponent::class)
30+
object AppModule {
31+
32+
@Provides
33+
@Singleton
34+
fun providesRoomDatabase(@ApplicationContext context: Context): AppDatabase =
35+
Room.databaseBuilder(context, AppDatabase::class.java, "workout_notes")
36+
.fallbackToDestructiveMigration().build()
37+
38+
@Provides
39+
@Singleton
40+
@UserInputSharedPreferences
41+
fun provideSharedPreferences(@ApplicationContext context: Context): SharedPreferences =
42+
context.getSharedPreferences("user-input-preferences", Context.MODE_PRIVATE)
43+
44+
@Provides
45+
@Singleton
46+
@DefaultSharedPreferences
47+
fun provideDefaultSharedPreferences(@ApplicationContext context: Context): SharedPreferences =
48+
PreferenceManager.getDefaultSharedPreferences(context)
49+
50+
@Provides
51+
@Singleton
52+
fun provideGlobalNavHost() = GlobalNavHost(R.id.navHostFragment)
53+
54+
@Provides
55+
@Singleton
56+
fun provideVersionName() = BuildConfig.VERSION_NAME
57+
58+
@Provides
59+
@Singleton
60+
fun providePendingIntent(@ApplicationContext context: Context): PendingIntent =
61+
PendingIntent.getActivity(
62+
context,
63+
0,
64+
Intent(context, HostActivity::class.java).also {
65+
it.action = Intent.ACTION_MAIN
66+
it.addCategory(Intent.CATEGORY_LAUNCHER)
67+
it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
68+
},
69+
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
70+
)
71+
72+
@Provides
73+
@Singleton
74+
fun provideNotification(
75+
@ApplicationContext context: Context,
76+
pendingIntent: PendingIntent
77+
): Notification = NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
78+
.setAutoCancel(false)
79+
.setOngoing(true)
80+
.setContentTitle(context.getString(R.string.notification_content_title))
81+
.setContentText(context.getString(R.string.notification_content_text))
82+
.setSmallIcon(R.drawable.ic_timer)
83+
.setContentIntent(pendingIntent)
84+
.build()
85+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* Android with clean and multi module architecture */
2+
@file:Suppress("unused")
3+
4+
package com.matrix.studyjournal.di
5+
6+
import com.matrix.core.data.repositories.DefaultCrudRepository
7+
import com.matrix.core.domain.CrudRepository
8+
import com.matrix.core.utils.navigation.GlobalDirections
9+
import com.matrix.timer.data.repositories.DefaultTimerRepository
10+
import com.matrix.timer.domain.repositories.TimerRepository
11+
import com.matrix.studyNote.data.SharedPrefUserInputStorage
12+
import com.matrix.studyNote.domain.storage.UserInputStorage
13+
import com.matrix.studyjournal.navigation.AppDirections
14+
import dagger.Binds
15+
import dagger.Module
16+
import dagger.hilt.InstallIn
17+
import dagger.hilt.components.SingletonComponent
18+
import javax.inject.Singleton
19+
20+
@Module
21+
@InstallIn(SingletonComponent::class)
22+
interface CoreModule {
23+
@Binds
24+
@Singleton
25+
fun bindGlobalDirections(appDirections: AppDirections): GlobalDirections
26+
27+
@Binds
28+
@Singleton
29+
fun bindCrudRepository(repository: DefaultCrudRepository): CrudRepository
30+
31+
@Binds
32+
fun bindTimerRepository(repository: DefaultTimerRepository): TimerRepository
33+
34+
@Binds
35+
@Singleton
36+
fun bindUserInputStorage(userInputStorage: SharedPrefUserInputStorage): UserInputStorage
37+
}

0 commit comments

Comments
 (0)