Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	modules/symja-evaluator/build.gradle
  • Loading branch information
duy committed Aug 30, 2024
2 parents 993ebe7 + 89e0033 commit 3e6c91a
Show file tree
Hide file tree
Showing 9 changed files with 983 additions and 21 deletions.
20 changes: 20 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ android {
}
}


// https://github.com/Celeral/log4j2-android
configurations.all { config ->
{
if (config.name.startsWith("test") || config.name.contains("Test") && !config.name.contains("Android")) {
exclude group: "com.celeral", module: "log4j2-android"
} else {
exclude group: "org.apache.logging.log4j", module: "log4j-core"
}
}
resolutionStrategy {
force "org.apache.logging.log4j:log4j-api:2.17.2"
}
}


dependencies {
configurations.configureEach {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
Expand Down Expand Up @@ -79,4 +95,8 @@ dependencies {
implementation "androidx.browser:browser:1.8.0"

implementation project(':modules:programming')

// https://github.com/Celeral/log4j2-android
runtimeOnly "com.celeral:log4j2-android:1.0.0"

}
674 changes: 674 additions & 0 deletions licence.txt

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions modules/common/src/main/java/com/symja/common/logging/DLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.symja.common.BuildConfig;

/**
* Android logcat
* Setup Crashlytics https://firebase.google.com/docs/crashlytics/get-started?authuser=0
*/
public class DLog {
private static final String TAG = "DLog";
public static boolean TEST_MODE = false;
public static int UITestmode = 0;
/**
* Show log
*/
public static final boolean DEBUG = BuildConfig.DEBUG;
private static final String TAG = "DLog";
public static boolean TEST_MODE = false;
public static int UITestmode = 0;
/**
* Android environment
*/
Expand Down Expand Up @@ -92,13 +94,11 @@ public static void w(Object msg) {
/**
* warning log
*/
public static void w(String TAG, Object msg) {
public static void w(String tag, Object obj) {
if (DEBUG) {
if (ANDROID) {
Log.w(TAG, msg.toString());
} else {
System.err.println(TAG + ": " + msg.toString());
}
if (obj instanceof Throwable) {
w(tag, ((Throwable) obj).getMessage(), (Throwable) obj);
}
}
}

Expand Down Expand Up @@ -213,10 +213,10 @@ public static void i(@NonNull Object msg) {
/**
* info log
*/
public static void i(String tag, @NonNull Object msg) {
public static void i(String tag, @Nullable Object msg) {
if (DEBUG) {
if (ANDROID) {
Log.i(tag, msg.toString());
Log.i(tag, String.valueOf(msg));
} else {
System.err.println(tag + ": " + msg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static SyntaxStyle[] loadStyles(Properties properties) {
styles[i] = parseStyle(property);
prev = styles[i];
} catch (Exception e) {
if (DLog.DEBUG) DLog.w(TAG, "loadStyles: failed " + styleName);
if (DLog.DEBUG) DLog.i(TAG, "loadStyles: failed " + styleName);
styles[i] = prev;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void load(Properties properties) {
String color = properties.getProperty(attr.getKey());
put(attr.getKey(), Color.parseColor(color));
} catch (Exception ignored) {
if (DLog.DEBUG) DLog.w(TAG, "load: can not find attr " + attr.getKey());
if (DLog.DEBUG) DLog.i(TAG, "load: can not find attr " + attr.getKey());
}
}
}
Expand Down
266 changes: 266 additions & 0 deletions modules/programming/src/main/assets/console/Document0.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceManager;

import com.symja.common.analyst.AppAnalytics;
import com.symja.common.analyst.AppAnalyticsEvents;
Expand All @@ -22,7 +22,6 @@
import com.symja.evaluator.SymjaResult;
import com.symja.evaluator.config.SymjaEvaluationConfig;
import com.symja.programming.BaseProgrammingFragment;
import com.symja.programming.BuildConfig;
import com.symja.programming.ProgrammingContract;
import com.symja.programming.ProgrammingPresenter;
import com.symja.programming.R;
Expand Down Expand Up @@ -221,14 +220,17 @@ private void loadEditingDocument() {

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean firstLaunch = preferences.getBoolean("console_first_launch", true);
if (firstLaunch && (BuildConfig.DEBUG && editingDocument.isEmpty())) {
if (firstLaunch && (editingDocument.isEmpty())) {
try {
String content = IOUtils.toString(getContext().getAssets().open("console/Document0.json"), StandardCharsets.UTF_8);
JSONObject jsonObject = new JSONObject(content);
ProgrammingConsoleDocument examples = new ProgrammingConsoleDocument(jsonObject.toMap());
this.editingDocument.addAll(examples);
preferences.edit().putBoolean("console_first_launch", false).apply();
} catch (IOException e) {
DLog.i(TAG, e.getMessage());
} catch (Exception e) {
e.printStackTrace();
DLog.w(TAG, e.getMessage());
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/symja-evaluator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ dependencies {

api project(':modules:common')

api 'com.google.guava:guava:33.0.0-android'
api('org.matheclipse:matheclipse-core:3.0.0') {
api 'com.google.guava:guava:33.3.0-android'
api('org.matheclipse:matheclipse-core:3.1.0-SNAPSHOT') {
exclude group: 'com.google.guava', module: 'guava'
}
api('org.matheclipse:matheclipse-api:3.0.0') {
api('org.matheclipse:matheclipse-api:3.1.0-SNAPSHOT') {
exclude group: 'org.matheclipse', module: 'matheclipse-core'
exclude group: 'org.matheclipse', module: 'matheclipse-gpl'
exclude group: 'org.matheclipse', module: 'matheclipse-io'
Expand Down
2 changes: 1 addition & 1 deletion symja_android_library

0 comments on commit 3e6c91a

Please sign in to comment.