mirror of
https://github.com/gsantner/dandelion
synced 2024-12-22 19:08:03 +01:00
Set windowSoftInputMode to adjustResize, Repair sharing text into app, Repair image sharing on 4.2
This commit is contained in:
parent
a1ca8596b8
commit
5c41c62c85
4 changed files with 46 additions and 21 deletions
|
@ -53,7 +53,7 @@
|
|||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:label="@string/diaspora">
|
||||
|
|
|
@ -134,6 +134,8 @@ public class MainActivity extends AppCompatActivity
|
|||
private TextView navheaderDescription;
|
||||
private ImageView navheaderImage;
|
||||
|
||||
private String textToBeShared;
|
||||
|
||||
|
||||
/**
|
||||
* END UI Bindings
|
||||
|
@ -234,6 +236,7 @@ public class MainActivity extends AppCompatActivity
|
|||
if(streamFragment == null) {
|
||||
AppLog.d(this, "StreamFragment was null");
|
||||
streamFragment = new StreamFragment();
|
||||
fm.beginTransaction().add(streamFragment, StreamFragment.TAG).commit();
|
||||
}
|
||||
return streamFragment;
|
||||
}
|
||||
|
@ -601,11 +604,10 @@ public class MainActivity extends AppCompatActivity
|
|||
AppLog.v(this, "handleSendText()");
|
||||
try {
|
||||
setSharedTexts(null, intent.getStringExtra(Intent.EXTRA_TEXT));
|
||||
openDiasporaUrl(urls.getNewPostUrl());
|
||||
} catch (Exception e) {
|
||||
AppLog.e(this, e.toString());
|
||||
}
|
||||
openDiasporaUrl(urls.getBlankUrl());
|
||||
openDiasporaUrl(urls.getNewPostUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -617,11 +619,10 @@ public class MainActivity extends AppCompatActivity
|
|||
AppLog.v(this, "handleSendSubject()");
|
||||
try {
|
||||
setSharedTexts(intent.getStringExtra(Intent.EXTRA_SUBJECT), intent.getStringExtra(Intent.EXTRA_TEXT));
|
||||
openDiasporaUrl(urls.getNewPostUrl());
|
||||
} catch (Exception e) {
|
||||
AppLog.e(this, e.toString());
|
||||
}
|
||||
openDiasporaUrl(urls.getBlankUrl()); //TODO: Necessary?
|
||||
openDiasporaUrl(urls.getNewPostUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -645,10 +646,11 @@ public class MainActivity extends AppCompatActivity
|
|||
if (sharedSubject != null) {
|
||||
AppLog.v(this, "Append subject to shared text");
|
||||
String escapedSubject = WebHelper.escapeHtmlText(WebHelper.replaceUrlWithMarkdown(sharedSubject));
|
||||
getStreamFragment().setTextToBeShared("**" + escapedSubject + "** " + escapedBody);
|
||||
AppLog.v(this, "Set shared text; Subject: \"" + escapedSubject + "\" Body: \"" + escapedBody + "\"");
|
||||
textToBeShared = "**" + escapedSubject + "** " + escapedBody;
|
||||
} else {
|
||||
AppLog.v(this, "Set shared text; Subject: \"" + sharedSubject + "\" Body: \"" + sharedBody + "\"");
|
||||
getStreamFragment().setTextToBeShared(escapedBody);
|
||||
textToBeShared = escapedBody;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -824,4 +826,12 @@ public class MainActivity extends AppCompatActivity
|
|||
grantResults);
|
||||
}
|
||||
}
|
||||
|
||||
public String getTextToBeShared() {
|
||||
return textToBeShared;
|
||||
}
|
||||
|
||||
public void setTextToBeShared(String textToBeShared) {
|
||||
this.textToBeShared = textToBeShared;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ public class StreamFragment extends WebViewFragment {
|
|||
private ValueCallback<Uri[]> imageUploadFilePathCallbackNew;
|
||||
private ValueCallback<Uri> imageUploadFilePathCallbackOld;
|
||||
private String mCameraPhotoPath;
|
||||
protected String textToBeShared;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -76,11 +75,19 @@ public class StreamFragment extends WebViewFragment {
|
|||
|
||||
// Setup WebView
|
||||
webView.addJavascriptInterface(new JavaScriptInterface(), "AndroidBridge");
|
||||
setWebChromeClient();
|
||||
|
||||
if(webView.getUrl() == null) {
|
||||
if(pendingUrl != null) {
|
||||
loadUrl(pendingUrl);
|
||||
pendingUrl = null;
|
||||
} else if (webView.getUrl() == null) {
|
||||
loadUrl(urls.getPodUrl());
|
||||
}
|
||||
|
||||
this.setRetainInstance(true);
|
||||
}
|
||||
|
||||
private void setWebChromeClient() {
|
||||
//Set WebChromeClient
|
||||
webView.setWebChromeClient(new WebChromeClient() {
|
||||
final ProgressBar pb = progressBar;
|
||||
|
@ -96,6 +103,7 @@ public class StreamFragment extends WebViewFragment {
|
|||
if (progress > 60) {
|
||||
WebHelper.optimizeMobileSiteLayout(wv);
|
||||
|
||||
String textToBeShared = ((MainActivity)getActivity()).getTextToBeShared();
|
||||
if (textToBeShared != null) {
|
||||
AppLog.d(this, "Share text into webView");
|
||||
WebHelper.shareTextIntoWebView(wv, textToBeShared);
|
||||
|
@ -110,7 +118,7 @@ public class StreamFragment extends WebViewFragment {
|
|||
protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
|
||||
{
|
||||
AppLog.v(this, "openFileChooser(ValCallback<Uri>, String, String");
|
||||
//imageUploadFilePathCallbackOld = uploadMsg;
|
||||
imageUploadFilePathCallbackOld = uploadMsg;
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
|
@ -188,8 +196,6 @@ public class StreamFragment extends WebViewFragment {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
this.setRetainInstance(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -273,10 +279,6 @@ public class StreamFragment extends WebViewFragment {
|
|||
return this.webView;
|
||||
}
|
||||
|
||||
public void setTextToBeShared(String text) {
|
||||
this.textToBeShared = text;
|
||||
}
|
||||
|
||||
public void onImageUploadResult(int requestCode, int resultCode, Intent data) {
|
||||
AppLog.d(this, "onImageUploadResult");
|
||||
switch (requestCode) {
|
||||
|
@ -359,7 +361,7 @@ public class StreamFragment extends WebViewFragment {
|
|||
|
||||
@JavascriptInterface
|
||||
public void contentHasBeenShared() {
|
||||
textToBeShared = null;
|
||||
((MainActivity)getActivity()).setTextToBeShared(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ public abstract class WebViewFragment extends CustomFragment {
|
|||
protected ProgressBar progressBar;
|
||||
protected AppSettings appSettings;
|
||||
|
||||
protected String pendingUrl;
|
||||
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
@ -279,17 +281,28 @@ public abstract class WebViewFragment extends CustomFragment {
|
|||
}
|
||||
|
||||
public void loadUrl(String url) {
|
||||
AppLog.v(this, "loadUrl("+url+")");
|
||||
getWebView().loadUrlNew(url);
|
||||
if(getWebView() != null) {
|
||||
AppLog.v(this, "loadUrl(): load "+url);
|
||||
getWebView().loadUrlNew(url);
|
||||
} else {
|
||||
AppLog.v(this, "loadUrl(): WebView null: Set pending url to "+url);
|
||||
pendingUrl = url;
|
||||
}
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return getWebView().getUrl();
|
||||
if(getWebView() != null) {
|
||||
return getWebView().getUrl();
|
||||
} else {
|
||||
return pendingUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadUrl() {
|
||||
AppLog.v(this, "reloadUrl()");
|
||||
getWebView().reload();
|
||||
if(getWebView() != null) {
|
||||
getWebView().reload();
|
||||
}
|
||||
}
|
||||
|
||||
public ContextMenuWebView getWebView() {
|
||||
|
|
Loading…
Reference in a new issue