mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 04:12:08 +01:00
.
This commit is contained in:
parent
2507dbd015
commit
d64a79dcf8
2 changed files with 43 additions and 18 deletions
|
@ -131,6 +131,7 @@ public class MainActivity extends AppCompatActivity
|
|||
private Snackbar snackbarExitApp;
|
||||
private Snackbar snackbarNewNotification;
|
||||
private Snackbar snackbarNoInternet;
|
||||
public String textToBeShared = null;
|
||||
|
||||
/**
|
||||
* UI Bindings
|
||||
|
@ -305,6 +306,10 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
if (progress > 60) {
|
||||
WebHelper.optimizeMobileSiteLayout(wv);
|
||||
|
||||
if(textToBeShared != null){
|
||||
WebHelper.shareTextIntoWebView(wv, textToBeShared);
|
||||
}
|
||||
}
|
||||
|
||||
progressBar.setVisibility(progress == 100 ? View.GONE : View.VISIBLE);
|
||||
|
@ -838,7 +843,6 @@ public class MainActivity extends AppCompatActivity
|
|||
}
|
||||
|
||||
void handleSendText(Intent intent) {
|
||||
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
||||
String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT));
|
||||
if(appSettings.isAppendSharedViaApp()) {
|
||||
// = \n
|
||||
|
@ -847,23 +851,10 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
final String sharedText = WebHelper.escapeHtmlText(content);
|
||||
if (sharedText != 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 = '" + sharedText + "'; " +
|
||||
" 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);
|
||||
}
|
||||
});
|
||||
textToBeShared = sharedText;
|
||||
}
|
||||
webView.stopLoading();
|
||||
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -882,7 +873,15 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
final String sharedSubject = WebHelper.escapeHtmlText(subject);
|
||||
final String sharedContent = WebHelper.escapeHtmlText(content);
|
||||
final String sharedText = "**" + sharedSubject + "** " + sharedContent;
|
||||
|
||||
if (sharedText != null) {
|
||||
textToBeShared = sharedText;
|
||||
}
|
||||
webView.stopLoading();
|
||||
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
||||
|
||||
/*
|
||||
if (subject != null) {
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
|
||||
|
@ -901,7 +900,7 @@ public class MainActivity extends AppCompatActivity
|
|||
webView.setWebViewClient(webViewClient);
|
||||
}
|
||||
});
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
//TODO: Implement?
|
||||
|
@ -944,6 +943,11 @@ public class MainActivity extends AppCompatActivity
|
|||
podUserProfile.parseJson(webMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void contentHasBeenShared(){
|
||||
textToBeShared = null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("StatementWithEmptyBody")
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.content.Intent;
|
|||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.text.TextUtilsCompat;
|
||||
import android.text.Html;
|
||||
import android.webkit.URLUtil;
|
||||
import android.webkit.WebView;
|
||||
|
@ -99,6 +100,26 @@ public class WebHelper {
|
|||
"})();");
|
||||
}
|
||||
|
||||
public static void shareTextIntoWebView(final WebView webView, String sharedText){
|
||||
sharedText = sharedText.replace("'", "'").replace("\"", """);
|
||||
webView.loadUrl("javascript:(function() { " +
|
||||
"if (typeof window.hasBeenSharedTo !== 'undefined') { AndroidBridge.contentHasBeenShared(); return; }" +
|
||||
"var textbox = document.getElementsByTagName('textarea')[0];" +
|
||||
"if (textbox) { " +
|
||||
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
||||
"document.getElementsByTagName('textarea')[0].innerHTML = '" + sharedText + "'; " +
|
||||
"window.hasBeenSharedTo = true;" +
|
||||
"}" +
|
||||
" 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\"));" +
|
||||
" }" +
|
||||
"})();");
|
||||
}
|
||||
|
||||
public static void showAspectList(final WebView wv, final App app) {
|
||||
wv.stopLoading();
|
||||
PodUserProfile profile = app.getPodUserProfile();
|
||||
|
|
Loading…
Reference in a new issue