Added search scheme

This commit is contained in:
M66B 2021-07-18 07:56:03 +02:00
parent 08bc0240aa
commit bfcbb50340
2 changed files with 21 additions and 1 deletions

View File

@ -214,6 +214,15 @@
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="eu.faircode.email.search" />
</intent-filter>
</activity>
<activity

View File

@ -20,20 +20,31 @@ package eu.faircode.email;
*/
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.RequiresApi;
public class ActivitySearch extends ActivityBase {
private static final String SEARCH_SCHEME = "eu.faircode.email.search";
@Override
@RequiresApi(api = Build.VERSION_CODES.M)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CharSequence query;
Uri uri = getIntent().getData();
if (uri == null || !SEARCH_SCHEME.equals(uri.getScheme()))
query = getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
else
query = uri.toString().substring(SEARCH_SCHEME.length() + 1);
Log.i("External search query=" + query);
Intent view = new Intent(this, ActivityView.class);
view.putExtra(Intent.EXTRA_PROCESS_TEXT, getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT));
view.putExtra(Intent.EXTRA_PROCESS_TEXT, query);
startActivity(view);
finish();