-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into release/1.50
- Loading branch information
Showing
32 changed files
with
512 additions
and
40 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
12 changes: 12 additions & 0 deletions
12
...osHyperskillApp/Sources/Services/ApplicationShortcuts/ApplicationShortcutIdentifier.swift
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,12 @@ | ||
import Foundation | ||
|
||
enum ApplicationShortcutIdentifier: String { | ||
case sendFeedback = "SendFeedback" | ||
|
||
init?(fullIdentifier: String) { | ||
guard let shortIdentifier = fullIdentifier.components(separatedBy: ".").last else { | ||
return nil | ||
} | ||
self.init(rawValue: shortIdentifier) | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
.../iosHyperskillApp/Sources/Services/ApplicationShortcuts/ApplicationShortcutsService.swift
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,94 @@ | ||
import shared | ||
import UIKit | ||
|
||
protocol ApplicationShortcutsServiceProtocol: AnyObject { | ||
func handleShortcutItem(_ shortcutItem: UIApplicationShortcutItem) -> Bool | ||
func handleLaunchOptions(_ launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool | ||
} | ||
|
||
final class ApplicationShortcutsService: ApplicationShortcutsServiceProtocol { | ||
private lazy var applicationShortcutsInteractor: ApplicationShortcutsInteractor = | ||
AppGraphBridge.sharedAppGraph.buildApplicationShortcutsDataComponent().applicationShortcutsInteractor | ||
|
||
private lazy var analyticInteractor = AnalyticInteractor.default | ||
|
||
private var sendEmailFeedbackController: SendEmailFeedbackController? | ||
|
||
// MARK: Protocol Conforming | ||
|
||
func handleLaunchOptions(_ launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
if let shortcutItem = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem { | ||
_ = handleShortcutItem(shortcutItem) | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
func handleShortcutItem(_ shortcutItem: UIApplicationShortcutItem) -> Bool { | ||
let shortcutType = shortcutItem.type | ||
|
||
analyticInteractor.logEvent( | ||
event: ApplicationShortcutItemClickedHyperskillAnalyticEvent(shortcutItemIdentifier: shortcutType) | ||
) | ||
|
||
guard let shortcutIdentifier = ApplicationShortcutIdentifier(fullIdentifier: shortcutType) else { | ||
#if DEBUG | ||
print("ApplicationShortcutsService: Did receive unknown shortcut identifier: \(shortcutType)") | ||
#endif | ||
return false | ||
} | ||
|
||
DispatchQueue.main.async { | ||
self.performAction(for: shortcutIdentifier) | ||
} | ||
|
||
return true | ||
} | ||
|
||
// MARK: Private API | ||
|
||
private func performAction(for shortcutIdentifier: ApplicationShortcutIdentifier) { | ||
switch shortcutIdentifier { | ||
case .sendFeedback: | ||
performSendFeedback() | ||
} | ||
} | ||
|
||
private func performSendFeedback() { | ||
applicationShortcutsInteractor.getSendFeedbackEmailData { [weak self] feedbackEmailData, error in | ||
if let error { | ||
#if DEBUG | ||
print("ApplicationShortcutsService: SendFeedback, failed get email data: \(error)") | ||
#endif | ||
return | ||
} | ||
|
||
guard let feedbackEmailData else { | ||
#if DEBUG | ||
print("ApplicationShortcutsService: SendFeedback, no email data") | ||
#endif | ||
return | ||
} | ||
|
||
assert(Thread.current.isMainThread) | ||
|
||
guard let currentPresentedViewController = SourcelessRouter().currentPresentedViewController() else { | ||
#if DEBUG | ||
print("ApplicationShortcutsService: SendFeedback, no current presented view controller") | ||
#endif | ||
return | ||
} | ||
|
||
let sendEmailFeedbackController = SendEmailFeedbackController() | ||
sendEmailFeedbackController.onDidFinish = { [weak self] in | ||
self?.sendEmailFeedbackController = nil | ||
} | ||
self?.sendEmailFeedbackController = sendEmailFeedbackController | ||
|
||
sendEmailFeedbackController.sendFeedback( | ||
feedbackEmailData: feedbackEmailData, | ||
presentationController: currentPresentedViewController | ||
) | ||
} | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
shared/src/commonMain/kotlin/org/hyperskill/app/main/cache/AppCacheDataSourceImpl.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,15 @@ | ||
package org.hyperskill.app.main.cache | ||
|
||
import com.russhwolf.settings.Settings | ||
import org.hyperskill.app.main.data.source.AppCacheDataSource | ||
|
||
internal class AppCacheDataSourceImpl( | ||
private val settings: Settings | ||
) : AppCacheDataSource { | ||
override fun isAppDidLaunchFirstTime(): Boolean = | ||
settings.getBoolean(AppCacheKeyValues.APP_DID_LAUNCH_FIRST_TIME, defaultValue = false) | ||
|
||
override fun setAppDidLaunchFirstTime() { | ||
settings.putBoolean(AppCacheKeyValues.APP_DID_LAUNCH_FIRST_TIME, true) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
shared/src/commonMain/kotlin/org/hyperskill/app/main/cache/AppCacheKeyValues.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 org.hyperskill.app.main.cache | ||
|
||
internal object AppCacheKeyValues { | ||
const val APP_DID_LAUNCH_FIRST_TIME = "app_did_launch_first_time" | ||
} |
15 changes: 15 additions & 0 deletions
15
shared/src/commonMain/kotlin/org/hyperskill/app/main/data/repository/AppRepositoryImpl.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,15 @@ | ||
package org.hyperskill.app.main.data.repository | ||
|
||
import org.hyperskill.app.main.data.source.AppCacheDataSource | ||
import org.hyperskill.app.main.domain.repository.AppRepository | ||
|
||
internal class AppRepositoryImpl( | ||
private val appCacheDataSource: AppCacheDataSource | ||
) : AppRepository { | ||
override fun isAppDidLaunchFirstTime(): Boolean = | ||
appCacheDataSource.isAppDidLaunchFirstTime() | ||
|
||
override fun setAppDidLaunchFirstTime() { | ||
appCacheDataSource.setAppDidLaunchFirstTime() | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
shared/src/commonMain/kotlin/org/hyperskill/app/main/data/source/AppCacheDataSource.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,6 @@ | ||
package org.hyperskill.app.main.data.source | ||
|
||
interface AppCacheDataSource { | ||
fun isAppDidLaunchFirstTime(): Boolean | ||
fun setAppDidLaunchFirstTime() | ||
} |
23 changes: 23 additions & 0 deletions
23
...tlin/org/hyperskill/app/main/domain/analytic/AppLaunchFirstTimeHyperskillAnalyticEvent.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,23 @@ | ||
package org.hyperskill.app.main.domain.analytic | ||
|
||
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticAction | ||
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticEvent | ||
import org.hyperskill.app.analytic.domain.model.hyperskill.HyperskillAnalyticRoute | ||
|
||
/** | ||
* Represents first time app launch analytic event. | ||
* | ||
* JSON payload: | ||
* ``` | ||
* { | ||
* "route": "app-launch-first-time", | ||
* "action": "view" | ||
* } | ||
* ``` | ||
* | ||
* @see HyperskillAnalyticEvent | ||
*/ | ||
object AppLaunchFirstTimeHyperskillAnalyticEvent : HyperskillAnalyticEvent( | ||
route = HyperskillAnalyticRoute.AppLaunchFirstTime(), | ||
action = HyperskillAnalyticAction.VIEW | ||
) |
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
6 changes: 6 additions & 0 deletions
6
shared/src/commonMain/kotlin/org/hyperskill/app/main/domain/repository/AppRepository.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,6 @@ | ||
package org.hyperskill.app.main.domain.repository | ||
|
||
interface AppRepository { | ||
fun isAppDidLaunchFirstTime(): Boolean | ||
fun setAppDidLaunchFirstTime() | ||
} |
Oops, something went wrong.