diff --git a/build.gradle b/build.gradle
index 86874358..dfe2f5ec 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,15 +4,16 @@ buildscript {
agp_version = '8.2.1'
}
repositories {
+ google()
maven {
url "https://plugins.gradle.org/m2/"
}
- google()
mavenCentral()
}
dependencies {
- classpath "com.android.tools.build:gradle:8.2.1" //8.2.1
+ //classpath "com.android.tools.build:gradle:8.2.1" //8.2.1
+ classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'io.github.gradle-nexus:publish-plugin:2.0.0-rc-1'
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
}
diff --git a/contentstack/build.gradle b/contentstack/build.gradle
index 70aab5f3..91635e58 100755
--- a/contentstack/build.gradle
+++ b/contentstack/build.gradle
@@ -4,17 +4,19 @@ plugins {
}
import com.vanniktech.maven.publish.SonatypeHost
+
android.buildFeatures.buildConfig true
mavenPublishing {
publishToMavenCentral(SonatypeHost.DEFAULT)
signAllPublications()
- coordinates("com.contentstack.sdk", "android", "3.12.4-rc2-SNAPSHOT")
+ coordinates("com.contentstack.sdk", "android", "3.12.5")
pom {
name = "contentstack-android"
description = "The Content Delivery SDK facilitates the retrieval of content from your Contentstack account, enabling seamless delivery to your web or mobile properties.."
inceptionYear = "2018"
+ packaging 'aar'
url = "https://github.com/contentstack/contentstack-android"
licenses {
license {
@@ -32,7 +34,7 @@ mavenPublishing {
}
scm {
url = "scm:git@github.com:contentstack/contentstack-android"
- connection = "scm:git:git://github.com/username/mylibrary.git"
+ connection = "scm:git:git://github.com/contentstack/contentstack-android.git"
developerConnection = "scm:git@github.com:contentstack/contentstack-android.git"
}
}
@@ -52,17 +54,18 @@ tasks.register('jacocoTestReport', JacocoReport) {
}))
}
}
+
android {
- namespace "com.contentstack.sdk"
+ //namespace "com.contentstack.sdk"
packagingOptions {
- exclude 'META-INF/DEPENDENCIES'
- exclude 'META-INF/LICENSE.md'
- exclude 'META-INF/LICENSE-notice.md'
- exclude 'META-INF/license.txt'
- exclude 'META-INF/NOTICE'
- exclude 'META-INF/NOTICE.txt'
- exclude 'META-INF/notice.txt'
- exclude 'META-INF/ASL2.0'
+ exclude("META-INF/DEPENDENCIES")
+ exclude("META-INF/LICENSE")
+ exclude("META-INF/LICENSE.txt")
+ exclude("META-INF/license.txt")
+ exclude("META-INF/NOTICE")
+ exclude("META-INF/NOTICE.txt")
+ exclude("META-INF/notice.txt")
+ exclude("META-INF/ASL2.0")
exclude("META-INF/*.kotlin_module")
}
@@ -75,22 +78,23 @@ android {
}
signingConfigs {
debug {
- storeFile file("/Users/shaileshmishra/keystore/release.keystore")
+ storeFile file("/Users/shaileshmishra/keystore/key.keystore")
storePassword 'android'
- keyAlias 'androiddebugkey'
+ keyAlias 'key0'
keyPassword 'android'
}
release {
- storeFile file("/Users/shaileshmishra/keystore/release.keystore")
+ storeFile file("/Users/shaileshmishra/keystore/key.keystore")
storePassword 'android'
- keyAlias 'androiddebugkey'
+ keyAlias 'key0'
keyPassword 'android'
}
}
- compileSdk 26
+ compileSdk 30
defaultConfig {
+ // Required when setting minSdkVersion to 20 or lower
multiDexEnabled true
- minSdkVersion 19
+ minSdkVersion 23
versionCode 1
versionName "1.0"
useLibrary 'org.apache.http.legacy'
@@ -105,6 +109,8 @@ android {
debug {
debuggable true
testCoverageEnabled true
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+
buildConfigField "String", "host", localProperties['host']
buildConfigField "String", "APIKey", localProperties['APIKey']
buildConfigField "String", "deliveryToken", localProperties['deliveryToken']
@@ -118,26 +124,32 @@ android {
}
}
//flavorDimensions "default"
- lintOptions { abortOnError false }
+ //lintOptions { abortOnError false }
compileOptions {
- //coreLibraryDesugaringEnabled true
+ // Flag to enable support for the new language APIs
+ coreLibraryDesugaringEnabled true
+ // Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
configurations { archives }
dependencies {
- def multidex_version = "2.0.1"
+ def multidex = "2.0.1"
+ //def sdk_utils = "1.2.6"
+ def volley = "1.2.1"
+ def junit = "4.13.2"
configurations.configureEach { resolutionStrategy.force 'com.android.support:support-annotations:23.1.0' }
implementation fileTree(include: ['*.jar'], dir: 'libs')
- implementation 'com.contentstack.sdk:utils:1.2.6'
- implementation 'com.android.volley:volley:1.2.1'
- implementation 'junit:junit:4.13.2'
+ //implementation "com.contentstack.sdk:utils:$sdk_utils"
+ implementation "com.android.volley:volley:$volley"
+ implementation "junit:junit:$junit"
+ // For AGP 7.4+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
- implementation "androidx.multidex:multidex:$multidex_version"
-
+ //implementation "androidx.multidex:multidex:$multidex"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:core:1.5.0'
+ //testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java
index bccd7bd3..5cca358e 100644
--- a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java
+++ b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java
@@ -1,6 +1,6 @@
package com.contentstack.sdk;
+
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
import android.util.Log;
import org.junit.BeforeClass;
@@ -13,6 +13,7 @@
import static junit.framework.Assert.assertTrue;
import static junit.framework.TestCase.assertEquals;
+import androidx.test.InstrumentationRegistry;
import androidx.test.core.app.ApplicationProvider;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java b/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java
index a80f90b8..c512193a 100644
--- a/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java
+++ b/contentstack/src/androidTest/java/com/contentstack/sdk/ExampleInstrumentedTest.java
@@ -4,10 +4,10 @@
import static org.junit.Assert.assertNotNull;
import android.content.Context;
-import android.support.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import android.util.Log;
import androidx.test.core.app.ApplicationProvider;
+import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/contentstack/src/main/java/com/contentstack/sdk/Config.java b/contentstack/src/main/java/com/contentstack/sdk/Config.java
index 226a6a24..7d188ece 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/Config.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/Config.java
@@ -2,8 +2,8 @@
import android.text.TextUtils;
+import java.util.Objects;
-import javax.validation.constraints.NotNull;
/**
* Set Configuration for stack instance creation.
@@ -47,13 +47,13 @@ public void setBranch(String branch) {
*
*
Example For Different Regions:
*
- * {@code - * config.setRegion(ContentstackRegion.US); - * config.setRegion(ContentstackRegion.EU); - * config.setRegion(ContentstackRegion.AZURE_EU); - * config.setRegion(ContentstackRegion.AZURE_NA); - * } - *+ * {@code + * config.setRegion(ContentstackRegion.US); + * config.setRegion(ContentstackRegion.EU); + * config.setRegion(ContentstackRegion.AZURE_EU); + * config.setRegion(ContentstackRegion.AZURE_NA); + * } + * */ public ContentstackRegion setRegion(ContentstackRegion region) { this.region = region; @@ -69,7 +69,10 @@ public String[] getEarlyAccess() { return this.earlyAccess; } - public Config earlyAccess(@NotNull String[] earlyAccess) { + public Config earlyAccess(String[] earlyAccess) { + if (earlyAccess == null) { + Objects.requireNonNull("Null early access"); + } this.earlyAccess = earlyAccess; return this; } diff --git a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java index 22433a47..97fe6402 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java @@ -7,10 +7,8 @@ import com.android.volley.RequestQueue; import com.android.volley.toolbox.Volley; - import java.io.File; - -import javax.validation.constraints.NotNull; +import java.util.Objects; /** * Contains all Contentstack SDK Classes And Methods. @@ -45,7 +43,9 @@ private Contentstack(Context context) { * @return {@link Stack} instance.
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "stag");* @throws Exception the exception */ - public static Stack stack(@NotNull Context context, @NotNull String apiKey, @NotNull String deliveryToken, @NotNull String environment) throws Exception { + public static Stack stack(Context context, String apiKey, String deliveryToken, String environment) throws Exception { + checkIfNull(context, apiKey, deliveryToken, environment); + if (!TextUtils.isEmpty(apiKey) || !TextUtils.isEmpty(deliveryToken) || !TextUtils.isEmpty(environment)) { Config config = new Config(); config.setEnvironment(environment); @@ -56,6 +56,13 @@ public static Stack stack(@NotNull Context context, @NotNull String apiKey, @Not } } + private static void checkIfNull(Context context, String apiKey, String deliveryToken, String environment) { + Objects.requireNonNull(context, "can not be null"); + Objects.requireNonNull(apiKey, "can not be null"); + Objects.requireNonNull(deliveryToken, "can not be null"); + Objects.requireNonNull(environment, "can not be null"); + } + /** * Authenticates the stack api key of your stack. * This must be called before your stack uses Contentstack sdk. @@ -70,7 +77,9 @@ public static Stack stack(@NotNull Context context, @NotNull String apiKey, @Not * @return {@link Stack} instance.
Config config = new Config(); config.setEnvironment("stag"); Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", config); * @throws Exception the exception */ - public static Stack stack(@NotNull Context context, @NotNull String apiKey, @NotNull String deliveryToken, @NotNull String environment, @NotNull Config config) throws Exception { + public static Stack stack(Context context, String apiKey, String deliveryToken, String environment, Config config) throws Exception { + checkIfNull(context, apiKey, deliveryToken, environment); + Objects.requireNonNull(config, "Config can not be null"); if (!TextUtils.isEmpty(apiKey) || !TextUtils.isEmpty(deliveryToken) || !TextUtils.isEmpty(environment)) { config.setEnvironment(environment); ctx = context; diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java index 3ba27756..d5bcb87b 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java @@ -4,6 +4,7 @@ import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; + import org.json.JSONException; import org.json.JSONObject; @@ -21,8 +22,6 @@ import java.util.Objects; import java.util.TimeZone; -import javax.validation.constraints.NotNull; - /** * To fetch stack level information of your application from Contentstack server. **/ public void getContentTypes(JSONObject params, final ContentTypesCallback callback) { try { @@ -350,9 +352,9 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap *@@ -51,7 +50,10 @@ public class Stack implements INotifyClass { protected Stack() { } - protected Stack(@NotNull String apiKey) { + protected Stack(String apiKey) { + if (apiKey==null){ + Objects.requireNonNull("Please provide a valid ApiKey"); + } this.stackApiKey = apiKey; if (this.localHeader == null) { this.localHeader = new ArrayMap<>(); @@ -224,7 +226,7 @@ public void setHeader(String key, String value) { } } - public void setHeaders(@NotNull ArrayMap
headers) { + public void setHeaders(ArrayMap headers) { if (this.localHeader == null) { this.localHeader = new ArrayMap<>(); } @@ -289,17 +291,17 @@ private String getImageUrl() { * This call returns comprehensive information of all the content types available in a particular stack in your account. *
Example :
*- * JSONObject params = new JSONObject(); - * params.put("include_snippet_schema", true); - * params.put("limit", 3); - * stack.getContentTypes(params, new ContentTypesCallback() { - * @Override public void onCompletion(ContentTypesModel contentTypesModel, Error error) { - * if (error == null){ - * // do your stuff. - * } - * } - * }); - *+ * JSONObject params = new JSONObject(); + * params.put("include_snippet_schema", true); + * params.put("limit", 3); + * stack.getContentTypes(params, new ContentTypesCallback() { + * @Override public void onCompletion(ContentTypesModel contentTypesModel, Error error) { + * if (error == null){ + * // do your stuff. + * } + * } + * }); + *
* - * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); - * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} - *+ * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); + * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} + * */ public void sync(SyncResultCallBack syncCallBack) { @@ -402,7 +404,7 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC * and the details of the content that was deleted or updated. *
- *+ * */ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { try { @@ -423,8 +425,8 @@ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { * *
- * stack.syncFromDate(start_date, new SyncResultCallBack()) { } - *+ * stack.syncFromDate(start_date, new SyncResultCallBack()) { } + * */ public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); @@ -494,7 +496,10 @@ public void syncLocale(Language language, SyncResultCallBack syncCallBack) { * However, if you do this, the subsequent syncs will only include the entries of the specified locales. * */ - public void syncLocale(@NotNull String localeCode, SyncResultCallBack syncCallBack) { + public void syncLocale(String localeCode, SyncResultCallBack syncCallBack) { + if (localeCode==null){ + Objects.requireNonNull("localeCode can not be null"); + } try { this.syncParams = new JSONObject(); this.syncParams.put("init", true); diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9f4197d5..6b0e6c07 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,8 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +#distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +#distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index b7965451..f699c255 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,18 +1,18 @@ pluginManagement { repositories { + google() mavenCentral() maven { url "https://plugins.gradle.org/m2/" } gradlePluginPortal() - google() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { - mavenCentral() google() + mavenCentral() } } rootProject.name = "contentstack-android"