-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to: #839
- Loading branch information
Showing
62 changed files
with
486 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...sale/app/src/main/java/com/emmsale/presentation/ui/eventDetail/eventSharer/EventSharer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.emmsale.presentation.ui.eventDetail.eventSharer | ||
|
||
import android.content.Context | ||
import com.emmsale.R | ||
import com.emmsale.presentation.common.extension.showToast | ||
import com.kakao.sdk.common.util.KakaoCustomTabsClient | ||
import com.kakao.sdk.share.ShareClient | ||
import com.kakao.sdk.share.WebSharerClient | ||
import com.kakao.sdk.template.model.FeedTemplate | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
|
||
class EventSharer @Inject constructor( | ||
@ApplicationContext private val context: Context, | ||
) { | ||
private val isNotKakaoTalkInstalled | ||
get() = !ShareClient.instance.isKakaoTalkSharingAvailable(context) | ||
|
||
fun shareEvent(eventTemplate: FeedTemplate) { | ||
if (isNotKakaoTalkInstalled) { | ||
handleKakaoNotInstalledError(eventTemplate) | ||
return | ||
} | ||
|
||
share(eventTemplate) | ||
} | ||
|
||
private fun handleKakaoNotInstalledError(eventTemplate: FeedTemplate) { | ||
val sharerUrl = WebSharerClient.instance.makeDefaultUrl(eventTemplate) | ||
|
||
runCatching { | ||
KakaoCustomTabsClient.openWithDefault(context, sharerUrl) | ||
}.onFailure { | ||
context.showToast(R.string.eventdetail_no_exist_browser) | ||
} | ||
|
||
runCatching { | ||
KakaoCustomTabsClient.open(context, sharerUrl) | ||
}.onFailure { | ||
context.showToast(R.string.eventdetail_no_exist_browser) | ||
} | ||
} | ||
|
||
private fun share(eventTemplate: FeedTemplate) { | ||
ShareClient.instance.shareDefault(context, eventTemplate) { sharingResult, error -> | ||
if (error != null) { | ||
context.showToast(R.string.eventdetail_kakao_share_fail) | ||
} else if (sharingResult != null) { | ||
context.startActivity(sharingResult.intent) | ||
} | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...p/src/main/java/com/emmsale/presentation/ui/eventDetail/eventSharer/EventTemplateMaker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.emmsale.presentation.ui.eventDetail.eventSharer | ||
|
||
import android.content.Context | ||
import com.emmsale.R | ||
import com.emmsale.presentation.ui.eventDetail.EventDetailViewModel | ||
import com.kakao.sdk.template.model.Button | ||
import com.kakao.sdk.template.model.Content | ||
import com.kakao.sdk.template.model.FeedTemplate | ||
import com.kakao.sdk.template.model.Link | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
|
||
class EventTemplateMaker @Inject constructor( | ||
@ApplicationContext private val context: Context, | ||
) { | ||
fun create( | ||
eventId: Long, | ||
eventName: String, | ||
posterUrl: String?, | ||
): FeedTemplate = FeedTemplate( | ||
content = Content( | ||
title = eventName, | ||
description = context.getString(R.string.eventdetail_share_template_description), | ||
imageUrl = posterUrl ?: "", | ||
link = Link(androidExecutionParams = mapOf(EventDetailViewModel.EVENT_ID_KEY to eventId.toString())), | ||
), | ||
buttons = listOf( | ||
Button( | ||
context.getString(R.string.eventdetail_share_button_title), | ||
Link(androidExecutionParams = mapOf(EventDetailViewModel.EVENT_ID_KEY to eventId.toString())), | ||
), | ||
), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
android/2023-emmsale/app/src/main/res/drawable/ic_eventdetail_share.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="16dp" | ||
android:height="20dp" | ||
android:viewportWidth="16" | ||
android:viewportHeight="20"> | ||
<path | ||
android:fillColor="#D9D9D9" | ||
android:pathData="M7,13H9V4H11L8,0L5,4H7V13ZM15,7H12V9H14V18H2V9H4V7H1C0.735,7 0.48,7.105 0.293,7.293C0.105,7.48 0,7.735 0,8V19C0,19.265 0.105,19.52 0.293,19.707C0.48,19.895 0.735,20 1,20H15C15.265,20 15.52,19.895 15.707,19.707C15.895,19.52 16,19.265 16,19V8C16,7.735 15.895,7.48 15.707,7.293C15.52,7.105 15.265,7 15,7Z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.