Skip to content
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

Null issue fixed and removed secret credentials #44

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
buildscript {
ext.jacoco_version = '0.8.8'
repositories {
maven { url "https://plugins.gradle.org/m2/" }
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
url "https://plugins.gradle.org/m2/"
}
google()
mavenCentral()
}
Expand All @@ -10,6 +13,7 @@ buildscript {
classpath "com.android.tools.build:gradle:7.2.2" //7.0.4
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
classpath "com.android.tools:r8:8.1.56"
}
}

Expand Down
204 changes: 178 additions & 26 deletions contentstack/build.gradle
Original file line number Diff line number Diff line change
@@ -1,48 +1,200 @@
apply plugin: 'com.android.library'
apply plugin: 'jacoco'
plugins {
id 'signing'
id 'maven-publish'
id 'com.android.library'
id 'jacoco'
}

def localProperties = new Properties()
localProperties.load(new FileInputStream(rootProject.file("local.properties")))

group = 'com.contentstack.sdk'
version = '3.12.4-SNAPSHOT'


//publishing {
// publications {
// mavenJava(MavenPublication) {
// artifactId = 'android'
// versionMapping {
// usage('java-api') {
// fromResolutionOf('runtimeClasspath')
// }
// usage('java-runtime') {
// fromResolutionResult()
// }
// }
// pom {
//
// name = 'contentstack-android'
// packaging 'aar'
// artifactId "android"
// description = 'Android SDK for Contentstack Content Delivery API, Contentstack is a headless CMS with an API-first approach'
// url = 'https://github.com/contentstack/contentstack-android'
//
// scm {
// url 'https://github.com/contentstack/contentstack-android/'
// connection 'scm:[email protected]:contentstack/contentstack-android'
// developerConnection 'scm:[email protected]:contentstack/contentstack-android.git'
// }
//
// licenses {
// license {
// name 'The MIT License'
// url 'http://www.opensource.org/licenses/mit-license.php'
// distribution 'repo'
// }
// }
// developers {
// developer {
// id 'ishaileshmishra'
// name 'Shailesh Mishra'
// email '[email protected]'
// }
// }
// }
// }
// }
// repositories {
// maven {
// def releasesRepoUrl = layout.buildDirectory.dir('repos/releases')
// def snapshotsRepoUrl = layout.buildDirectory.dir('repos/snapshots')
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
// }
// }
//}

apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
//signing {
// sign publishing.publications.mavenJava
//}


//javadoc {
// if (JavaVersion.current().isJava9Compatible()) {
// options.addBooleanOption('html5', true)
// }
//}


tasks.register('jacocoTestReport', JacocoReport) {
// dependsOn['testDebugUnitTest', 'createDebugCoverageReport']
reports {
html.enabled = true
}

// afterEvaluate {
// classDirectories.setFrom(files(classDirectories.files.collect {
// fileTree(dir: it, exclude: '**com/contentstack/okhttp**')
// fileTree(dir: it, exclude: '**com/contentstack/okio**')
// fileTree(dir: it, exclude: '**com/contentstack/txtmark**')
// }))
// }
}
android {
compileSdk 33
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/*.kotlin_module")
}
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
signingConfigs {
debug {
storeFile file("/Users/shaileshmishra/keystore/release.keystore")
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
storeFile file("/Users/shaileshmishra/keystore/release.keystore")
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
compileSdk 26
defaultConfig {
minSdk 19
targetSdk 33
minSdkVersion 19
versionCode 1
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
useLibrary 'org.apache.http.legacy'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.release
}

buildTypes {
def localProperties = new Properties()
localProperties.load(new FileInputStream(rootProject.file("local.properties")))
debug {
debuggable true
testCoverageEnabled true
buildConfigField "String", "host", localProperties['host']
buildConfigField "String", "APIKey", localProperties['APIKey']
buildConfigField "String", "deliveryToken", localProperties['deliveryToken']
buildConfigField "String", "environment", localProperties['env']
buildConfigField "String", "contentTypeUID", localProperties['contentType']
buildConfigField "String", "assetUID", localProperties['assetUid']
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "default"
lintOptions { abortOnError false }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
unitTests.returnDefaultValues = true
}
}
repositories {
// flatDir { dirs 'libs' }
// mavenCentral()
// mavenLocal()
}

configurations { archives }

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.6.1'
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.support:appcompat-v7:26.1.0'
// implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.volley:volley:1.2.1'
implementation 'androidx.test:core:1.5.0'
implementation 'junit:junit:4.13.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test:core:1.5.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
tasks.register('clearJar', Delete) { delete 'build/libs/Contentstack.jar' }
tasks.register('unzip', Copy) {
def zipFile = file('build/intermediates/intermediate-jars/release/classes.jar')
def outputDir = file("${buildDir}/contentstack-jar")
from zipTree(zipFile)
into outputDir
}
tasks.register('createJar', Jar) {
archivesBaseName = "contentstack.jar"
from('build/contentstack-jar/')
include 'com/contentstack/'
include 'META-INF/'
}
createJar.dependsOn(clearJar, unzip, build)

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

class AssetsModel {
List<Object> objects = new ArrayList<Object>();
List<Object> objects = new ArrayList<>();

public AssetsModel(JSONObject jsonObject, boolean isFromCache) {
jsonObject = !isFromCache && jsonObject.opt("response") == null ? jsonObject : jsonObject.optJSONObject("response");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.VolleyError;
Expand Down Expand Up @@ -209,7 +208,7 @@ private String getParams(HashMap<String, Object> params) {
}

} catch (Exception e1) {
SDKUtil.showLog(TAG, "--------------------getQueryParam--||" + e1.toString());
SDKUtil.showLog(TAG, "-getQueryParam--||" + e1.toString());
}
}

Expand Down Expand Up @@ -239,7 +238,7 @@ public void send() {
}
headers.put("Content-Type", "application/json");
headers.put("User-Agent", defaultUserAgent());
headers.put("X-User-Agent", "contentstack-android/" + SDKConstant.SDK_VERSION);
headers.put("X-User-Agent", "contentstack-delivery-android/" + SDKConstant.SDK_VERSION);
jsonObjectRequest = new JSONUTF8Request(requestId, url, requestJSON, response -> {
this.responseJSON = response;
if (this.responseJSON != null) {
Expand Down
27 changes: 20 additions & 7 deletions contentstack/src/main/java/com/contentstack/sdk/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.text.TextUtils;


import javax.validation.constraints.NotNull;

/**
* Set Configuration for stack instance creation.
*
Expand All @@ -13,6 +16,7 @@ public class Config {
protected String VERSION = "v3";
protected String environment = null;
protected String branch = null;
protected String[] earlyAccess = null;


/**
Expand Down Expand Up @@ -43,13 +47,13 @@ public void setBranch(String branch) {
*
* <br><br><b>Example For Different Regions:</b><br>
* <pre>
* {@code
* config.setRegion(ContentstackRegion.US);
* config.setRegion(ContentstackRegion.EU);
* config.setRegion(ContentstackRegion.AZURE_EU);
* config.setRegion(ContentstackRegion.AZURE_NA);
* }
* </pre>
* {@code
* config.setRegion(ContentstackRegion.US);
* config.setRegion(ContentstackRegion.EU);
* config.setRegion(ContentstackRegion.AZURE_EU);
* config.setRegion(ContentstackRegion.AZURE_NA);
* }
* </pre>
*/
public ContentstackRegion setRegion(ContentstackRegion region) {
this.region = region;
Expand All @@ -61,6 +65,15 @@ public ContentstackRegion getRegion() {
return this.region;
}

public String[] getEarlyAccess() {
return this.earlyAccess;
}

public Config earlyAccess(@NotNull String[] earlyAccess) {
this.earlyAccess = earlyAccess;
return this;
}

public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

import org.jetbrains.annotations.NotNull;

import java.io.File;

import javax.validation.constraints.NotNull;

/**
* Contains all Contentstack SDK Classes And Methods.
*
Expand Down Expand Up @@ -87,6 +88,10 @@ private static Stack initializeStack(Context appContext, String apiKey, String d
if (config.getBranch() != null) {
stack.setHeader("branch", config.getBranch());
}
if (config.getEarlyAccess() != null && config.getEarlyAccess().length > 0) {
String eaValues = String.join(",", config.earlyAccess).replace("\"", "");
stack.setHeader("x-header-ea", eaValues);
}
stack.setConfig(config);
initializeCache(appContext);
return stack;
Expand Down
4 changes: 2 additions & 2 deletions contentstack/src/main/java/com/contentstack/sdk/Stack.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;

import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;

Expand All @@ -23,6 +21,8 @@
import java.util.Objects;
import java.util.TimeZone;

import javax.validation.constraints.NotNull;

/**
* To fetch stack level information of your application from Contentstack server.
* <p>
Expand Down
Loading
Loading