Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix various UI issues with cancelling an ongoing search
  • Loading branch information
razvanfilea committed Apr 26, 2021
commit d60b9ff46dba92aaaf4a43de0be60ad183ca9cdc
8 changes: 1 addition & 7 deletions ChessAndroid/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
applicationId "net.theluckycoder.chess"
minSdkVersion 21
targetSdkVersion 30
versionCode 1201
versionCode 1202
versionName "1.2.0"
resConfigs "en"
}
Expand All @@ -20,12 +20,6 @@ android {
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

externalNativeBuild {
cmake {
abiFilters "arm64-v8a", "armeabi-v7a"
}
}

packagingOptions {
resources {
excludes.add("DebugProbesKt.bin")
Expand Down
5 changes: 4 additions & 1 deletion ChessAndroid/app/src/main/cpp/JniCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace JniCache
{
jclass boardChangeListenerClass;
jclass searchListenerClass;
jclass indexedPieceClass;
jclass moveClass;
jclass searchOptionsClass;
Expand All @@ -17,7 +18,8 @@ namespace JniCache

void createCaches(JNIEnv *env)
{
boardChangeListenerClass = cacheClass(env, "net/theluckycoder/chess/BoardChangeListener");
boardChangeListenerClass = cacheClass(env, "net/theluckycoder/chess/cpp/BoardChangeListener");
searchListenerClass = cacheClass(env, "net/theluckycoder/chess/cpp/SearchListener");
indexedPieceClass = cacheClass(env, "net/theluckycoder/chess/model/IndexedPiece");
moveClass = cacheClass(env, "net/theluckycoder/chess/model/Move");
searchOptionsClass = cacheClass(env, "net/theluckycoder/chess/model/SearchOptions");
Expand All @@ -26,6 +28,7 @@ namespace JniCache
void cleanCaches(JNIEnv *env)
{
env->DeleteGlobalRef(boardChangeListenerClass);
env->DeleteGlobalRef(searchListenerClass);
env->DeleteGlobalRef(indexedPieceClass);
env->DeleteGlobalRef(moveClass);
env->DeleteGlobalRef(searchOptionsClass);
Expand Down
37 changes: 37 additions & 0 deletions ChessAndroid/app/src/main/cpp/JniUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <android/log.h>
#include <cassert>

#define LOGV(LOG_TAG, ...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
#define LOGI(LOG_TAG, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGD(LOG_TAG, ...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGW(LOG_TAG, ...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define LOGE(LOG_TAG, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)

class NativeThreadAttach
{
public:
explicit NativeThreadAttach(JavaVM *jvm)
: _jvm(jvm)
{
_jvmEnvState = _jvm->GetEnv(reinterpret_cast<void **>(&_env), JNI_VERSION_1_6);

if (_jvmEnvState == JNI_EDETACHED)
_jvm->AttachCurrentThread(&_env, nullptr);
_env->ExceptionClear();
}

JNIEnv *getEnv() { return _env; }

~NativeThreadAttach()
{
if (_jvmEnvState == JNI_EDETACHED)
_jvm->DetachCurrentThread();
}

private:
JavaVM *_jvm;
JNIEnv *_env = nullptr;
int _jvmEnvState{};
};
9 changes: 0 additions & 9 deletions ChessAndroid/app/src/main/cpp/Log.h

This file was deleted.

Loading