mirror of
https://github.com/gsantner/dandelion
synced 2024-11-25 22:02:08 +01:00
Improve sharing to activity (Kepp one webview) #32
This commit is contained in:
parent
d64a79dcf8
commit
ebb6d36b7d
2 changed files with 18 additions and 38 deletions
|
@ -853,7 +853,9 @@ public class MainActivity extends AppCompatActivity
|
||||||
if (sharedText != null) {
|
if (sharedText != null) {
|
||||||
textToBeShared = sharedText;
|
textToBeShared = sharedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
webView.stopLoading();
|
webView.stopLoading();
|
||||||
|
webView.loadUrl("about:blank");
|
||||||
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,34 +875,11 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
final String sharedSubject = WebHelper.escapeHtmlText(subject);
|
final String sharedSubject = WebHelper.escapeHtmlText(subject);
|
||||||
final String sharedContent = WebHelper.escapeHtmlText(content);
|
final String sharedContent = WebHelper.escapeHtmlText(content);
|
||||||
final String sharedText = "**" + sharedSubject + "** " + sharedContent;
|
textToBeShared = "**" + sharedSubject + "** " + sharedContent;
|
||||||
|
|
||||||
if (sharedText != null) {
|
|
||||||
textToBeShared = sharedText;
|
|
||||||
}
|
|
||||||
webView.stopLoading();
|
webView.stopLoading();
|
||||||
|
webView.loadUrl("about:blank");
|
||||||
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
||||||
|
|
||||||
/*
|
|
||||||
if (subject != null) {
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
|
||||||
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
|
||||||
webView.loadUrl("javascript:(function() { " +
|
|
||||||
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
|
||||||
"document.getElementsByTagName('textarea')[0].innerHTML = '**" + sharedSubject + "** " + sharedContent + "'; " +
|
|
||||||
" if(document.getElementById(\"main_nav\")) {" +
|
|
||||||
" document.getElementById(\"main_nav\").parentNode.removeChild(" +
|
|
||||||
" document.getElementById(\"main_nav\"));" +
|
|
||||||
" } else if (document.getElementById(\"main-nav\")) {" +
|
|
||||||
" document.getElementById(\"main-nav\").parentNode.removeChild(" +
|
|
||||||
" document.getElementById(\"main-nav\"));" +
|
|
||||||
" }" +
|
|
||||||
"})();");
|
|
||||||
webView.setWebViewClient(webViewClient);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Implement?
|
//TODO: Implement?
|
||||||
|
@ -948,6 +927,11 @@ public class MainActivity extends AppCompatActivity
|
||||||
public void contentHasBeenShared(){
|
public void contentHasBeenShared(){
|
||||||
textToBeShared = null;
|
textToBeShared = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void log(final String log){
|
||||||
|
//Log.d(App.TAG, "[wv] " + log);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("StatementWithEmptyBody")
|
@SuppressWarnings("StatementWithEmptyBody")
|
||||||
|
|
|
@ -103,19 +103,15 @@ public class WebHelper {
|
||||||
public static void shareTextIntoWebView(final WebView webView, String sharedText){
|
public static void shareTextIntoWebView(final WebView webView, String sharedText){
|
||||||
sharedText = sharedText.replace("'", "'").replace("\"", """);
|
sharedText = sharedText.replace("'", "'").replace("\"", """);
|
||||||
webView.loadUrl("javascript:(function() { " +
|
webView.loadUrl("javascript:(function() { " +
|
||||||
"if (typeof window.hasBeenSharedTo !== 'undefined') { AndroidBridge.contentHasBeenShared(); return; }" +
|
" document.documentElement.style.paddingBottom = '500px';" +
|
||||||
"var textbox = document.getElementsByTagName('textarea')[0];" +
|
" if (typeof window.hasBeenSharedTo !== 'undefined') { AndroidBridge.contentHasBeenShared(); return; }" +
|
||||||
"if (textbox) { " +
|
" var textbox = document.getElementsByTagName('textarea')[0];" +
|
||||||
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
" var textToBeShared = '" + sharedText + "';" +
|
||||||
"document.getElementsByTagName('textarea')[0].innerHTML = '" + sharedText + "'; " +
|
" if (textbox) { " +
|
||||||
"window.hasBeenSharedTo = true;" +
|
" textbox.style.height='210px'; " +
|
||||||
"}" +
|
" textbox.innerHTML = textToBeShared; " +
|
||||||
" if(document.getElementById(\"main_nav\")) {" +
|
" window.hasBeenSharedTo = true;" +
|
||||||
" document.getElementById(\"main_nav\").parentNode.removeChild(" +
|
" window.lastShared = textToBeShared;" +
|
||||||
" document.getElementById(\"main_nav\"));" +
|
|
||||||
" } else if (document.getElementById(\"main-nav\")) {" +
|
|
||||||
" document.getElementById(\"main-nav\").parentNode.removeChild(" +
|
|
||||||
" document.getElementById(\"main-nav\"));" +
|
|
||||||
" }" +
|
" }" +
|
||||||
"})();");
|
"})();");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue