Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT/#59] 네이버 길찾기 기능 및 함수 구현 #94

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@
</intent-filter>
</activity>
</application>
<queries>
<package android:name="com.nhn.android.nmap" />

<intent>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent>
</queries>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.spoony.spoony.presentation.placeDetail

import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -23,6 +28,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -94,6 +100,8 @@ fun PlaceDetailRoute(
addMapCount = data.addMapCount,
isScooped = data.isScooped,
isAddMap = data.isAddMap,
latitude = data.latitude,
longitude = data.longitude,
onScoopButtonClick = viewModel::useSpoon,
onAddMapButtonClick = viewModel::updateAddMap,
dropdownMenuList = state.dropDownMenuList,
Expand Down Expand Up @@ -123,13 +131,16 @@ private fun PlaceDetailScreen(
addMapCount: Int,
isAddMap: Boolean,
isScooped: Boolean,
latitude: Double,
longitude: Double,
onScoopButtonClick: () -> Unit,
onAddMapButtonClick: (Boolean) -> Unit,
onBackButtonClick: () -> Unit,
dropdownMenuList: ImmutableList<String>,
onReportButtonClick: (String) -> Unit
) {
val scrollState = rememberScrollState()
val context = LocalContext.current

Column(
modifier = Modifier
Expand Down Expand Up @@ -226,13 +237,50 @@ private fun PlaceDetailScreen(
isAddMap = isAddMap,
onScoopButtonClick = onScoopButtonClick,
onSearchMapClick = {
// 네이버 길찾기 코드
searchPlaceNaverMap(
latitude = latitude,
longitude = longitude,
placeName = placeName,
context = context
)
},
onAddMapButtonClick = onAddMapButtonClick
)
}
}

private fun searchPlaceNaverMap(
latitude: Double,
longitude: Double,
placeName: String,
context: Context
) {
val url = "nmap://place?lat=$latitude&lng=$longitude&name=$placeName&appname=${context.packageName}"
val isInstalled = try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.packageManager.getPackageInfo(
"com.nhn.android.nmap",
PackageManager.PackageInfoFlags.of(0)
)
} else {
context.packageManager.getPackageInfo("com.nhn.android.nmap", 0)
}
true
} catch (e: PackageManager.NameNotFoundException) {
false
}
if (!isInstalled) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!isInstalled) {
if (isInstalled) {

P4: 이렇게 ! 안붙은거 먼저 해주면 너무 좋을 것 같아요..!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다!

Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.nhn.android.nmap")).apply {
context.startActivity(this)
}
} else {
Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply {
addCategory(Intent.CATEGORY_BROWSABLE)
context.startActivity(this)
}
}
}

@Composable
private fun PlaceDetailBottomBar(
addMapCount: Int,
Expand Down
Loading