handle share text intent
This commit is contained in:
parent
43a66ac0d3
commit
a361a32234
2 changed files with 26 additions and 15 deletions
|
@ -394,7 +394,7 @@
|
|||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT" />
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
|
|
|
@ -56,7 +56,7 @@ public class IntentHelper {
|
|||
applied = parseOpenGpxIntent();
|
||||
}
|
||||
if (!applied) {
|
||||
applied = parseExtraTextIntent();
|
||||
applied = parseSendIntent();
|
||||
}
|
||||
return applied;
|
||||
}
|
||||
|
@ -257,21 +257,32 @@ public class IntentHelper {
|
|||
intent.setData(null);
|
||||
}
|
||||
|
||||
private boolean parseExtraTextIntent() {
|
||||
private boolean parseSendIntent() {
|
||||
Intent intent = mapActivity.getIntent();
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M && intent != null) {
|
||||
CharSequence text = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
|
||||
if (!Algorithms.isEmpty(text)) {
|
||||
return QuickSearchDialogFragment.showInstance(
|
||||
mapActivity,
|
||||
text.toString(),
|
||||
null,
|
||||
QuickSearchDialogFragment.QuickSearchType.REGULAR,
|
||||
QuickSearchDialogFragment.QuickSearchTab.CATEGORIES,
|
||||
null
|
||||
);
|
||||
if (intent != null) {
|
||||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
if ("text/plain".equals(type)) {
|
||||
return handleSendText(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleSendText(Intent intent) {
|
||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
if (!Algorithms.isEmpty(sharedText)) {
|
||||
return QuickSearchDialogFragment.showInstance(
|
||||
mapActivity,
|
||||
sharedText,
|
||||
null,
|
||||
QuickSearchDialogFragment.QuickSearchType.REGULAR,
|
||||
QuickSearchDialogFragment.QuickSearchTab.CATEGORIES,
|
||||
null
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue