Skip to content

Commit 2749747

Browse files
stslexstslex
andauthored
Develop (#35)
* Refactor/mapper (#26) * refactor mappers injection * add tests * add tests * add tests * refactoring (#28) * Refactor/modules structure (#29) * refactoring * refactor catalogs and modules structure * refactor * merge changes * refactor navigation on one screen (#31) * Feature/main (#33) * add feature main * refactor insets * refactor error handlers Co-authored-by: stslex <[email protected]>
1 parent 2a28cd2 commit 2749747

File tree

52 files changed

+740
-340
lines changed

Some content is hidden

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

52 files changed

+740
-340
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,14 @@ dependencies {
4444
implementation(project(":feature-profile"))
4545
implementation(project(":feature-auth-phonenumber"))
4646
implementation(project(":feature-auth-code"))
47+
implementation(project(":feature-main"))
4748

4849
with(libs) {
4950
implementation(koin.core)
5051
implementation(koin.android)
5152
implementation(koin.androidx.compose)
5253
implementation(koin.annotations)
5354
ksp(koin.ksp)
54-
implementation(androidx.paging.runtime)
55-
implementation(androidx.paging.compose)
5655
implementation(androidx.core.kts)
57-
implementation(androidx.core.google.shortcuts)
58-
implementation(google.accompanist.systemuicontroller)
5956
}
6057
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
android:supportsRtl="true"
1212
android:theme="@style/Theme.CNotes">
1313
<activity
14-
android:name=".MainActivity"
14+
android:name="st.slex.feature_main.ui.MainActivity"
1515
android:exported="true"
1616
android:theme="@style/Theme.CNotes">
1717
<intent-filter>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.stslex.cnotes
2+
3+
import org.koin.android.ext.koin.androidContext
4+
import org.koin.core.annotation.Single
5+
import org.koin.core.component.KoinComponent
6+
import org.koin.core.module.dsl.bind
7+
import org.koin.core.module.dsl.singleOf
8+
import org.koin.dsl.module
9+
import st.slex.feature_main.di.ActivityComponent
10+
import st.slex.feature_main.di.ActivityComponentImpl
11+
import st.slex.feature_main.ui.ShortcutBuilder
12+
import com.stslex.cnotes.shortcut.ShortcutBuilderImpl
13+
14+
@Single
15+
class AppComponent : KoinComponent {
16+
val appModules = module {
17+
single<ShortcutBuilder> {
18+
ShortcutBuilderImpl(androidContext())
19+
}
20+
singleOf(::ActivityComponentImpl) {
21+
bind<ActivityComponent>()
22+
}
23+
}
24+
}

app/src/main/java/com/stslex/cnotes/CNoteApplication.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.app.Application
44
import com.stslex.feature_auth_code.di.AuthCodeModule
55
import com.stslex.feature_auth_phonenumber.di.AuthPhoneNumberModule
66
import com.stslex.feature_note_list.di.NoteListModule
7-
import com.stslex.cnotes.di.AppComponent
87
import com.stslex.core.CoroutinesModule
98
import com.stslex.core_data_source.di.RoomDatabaseModule
109
import com.stslex.core_firebase.di.FirebaseModule

app/src/main/java/com/stslex/cnotes/di/ActivityComponent.kt

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/src/main/java/com/stslex/cnotes/di/AppComponent.kt

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.stslex.cnotes.shortcut
2+
3+
import com.stslex.core_navigation.destinations.ProfileDestination
4+
import com.stslex.core_navigation.destinations.SingleNoteDestination
5+
import com.stslex.core_ui.R
6+
import com.stslex.feature_main.R.drawable
7+
8+
9+
sealed class AppShortcuts(
10+
val shortcut: Shortcut
11+
) {
12+
13+
object Profile : AppShortcuts(
14+
Shortcut(
15+
labelSource = R.string.lb_short_shortcut_profile,
16+
shortLabelSource = R.string.lb_short_shortcut_profile,
17+
longLabelSource = R.string.lb_long_shortcut_profile,
18+
disabledMessageSource = R.string.lb_shortcut_disabled_message,
19+
iconSource = drawable.ic_baseline_person_outline_24,
20+
intentDestination = ProfileDestination.route
21+
)
22+
)
23+
24+
object CreateNewNote : AppShortcuts(
25+
Shortcut(
26+
labelSource = R.string.lb_short_shortcut_create,
27+
shortLabelSource = R.string.lb_short_shortcut_create,
28+
longLabelSource = R.string.lb_long_shortcut_create,
29+
disabledMessageSource = R.string.lb_shortcut_disabled_message,
30+
iconSource = drawable.ic_baseline_add_24,
31+
intentDestination = "${SingleNoteDestination.route}/-1"
32+
)
33+
)
34+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.stslex.cnotes.shortcut
2+
3+
import android.content.Context
4+
import android.content.Intent
5+
import android.net.Uri
6+
import androidx.core.content.pm.ShortcutInfoCompat
7+
import androidx.core.content.pm.ShortcutManagerCompat
8+
import androidx.core.graphics.drawable.IconCompat
9+
import st.slex.feature_main.ui.MainActivity
10+
11+
data class Shortcut(
12+
val labelSource: Int,
13+
val shortLabelSource: Int,
14+
val longLabelSource: Int,
15+
val disabledMessageSource: Int,
16+
val iconSource: Int,
17+
val intentDestination: String
18+
) : ShortcutAction {
19+
20+
override fun push(context: Context) {
21+
ShortcutManagerCompat.pushDynamicShortcut(
22+
context,
23+
shortcutInfoCompat(context)
24+
)
25+
}
26+
27+
private val shortcutInfoCompat: (context: Context) -> ShortcutInfoCompat
28+
get() = { context ->
29+
ShortcutInfoCompat.Builder(
30+
context, context.getString(labelSource)
31+
).setShortLabel(context.getString(shortLabelSource))
32+
.setLongLabel(context.getString(longLabelSource))
33+
.setDisabledMessage(context.getString(disabledMessageSource))
34+
.setIcon(IconCompat.createWithResource(context, iconSource))
35+
.setIntent(context.shortcutIntent).build()
36+
}
37+
38+
private val Context.shortcutIntent: Intent
39+
get() = Intent(
40+
Intent.ACTION_VIEW,
41+
Uri.parse("$APP_URI_PREFIX${intentDestination}"),
42+
this,
43+
MainActivity::class.java
44+
)
45+
46+
companion object {
47+
private const val APP_URI_PREFIX = "app://"
48+
}
49+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.stslex.cnotes.shortcut
2+
3+
import android.content.Context
4+
5+
interface ShortcutAction {
6+
fun push(context: Context)
7+
}

0 commit comments

Comments
 (0)