android: Keep the splash screen up until we're connected to our server and loaded the page. Smooths out the launch.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 31m38s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 31m38s
This commit is contained in:
@@ -25,6 +25,7 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.Window;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.DownloadListener;
|
||||
import android.webkit.JsPromptResult;
|
||||
@@ -58,6 +59,8 @@ public class TildeFriendsActivity extends Activity {
|
||||
private ValueCallback<Uri[]> upload_message;
|
||||
private final static int FILECHOOSER_RESULT = 1;
|
||||
private float touch_down_y;
|
||||
private boolean ready = false;
|
||||
private boolean loaded = false;
|
||||
|
||||
static {
|
||||
Log.w("tildefriends", "Calling system.loadLibrary().");
|
||||
@@ -70,7 +73,6 @@ public class TildeFriendsActivity extends Activity {
|
||||
|
||||
private void createThread() {
|
||||
web_view = (TildeFriendsWebView)findViewById(R.id.web);
|
||||
set_status("Extracting executable...");
|
||||
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("nativeLibraryDir is %s", getApplicationInfo().nativeLibraryDir));
|
||||
@@ -81,7 +83,6 @@ public class TildeFriendsActivity extends Activity {
|
||||
|
||||
TildeFriendsActivity activity = this;
|
||||
|
||||
set_status("Starting server...");
|
||||
server_thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -233,6 +234,7 @@ public class TildeFriendsActivity extends Activity {
|
||||
});
|
||||
|
||||
web_view.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
|
||||
{
|
||||
if (request.getUrl() != null && request.getUrl().toString().startsWith(base_url)) {
|
||||
@@ -242,6 +244,11 @@ public class TildeFriendsActivity extends Activity {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
s_activity.loaded = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -271,6 +278,21 @@ public class TildeFriendsActivity extends Activity {
|
||||
refresh.setVisibility(View.GONE);
|
||||
refresh.setText("REFRESH");
|
||||
|
||||
final View content = findViewById(android.R.id.content);
|
||||
content.getViewTreeObserver().addOnPreDrawListener(
|
||||
new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
if (s_activity.ready && s_activity.loaded) {
|
||||
content.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
create_thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -376,19 +398,6 @@ public class TildeFriendsActivity extends Activity {
|
||||
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);
|
||||
}
|
||||
|
||||
public static void start_sandbox(int pipe_fd) {
|
||||
Log.w("tildefriends", "starting service with fd: " + pipe_fd);
|
||||
Intent intent = new Intent(s_activity, TildeFriendsSandboxService.class);
|
||||
@@ -442,15 +451,11 @@ public class TildeFriendsActivity extends Activity {
|
||||
if (port >= 0) {
|
||||
base_url = "http://127.0.0.1:" + String.valueOf(port) + "/";
|
||||
runOnUiThread(() -> {
|
||||
hide_status();
|
||||
ready = true;
|
||||
web_view.loadUrl(base_url + "login/auto");
|
||||
});
|
||||
observer.stopWatching();
|
||||
observer = null;
|
||||
} else {
|
||||
runOnUiThread(() -> {
|
||||
set_status("Waiting to connect...");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,11 +10,6 @@
|
||||
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_height="match_parent"
|
||||
android:gravity="center_horizontal|center_vertical"/>
|
||||
<TextView
|
||||
android:id="@+id/refresh"
|
||||
android:layout_width="match_parent"
|
||||
|
Reference in New Issue
Block a user