mirror of https://github.com/M66B/FairEmail.git
Added search scheme
This commit is contained in:
parent
08bc0240aa
commit
bfcbb50340
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue