-
Notifications
You must be signed in to change notification settings - Fork 0
Added no-codes logic #236
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
Merged
Merged
Added no-codes logic #236
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
392ce5f
Added no-codes logic
actions-user f2311c4
Updated deployment target
actions-user d3a8b78
Updated logic
actions-user fa2c9b2
Update android/sandwich/src/main/kotlin/io/qonversion/sandwich/NoCode…
suriksarkisyan 3c6f7b6
Review fixes
actions-user ac7a27d
Removed automations and fixed small issues
actions-user 9a76f9f
Removed useless functions and files
actions-user b7fd27e
Small fixes
SpertsyanKM 53e1b0b
Removed unused import
actions-user d91fdcd
Merge branch 'feature/no-codes' of github.com:qonversion/sandwich-sdk…
actions-user bf7a981
Fixed parameter wrong name
actions-user a5d32a1
Updated naming
actions-user File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
android/sandwich/src/main/kotlin/io/qonversion/sandwich/NoCodesEventListener.kt
This file contains hidden or 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 io.qonversion.sandwich | ||
|
|
||
| interface NoCodesEventListener { | ||
| fun onNoCodesEvent(event: Event, payload: BridgeData? = null) | ||
|
|
||
| enum class Event(val key: String) { | ||
| ScreenShown("nocodes_screen_shown"), | ||
| ScreenClosed("nocodes_screen_closed"), | ||
| ActionStarted("nocodes_action_started"), | ||
| ActionFinished("nocodes_action_finished"), | ||
| ActionFailed("nocodes_action_failed"), | ||
| ScreenFailedToLoad("nocodes_screen_failed_to_load") | ||
|
suriksarkisyan marked this conversation as resolved.
|
||
| } | ||
| } | ||
159 changes: 159 additions & 0 deletions
159
android/sandwich/src/main/kotlin/io/qonversion/sandwich/NoCodesSandwich.kt
This file contains hidden or 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,159 @@ | ||
| package io.qonversion.sandwich | ||
|
|
||
| import android.app.Application | ||
| import android.content.Context | ||
| import io.qonversion.nocodes.NoCodes | ||
| import io.qonversion.nocodes.NoCodesConfig | ||
| import io.qonversion.nocodes.dto.LogLevel | ||
| import io.qonversion.nocodes.interfaces.NoCodesDelegate | ||
| import io.qonversion.nocodes.interfaces.ScreenCustomizationDelegate | ||
| import io.qonversion.nocodes.dto.QScreenPresentationConfig | ||
| import io.qonversion.nocodes.dto.QScreenPresentationStyle | ||
| import io.qonversion.nocodes.dto.QAction | ||
| import io.qonversion.nocodes.error.NoCodesError | ||
| import io.qonversion.nocodes.error.NoCodesException | ||
|
|
||
| class NoCodesSandwich( | ||
| private val application: Application, | ||
| private val activityProvider: ActivityProvider | ||
| ) { | ||
|
|
||
| private var defaultPresentationConfig: QScreenPresentationConfig? = null | ||
| private val screenPresentationConfigs = mutableMapOf<String, QScreenPresentationConfig>() | ||
| private var isCustomizationDelegateSet = false | ||
| private val screenCustomizationDelegate = object : ScreenCustomizationDelegate { | ||
| override fun getPresentationConfigurationForScreen(screenId: String): QScreenPresentationConfig { | ||
| return screenPresentationConfigs[screenId] ?: defaultPresentationConfig ?: QScreenPresentationConfig() | ||
| } | ||
| } | ||
|
|
||
| // region Initialization | ||
|
|
||
| fun initialize( | ||
| context: Context, | ||
| projectKey: String, | ||
| proxyUrl: String? = null, | ||
| logLevelKey: String? = null, | ||
| logTag: String? = null | ||
| ) { | ||
| val configBuilder = NoCodesConfig.Builder(context, projectKey) | ||
|
|
||
| proxyUrl?.let { | ||
| configBuilder.setProxyURL(it) | ||
| } | ||
|
|
||
| logLevelKey?.let { | ||
| try { | ||
| val logLevel = LogLevel.valueOf(it) | ||
| configBuilder.setLogLevel(logLevel) | ||
| } catch (e: IllegalArgumentException) { | ||
| // Ignore invalid log level | ||
|
suriksarkisyan marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
|
|
||
| logTag?.let { | ||
| configBuilder.setLogTag(it) | ||
| } | ||
|
|
||
| NoCodes.initialize(configBuilder.build()) | ||
| } | ||
|
|
||
| // endregion | ||
|
|
||
| // region Delegate | ||
|
|
||
| fun setDelegate(eventListener: NoCodesEventListener) { | ||
| NoCodes.shared.setDelegate(createNoCodesDelegate(eventListener)) | ||
| } | ||
|
|
||
| fun setScreenCustomizationDelegate() { | ||
| if (!isCustomizationDelegateSet) { | ||
| isCustomizationDelegateSet = true | ||
| NoCodes.shared.setScreenCustomizationDelegate(screenCustomizationDelegate) | ||
| } | ||
| } | ||
|
|
||
| fun setScreenPresentationConfig(configData: Map<String, Any?>, screenId: String? = null) { | ||
| val config = configData.toNoCodesScreenPresentationConfig() | ||
|
|
||
| if (!isCustomizationDelegateSet) { | ||
| isCustomizationDelegateSet = true | ||
| NoCodes.shared.setScreenCustomizationDelegate(screenCustomizationDelegate) | ||
| } | ||
|
|
||
| screenId?.let { | ||
| screenPresentationConfigs[screenId] = config | ||
| } ?: run { | ||
| screenPresentationConfigs.clear() | ||
| defaultPresentationConfig = config | ||
| } | ||
| } | ||
|
|
||
| // endregion | ||
|
|
||
| // region Screen Management | ||
|
|
||
| fun showScreen(screenId: String) { | ||
| NoCodes.shared.showScreen(screenId) | ||
| } | ||
|
|
||
| fun close() { | ||
| NoCodes.shared.close() | ||
| } | ||
|
|
||
| // endregion | ||
|
|
||
| // region Configuration | ||
|
|
||
| fun setLogLevel(logLevelKey: String) { | ||
| val logLevel = LogLevel.valueOf(logLevelKey) | ||
| NoCodes.shared.setLogLevel(logLevel) | ||
| } | ||
|
|
||
| fun setLogTag(logTag: String) { | ||
| NoCodes.shared.setLogTag(logTag) | ||
| } | ||
|
|
||
| // endregion | ||
|
|
||
| // region Private | ||
|
|
||
| private fun createNoCodesDelegate(eventListener: NoCodesEventListener): NoCodesDelegate { | ||
| return object : NoCodesDelegate { | ||
| override fun onScreenShown(screenId: String) { | ||
| val payload = mapOf("screenId" to screenId) | ||
| eventListener.onNoCodesEvent(NoCodesEventListener.Event.ScreenShown, payload) | ||
| } | ||
|
|
||
| override fun onActionStartedExecuting(action: QAction) { | ||
| val payload = mapOf("action" to action.toMap()) | ||
| eventListener.onNoCodesEvent(NoCodesEventListener.Event.ActionStarted, payload) | ||
| } | ||
|
|
||
| override fun onActionFailedToExecute(action: QAction) { | ||
| val payload = mapOf("action" to action.toMap()) | ||
| eventListener.onNoCodesEvent(NoCodesEventListener.Event.ActionFailed, payload) | ||
| } | ||
|
|
||
| override fun onActionFinishedExecuting(action: QAction) { | ||
| val payload = mapOf("action" to action.toMap()) | ||
| eventListener.onNoCodesEvent(NoCodesEventListener.Event.ActionFinished, payload) | ||
| } | ||
|
|
||
| override fun onFinished() { | ||
| eventListener.onNoCodesEvent(NoCodesEventListener.Event.ScreenClosed) | ||
| } | ||
|
|
||
| override fun onScreenFailedToLoad(error: NoCodesError) { | ||
| val payload = mapOf( | ||
| "code" to error.code.toString(), | ||
| "description" to error.details, | ||
| "additionalMessage" to error.qonversionError?.additionalMessage | ||
| ) | ||
|
suriksarkisyan marked this conversation as resolved.
Outdated
|
||
| eventListener.onNoCodesEvent(NoCodesEventListener.Event.ScreenFailedToLoad, payload) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // endregion | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| source 'https://github.com/CocoaPods/Specs.git' | ||
|
|
||
| # Uncomment the next line to define a global platform for your project | ||
| platform :ios, '9.0' | ||
| platform :ios, '13.0' | ||
|
|
||
| use_frameworks! | ||
|
|
||
| target 'QonversionSandwich' do | ||
| pod 'Qonversion', '5.13.0' | ||
|
suriksarkisyan marked this conversation as resolved.
|
||
| pod 'NoCodes', '0.0.5' | ||
| end | ||
|
|
||
|
Comment on lines
+7
to
11
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed? |
||
| target 'Sample' do | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,26 +1,30 @@ | ||
| PODS: | ||
| - Qonversion (5.13.0): | ||
| - Qonversion/Main (= 5.13.0) | ||
| - Qonversion/Main (5.13.0) | ||
| - QonversionSandwich (5.1.7): | ||
| - Qonversion (= 5.13.0) | ||
| - NoCodes (0.0.5): | ||
| - Qonversion (= 5.13.3) | ||
| - Qonversion (5.13.3): | ||
| - Qonversion/Main (= 5.13.3) | ||
| - Qonversion/Main (5.13.3) | ||
| - QonversionSandwich (5.3.0): | ||
| - NoCodes (= 0.0.5) | ||
|
|
||
| DEPENDENCIES: | ||
| - Qonversion (= 5.13.0) | ||
| - NoCodes (= 0.0.5) | ||
| - QonversionSandwich (from `../`) | ||
|
|
||
| SPEC REPOS: | ||
| https://github.com/CocoaPods/Specs.git: | ||
| - NoCodes | ||
| - Qonversion | ||
|
|
||
| EXTERNAL SOURCES: | ||
| QonversionSandwich: | ||
| :path: "../" | ||
|
|
||
| SPEC CHECKSUMS: | ||
| Qonversion: 37addeba74c5b328de9e1173b580c971b6d764ec | ||
| QonversionSandwich: 6aa0afcf15dc79817eef20bf5dfe475b32bcff9a | ||
| NoCodes: 40aab24087b8e27f1f9da901ab023a64a0d35d15 | ||
| Qonversion: 2b32ae8681de3ba02db5b5ed69c8f213ac4a28fa | ||
| QonversionSandwich: fdf2cc9b254bbbb6bf5e9ba545d570de9be013ac | ||
|
|
||
| PODFILE CHECKSUM: ea5d129345e5e6f263575a7a6d165488b50b6991 | ||
| PODFILE CHECKSUM: bf8d60259bbb4b0784fe7e49fb6de90eada0700c | ||
|
|
||
| COCOAPODS: 1.15.2 | ||
| COCOAPODS: 1.16.2 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.