|
|
|
@ -21,12 +21,13 @@ import android.view.ViewGroup.LayoutParams;
|
|
|
|
|
import android.view.Window;
|
|
|
|
|
import android.webkit.CookieManager;
|
|
|
|
|
import android.webkit.DownloadListener;
|
|
|
|
|
import android.webkit.JsPromptResult;
|
|
|
|
|
import android.webkit.JsResult;
|
|
|
|
|
import android.webkit.URLUtil;
|
|
|
|
|
import android.webkit.ValueCallback;
|
|
|
|
|
import android.webkit.WebChromeClient;
|
|
|
|
|
import android.webkit.WebResourceRequest;
|
|
|
|
|
//import android.webkit.WebView;
|
|
|
|
|
import android.webkit.WebView;
|
|
|
|
|
import android.webkit.WebViewClient;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
@ -49,8 +50,8 @@ import java.nio.file.WatchKey;
|
|
|
|
|
import java.nio.file.WatchService;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends Activity {
|
|
|
|
|
WebView web_view;
|
|
|
|
|
public class TildeFriendsActivity extends Activity {
|
|
|
|
|
TildeFriendsWebView web_view;
|
|
|
|
|
String base_url;
|
|
|
|
|
Process process;
|
|
|
|
|
Thread thread;
|
|
|
|
@ -69,7 +70,7 @@ public class MainActivity extends Activity {
|
|
|
|
|
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
|
|
|
|
|
web_view = (WebView)findViewById(R.id.web);
|
|
|
|
|
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()));
|
|
|
|
@ -79,7 +80,7 @@ public class MainActivity extends Activity {
|
|
|
|
|
new File(port_file_path).delete();
|
|
|
|
|
base_url = "http://127.0.0.1:12345/";
|
|
|
|
|
|
|
|
|
|
MainActivity activity = this;
|
|
|
|
|
TildeFriendsActivity activity = this;
|
|
|
|
|
|
|
|
|
|
thread = new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
@ -182,7 +183,8 @@ public class MainActivity extends Activity {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
web_view.setWebChromeClient(new WebChromeClient() {
|
|
|
|
|
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
|
|
|
|
|
new AlertDialog.Builder(view.getContext())
|
|
|
|
|
.setTitle("Tilde Friends")
|
|
|
|
|
.setMessage(message)
|
|
|
|
@ -210,15 +212,17 @@ public class MainActivity extends Activity {
|
|
|
|
|
** https://stackoverflow.com/questions/8586691/how-to-open-file-save-dialog-in-android
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> message, WebChromeClient.FileChooserParams params) {
|
|
|
|
|
upload_message = message;
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
|
|
intent.setType("*/*");
|
|
|
|
|
MainActivity.this.startActivityForResult(Intent.createChooser(intent, "File Chooser"), MainActivity.FILECHOOSER_RESULT);
|
|
|
|
|
TildeFriendsActivity.this.startActivityForResult(Intent.createChooser(intent, "File Chooser"), TildeFriendsActivity.FILECHOOSER_RESULT);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onConsoleMessage(android.webkit.ConsoleMessage consoleMessage) {
|
|
|
|
|
Log.d("tildefriends", consoleMessage.message() + " -- From line " + consoleMessage.lineNumber() + " of " + consoleMessage.sourceId());
|
|
|
|
|
return true;
|