mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 04:12:08 +01:00
make difference intent with/without extra_subject
This commit is contained in:
parent
7f2eda535b
commit
f439be77d7
2 changed files with 49 additions and 11 deletions
|
@ -49,13 +49,19 @@
|
|||
android:label="@string/new_post"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:screenOrientation="portrait" >
|
||||
<intent-filter android:label="@string/new_post"
|
||||
android:icon="@drawable/ic_launcher">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/*" />
|
||||
<data android:mimeType="image/*" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
|
||||
<!-- //TODO Handle single image being sent
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="image/*" />
|
||||
</intent-filter>-->
|
||||
|
||||
</activity>
|
||||
|
||||
<service
|
||||
|
@ -66,3 +72,6 @@
|
|||
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ public class ShareActivity extends MainActivity {
|
|||
Intent intent = new Intent(ShareActivity.this, MainActivity.class);
|
||||
startActivityForResult(intent, 100);
|
||||
overridePendingTransition(0, 0);
|
||||
finish();
|
||||
} else {
|
||||
Snackbar.make(swipeView, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -211,12 +212,15 @@ public class ShareActivity extends MainActivity {
|
|||
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
if ("text/plain".equals(type)) {
|
||||
handleSendText(intent); // Handle text being sent TODO difference of "text/plain" intents with and without EXTRA_SUBJECT
|
||||
if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
|
||||
handleSendSubject(intent);
|
||||
} else {
|
||||
handleSendText(intent);}
|
||||
} else if (type.startsWith("image/")) {
|
||||
// TODO Handle single image being sent
|
||||
// TODO Handle single image being sent -> see manifest
|
||||
handleSendImage(intent);
|
||||
}
|
||||
} else {
|
||||
//} else {
|
||||
// Handle other intents, such as being started from the home screen
|
||||
}
|
||||
|
||||
|
@ -231,6 +235,20 @@ public class ShareActivity extends MainActivity {
|
|||
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
|
||||
finish();
|
||||
|
||||
Intent i = new Intent(ShareActivity.this, MainActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(i);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
webView.loadUrl("javascript:(function() { " +
|
||||
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
||||
"document.getElementsByTagName('textarea')[0].innerHTML = '> " + sharedText + " " + sharedBy + "'; " +
|
||||
|
@ -244,11 +262,9 @@ public class ShareActivity extends MainActivity {
|
|||
"})();");
|
||||
}
|
||||
});
|
||||
// Update UI to reflect text being shared
|
||||
}
|
||||
}
|
||||
|
||||
// TODO difference of "text/plain" intents with and without EXTRA_SUBJECT
|
||||
void handleSendSubject(Intent intent) {
|
||||
final String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
final String sharedSubject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
|
||||
|
@ -258,6 +274,20 @@ public class ShareActivity extends MainActivity {
|
|||
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
|
||||
finish();
|
||||
|
||||
Intent i = new Intent(ShareActivity.this, MainActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(i);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
webView.loadUrl("javascript:(function() { " +
|
||||
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
||||
"document.getElementsByTagName('textarea')[0].innerHTML = '**" + sharedSubject + "** " + sharedText + " " + sharedBy + "'; " +
|
||||
|
@ -271,11 +301,10 @@ public class ShareActivity extends MainActivity {
|
|||
"})();");
|
||||
}
|
||||
});
|
||||
// Update UI to reflect text being shared
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Handle single image being sent
|
||||
// TODO Handle single image being sent -> see manifest
|
||||
|
||||
void handleSendImage(Intent intent) {
|
||||
final Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
|
|
Loading…
Reference in a new issue