Skip to content
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
91 changes: 44 additions & 47 deletions lib/android_build/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
apply plugin: 'com.android.application'

apply from: "$rootProject.projectDir/tools.gradle"

android {
defaultConfig {
applicationId "com.microsoft.applications.events.maesdktest"
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
// Passes optional arguments to CMake.
arguments "-DANDROID_STL=c++_shared", "-DUSE_ROOM=1"
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':maesdk')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
apply plugin: 'com.android.application'

apply from: "$rootProject.projectDir/tools.gradle"

android {
defaultConfig {
applicationId "com.microsoft.applications.events.maesdktest"
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
// Passes optional arguments to CMake.
arguments "-DANDROID_STL=c++_shared", "-DUSE_ROOM=1"
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':maesdk')
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
11 changes: 0 additions & 11 deletions lib/android_build/app/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,6 @@ int RunTests::run_all_tests(JNIEnv* env, jobject java_logger)
return RUN_ALL_TESTS();
}

extern "C" JNIEXPORT jstring JNICALL
Java_com_microsoft_applications_events_maesdktest_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */,
jstring path)
{
auto result = RunTests::run_all_tests(env, path);
std::string hello = std::to_string(result);
return env->NewStringUTF(hello.c_str());
}

extern "C" JNIEXPORT jint JNICALL

Java_com_microsoft_applications_events_maesdktest_TestStub_runNativeTests(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
//
package com.microsoft.applications.events.maesdktest;

import androidx.annotation.Keep;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this necessary to avoid the obfuscator from stripping/changing the method signature?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is app that executes tests, is not part of maesdk


@Keep
public abstract class MaeUnitLogger {
abstract void log_failure(String filename, int line, String summary);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,54 @@
//
package com.microsoft.applications.events.maesdktest;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

import com.microsoft.applications.events.HttpClient;
import com.microsoft.applications.events.OfflineRoom;
import java.util.concurrent.ExecutionException;

public class MainActivity extends AppCompatActivity {
class DummyLogger extends MaeUnitLogger {
import java.util.Locale;
import java.util.concurrent.ExecutionException;

@Override
void log_failure(String filename, int line, String summary) {
Log.e("MAE", String.format("Uh oh %s: %s", filename, summary));
public class MainActivity extends Activity {
static class DummyLogger extends MaeUnitLogger {
@Override
void log_failure(String filename, int line, String summary) {
Log.e("MAE", String.format("Uh oh %s: %s", filename, summary));
}
}
}

// Used to load the 'native-lib' library on application startup.
static {
System.loadLibrary("native-lib");
System.loadLibrary("maesdk");
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

m_client = new HttpClient(getApplicationContext());
OfflineRoom.connectContext(getApplicationContext());
TestStub testStub = new TestStub();
DummyLogger dummyLogger = new DummyLogger();
// Example of a call to a native method
TextView tv = findViewById(R.id.sample_text);
try {
Integer result = testStub.executorRun(dummyLogger);
tv.setText(String.format("Tests returned %d", result));
}
catch(ExecutionException e) {
tv.setText("Woopsy");
}
catch(InterruptedException e) {
tv.setText("Interrupted!");

// Used to load the 'native-lib' library on application startup.
static {
System.loadLibrary("native-lib");
System.loadLibrary("maesdk");
}
}

/**
* A native method that is implemented by the 'native-lib' native library, which is packaged with
* this application.
*/
public native String stringFromJNI(String path);
HttpClient m_client;

HttpClient m_client;
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

m_client = new HttpClient(getApplicationContext());
OfflineRoom.connectContext(getApplicationContext());
TestStub testStub = new TestStub();
DummyLogger dummyLogger = new DummyLogger();
// Example of a call to a native method
TextView tv = findViewById(R.id.sample_text);
try {
Integer result = testStub.executorRun(dummyLogger);
tv.setText(String.format(Locale.ROOT, "Tests returned %d", result));
} catch (ExecutionException e) {
tv.setText("Woopsy");
} catch (InterruptedException e) {
tv.setText("Interrupted!");
}
}
}

12 changes: 4 additions & 8 deletions lib/android_build/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_gravity="center"
android:id="@+id/sample_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:text="Hello World!"/>

</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
6 changes: 0 additions & 6 deletions lib/android_build/app/src/main/res/values/colors.xml

This file was deleted.

7 changes: 1 addition & 6 deletions lib/android_build/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<style name="AppTheme" parent="android:Theme.Black">
</style>

</resources>
12 changes: 1 addition & 11 deletions lib/android_build/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ buildscript {
repositories {
google() // to fetch com.android.tools.build:gradle
mavenCentral()
maven { url 'https://maven.google.com' }
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://jcenter.bintray.com" }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
Expand All @@ -22,14 +17,9 @@ allprojects {
repositories {
google() // to fetch com.android.tools.build:gradle
mavenCentral()
maven { url 'https://maven.google.com' }
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://jcenter.bintray.com" }
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
}
12 changes: 5 additions & 7 deletions lib/android_build/maesdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ plugins {

apply plugin: 'com.android.library'

apply from: "$rootProject.projectDir/tools.gradle"
apply from: "$projectDir/../tools.gradle"

android {
defaultConfig {
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand Down Expand Up @@ -65,9 +63,9 @@ dependencies {
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

testImplementation 'junit:junit:4.13.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-inline:3.2.4'
testImplementation "androidx.room:room-testing:$room_version"
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
package com.microsoft.applications.events.maesdktest;
package com.microsoft.applications.events;

import com.microsoft.applications.events.HttpClientRequest;

Expand Down