Show more context in the Android app when starting the server.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4502 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
d8530f228e
commit
2c1a5359c6
@ -20,6 +20,7 @@ import android.webkit.WebResourceRequest;
|
|||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -54,11 +55,14 @@ public class MainActivity extends Activity {
|
|||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
web_view = (WebView)findViewById(R.id.web);
|
web_view = (WebView)findViewById(R.id.web);
|
||||||
|
set_status("Extracting executable...");
|
||||||
Log.w("tildefriends", String.format("getFilesDir() is %s", getFilesDir().toString()));
|
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("getPackageResourcePath() is %s", getPackageResourcePath().toString()));
|
||||||
|
|
||||||
if (!extract_executable()) {
|
if (!extract_executable()) {
|
||||||
Log.w("tildefriends", "Failed to extract a compatible executable.");
|
Log.w("tildefriends", "Failed to extract a compatible executable.");
|
||||||
|
set_status("No compatible ABI found.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String port_file_path = getFilesDir().toString() + "/port.txt";
|
String port_file_path = getFilesDir().toString() + "/port.txt";
|
||||||
@ -84,9 +88,14 @@ public class MainActivity extends Activity {
|
|||||||
if (port >= 0) {
|
if (port >= 0) {
|
||||||
base_url = "http://127.0.0.1:" + String.valueOf(port) + "/";
|
base_url = "http://127.0.0.1:" + String.valueOf(port) + "/";
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
|
activity.hide_status();
|
||||||
web_view.loadUrl(base_url);
|
web_view.loadUrl(base_url);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
activity.runOnUiThread(() -> {
|
||||||
|
activity.set_status("Waiting to connect...");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,6 +113,7 @@ public class MainActivity extends Activity {
|
|||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
|
set_status("Starting server...");
|
||||||
String exe = getFilesDir().toString() + "/tildefriends";
|
String exe = getFilesDir().toString() + "/tildefriends";
|
||||||
ProcessBuilder builder = new ProcessBuilder(exe, "run", "-z", getPackageResourcePath().toString(), "-a", "out_http_port_file=" + port_file_path, "-p", "0");
|
ProcessBuilder builder = new ProcessBuilder(exe, "run", "-z", getPackageResourcePath().toString(), "-a", "out_http_port_file=" + port_file_path, "-p", "0");
|
||||||
Log.w("tildefriends", "files = " + getFilesDir().toString());
|
Log.w("tildefriends", "files = " + getFilesDir().toString());
|
||||||
@ -261,4 +271,17 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void set_status(String text) {
|
||||||
|
TextView text_view = (TextView)findViewById(R.id.text);
|
||||||
|
web_view.setVisibility(View.GONE);
|
||||||
|
text_view.setVisibility(View.VISIBLE);
|
||||||
|
text_view.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hide_status() {
|
||||||
|
TextView text_view = (TextView)findViewById(R.id.text);
|
||||||
|
web_view.setVisibility(View.VISIBLE);
|
||||||
|
text_view.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,14 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<WebView
|
<WebView
|
||||||
|
android:id="@+id/web"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/web">
|
android:gravity="center_horizontal|center_vertical"/>
|
||||||
</WebView>
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/refresh"
|
android:id="@+id/refresh"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user