First signs of WebView working.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4213 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
12a8b7a058
commit
f74f4f6da9
@ -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;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
versionName="0.0.4">
|
||||
<uses-sdk android:minSdkVersion="16"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<application android:label="Tilde Friends">
|
||||
<application android:label="Tilde Friends" android:usesCleartextTraffic="true">
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
@ -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);
|
||||
|
@ -5,8 +5,8 @@
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/my_text"/>
|
||||
<WebView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/web"/>
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user