-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #351 from CleverTap/task/SDK-1769/PushPrimer
[SDK-1970] - Push primer for Android 13
- Loading branch information
Showing
78 changed files
with
2,236 additions
and
461 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
50 changes: 50 additions & 0 deletions
50
clevertap-core/src/main/java/com/clevertap/android/sdk/CTPreferenceCache.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,50 @@ | ||
package com.clevertap.android.sdk | ||
|
||
import android.content.Context | ||
import com.clevertap.android.sdk.inapp.InAppController | ||
import com.clevertap.android.sdk.task.CTExecutorFactory | ||
|
||
class CTPreferenceCache { | ||
|
||
fun isFirstTimeRequest() = firstTimeRequest | ||
fun setFirstTimeRequest(fTR : Boolean) { | ||
firstTimeRequest = fTR | ||
} | ||
|
||
companion object { | ||
|
||
@Volatile | ||
private var INSTANCE: CTPreferenceCache? = null | ||
|
||
@JvmField | ||
var firstTimeRequest = true | ||
|
||
@JvmStatic | ||
fun getInstance(context: Context, config: CleverTapInstanceConfig): CTPreferenceCache = | ||
INSTANCE ?: synchronized(this) { | ||
INSTANCE ?: buildCache(context, config).also { INSTANCE = it } | ||
} | ||
|
||
private fun buildCache(context: Context, config: CleverTapInstanceConfig): CTPreferenceCache { | ||
CTExecutorFactory.executors(config).ioTask<Void>().execute("buildCache") { | ||
firstTimeRequest = StorageHelper.getBoolean( | ||
context, | ||
InAppController.IS_FIRST_TIME_PERMISSION_REQUEST, true | ||
) | ||
null | ||
} | ||
return CTPreferenceCache() | ||
} | ||
|
||
@JvmStatic | ||
fun updateCacheToDisk(context: Context, config: CleverTapInstanceConfig) { | ||
CTExecutorFactory.executors(config).ioTask<Void>().execute("updateCacheToDisk") { | ||
StorageHelper.putBooleanImmediate( | ||
context, InAppController.IS_FIRST_TIME_PERMISSION_REQUEST, | ||
firstTimeRequest | ||
) | ||
null | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
clevertap-core/src/main/java/com/clevertap/android/sdk/CTStringResources.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,21 @@ | ||
package com.clevertap.android.sdk | ||
|
||
import android.content.Context | ||
import androidx.annotation.RestrictTo | ||
import androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP | ||
|
||
@RestrictTo(LIBRARY_GROUP) | ||
class CTStringResources(private val context: Context, vararg sRID: Int) { | ||
|
||
private var sArray: Array<String> | ||
|
||
init { | ||
sArray = Array(sRID.size) { context.getString(sRID[it]) } | ||
} | ||
|
||
operator fun component1(): String? = sArray.getOrNull(0) | ||
operator fun component2(): String? = sArray.getOrNull(1) | ||
operator fun component3(): String? = sArray.getOrNull(2) | ||
operator fun component4(): String? = sArray.getOrNull(3) | ||
operator fun component5(): String? = sArray.getOrNull(4) | ||
} |
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
clevertap-core/src/main/java/com/clevertap/android/sdk/CTXtensions.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,12 @@ | ||
@file:JvmName("CTXtensions") | ||
|
||
package com.clevertap.android.sdk | ||
|
||
import android.content.Context | ||
import android.os.Build.VERSION | ||
|
||
fun Context.isPackageAndOsTargetsAbove(apiLevel: Int) = | ||
VERSION.SDK_INT > apiLevel && targetSdkVersion > apiLevel | ||
|
||
val Context.targetSdkVersion | ||
get() = applicationContext.applicationInfo.targetSdkVersion |
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
Oops, something went wrong.