Skip to content

Commit

Permalink
feat: Bump up compile SDK to 33 and ktlint version (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
mchuangatmp committed Oct 3, 2022
1 parent 872f7d6 commit 67dc378
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 94 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- name: "Checkout development branch"
uses: actions/checkout@v2
with:
token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
repository: mparticle/mparticle-android-sdk
ref: development
submodules: recursive
Expand Down Expand Up @@ -73,6 +74,7 @@ jobs:
- name: "Checkout public main branch"
uses: actions/checkout@v2
with:
token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
fetch-depth: 0
ref: main
- name: "Import GPG Key"
Expand Down
7 changes: 4 additions & 3 deletions android-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ apply from: '../scripts/maven.gradle'
apply plugin: 'kotlin-android'

android {
compileSdk 32
namespace 'com.mparticle'
compileSdk 33
packagingOptions {
exclude 'META-INF/LICENSE'
}
Expand Down Expand Up @@ -42,8 +43,8 @@ android {
}

defaultConfig {
minSdkVersion 14
targetSdk 32
minSdk 14
targetSdk 33
versionName project.version.toString().replace('-SNAPSHOT', '')
versionCode Integer.parseInt(new Date().format('yyyyMMdd'))

Expand Down
8 changes: 4 additions & 4 deletions android-core/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mparticle">
xmlns:tools="http://schemas.android.com/tools">

<uses-sdk android:minSdkVersion="21" tools:overrideLibrary="com.mparticle.testutils"/>

Expand All @@ -14,12 +13,13 @@
<application
android:usesCleartextTraffic="true">

<activity android:exported="true" android:name=".WebViewActivity">
<activity android:exported="true" android:name="com.mparticle.WebViewActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:exported="true" android:name=".MPService"/>
<service android:exported="true" android:name="com.mparticle.MPService" />
</application>

</manifest>
21 changes: 7 additions & 14 deletions android-core/src/androidTest/java/com/mparticle/MParticleTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.mparticle;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.location.Location;
import android.os.Handler;
import android.os.Looper;
Expand All @@ -17,8 +21,6 @@
import com.mparticle.internal.MParticleJSInterface;
import com.mparticle.internal.MessageManager;
import com.mparticle.internal.PushRegistrationHelper;
import com.mparticle.internal.database.MPDatabase;
import com.mparticle.internal.database.services.MParticleDBManager;
import com.mparticle.networking.Matcher;
import com.mparticle.networking.MockServer;
import com.mparticle.networking.Request;
Expand All @@ -27,29 +29,20 @@
import com.mparticle.testutils.MPLatch;
import com.mparticle.testutils.TestingUtils;

import junit.framework.Assert;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.Assert;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static junit.framework.Assert.fail;
import static junit.framework.TestCase.assertNull;

public class MParticleTest extends BaseCleanStartedEachTest {
private String configResponse = "{\"dt\":\"ac\", \"id\":\"fddf1f96-560e-41f6-8f9b-ddd070be0765\", \"ct\":1434392412994, \"dbg\":false, \"cue\":\"appdefined\", \"pmk\":[\"mp_message\", \"com.urbanairship.push.ALERT\", \"alert\", \"a\", \"message\"], \"cnp\":\"appdefined\", \"soc\":0, \"oo\":false, \"eks\":[] }, \"pio\":30 }";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ public class WebViewActivity extends Activity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web_view_activity);

}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.mparticle.internal;

import static com.mparticle.testutils.TestingUtils.assertJsonEqual;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
import android.util.MutableBoolean;
import android.webkit.CookieManager;
import android.webkit.JavascriptInterface;
Expand All @@ -15,6 +18,9 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.platform.app.InstrumentationRegistry;

import com.mparticle.BaseEvent;
import com.mparticle.MParticle;
import com.mparticle.WebViewActivity;
Expand Down Expand Up @@ -53,15 +59,10 @@
import java.util.Map;
import java.util.concurrent.CountDownLatch;

import static com.mparticle.testutils.TestingUtils.assertJsonEqual;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

public class MParticleJSInterfaceITest extends BaseCleanStartedEachTest {

@Rule
public ActivityTestRule<WebViewActivity> rule = new ActivityTestRule<WebViewActivity>(WebViewActivity.class);
public ActivityScenarioRule<WebViewActivity> rule = new ActivityScenarioRule<WebViewActivity>(WebViewActivity.class);

private static String jsSdk;
private static boolean sdkFetchedSuccessfully = false;
Expand Down Expand Up @@ -597,45 +598,46 @@ private String getJavascriptWrappedinHtml(String testJavascript) {

private void runJavascriptTest(final String testJavascript, final MParticleJSInterface jsInterface) {
new Handler(Looper.getMainLooper()).post(
new Runnable() {
@Override
public void run() {
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
WebView wv = rule.getActivity().findViewById(R.id.web_view);
wv.setWebViewClient(new WebViewClient() {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
//Overriding the method and allowing Options response essentially
//disables CORS, which will allow us to point network requests at our
//local server
if (request.getMethod().equalsIgnoreCase("OPTIONS")) {
return OptionsAllowResponse.build();
}

return null;
}
});
cookieManager.setAcceptThirdPartyCookies(wv, true);
wv.getSettings().setDomStorageEnabled(true);
wv.getSettings().setJavaScriptEnabled(true);
String bridgeName = MParticleJSInterface.getBridgeName(bridgeToken);
wv.removeJavascriptInterface(bridgeName);
wv.addJavascriptInterface(jsInterface, bridgeName);
wv.setWebChromeClient(new WebChromeClient() {
public void onConsoleMessage(String message, int lineNumber, String sourceID) {
Logger.warning("MParticle JS sdk", message + " -- From line "
+ lineNumber);
() -> {
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
rule.getScenario().onActivity(
activity -> {
WebView wv = activity.findViewById(R.id.web_view);
wv.setWebViewClient(new WebViewClient() {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
//Overriding the method and allowing Options response essentially
//disables CORS, which will allow us to point network requests at our
//local server
if (request.getMethod().equalsIgnoreCase("OPTIONS")) {
return OptionsAllowResponse.build();
}

return null;
}
});
cookieManager.setAcceptThirdPartyCookies(wv, true);
wv.getSettings().setDomStorageEnabled(true);
wv.getSettings().setJavaScriptEnabled(true);
String bridgeName = MParticleJSInterface.getBridgeName(bridgeToken);
wv.removeJavascriptInterface(bridgeName);
wv.addJavascriptInterface(jsInterface, bridgeName);
wv.setWebChromeClient(new WebChromeClient() {
public void onConsoleMessage(String message, int lineNumber, String sourceID) {
Logger.warning("MParticle JS sdk", message + " -- From line "
+ lineNumber);
}
});

String jsString = getJavascriptWrappedinHtml(testJavascript);
Logger.error(jsString);
wv.loadDataWithBaseURL("http://localhost/",
jsString,
"text/html", "utf-8",
null);
}
});

String jsString = getJavascriptWrappedinHtml(testJavascript);
Logger.error(jsString);
wv.loadDataWithBaseURL("http://localhost/",
jsString,
"text/html", "utf-8",
null);
}
);
});
}

Expand Down
5 changes: 1 addition & 4 deletions android-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mparticle">

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />

</manifest>
6 changes: 4 additions & 2 deletions android-kit-base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ apply plugin: 'kotlin-android'


android {
compileSdk 31
namespace 'com.mparticle.kits'
testNamespace 'com.mparticle.kittests'
compileSdk 33
testBuildType 'debug'

defaultConfig {
minSdkVersion 14
targetSdk 31
targetSdk 33
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

Expand Down
4 changes: 1 addition & 3 deletions android-kit-base/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mparticle.kittests">

xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:minSdkVersion="21" tools:overrideLibrary="com.mparticle.testutils"/>

<uses-permission android:name="android.permission.INTERNET" />
Expand Down
2 changes: 1 addition & 1 deletion android-kit-base/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.mparticle.kits" />
<manifest />
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.gradle_version = '7.1.3'
ext.gradle_version = '7.3.0'

repositories {
mavenCentral()
Expand All @@ -14,7 +14,7 @@ buildscript {

plugins {
id "org.sonarqube" version "3.4.0.2513"
id "org.jlleitschuh.gradle.ktlint" version "10.2.1"
id "org.jlleitschuh.gradle.ktlint" version "11.0.0"
}

sonarqube {
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
android.enableJetifier=true
#android.enableJetifier=true
android.useAndroidX=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2560m
org.gradle.jvmargs=-Xmx2560m
#-XX:ThreadStackSize=4096 -XX:CompilerThreadStackSize=4096
2 changes: 1 addition & 1 deletion kit-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ apply from: '../scripts/maven.gradle'
dependencies {
implementation gradleApi()
implementation localGroovy()
compileOnly "com.android.tools.build:gradle:7.1.3"
compileOnly "com.android.tools.build:gradle:7.3.0"
testImplementation "com.android.tools.build:gradle:4.1.3"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class KitPlugin implements Plugin<Project> {
target.dependencies.add('compileOnly', 'androidx.annotation:annotation:[1.0.0,)')
target.extensions.create("mparticle", MParticlePluginExtension)
LibraryExtension androidLib = target.android
androidLib.compileSdk 31
androidLib.compileSdk 33
int dateInt = Integer.parseInt(new Date().format('yyyyMMdd'))
androidLib.defaultConfig.versionCode = dateInt
androidLib.defaultConfig.minSdk 14
androidLib.defaultConfig.targetSdk 31
androidLib.defaultConfig.minSdk 16
androidLib.defaultConfig.targetSdk 33
androidLib.defaultConfig.buildConfigField("String", "VERSION_CODE", '\"' + dateInt + '\"')
androidLib.buildTypes.release.minifyEnabled false
androidLib.buildTypes.release.consumerProguardFiles 'consumer-proguard.pro'
Expand Down
6 changes: 4 additions & 2 deletions testutils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdk 32
namespace 'com.mparticle.testutils'
testNamespace 'com.mparticle.legacyTest'
compileSdk 33

defaultConfig {
//This is set to 21 to avoid slow multidex.
minSdk 21
targetSdk 32
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand Down
4 changes: 1 addition & 3 deletions testutils/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mparticle.legacyTest">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
android:usesCleartextTraffic="true">
</application>
Expand Down
4 changes: 1 addition & 3 deletions testutils/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mparticle.testutils">

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:requestLegacyExternalStorage="true" >
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
Expand Down

0 comments on commit 67dc378

Please sign in to comment.