-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a Url Opener Helper for... opening urls on both platforms
- Loading branch information
Antoine Robiez
committed
Mar 11, 2024
1 parent
4e18f52
commit b469cca
Showing
11 changed files
with
88 additions
and
7 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
3 changes: 0 additions & 3 deletions
3
androidApp/src/main/java/fr/paug/androidmakers/ui/theme/AndroidMakersTheme.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
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
14 changes: 14 additions & 0 deletions
14
shared/domain/src/androidMain/kotlin/fr/androidmakers/domain/utils/UrlOpener.android.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,14 @@ | ||
package fr.androidmakers.domain.utils | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
|
||
actual class UrlOpener(private val context: Context) { | ||
actual fun openUrl(url: String) { | ||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply { | ||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
} | ||
context.startActivity(intent) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/interactor/OpenCocUseCase.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,10 @@ | ||
package fr.androidmakers.domain.interactor | ||
|
||
import fr.androidmakers.domain.utils.Constants | ||
import fr.androidmakers.domain.utils.UrlOpener | ||
|
||
class OpenCocUseCase( | ||
private val urlOpener: UrlOpener | ||
) { | ||
operator fun invoke() = urlOpener.openUrl(Constants.Urls.coc) | ||
} |
10 changes: 10 additions & 0 deletions
10
shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/interactor/OpenFaqUseCase.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,10 @@ | ||
package fr.androidmakers.domain.interactor | ||
|
||
import fr.androidmakers.domain.utils.Constants | ||
import fr.androidmakers.domain.utils.UrlOpener | ||
|
||
class OpenFaqUseCase( | ||
private val urlOpener: UrlOpener | ||
) { | ||
operator fun invoke() = urlOpener.openUrl(Constants.Urls.faq) | ||
} |
10 changes: 10 additions & 0 deletions
10
shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/interactor/OpenYoutubeUseCase.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,10 @@ | ||
package fr.androidmakers.domain.interactor | ||
|
||
import fr.androidmakers.domain.utils.Constants | ||
import fr.androidmakers.domain.utils.UrlOpener | ||
|
||
class OpenYoutubeUseCase( | ||
private val urlOpener: UrlOpener | ||
) { | ||
operator fun invoke() = urlOpener.openUrl(Constants.Urls.youtube) | ||
} |
9 changes: 9 additions & 0 deletions
9
shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/utils/Constants.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,9 @@ | ||
package fr.androidmakers.domain.utils | ||
|
||
object Constants { | ||
object Urls { | ||
const val faq = "https://androidmakers.droidcon.com/faqs/" | ||
const val coc = "https://androidmakers.droidcon.com/code-of-conduct/" | ||
const val youtube = "https://www.youtube.com/channel/UCkatLlah5weIpN23LqMgdTg" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/utils/UrlOpener.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,5 @@ | ||
package fr.androidmakers.domain.utils | ||
|
||
expect class UrlOpener { | ||
fun openUrl(url: String) | ||
} |
13 changes: 13 additions & 0 deletions
13
shared/domain/src/iosMain/kotlin/fr/androidmakers/domain/utils/UrlOpener.ios.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,13 @@ | ||
package fr.androidmakers.domain.utils | ||
|
||
import platform.Foundation.NSURL | ||
import platform.UIKit.UIApplication | ||
|
||
actual class UrlOpener { | ||
actual fun openUrl(url: String) { | ||
val urlObj = NSURL(string = url) | ||
if (UIApplication.sharedApplication.canOpenURL(urlObj)) { | ||
UIApplication.sharedApplication.openURL(urlObj) | ||
} | ||
} | ||
} |