feat(rustadapter): index notebook
This commit is contained in:
parent
e292058b5c
commit
ea3a307f96
12 changed files with 170 additions and 18 deletions
|
|
@ -63,5 +63,6 @@ dependencies {
|
|||
|
||||
debugImplementation("androidx.compose.ui:ui-tooling")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview")
|
||||
implementation("androidx.annotation:annotation")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ package net.mbess.popequer
|
|||
import android.content.Context
|
||||
|
||||
class AppContext(
|
||||
val androidContext: Context
|
||||
val androidContext: Context,
|
||||
) {
|
||||
val gitActions = GitActions(androidContext)
|
||||
val popequer = PopequerAdapter(gitActions.cloneFolder.absolutePath)
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ import kotlin.math.absoluteValue
|
|||
class GitActions(
|
||||
private val context: Context
|
||||
) {
|
||||
private val cloneFolder = context.filesDir.resolve("popequer")
|
||||
val cloneFolder = context.filesDir.resolve("popequer")
|
||||
private val myCommitter = "Mobile Sandbox" to "example@example.org"
|
||||
private val credentials = UsernamePasswordCredentialsProvider(
|
||||
"popequer-mobile-sandbox",
|
||||
|
|
|
|||
47
app/src/main/java/net/mbess/popequer/PopequerAdapter.java
Normal file
47
app/src/main/java/net/mbess/popequer/PopequerAdapter.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// Automatically generated by flapigen
|
||||
package net.mbess.popequer;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public final class PopequerAdapter {
|
||||
|
||||
public PopequerAdapter(@NonNull String notebook_fs_path) {
|
||||
mNativeObj = init(notebook_fs_path);
|
||||
}
|
||||
private static native long init(@NonNull String notebook_fs_path);
|
||||
|
||||
public final @NonNull String index() {
|
||||
String ret = do_index(mNativeObj);
|
||||
|
||||
return ret;
|
||||
}
|
||||
private static native @NonNull String do_index(long self);
|
||||
|
||||
public final @NonNull String upcomingEvents() {
|
||||
String ret = do_upcomingEvents(mNativeObj);
|
||||
|
||||
return ret;
|
||||
}
|
||||
private static native @NonNull String do_upcomingEvents(long self);
|
||||
|
||||
public synchronized void delete() {
|
||||
if (mNativeObj != 0) {
|
||||
do_delete(mNativeObj);
|
||||
mNativeObj = 0;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
delete();
|
||||
}
|
||||
finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
private static native void do_delete(long me);
|
||||
/*package*/ PopequerAdapter(InternalPointerMarker marker, long ptr) {
|
||||
assert marker == InternalPointerMarker.RAW_PTR;
|
||||
this.mNativeObj = ptr;
|
||||
}
|
||||
/*package*/ long mNativeObj;
|
||||
}
|
||||
23
app/src/main/java/net/mbess/popequer/PopequerAdapterErr.java
Normal file
23
app/src/main/java/net/mbess/popequer/PopequerAdapterErr.java
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Automatically generated by flapigen
|
||||
package net.mbess.popequer;
|
||||
|
||||
|
||||
public enum PopequerAdapterErr {
|
||||
ReadDb(0),
|
||||
Indexing(1),
|
||||
View(2);
|
||||
|
||||
private final int value;
|
||||
PopequerAdapterErr(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
public final int getValue() { return value; }
|
||||
/*package*/ static PopequerAdapterErr fromInt(int x) {
|
||||
switch (x) {
|
||||
case 0: return ReadDb;
|
||||
case 1: return Indexing;
|
||||
case 2: return View;
|
||||
default: throw new Error("Invalid value for enum PopequerAdapterErr: " + x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package net.mbess.popequer
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
class PopequerProvider(
|
||||
private val context: Context
|
||||
) {
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ fun AppContainer(
|
|||
onClick = {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
runCatching {
|
||||
context.gitActions.trigger()
|
||||
// context.gitActions.trigger()
|
||||
}.onFailure {
|
||||
Log.e("MainActivity", "Failed to trigger git actions", it)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,17 +19,17 @@ import net.mbess.popequer.Foo
|
|||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
System.loadLibrary("rustadapter")
|
||||
|
||||
val appContext = AppContext(this)
|
||||
//Native.fsInfo(appContext.gitActions.cloneFolder.absolutePath).let {
|
||||
// Log.d("MainActivity", "From foreign rust result fsInfo $it")
|
||||
//}
|
||||
System.loadLibrary("rustadapter")
|
||||
|
||||
|
||||
val foo_instance = Foo(10)
|
||||
Log.d("MainActivity", "From rust: " + foo_instance.f(32, 43))
|
||||
foo_instance.setField(154)
|
||||
Log.d("MainActivity", "${foo_instance.data}")
|
||||
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
Looper.prepare()
|
||||
runCatching {
|
||||
|
|
@ -40,6 +40,10 @@ class MainActivity : ComponentActivity() {
|
|||
Toast.makeText(appContext.androidContext, "A repo was just cloned", Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
appContext.gitActions.sync()
|
||||
Log.d("Ppq", "${appContext.popequer}");
|
||||
Log.d("Ppq", "Index: ${appContext.popequer.index()}");
|
||||
Log.d("Ppq", "Upcoming: ${appContext.popequer.upcomingEvents()}");
|
||||
}.onFailure {
|
||||
Log.e("MainActivity", "Failed to prepare git repo", it)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue