diff --git a/MinimalBible/src/main/assets/book.html b/MinimalBible/src/main/assets/book.html new file mode 100644 index 0000000..75f4951 --- /dev/null +++ b/MinimalBible/src/main/assets/book.html @@ -0,0 +1,11 @@ + +
+ + + + + \ No newline at end of file diff --git a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/viewer/BookFragment.java b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/viewer/BookFragment.java index c108ed3..19f32a4 100644 --- a/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/viewer/BookFragment.java +++ b/MinimalBible/src/main/java/org/bspeice/minimalbible/activities/viewer/BookFragment.java @@ -7,12 +7,15 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; +import android.webkit.WebViewClient; import org.bspeice.minimalbible.MinimalBible; import org.bspeice.minimalbible.R; import org.bspeice.minimalbible.activities.BaseFragment; import org.crosswire.jsword.book.Book; +import java.util.List; + import javax.inject.Inject; import butterknife.ButterKnife; @@ -61,6 +64,7 @@ public class BookFragment extends BaseFragment { View rootView = inflater.inflate(R.layout.fragment_viewer_main, container, false); ButterKnife.inject(this, rootView); + mainContent.getSettings().setJavaScriptEnabled(true); // TODO: Load initial text from SharedPreferences @@ -99,6 +103,38 @@ public class BookFragment extends BaseFragment { private void displayBook(Book b) { Log.d("BookFragment", b.getName()); ((BibleViewer)getActivity()).setActionBarTitle(b.getInitials()); - mainContent.loadData("" + b.getName() + "
", "text/html", "utf-8"); + mainContent.loadUrl(getString(R.string.content_page)); + mainContent.setWebViewClient(new WebViewClient(){ + @Override + public void onPageFinished(WebView view, String url) { + super.onPageFinished(view, url); + invokeJavascript("set_content", "Hello, world."); + } + }); + + } + + private void invokeJavascript(String function, Object arg) { + mainContent.loadUrl("javascript:" + function + "('" + arg.toString() + "')"); + } + + private void invokeJavascript(String function, List