Add support for fdroid.search:<query> and market://search?q=<query>
This commit is contained in:
parent
17302321b8
commit
da5877c9c4
@ -138,6 +138,24 @@
|
|||||||
<action android:name="android.intent.action.SEARCH" />
|
<action android:name="android.intent.action.SEARCH" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
|
<data android:scheme="market" android:host="search" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
|
<data android:scheme="fdroid.search" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.searchable"
|
android:name="android.app.searchable"
|
||||||
android:resource="@xml/searchable" />
|
android:resource="@xml/searchable" />
|
||||||
|
@ -26,6 +26,7 @@ import android.support.v4.view.MenuItemCompat;
|
|||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.app.SearchManager;
|
import android.app.SearchManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -47,6 +48,21 @@ public class SearchResults extends ListActivity {
|
|||||||
|
|
||||||
private String mQuery;
|
private String mQuery;
|
||||||
|
|
||||||
|
protected void getQuery(Intent intent) {
|
||||||
|
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||||
|
mQuery = intent.getStringExtra(SearchManager.QUERY);
|
||||||
|
} else {
|
||||||
|
Uri data = intent.getData();
|
||||||
|
if (data.isHierarchical()) {
|
||||||
|
mQuery = data.getQueryParameter("q");
|
||||||
|
} else {
|
||||||
|
mQuery = data.getEncodedSchemeSpecificPart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mQuery == null || mQuery.length() == 0)
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
@ -58,19 +74,14 @@ public class SearchResults extends ListActivity {
|
|||||||
// Start a search by just typing
|
// Start a search by just typing
|
||||||
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
|
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
getQuery(getIntent());
|
||||||
|
|
||||||
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
|
||||||
mQuery = intent.getStringExtra(SearchManager.QUERY);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateView();
|
updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
if (Intent.ACTION_SEARCH.equals(intent.getAction()))
|
getQuery(intent);
|
||||||
mQuery = intent.getStringExtra(SearchManager.QUERY);
|
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
updateView();
|
updateView();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user