mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-02 12:56:16 +08:00
Android: Move native code to its own class
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
#include <git2.h>
|
#include <git2.h>
|
||||||
|
|
||||||
extern "C" JNIEXPORT jstring JNICALL
|
extern "C" JNIEXPORT jstring JNICALL
|
||||||
Java_io_gitjournal_gitjournal_MainActivity_stringFromJNI(
|
Java_io_gitjournal_gitjournal_Git_stringFromJNI(
|
||||||
JNIEnv *env,
|
JNIEnv *env,
|
||||||
jobject /* this */) {
|
jobject /* this */) {
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ Java_io_gitjournal_gitjournal_MainActivity_stringFromJNI(
|
|||||||
hello += " SSH Version: ";
|
hello += " SSH Version: ";
|
||||||
hello += ssh2_version;
|
hello += ssh2_version;
|
||||||
|
|
||||||
//git_libgit2_init();
|
git_libgit2_init();
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
int patch;
|
int patch;
|
||||||
|
13
android/app/src/main/java/io/gitjournal/gitjournal/Git.java
Normal file
13
android/app/src/main/java/io/gitjournal/gitjournal/Git.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package io.gitjournal.gitjournal;
|
||||||
|
|
||||||
|
public class Git {
|
||||||
|
static {
|
||||||
|
System.loadLibrary("native-lib");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A native method that is implemented by the 'native-lib' native library,
|
||||||
|
* which is packaged with this application.
|
||||||
|
*/
|
||||||
|
public native String stringFromJNI();
|
||||||
|
}
|
@ -21,23 +21,13 @@ import io.flutter.util.PathUtils;
|
|||||||
// For MethodChannel
|
// For MethodChannel
|
||||||
|
|
||||||
public class MainActivity extends FlutterActivity implements MethodCallHandler {
|
public class MainActivity extends FlutterActivity implements MethodCallHandler {
|
||||||
static {
|
|
||||||
System.loadLibrary("native-lib");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A native method that is implemented by the 'native-lib' native library,
|
|
||||||
* which is packaged with this application.
|
|
||||||
*/
|
|
||||||
public native String stringFromJNI();
|
|
||||||
|
|
||||||
|
|
||||||
private static final String CHANNEL_NAME = "gitjournal.io/git";
|
private static final String CHANNEL_NAME = "gitjournal.io/git";
|
||||||
static MethodChannel channel;
|
static MethodChannel channel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
Log.d("VISH", stringFromJNI());
|
Git git = new Git();
|
||||||
|
Log.d("VISH", git.stringFromJNI());
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
GeneratedPluginRegistrant.registerWith(this);
|
GeneratedPluginRegistrant.registerWith(this);
|
||||||
|
Reference in New Issue
Block a user