Browse Source

Initial

master
Daniel 9 months ago
commit
0a33bf45bb
13 changed files with 335 additions and 0 deletions
  1. +2
    -0
      .gitignore
  2. +33
    -0
      build.gradle
  3. BIN
     
  4. +6
    -0
      gradle/wrapper/gradle-wrapper.properties
  5. +7
    -0
      help
  6. +21
    -0
      src/main/AndroidManifest.xml
  7. +143
    -0
      src/main/assets/index.html
  8. +11
    -0
      src/main/cpp/CMakeLists.txt
  9. +1
    -0
      src/main/cpp/biblec
  10. +1
    -0
      src/main/cpp/fbrp
  11. +63
    -0
      src/main/cpp/main.c
  12. +47
    -0
      src/main/java/MainActivity.java
  13. BIN
     

+ 2
- 0
.gitignore View File

@@ -0,0 +1,2 @@
.gradle
build

+ 33
- 0
build.gradle View File

@@ -0,0 +1,33 @@
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.google.com/' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
}
allprojects {
repositories {
mavenCentral()
maven { url 'https://maven.google.com/' }
jcenter()
}
}

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
}
}
}

dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
}

BIN
View File


+ 6
- 0
gradle/wrapper/gradle-wrapper.properties View File

@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionSha256Sum=e7cf7d1853dfc30c1c44f571d3919eeeedef002823b66b6a988d27e919686389

+ 7
- 0
help View File

@@ -0,0 +1,7 @@
https://wiki.debian.org/AndroidTools
https://packages.debian.org/sid/devel/google-android-ndk-installer

sudo apt install libncurses-dev
sudo apt-get install libncurses5:i386
sudo apt-get install ia32-libs
sudo apt-get install libncurses5 # fixed it

+ 21
- 0
src/main/AndroidManifest.xml View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.heb12.android">
<uses-sdk
android:maxSdkVersion="19"
android:minSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:label="Heb12 Android"
android:icon="@drawable/icon"
android:supportsRtl="true">
<activity android:name="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

+ 143
- 0
src/main/assets/index.html View File

@@ -0,0 +1,143 @@
<!DOCTYPE html>
<html>
<head>
<title>Heb12 Bible</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
}

.screen {
width: 100%;
height: 100%;
display: none;
}

#nojs {display: block;}
#content {width: 100%;}

#content p {
margin: 0;
padding: 20px 20px;
cursor: pointer;
}

.page{padding: 10px;}

.top {
border-bottom: 2px solid black;
/* box-shadow: 0px 5px 8px grey; */
text-align: center;
height: 40px;
}

.top input {
border: transparent;
outline: none;
font-size: 22px;
text-align: center;

width: 200px;
}

.top img {padding: 2px 2px;}

.top img.left {
float: left;
}

.click {
cursor: pointer;
}

img.clickable, .top input {
height: 100%;
box-sizing: border-box;
}

img.clickable {
cursor: pointer;
}

#content p:hover, img.clickable:hover, .top input:hover {background: lightgrey;}
#content p:active, img.clickable:active {background: grey;}
</style>
</head>
<body>
<div class="screen" id="nojs">
<span>For a JavaScript-less experience, visit ...</span>
</div>

<div class="screen" id="main">
<div class="top">
<img class="clickable left" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAK0lEQVR4Ae3UoREAAAgDMfZfGjZAQkVyV/+qRSCgj7cTBN/8kKBs4IcEATB7U/sFHIey0AAAAABJRU5ErkJggg==" onclick="showScreen('settings');">
<input id="verse" value="Heb 12 1-10" onkeypress="checkEnter(event, updateContent)">
</div>
<div id="content">

</div>
</div>

<div class="screen" id="settings">
<div class="top">
<img class="clickable left" onclick="showScreen('main');" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAABYklEQVR4Ae3XIWzCQBiG4YmKikq8mg8+OHwqEMjJyfNBICqQ+CCRFQi8QiAQlRMIBKISOVHx7xUTyyWXL/l3NRtv8jhCvpTrJbw8+y9N0eCAM27fTmixwitGrUTAHQZIH3hDgazVuMKcOsyQpQaWwYB3uCvQwjLbwtUGNgrHk1rCRjRgBtJV6MUBNU1+tkMB2Rrq99/ChKDPIVeCqMQDFsMRRHpUiF6OLnlPiebid1+oUQj4WYAliRt9B3OM8o0BVkh2gflGOcYALZLdYZ5RrjHACclMi0eJMdrNMUi8TeKgC3ck691j/KPOSNY5xwQsnKMOSLZ3jRFXgtAgWe0bA/+oKZJV+NSPNh4jR3XyQDsPZIjH6FHq+3QTPMQhNAUDjrCEK0roKMBGVkOn37gsGu//sBMssxbuysxPaoMCvy6Ig670WCJrE2yje0p5YI0Ko1Whxh4d+uiiu2CHOUo8+9t9AUcCWfVf/Xv1AAAAAElFTkSuQmCC">
</div>
<div class="page">
foo
</div>
</div>
</body>

<script>
// Current interchangable UI bindings
var bindings = {
getVerses: function(reference, callback) {
callback(b.getVerses(reference).split("<br>"));
}
}
</script>

<script>
window.onload = function() {
updateContent("Heb 12 1-10");
}

// Current and default screen
var screen = "nojs";
showScreen("main");

// Function to update page contents
function updateContent(reference) {
var content = document.getElementById("content");
while (content.firstChild) {
content.removeChild(content.firstChild);
}

bindings.getVerses(reference, function(verses) {
for (var i = 0; i < verses.length; i++) {
var p = document.createElement("p");
p.innerHTML += "<b>" + (i + 1) + " </b>" + verses[i];
p.onclick = function() {};

content.appendChild(p);
}
});
}

function showScreen(next) {
document.getElementById(screen).style.display = "none";
document.getElementById(next).style.display = "block";
screen = next;
}

// Input handler
function checkEnter(env, code) {
if (env.keyCode == 13) {
updateContent(verse.value);
}
}
</script>
</html>

+ 11
- 0
src/main/cpp/CMakeLists.txt View File

@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.4.1)

add_library(backend SHARED
fbrp/fbrp.c
main.c
biblec/biblec.c)

# Include libraries needed for hello-jni lib
target_link_libraries(backend
android
log)

+ 1
- 0
src/main/cpp/biblec

@@ -0,0 +1 @@
Subproject commit e096caf0fa15674ab6e961488db8bc2925c8c7e5

+ 1
- 0
src/main/cpp/fbrp

@@ -0,0 +1 @@
Subproject commit 09c329755c0fee47fe58c3d25e321454f5d9d363

+ 63
- 0
src/main/cpp/main.c View File

@@ -0,0 +1,63 @@
#include <string.h>
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <android/log.h>
#include "biblec/biblec.h"
#include "fbrp/reference.h"
#include "fbrp/fbrp.h"

struct Translation loadedTranslations[10];

JNIEXPORT jintArray JNICALL Java_com_heb12_android_MainActivity_arrayTest(JNIEnv* env, jobject thiz, jstring ref) {
int tryFile = 0;
parseIndexFile(
&tryFile,
&loadedTranslations[0],
"/sdcard/heb12data/web.i",
"/sdcard/heb12data/web.t"
);

const char *nativeRef = (*env)->GetStringUTFChars(env, ref, 0);

int *tryRef;
struct Reference reference;
parseReference(tryRef, nativeRef, &reference);

int to = 1;
if (reference.verse[0].r[0] != reference.verse[0].r[1]) {
to = reference.verse[0].r[1] - reference.verse[0].r[0] + 1;
}

char result[30][600];
int tryStruct;
getVerses(
&tryStruct,
result,
loadedTranslations[0],
reference.book,
reference.chapter[0].r[0],
reference.verse[0].r[0],
to
);

// Convert native array into java array
jobjectArray array;
array = (*env)->NewObjectArray(
env,
to,
(*env)->FindClass(env, "java/lang/String"),
(*env)->NewStringUTF(env, "")
);

for (int i = 0; i < to; i++) {
(*env)->SetObjectArrayElement(
env,
array,
i,
(*env)->NewStringUTF(env, result[i])
);
}

return array;
}

+ 47
- 0
src/main/java/MainActivity.java View File

@@ -0,0 +1,47 @@
package com.heb12.android;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebSettings;
import android.widget.TextView;
import android.webkit.WebView;
import android.webkit.JavascriptInterface;
import android.text.TextUtils;
import android.support.v7.app.AppCompatActivity;

public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);

WebView webview = new WebView(this);
webview.setWebContentsDebuggingEnabled(true);
WebSettings settings = webview.getSettings();
settings.setJavaScriptEnabled(true);

settings.setBuiltInZoomControls(true);
settings.setDomStorageEnabled(true);
settings.setLoadWithOverviewMode(true);
webview.loadUrl("file:///android_asset/index.html");

webview.addJavascriptInterface(new backend(), "b");

setContentView(webview);
}

public class backend {
@JavascriptInterface
public String getVerses(String reference) {
return TextUtils.join("<br>", arrayTest(reference));
}
}

public native String[] arrayTest(String ref);

static {
System.loadLibrary("backend");
}
}

BIN
View File


Loading…
Cancel
Save