diff --git a/core/core.js b/core/core.js index f218453e..5d08a187 100644 --- a/core/core.js +++ b/core/core.js @@ -791,6 +791,11 @@ async function loadSettings() { } catch (error) { print("Settings not found in database:", error); } + for (let [key, value] of Object.entries(k_global_settings)) { + if (data[key] === undefined) { + data[key] = value.default_value; + } + } gGlobalSettings = data; } diff --git a/src/android/AndroidManifest.xml b/src/android/AndroidManifest.xml index 3ebbc8b5..c6412284 100644 --- a/src/android/AndroidManifest.xml +++ b/src/android/AndroidManifest.xml @@ -5,7 +5,7 @@ versionName="0.0.4"> - + diff --git a/src/android/com/unprompted/tildefriends/MainActivity.java b/src/android/com/unprompted/tildefriends/MainActivity.java index 5e725b51..b9fed427 100644 --- a/src/android/com/unprompted/tildefriends/MainActivity.java +++ b/src/android/com/unprompted/tildefriends/MainActivity.java @@ -1,20 +1,46 @@ package com.unprompted.tildefriends; import android.app.Activity; -import android.util.Log; +import android.content.Intent; +import android.net.Uri; import android.os.Bundle; -import android.widget.TextView; +import android.os.CountDownTimer; +import android.os.SystemClock; +import android.util.Log; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import java.lang.Thread; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - TextView text = (TextView)findViewById(R.id.my_text); + + WebView web = (WebView)findViewById(R.id.web); Log.w("tildefriends", String.format("getFilesDir() is %s", getFilesDir().toString())); Log.w("tildefriends", String.format("getPackageResourcePath() is %s", getPackageResourcePath().toString())); Log.w("tildefriends", String.format("getPackageCodePath() is %s", getPackageCodePath().toString())); setFilesPath(getFilesDir().toString(), getPackageResourcePath().toString()); + try { + Thread.sleep(1000); + } catch (java.lang.InterruptedException e) { + } + web.getSettings().setJavaScriptEnabled(true); + + web.setWebViewClient(new WebViewClient() { + public boolean shouldOverrideUrlLoading(WebView view, String url) + { + if (url != null && url.startsWith("http://127.0.0.1:12345/")) { + return false; + } else { + view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return true; + } + } + }); + + web.loadUrl("http://127.0.0.1:12345/~core/apps/"); } public native void setFilesPath(String files_path, String apk_path); diff --git a/src/android/res/layout/activity_main.xml b/src/android/res/layout/activity_main.xml index 18d85d6e..810a83f1 100644 --- a/src/android/res/layout/activity_main.xml +++ b/src/android/res/layout/activity_main.xml @@ -5,8 +5,8 @@ android:layout_height="match_parent" android:gravity="center" android:orientation="vertical"> - +