-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8756fd
commit 2cac072
Showing
1 changed file
with
45 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,64 @@ | ||
# SearchPreference | ||
Search inside Android Preferences | ||
|
||
[ ![Download](https://api.bintray.com/packages/bytehamster/android/SearchPreference/images/download.svg) ](https://bintray.com/bytehamster/android/SearchPreference/_latestVersion) | ||
|
||
<img width="200" src="https://raw.githubusercontent.com/ByteHamster/PreferenceSearch/master/screenshots/main.png" /> <img width="200" src="https://raw.githubusercontent.com/ByteHamster/PreferenceSearch/master/screenshots/history.png" /> <img width="200" src="https://raw.githubusercontent.com/ByteHamster/PreferenceSearch/master/screenshots/suggestions.png" /> <img width="200" src="https://raw.githubusercontent.com/ByteHamster/PreferenceSearch/master/screenshots/result.png" /> | ||
|
||
## How to add to your app | ||
## Adding to your app | ||
|
||
Add PreferenceSearch to your `build.gradle`: | ||
``` | ||
dependencies { | ||
compile 'com.bytehamster.lib:searchpreference:1.0.0@aar' | ||
} | ||
``` | ||
|
||
dependencies { | ||
compile 'com.bytehamster.lib:searchpreference:1.0.0' | ||
} | ||
|
||
Add PreferenceSearch to your `settings.gradle`: | ||
``` | ||
allprojects { | ||
repositories { | ||
// ... | ||
maven { | ||
url "https://dl.bintray.com/bytehamster/android" | ||
|
||
allprojects { | ||
repositories { | ||
// ... | ||
maven { | ||
url "https://dl.bintray.com/bytehamster/android" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Add search bar to your `preferences.xml` file: | ||
```xml | ||
<com.bytehamster.lib.preferencesearch.SearchPreference | ||
android:key="searchPreference" /> | ||
``` | ||
|
||
<com.bytehamster.lib.preferencesearch.SearchPreference | ||
android:key="searchPreference" /> | ||
Define search index and react to search results in your `PreferenceFragment`: | ||
```java | ||
public static class PrefsFragment extends PreferenceFragment { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
addPreferencesFromResource(R.xml.preferences); | ||
|
||
SearchPreference searchPreference = (SearchPreference) findPreference("searchPreference"); | ||
searchPreference.openActivityOnResultClick(SimpleExample.class); | ||
searchPreference.addResourceFileToIndex(R.xml.preferences); | ||
} | ||
|
||
@Override | ||
public void onStart() { | ||
super.onStart(); | ||
|
||
SearchPreferenceResult result = new SearchPreferenceResult(this, | ||
getActivity().getIntent().getExtras()); | ||
if (result.hasData()) { | ||
// A search result was clicked | ||
result.scrollTo(); | ||
result.setIcon(); | ||
public static class PrefsFragment extends PreferenceFragment { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
addPreferencesFromResource(R.xml.preferences); | ||
|
||
SearchPreference searchPreference = (SearchPreference) findPreference("searchPreference"); | ||
searchPreference.openActivityOnResultClick(SimpleExample.class); | ||
searchPreference.addResourceFileToIndex(R.xml.preferences); | ||
} | ||
|
||
@Override | ||
public void onStart() { | ||
super.onStart(); | ||
|
||
SearchPreferenceResult result = new SearchPreferenceResult(this, | ||
getActivity().getIntent().getExtras()); | ||
if (result.hasData()) { | ||
// A search result was clicked | ||
result.scrollTo(); | ||
result.setIcon(); | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Developer info | ||
|
||
Releasing to bintray: | ||
|
||
build generatePomFileForReleasePublication bintrayUpload |