From cd9e2d847823644f68235f32230fac2b88484fdf Mon Sep 17 00:00:00 2001 From: Jonathan Reisdorf Date: Mon, 24 Sep 2018 14:55:52 +0200 Subject: [PATCH 1/2] file uploads wip --- app/build.gradle | 4 ++-- app/src/main/AndroidManifest.xml | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 456bae1..7b1aa54 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "org.crossnode.bb10beol" minSdkVersion 18 targetSdkVersion 18 - versionCode 15 - versionName "1.8.0" + versionCode 16 + versionName "1.8.1" } buildTypes { debug { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 871e961..c264234 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,9 @@ + + + Date: Fri, 5 Oct 2018 10:29:38 +0100 Subject: [PATCH 2/2] file uploads done --- .idea/caches/build_file_checksums.ser | Bin 589 -> 589 bytes .../java/org/crossnode/bb10beol/Browser.java | 16 +++--- .../crossnode/bb10beol/BrowserTabManager.java | 7 +-- .../crossnode/bb10beol/BrowserUIClient.java | 26 ++++++++++ .../org/crossnode/bb10beol/MainActivity.java | 31 +++++++++--- .../NavigationConvenienceJsInterface.java | 5 +- .../bb10beol/NavigationJsInterface.java | 46 +++++++++--------- .../bb10beol/PageContextInterface.java | 6 +-- .../crossnode/bb10beol/TabsJsInterface.java | 6 +-- 9 files changed, 90 insertions(+), 53 deletions(-) create mode 100644 app/src/main/java/org/crossnode/bb10beol/BrowserUIClient.java diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index de33b87e3107c37da3884167c7829bb3ade0e201..adac57103ff356432f45f43ad892145cdf820c6f 100644 GIT binary patch delta 63 zcmV-F0Kosv1kD7Hmjz}SrF-#_oaGRoaGR?5!LG7GcT>4$$a{v9kpW_pAp#o^Ft6$n V&cH>ftY;_Z*W$3{lkovA0eI%8A3Fd5 delta 62 zcmV-E0Kxyw1kD7Hmjz^Q%1 uploadFile, String acceptType, String capture) { + if (_activity.fileChooser == null) { + _activity.fileChooser = new XWalkFileChooser(_activity); + } + + _activity.fileChooser.showFileChooser(uploadFile, acceptType, capture); + } +} diff --git a/app/src/main/java/org/crossnode/bb10beol/MainActivity.java b/app/src/main/java/org/crossnode/bb10beol/MainActivity.java index 21ae9a8..020eec0 100644 --- a/app/src/main/java/org/crossnode/bb10beol/MainActivity.java +++ b/app/src/main/java/org/crossnode/bb10beol/MainActivity.java @@ -1,13 +1,15 @@ package org.crossnode.bb10beol; -//import android.view.WindowManager; - -import android.app.Activity; import android.widget.LinearLayout; import android.os.Bundle; +import android.content.Intent; + +import org.xwalk.core.XWalkActivity; +import org.xwalk.core.XWalkFileChooser; -public class MainActivity extends Activity { - private Browser browser; +public class MainActivity extends XWalkActivity { + public Browser browser = null; + public XWalkFileChooser fileChooser = null; @Override protected void onCreate(Bundle savedInstanceState) { @@ -15,13 +17,26 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); LinearLayout mainLayout = (LinearLayout) this.findViewById(R.id.mainLayout); browser = new Browser(this, mainLayout); - browser.initialize(null); - //this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } @Override protected void onResume() { super.onResume(); - browser.onResume(); + + if (browser.isInitialized) { + browser.onResume(); + } + } + + @Override + protected void onXWalkReady() { + browser.initialize(null); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (fileChooser != null) { + fileChooser.onActivityResult(requestCode, resultCode, data); + } } } diff --git a/app/src/main/java/org/crossnode/bb10beol/NavigationConvenienceJsInterface.java b/app/src/main/java/org/crossnode/bb10beol/NavigationConvenienceJsInterface.java index 4b3af6a..e62d1fa 100644 --- a/app/src/main/java/org/crossnode/bb10beol/NavigationConvenienceJsInterface.java +++ b/app/src/main/java/org/crossnode/bb10beol/NavigationConvenienceJsInterface.java @@ -1,6 +1,5 @@ package org.crossnode.bb10beol; -import android.app.Activity; import android.content.Context; import android.content.ClipboardManager; import android.content.ClipData; @@ -10,10 +9,10 @@ public class NavigationConvenienceJsInterface { private boolean _isEnabled = false; - private Activity _activity; + private MainActivity _activity; private String _clipboardText = null; - NavigationConvenienceJsInterface(Activity activity) { + NavigationConvenienceJsInterface(MainActivity activity) { _activity = activity; } diff --git a/app/src/main/java/org/crossnode/bb10beol/NavigationJsInterface.java b/app/src/main/java/org/crossnode/bb10beol/NavigationJsInterface.java index 9159e89..14c99bf 100644 --- a/app/src/main/java/org/crossnode/bb10beol/NavigationJsInterface.java +++ b/app/src/main/java/org/crossnode/bb10beol/NavigationJsInterface.java @@ -1,30 +1,28 @@ package org.crossnode.bb10beol; -import android.app.Activity; - import org.xwalk.core.XWalkView; import org.xwalk.core.JavascriptInterface; class NavigationJsInterface { - private Activity activity; - private BrowserTabManager browserTabManager; + private MainActivity _activity; + private BrowserTabManager _browserTabManager; private String tabsOverviewFileUrl = "file:///android_asset/tabs.html"; private String contextMenuFileUrl = "file:///android_asset/context.html"; - NavigationJsInterface(Activity activity, BrowserTabManager browserTabManager) { - this.activity = activity; - this.browserTabManager = browserTabManager; + NavigationJsInterface(MainActivity activity, BrowserTabManager browserTabManager) { + _activity = activity; + _browserTabManager = browserTabManager; } @JavascriptInterface public void openUrl(final String url) { - activity.runOnUiThread(new Runnable() { + _activity.runOnUiThread(new Runnable() { @Override public void run() { - if (!browserTabManager.currentResourceClient.isSystem) { + if (!_browserTabManager.currentResourceClient.isSystem) { // TODO load on previous/non-system/new tab in that case! - browserTabManager.load(url); + _browserTabManager.load(url); } } }); @@ -32,62 +30,62 @@ public void run() { @JavascriptInterface public void setUserAgentString(final String userAgentString) { - activity.runOnUiThread(new Runnable() { + _activity.runOnUiThread(new Runnable() { @Override public void run() { - browserTabManager.currentTab.setUserAgentString(userAgentString); + _browserTabManager.currentTab.setUserAgentString(userAgentString); } }); } @JavascriptInterface public void showTabsOverview() { - activity.runOnUiThread(new Runnable() { + _activity.runOnUiThread(new Runnable() { @Override public void run() { - XWalkView webview = browserTabManager.addTab(tabsOverviewFileUrl, true); - webview.addJavascriptInterface(new TabsJsInterface(activity, webview, browserTabManager), "tabs"); + XWalkView webview = _browserTabManager.addTab(tabsOverviewFileUrl, true); + webview.addJavascriptInterface(new TabsJsInterface(_activity, webview, _browserTabManager), "tabs"); } }); } @JavascriptInterface public void showContextMenu() { - activity.runOnUiThread(new Runnable() { + _activity.runOnUiThread(new Runnable() { @Override public void run() { - XWalkView webview = browserTabManager.addTab(contextMenuFileUrl, true); - webview.addJavascriptInterface(new PageContextInterface(activity, browserTabManager), "pageContext"); + XWalkView webview = _browserTabManager.addTab(contextMenuFileUrl, true); + webview.addJavascriptInterface(new PageContextInterface(_activity, _browserTabManager), "pageContext"); } }); } @JavascriptInterface public void closeSystemTab() { - activity.runOnUiThread(new Runnable() { + _activity.runOnUiThread(new Runnable() { @Override public void run() { - browserTabManager.closeSystemTab(); + _browserTabManager.closeSystemTab(); } }); } @JavascriptInterface public void goPrev() { - activity.runOnUiThread(new Runnable() { + _activity.runOnUiThread(new Runnable() { @Override public void run() { - browserTabManager.currentResourceClient.goPrev(); + _browserTabManager.currentResourceClient.goPrev(); } }); } @JavascriptInterface public void goNext() { - activity.runOnUiThread(new Runnable() { + _activity.runOnUiThread(new Runnable() { @Override public void run() { - browserTabManager.currentResourceClient.goNext(); + _browserTabManager.currentResourceClient.goNext(); } }); } diff --git a/app/src/main/java/org/crossnode/bb10beol/PageContextInterface.java b/app/src/main/java/org/crossnode/bb10beol/PageContextInterface.java index 1ec5fb0..8053dea 100644 --- a/app/src/main/java/org/crossnode/bb10beol/PageContextInterface.java +++ b/app/src/main/java/org/crossnode/bb10beol/PageContextInterface.java @@ -1,7 +1,5 @@ package org.crossnode.bb10beol; -import android.app.Activity; - import org.json.JSONException; import org.json.JSONObject; @@ -9,14 +7,14 @@ public class PageContextInterface { - private Activity _activity; + private MainActivity _activity; private BrowserTabManager _browserTabManager; private BrowserResourceClient _resourceClient; private String _title; private String _url; - PageContextInterface(Activity activity, BrowserTabManager browserTabManager) { + PageContextInterface(MainActivity activity, BrowserTabManager browserTabManager) { _activity = activity; _browserTabManager = browserTabManager; _resourceClient = browserTabManager.previousResourceClient; diff --git a/app/src/main/java/org/crossnode/bb10beol/TabsJsInterface.java b/app/src/main/java/org/crossnode/bb10beol/TabsJsInterface.java index 32642d5..4bc347b 100644 --- a/app/src/main/java/org/crossnode/bb10beol/TabsJsInterface.java +++ b/app/src/main/java/org/crossnode/bb10beol/TabsJsInterface.java @@ -1,7 +1,5 @@ package org.crossnode.bb10beol; -import android.app.Activity; - import org.json.JSONArray; import org.xwalk.core.JavascriptInterface; @@ -9,11 +7,11 @@ class TabsJsInterface { - private Activity _activity; + private MainActivity _activity; private XWalkView _webview; private BrowserTabManager _browserTabManager; - TabsJsInterface(Activity activity, XWalkView webview, BrowserTabManager browserTabManager) { + TabsJsInterface(MainActivity activity, XWalkView webview, BrowserTabManager browserTabManager) { this._activity = activity; this._webview = webview; this._browserTabManager = browserTabManager;