Skip to content

Commit

Permalink
[#948] 주요 화면 DeepLink 처리 (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
l2hyunwoo authored Oct 29, 2024
1 parent f929bee commit 14eb4c7
Show file tree
Hide file tree
Showing 15 changed files with 241 additions and 24 deletions.
6 changes: 6 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ plugins {
sopt("application")
sopt("test")
sopt("compose")
sopt("deeplink")
alias(libs.plugins.google.services)
alias(libs.plugins.crashlytics)
alias(libs.plugins.ktlint)
Expand Down Expand Up @@ -112,6 +113,11 @@ android {
}
}

ksp {
arg("deepLink.incremental", "true")
arg("deepLink.customAnnotations", "com.airbnb.AppDeepLink|com.airbnb.WebDeepLink")
}

dependencies {
implementation(projects.core.designsystem)
implementation(projects.domain.soptamp)
Expand Down
42 changes: 22 additions & 20 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,53 +62,55 @@

<activity
android:name=".feature.auth.AuthActivity"
android:exported="true"
android:theme="@style/Theme.SOPT">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".feature.deeplink.DeepLinkSchemeActivity"
android:exported="true"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="sopt" />
</intent-filter>
</activity>
<activity
android:name=".feature.attendance.AttendanceActivity"
android:exported="false"
android:launchMode="singleTop"
android:theme="@style/Theme.SOPT" />
android:launchMode="singleTop" />
<activity
android:name=".stamp.SoptampActivity"
android:exported="false"
android:launchMode="singleTop"
android:theme="@style/Theme.SOPT" />
android:launchMode="singleTop" />
<activity
android:name=".feature.home.HomeActivity"
android:exported="false"
android:launchMode="singleTop"
android:theme="@style/Theme.SOPT" />
android:launchMode="singleTop" />
<activity
android:name=".feature.mypage.mypage.MyPageActivity"
android:exported="false"
android:launchMode="singleTop"
android:theme="@style/Theme.SOPT" />
android:launchMode="singleTop" />
<activity
android:name=".feature.mypage.signOut.SignOutActivity"
android:exported="false"
android:theme="@style/Theme.SOPT" />
android:exported="false" />
<activity
android:name=".feature.mypage.soptamp.sentence.AdjustSentenceActivity"
android:exported="false"
android:theme="@style/Theme.SOPT" />
android:exported="false" />
<activity
android:name=".feature.poke.onboarding.OnboardingActivity"
android:exported="false"
android:theme="@style/Theme.SOPT" />
android:exported="false" />
<activity
android:name=".feature.poke.main.PokeMainActivity"
android:exported="false"
android:launchMode="singleTop" />
android:exported="false" />
<activity
android:name=".feature.poke.notification.PokeNotificationActivity"
android:exported="false"
android:launchMode="singleTop" />
android:exported="false" />
<activity
android:name=".feature.poke.friend.summary.FriendListSummaryActivity"
android:exported="false" />
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/org/sopt/official/deeplink/AppDeeplinkModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.deeplink

import com.airbnb.deeplinkdispatch.DeepLinkModule

@DeepLinkModule
class AppDeeplinkModule
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import androidx.core.view.isVisible
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.RecyclerView
import com.airbnb.deeplinkdispatch.DeepLink
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -65,6 +66,7 @@ import org.sopt.official.feature.attendance.model.AttendanceState
import org.sopt.official.type.SoptColors

@AndroidEntryPoint
@DeepLink("sopt://attendance")
class AttendanceActivity : AppCompatActivity() {
private lateinit var binding: ActivityAttendanceBinding
private val viewModel by viewModels<AttendanceViewModel>()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.feature.deeplink

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.airbnb.deeplinkdispatch.DeepLinkHandler
import dagger.hilt.android.AndroidEntryPoint
import org.sopt.official.common.navigator.NavigatorProvider
import org.sopt.official.deeplink.AppDeeplinkModule
import org.sopt.official.deeplink.AppDeeplinkModuleRegistry
import org.sopt.official.feature.fortune.deeplink.FortuneDeeplinkModule
import org.sopt.official.feature.fortune.deeplink.FortuneDeeplinkModuleRegistry
import org.sopt.official.network.persistence.SoptDataStore
import org.sopt.official.webview.deeplink.WebDeeplinkModule
import org.sopt.official.webview.deeplink.WebDeeplinkModuleRegistry
import javax.inject.Inject

@AndroidEntryPoint
@DeepLinkHandler(value = [AppDeeplinkModule::class, FortuneDeeplinkModule::class, WebDeeplinkModule::class])
class DeepLinkSchemeActivity : AppCompatActivity() {

@Inject
lateinit var dataStore: SoptDataStore

@Inject
lateinit var navigator: NavigatorProvider

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

if (dataStore.accessToken.isEmpty()) {
startActivity(navigator.getAuthActivityIntent())
finish()
return
}

DeepLinkDelegate(
AppDeeplinkModuleRegistry(),
FortuneDeeplinkModuleRegistry(),
WebDeeplinkModuleRegistry()
).dispatchFrom(this)
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Rect
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.View
Expand All @@ -44,6 +43,7 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.airbnb.deeplinkdispatch.DeepLink
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand Down Expand Up @@ -83,6 +83,7 @@ import java.io.Serializable
import javax.inject.Inject

@AndroidEntryPoint
@DeepLink("sopt://home")
class HomeActivity : AppCompatActivity() {
private val binding by viewBinding(ActivitySoptMainBinding::inflate)
private val viewModel by viewModels<HomeViewModel>()
Expand Down
4 changes: 4 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ gradlePlugin {
id = "org.sopt.official.retrofit"
implementationClass = "org.sopt.official.plugin.RetrofitPlugin"
}
create("deeplink") {
id = "org.sopt.official.deeplink"
implementationClass = "org.sopt.official.plugin.DeeplinkPlugin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.sopt.official.plugin

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType

class DeeplinkPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
with(plugins) {
apply("com.google.devtools.ksp")
}

val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
dependencies {
"implementation"(libs.findLibrary("deeplink.dispatch").get())
"ksp"(libs.findLibrary("deeplink.dispatch.processor").get())
}
}
}
6 changes: 6 additions & 0 deletions core/webview/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

plugins {
sopt("feature")
sopt("deeplink")
}

android {
Expand All @@ -34,6 +35,11 @@ android {
}
}

ksp {
arg("deepLink.incremental", "true")
arg("deepLink.customAnnotations", "com.airbnb.AppDeepLink|com.airbnb.WebDeepLink")
}

dependencies {
implementation(projects.core.network)
implementation(projects.core.common)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.webview.deeplink

import com.airbnb.deeplinkdispatch.DeepLinkModule

@DeepLinkModule
class WebDeeplinkModule
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ import androidx.activity.addCallback
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.airbnb.deeplinkdispatch.DeepLink
import dagger.hilt.android.AndroidEntryPoint
import org.sopt.official.common.util.viewBinding
import org.sopt.official.webview.databinding.ActivityWebViewBinding

@AndroidEntryPoint
@DeepLink("sopt://web")
class WebViewActivity : AppCompatActivity() {
private val binding by viewBinding(ActivityWebViewBinding::inflate)
private var filePathCallback: ValueCallback<Array<Uri>>? = null
Expand Down Expand Up @@ -79,8 +81,13 @@ class WebViewActivity : AppCompatActivity() {
}

private fun handleLinkUrl() {
val linkUrl = intent.getStringExtra(INTENT_URL)
linkUrl?.let { binding.webView.loadUrl(it) }
if (intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false)) {
val url = intent.extras?.getString(INTENT_URL) ?: intent.getStringExtra(INTENT_URL) ?: "https://google.com"
binding.webView.loadUrl(url)
} else {
val linkUrl = intent.getStringExtra(INTENT_URL)
linkUrl?.let { binding.webView.loadUrl(it) }
}
}

private fun handleOnBackPressed() {
Expand All @@ -100,6 +107,6 @@ class WebViewActivity : AppCompatActivity() {
}

companion object {
const val INTENT_URL = "_intent_url"
const val INTENT_URL = "url"
}
}
6 changes: 6 additions & 0 deletions feature/fortune/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ plugins {
sopt("feature")
sopt("compose")
sopt("test")
sopt("deeplink")
}

android {
namespace = "org.sopt.official.feature.fortune"
}

ksp {
arg("deepLink.incremental", "true")
arg("deepLink.customAnnotations", "com.airbnb.AppDeepLink|com.airbnb.WebDeepLink")
}

dependencies {
// domain
implementation(projects.domain.fortune)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import com.airbnb.deeplinkdispatch.DeepLink
import dagger.hilt.android.AndroidEntryPoint
import dagger.hilt.android.EntryPointAccessors
import org.sopt.official.analytics.AmplitudeTracker
Expand All @@ -51,6 +52,7 @@ internal val LocalAmplitudeTracker = staticCompositionLocalOf<AmplitudeTracker>
}

@AndroidEntryPoint
@DeepLink("sopt://fortune")
class FortuneActivity : AppCompatActivity() {

@Inject
Expand Down
Loading

0 comments on commit 14eb4c7

Please sign in to comment.