├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── debug
│ └── resources
│ │ └── slf4j.properties
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── cheeselist.txt
│ ├── ic_launcher-web.png
│ ├── java
│ └── danbroid
│ │ └── searchview
│ │ ├── BaseActivity.kt
│ │ ├── CheeseData.kt
│ │ ├── CheeseSuggestionsProvider.kt
│ │ └── activities
│ │ ├── CustomSuggestionLayoutActivity.kt
│ │ ├── DarkDropDownActivity.kt
│ │ ├── LightDropDownActivity.kt
│ │ ├── MainActivity.kt
│ │ └── SearchDialogActivity.kt
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── ic_launcher_background.xml
│ ├── ic_search.xml
│ └── ic_sentiment_satisfied.xml
│ ├── layout
│ ├── activity.xml
│ └── search_dropdown.xml
│ ├── menu
│ └── menu.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── ic_launcher_background.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ └── searchable.xml
├── build.gradle
├── docs
├── demo1.png
├── demo2.png
└── demo3.png
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | /app/release
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | Android SearchView Demo
3 | ======================
4 | This is a small demonstration of how I managed to get the Android [SearchView](http://developer.android.com/reference/android/support/v7/widget/SearchView.html) widget working nice.
5 | If you have been going mad trying to make the SearchView's autocomplete dropdown look nice with a dark action bar
6 | then this code will help.
7 |
8 |
9 | This is a standalone app supporting android versions 14 -> 28 featuring:
10 |
11 | - Proper material theme styling of the search view
12 | - How to wire up the search view to a ContentProvider
13 | - How to use the [SearchRecentSuggestionsProvider](http://developer.android.com/reference/android/content/SearchRecentSuggestionsProvider.html)
14 | - How to programmatically close the SearchView when the back button is pressed
15 | - How to programmatically close the SearchView without weird highlighting of the actionBar
16 |
17 |
18 | 
19 | 
20 |
21 | There is also an example of implementing a custom suggestion layout
22 |
23 | 
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 28
9 |
10 | defaultConfig {
11 | applicationId "danbroid.searchview"
12 | minSdkVersion 14
13 | targetSdkVersion 28
14 | versionCode 8
15 | versionName "v1.08"
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 |
20 |
21 | signingConfigs {
22 | release {
23 | storeFile file("/home/dan/.android/keystore_searchviewdemo")
24 | storePassword KEYSTORE_PASSWORD
25 | keyAlias "demo_searchview"
26 | keyPassword KEYSTORE_PASSWORD
27 | }
28 | }
29 |
30 | buildTypes {
31 | release {
32 | minifyEnabled false
33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34 | signingConfig signingConfigs.release
35 | }
36 | }
37 |
38 | }
39 |
40 | project.afterEvaluate {
41 | android.applicationVariants.all { variant ->
42 | task "installRun${variant.name.capitalize()}"(type: Exec, dependsOn: "install${variant.name.capitalize()}", group: "run") {
43 | commandLine = ["adb", "shell", "monkey", "-p", variant.applicationId + " 1"]
44 | doLast {
45 | println "Launching ${variant.applicationId}"
46 | }
47 | }
48 | }
49 | }
50 |
51 |
52 | dependencies {
53 | implementation "org.slf4j:slf4j-api:1.7.25"
54 |
55 | //for some colored log output. see the app/src/debug/resources/slf4j.properties
56 | debugRuntimeOnly 'com.github.danbrough.util:slf4j:1.0.7'
57 |
58 | //or you can use the standard
59 | //implementation "org.slf4j:slf4j-android:1.7.25"
60 |
61 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
62 | implementation 'androidx.appcompat:appcompat:1.0.2'
63 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
64 | implementation 'com.google.android.material:material:1.0.0'
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/debug/resources/slf4j.properties:
--------------------------------------------------------------------------------
1 | tag=SEARCH_DEMO
2 | #whether to use coloured output
3 | color=true
4 |
5 | #one of native (configured via adb),verbose,debug,info,warn,error
6 | level=verbose
7 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
27 |
28 |
33 |
34 |
35 |
36 |
37 |
38 |
41 |
42 |
43 |
48 |
49 |
50 |
51 |
52 |
55 |
56 |
57 |
58 |
63 |
64 |
65 |
66 |
67 |
70 |
71 |
72 |
73 |
78 |
79 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/app/src/main/assets/cheeselist.txt:
--------------------------------------------------------------------------------
1 | Any New Zealand Cheese
2 | Abbaye de Belloc
3 | Abbaye du Mont des Cats
4 | Abertam
5 | Abondance
6 | Ackawi
7 | Acorn
8 | Adelost
9 | Affidelice au Chablis
10 | Afuega'l Pitu
11 | Airag
12 | Airedale
13 | Aisy Cendre
14 | Allgauer Emmentaler
15 | Alverca
16 | Ambert
17 | American Cheese
18 | Ami du Chambertin
19 | Anejo Enchilado
20 | Anneau du Vic-Bilh
21 | Anthoriro
22 | Appenzell
23 | Aragon
24 | Ardi Gasna
25 | Ardrahan
26 | Armenian String
27 | Aromes au Gene de Marc
28 | Asadero
29 | Asiago
30 | Aubisque Pyrenees
31 | Autun
32 | Avaxtskyr
33 | Baby Swiss
34 | Babybel
35 | Baguette Laonnaise
36 | Bakers
37 | Baladi
38 | Balaton
39 | Bandal
40 | Banon
41 | Barry's Bay Cheddar
42 | Basing
43 | Basket Cheese
44 | Bath Cheese
45 | Bavarian Bergkase
46 | Baylough
47 | Beaufort
48 | Beauvoorde
49 | Beenleigh Blue
50 | Beer Cheese
51 | Bel Paese
52 | Bergader
53 | Bergere Bleue
54 | Berkswell
55 | Beyaz Peynir
56 | Bierkase
57 | Bishop Kennedy
58 | Blarney
59 | Bleu d'Auvergne
60 | Bleu de Gex
61 | Bleu de Laqueuille
62 | Bleu de Septmoncel
63 | Bleu Des Causses
64 | Blue
65 | Blue Castello
66 | Blue Rathgore
67 | Blue Vein (New Zealand)
68 | Blue Vein Cheeses
69 | Bocconcini
70 | Bocconcini (New Zealand)
71 | Boeren Leidenkaas
72 | Bonchester
73 | Bosworth
74 | Bougon
75 | Boule Du Roves
76 | Boulette d'Avesnes
77 | Boursault
78 | Boursin
79 | Bouyssou
80 | Bra
81 | Braudostur
82 | Breakfast Cheese
83 | Brebis du Lavort
84 | Brebis du Lochois
85 | Brebis du Puyfaucon
86 | Bresse Bleu
87 | Brick
88 | Brie
89 | Brie de Meaux
90 | Brie de Melun
91 | Brillat-Savarin
92 | Brin
93 | Brin d' Amour
94 | Brin d'Amour
95 | Brinza (Burduf Brinza)
96 | Briquette de Brebis
97 | Briquette du Forez
98 | Broccio
99 | Broccio Demi-Affine
100 | Brousse du Rove
101 | Bruder Basil
102 | Brusselae Kaas (Fromage de Bruxelles)
103 | Bryndza
104 | Buchette d'Anjou
105 | Buffalo
106 | Burgos
107 | Butte
108 | Butterkase
109 | Button (Innes)
110 | Buxton Blue
111 | Cabecou
112 | Caboc
113 | Cabrales
114 | Cachaille
115 | Caciocavallo
116 | Caciotta
117 | Caerphilly
118 | Cairnsmore
119 | Calenzana
120 | Cambazola
121 | Camembert de Normandie
122 | Canadian Cheddar
123 | Canestrato
124 | Cantal
125 | Caprice des Dieux
126 | Capricorn Goat
127 | Capriole Banon
128 | Carre de l'Est
129 | Casciotta di Urbino
130 | Cashel Blue
131 | Castellano
132 | Castelleno
133 | Castelmagno
134 | Castelo Branco
135 | Castigliano
136 | Cathelain
137 | Celtic Promise
138 | Cendre d'Olivet
139 | Cerney
140 | Chabichou
141 | Chabichou du Poitou
142 | Chabis de Gatine
143 | Chaource
144 | Charolais
145 | Chaumes
146 | Cheddar
147 | Cheddar Clothbound
148 | Cheshire
149 | Chevres
150 | Chevrotin des Aravis
151 | Chontaleno
152 | Civray
153 | Coeur de Camembert au Calvados
154 | Coeur de Chevre
155 | Colby
156 | Cold Pack
157 | Comte
158 | Coolea
159 | Cooleney
160 | Coquetdale
161 | Corleggy
162 | Cornish Pepper
163 | Cotherstone
164 | Cotija
165 | Cottage Cheese
166 | Cottage Cheese (New Zealand)
167 | Cougar Gold
168 | Coulommiers
169 | Coverdale
170 | Crayeux de Roncq
171 | Cream Cheese
172 | Cream Havarti
173 | Crema Agria
174 | Crema Mexicana
175 | Creme Fraiche
176 | Crescenza
177 | Croghan
178 | Crottin de Chavignol
179 | Crottin du Chavignol
180 | Crowdie
181 | Crowley
182 | Cuajada
183 | Curd
184 | Cure Nantais
185 | Curworthy
186 | Cwmtawe Pecorino
187 | Cypress Grove Chevre
188 | Danablu (Danish Blue)
189 | Danbo
190 | Danish Fontina
191 | Daralagjazsky
192 | Dauphin
193 | Delice des Fiouves
194 | Denhany Dorset Drum
195 | Derby
196 | Dessertnyj Belyj
197 | Devon Blue
198 | Devon Garland
199 | Dolcelatte
200 | Doolin
201 | Doppelrhamstufel
202 | Dorset Blue Vinney
203 | Double Gloucester
204 | Double Worcester
205 | Dreux a la Feuille
206 | Dry Jack
207 | Duddleswell
208 | Dunbarra
209 | Dunlop
210 | Dunsyre Blue
211 | Duroblando
212 | Durrus
213 | Dutch Mimolette (Commissiekaas)
214 | Edam
215 | Edelpilz
216 | Emental Grand Cru
217 | Emlett
218 | Emmental
219 | Epoisses de Bourgogne
220 | Esbareich
221 | Esrom
222 | Etorki
223 | Evansdale Farmhouse Brie
224 | Evora De L'Alentejo
225 | Exmoor Blue
226 | Explorateur
227 | Feta
228 | Feta (New Zealand)
229 | Figue
230 | Filetta
231 | Fin-de-Siecle
232 | Finlandia Swiss
233 | Finn
234 | Fiore Sardo
235 | Fleur du Maquis
236 | Flor de Guia
237 | Flower Marie
238 | Folded
239 | Folded cheese with mint
240 | Fondant de Brebis
241 | Fontainebleau
242 | Fontal
243 | Fontina Val d'Aosta
244 | Formaggio di capra
245 | Fougerus
246 | Four Herb Gouda
247 | Fourme d' Ambert
248 | Fourme de Haute Loire
249 | Fourme de Montbrison
250 | Fresh Jack
251 | Fresh Mozzarella
252 | Fresh Ricotta
253 | Fresh Truffles
254 | Fribourgeois
255 | Friesekaas
256 | Friesian
257 | Friesla
258 | Frinault
259 | Fromage a Raclette
260 | Fromage Corse
261 | Fromage de Montagne de Savoie
262 | Fromage Frais
263 | Fruit Cream Cheese
264 | Frying Cheese
265 | Fynbo
266 | Gabriel
267 | Galette du Paludier
268 | Galette Lyonnaise
269 | Galloway Goat's Milk Gems
270 | Gammelost
271 | Gaperon a l'Ail
272 | Garrotxa
273 | Gastanberra
274 | Geitost
275 | Gippsland Blue
276 | Gjetost
277 | Gloucester
278 | Golden Cross
279 | Gorgonzola
280 | Gornyaltajski
281 | Gospel Green
282 | Gouda
283 | Goutu
284 | Gowrie
285 | Grabetto
286 | Graddost
287 | Grafton Village Cheddar
288 | Grana
289 | Grana Padano
290 | Grand Vatel
291 | Grataron d' Areches
292 | Gratte-Paille
293 | Graviera
294 | Greuilh
295 | Greve
296 | Gris de Lille
297 | Gruyere
298 | Gubbeen
299 | Guerbigny
300 | Halloumi
301 | Halloumy (New Zealand)
302 | Haloumi-Style Cheese
303 | Harbourne Blue
304 | Havarti
305 | Heidi Gruyere
306 | Hereford Hop
307 | Herrgardsost
308 | Herriot Farmhouse
309 | Herve
310 | Hipi Iti
311 | Hubbardston Blue Cow
312 | Hushallsost
313 | Iberico
314 | Idaho Goatster
315 | Idiazabal
316 | Il Boschetto al Tartufo
317 | Ile d'Yeu
318 | Isle of Mull
319 | Jarlsberg
320 | Jermi Tortes
321 | Jibneh Arabieh
322 | Jindi Brie
323 | Jubilee Blue
324 | Juustoleipa
325 | Kadchgall
326 | Kaseri
327 | Kashta
328 | Kefalotyri
329 | Kenafa
330 | Kernhem
331 | Kervella Affine
332 | Kikorangi
333 | King Island Cape Wickham Brie
334 | King River Gold
335 | Klosterkaese
336 | Knockalara
337 | Kugelkase
338 | L'Aveyronnais
339 | L'Ecir de l'Aubrac
340 | La Taupiniere
341 | La Vache Qui Rit
342 | Laguiole
343 | Lairobell
344 | Lajta
345 | Lanark Blue
346 | Lancashire
347 | Langres
348 | Lappi
349 | Laruns
350 | Lavistown
351 | Le Brin
352 | Le Fium Orbo
353 | Le Lacandou
354 | Le Roule
355 | Leafield
356 | Lebbene
357 | Leerdammer
358 | Leicester
359 | Leyden
360 | Limburger
361 | Lincolnshire Poacher
362 | Lingot Saint Bousquet d'Orb
363 | Liptauer
364 | Little Rydings
365 | Livarot
366 | Llanboidy
367 | Llanglofan Farmhouse
368 | Loch Arthur Farmhouse
369 | Loddiswell Avondale
370 | Longhorn
371 | Lou Palou
372 | Lou Pevre
373 | Lyonnais
374 | Maasdam
375 | Macconais
376 | Mahoe Aged Gouda
377 | Mahon
378 | Malvern
379 | Mamirolle
380 | Manchego
381 | Manouri
382 | Manur
383 | Marble Cheddar
384 | Marbled Cheeses
385 | Maredsous
386 | Margotin
387 | Maribo
388 | Maroilles
389 | Mascares
390 | Mascarpone
391 | Mascarpone (New Zealand)
392 | Mascarpone Torta
393 | Matocq
394 | Maytag Blue
395 | Meira
396 | Menallack Farmhouse
397 | Menonita
398 | Meredith Blue
399 | Mesost
400 | Metton (Cancoillotte)
401 | Meyer Vintage Gouda
402 | Mihalic Peynir
403 | Milleens
404 | Mimolette
405 | Mine-Gabhar
406 | Mini Baby Bells
407 | Mixte
408 | Molbo
409 | Monastery Cheeses
410 | Mondseer
411 | Mont D'or Lyonnais
412 | Montasio
413 | Monterey Jack
414 | Monterey Jack Dry
415 | Morbier
416 | Morbier Cru de Montagne
417 | Mothais a la Feuille
418 | Mozzarella
419 | Mozzarella (New Zealand)
420 | Mozzarella di Bufala
421 | Mozzarella Fresh, in water
422 | Mozzarella Rolls
423 | Munster
424 | Murol
425 | Mycella
426 | Myzithra
427 | Naboulsi
428 | Nantais
429 | Neufchatel
430 | Neufchatel (New Zealand)
431 | Niolo
432 | Nokkelost
433 | Northumberland
434 | Oaxaca
435 | Olde York
436 | Olivet au Foin
437 | Olivet Bleu
438 | Olivet Cendre
439 | Orkney Extra Mature Cheddar
440 | Orla
441 | Oschtjepka
442 | Ossau Fermier
443 | Ossau-Iraty
444 | Oszczypek
445 | Oxford Blue
446 | P'tit Berrichon
447 | Palet de Babligny
448 | Paneer
449 | Panela
450 | Pannerone
451 | Pant ys Gawn
452 | Parmesan (Parmigiano)
453 | Parmigiano Reggiano
454 | Pas de l'Escalette
455 | Passendale
456 | Pasteurized Processed
457 | Pate de Fromage
458 | Patefine Fort
459 | Pave d'Affinois
460 | Pave d'Auge
461 | Pave de Chirac
462 | Pave du Berry
463 | Pecorino
464 | Pecorino in Walnut Leaves
465 | Pecorino Romano
466 | Peekskill Pyramid
467 | Pelardon des Cevennes
468 | Pelardon des Corbieres
469 | Penamellera
470 | Penbryn
471 | Pencarreg
472 | Perail de Brebis
473 | Petit Morin
474 | Petit Pardou
475 | Petit-Suisse
476 | Picodon de Chevre
477 | Picos de Europa
478 | Piora
479 | Pithtviers au Foin
480 | Plateau de Herve
481 | Plymouth Cheese
482 | Podhalanski
483 | Poivre d'Ane
484 | Polkolbin
485 | Pont l'Eveque
486 | Port Nicholson
487 | Port-Salut
488 | Postel
489 | Pouligny-Saint-Pierre
490 | Pourly
491 | Prastost
492 | Pressato
493 | Prince-Jean
494 | Processed Cheddar
495 | Provolone
496 | Provolone (New Zealand)
497 | Pyengana Cheddar
498 | Pyramide
499 | Quark
500 | Quark (New Zealand)
501 | Quartirolo Lombardo
502 | Quatre-Vents
503 | Quercy Petit
504 | Queso Blanco
505 | Queso Blanco con Frutas --Pina y Mango
506 | Queso de Murcia
507 | Queso del Montsec
508 | Queso del Tietar
509 | Queso Fresco
510 | Queso Fresco (Adobera)
511 | Queso Iberico
512 | Queso Jalapeno
513 | Queso Majorero
514 | Queso Media Luna
515 | Queso Para Frier
516 | Queso Quesadilla
517 | Rabacal
518 | Raclette
519 | Ragusano
520 | Raschera
521 | Reblochon
522 | Red Leicester
523 | Regal de la Dombes
524 | Reggianito
525 | Remedou
526 | Requeson
527 | Richelieu
528 | Ricotta
529 | Ricotta (New Zealand)
530 | Ricotta Salata
531 | Ridder
532 | Rigotte
533 | Rocamadour
534 | Rollot
535 | Romano
536 | Romans Part Dieu
537 | Roncal
538 | Roquefort
539 | Roule
540 | Rouleau De Beaulieu
541 | Royalp Tilsit
542 | Rubens
543 | Rustinu
544 | Saaland Pfarr
545 | Saanenkaese
546 | Saga
547 | Sage Derby
548 | Sainte Maure
549 | Saint-Marcellin
550 | Saint-Nectaire
551 | Saint-Paulin
552 | Salers
553 | Samso
554 | San Simon
555 | Sancerre
556 | Sap Sago
557 | Sardo
558 | Sardo Egyptian
559 | Sbrinz
560 | Scamorza
561 | Schabzieger
562 | Schloss
563 | Selles sur Cher
564 | Selva
565 | Serat
566 | Seriously Strong Cheddar
567 | Serra da Estrela
568 | Sharpam
569 | Shelburne Cheddar
570 | Shropshire Blue
571 | Siraz
572 | Sirene
573 | Smoked Gouda
574 | Somerset Brie
575 | Sonoma Jack
576 | Sottocenare al Tartufo
577 | Soumaintrain
578 | Sourire Lozerien
579 | Spenwood
580 | Sraffordshire Organic
581 | St. Agur Blue Cheese
582 | Stilton
583 | Stinking Bishop
584 | String
585 | Sussex Slipcote
586 | Sveciaost
587 | Swaledale
588 | Sweet Style Swiss
589 | Swiss
590 | Syrian (Armenian String)
591 | Tala
592 | Taleggio
593 | Tamie
594 | Tasmania Highland Chevre Log
595 | Taupiniere
596 | Teifi
597 | Telemea
598 | Testouri
599 | Tete de Moine
600 | Tetilla
601 | Texas Goat Cheese
602 | Tibet
603 | Tillamook Cheddar
604 | Tilsit
605 | Timboon Brie
606 | Toma
607 | Tomme Brulee
608 | Tomme d'Abondance
609 | Tomme de Chevre
610 | Tomme de Romans
611 | Tomme de Savoie
612 | Tomme des Chouans
613 | Tommes
614 | Torta del Casar
615 | Toscanello
616 | Touree de L'Aubier
617 | Tourmalet
618 | Trappe (Veritable)
619 | Trois Cornes De Vendee
620 | Tronchon
621 | Trou du Cru
622 | Truffe
623 | Tupi
624 | Turunmaa
625 | Tymsboro
626 | Tyn Grug
627 | Tyning
628 | Ubriaco
629 | Ulloa
630 | Vacherin-Fribourgeois
631 | Valencay
632 | Vasterbottenost
633 | Venaco
634 | Vendomois
635 | Vieux Corse
636 | Vignotte
637 | Vulscombe
638 | Waimata Farmhouse Blue
639 | Waterloo
640 | Weichkaese
641 | Wellington
642 | Wensleydale
643 | White Stilton
644 | Whitestone Farmhouse
645 | Wigmore
646 | Woodside Cabecou
647 | Xanadu
648 | Xynotyro
649 | Yarg Cornish
650 | Yarra Valley Pyramid
651 | Yorkshire Blue
652 | Zamorano
653 | Zanetti Grana Padano
654 | Zanetti Parmigiano Reggiano
655 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/java/danbroid/searchview/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package danbroid.searchview
2 |
3 | import android.app.SearchManager
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.os.Bundle
7 | import android.provider.SearchRecentSuggestions
8 | import android.view.Menu
9 | import android.view.MenuItem
10 | import android.view.View
11 | import android.view.ViewGroup
12 | import android.widget.Button
13 | import android.widget.TextView
14 | import android.widget.Toast
15 | import androidx.appcompat.app.AppCompatActivity
16 | import com.google.android.material.snackbar.Snackbar
17 | import kotlinx.android.synthetic.main.activity.*
18 | import java.util.*
19 |
20 |
21 | abstract class BaseActivity : AppCompatActivity() {
22 |
23 | private var menu: Menu? = null
24 |
25 | protected val cheeseData: CheeseData by lazy {
26 | CheeseData.getInstance(this)
27 | }
28 |
29 | protected val themedContext: Context
30 | get() = supportActionBar!!.themedContext
31 |
32 |
33 | protected val suggestions: SearchRecentSuggestions by lazy {
34 | SearchRecentSuggestions(
35 | this,
36 | CheeseSuggestionsProvider.AUTHORITY,
37 | CheeseSuggestionsProvider.MODE
38 | )
39 | }
40 |
41 | protected val searchManager: SearchManager by lazy {
42 | getSystemService(Context.SEARCH_SERVICE) as SearchManager
43 | }
44 |
45 |
46 | override fun onCreate(savedInstanceState: Bundle?) {
47 | super.onCreate(savedInstanceState)
48 |
49 | setContentView(R.layout.activity)
50 | setSupportActionBar(toolbar)
51 | supportActionBar!!.setDisplayHomeAsUpEnabled(!isTaskRoot)
52 | }
53 |
54 |
55 | fun addButton(title: CharSequence, onClick: () -> Unit): View =
56 | Button(this).apply {
57 | text = title
58 |
59 | layoutParams = ViewGroup.LayoutParams(
60 | ViewGroup.LayoutParams.WRAP_CONTENT,
61 | ViewGroup.LayoutParams.WRAP_CONTENT)
62 |
63 | setOnClickListener {
64 | onClick()
65 | }
66 | }.also {
67 | content_container.addView(it)
68 | }
69 |
70 |
71 | fun addNote(text: String) {
72 | content_container.addView(
73 | TextView(this).apply {
74 | this.text = text
75 |
76 | layoutParams = ViewGroup.LayoutParams(
77 | ViewGroup.LayoutParams.MATCH_PARENT,
78 | ViewGroup.LayoutParams.WRAP_CONTENT
79 | )
80 | }
81 | )
82 | }
83 |
84 |
85 | override fun onNewIntent(intent: Intent) {
86 | super.onNewIntent(intent)
87 |
88 | val extras = intent.extras ?: return
89 |
90 | StringBuilder("onNewIntent():\n").apply {
91 | for (key in extras.keySet()) {
92 | append("${key} => ${extras[key]}\n")
93 | }
94 | }.toString().also {
95 | log.debug(it)
96 | Toast.makeText(this, it, Toast.LENGTH_SHORT).show()
97 | }
98 |
99 | if (extras.containsKey(SearchManager.USER_QUERY)) {
100 | val userQuery = extras[SearchManager.USER_QUERY]!!.toString()
101 | if (extras.containsKey(SearchManager.QUERY)) {
102 | val query = extras[SearchManager.QUERY]!!.toString()
103 | if (query == userQuery) {
104 | val msg = "saving user query: $userQuery to recent suggestions"
105 | log.debug(msg)
106 | Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
107 | suggestions.saveRecentQuery(userQuery, "Saved at ${Date()}")
108 | }
109 | }
110 | }
111 |
112 | closeSearchView()
113 | }
114 |
115 | /**
116 | * toolbar.collapseActionView() is enough to close any expanded action view
117 | * while content_container.requestFocus() moves the focus elsewhere so that
118 | * no parts of the action bar become highlighted when the search view is closed
119 | *
120 | */
121 | protected fun closeSearchView() {
122 | log.debug("closeSearchView()")
123 | toolbar.collapseActionView()
124 | content_container.requestFocus()
125 | }
126 |
127 | override fun onBackPressed() {
128 | super.onBackPressed()
129 | closeSearchView()
130 | }
131 |
132 | override fun onCreateOptionsMenu(menu: Menu): Boolean {
133 | // Inflate the menu; this adds items to the action bar if it is present.
134 | menuInflater.inflate(R.menu.menu, menu)
135 | this.menu = menu
136 | menu.findItem(R.id.action_search)?.let {
137 | configureSearchMenu(it)
138 | }
139 | return true
140 | }
141 |
142 | protected abstract fun configureSearchMenu(menuItem: MenuItem)
143 |
144 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
145 | // Handle action bar item clicks here. The action bar will
146 | // automatically handle clicks on the Home/Up button, so long
147 | // as you specify a parent activity in AndroidManifest.xml.
148 | return when (item.itemId) {
149 | R.id.action_about -> onAbout()
150 | android.R.id.home -> {
151 | onBackPressed(); true
152 | }
153 |
154 | else -> super.onOptionsItemSelected(item)
155 | }
156 | }
157 |
158 | protected fun onAbout(): Boolean {
159 | Snackbar.make(content_container, "On About", Snackbar.LENGTH_SHORT).show()
160 | return true
161 | }
162 | }
163 |
164 | private val log =
165 | org.slf4j.LoggerFactory.getLogger(BaseActivity::class.java)
166 |
167 |
--------------------------------------------------------------------------------
/app/src/main/java/danbroid/searchview/CheeseData.kt:
--------------------------------------------------------------------------------
1 | package danbroid.searchview
2 |
3 | import android.content.Context
4 | import android.text.TextUtils
5 | import java.io.BufferedReader
6 | import java.io.InputStreamReader
7 | import java.util.*
8 |
9 | class CheeseData(context: Context) {
10 |
11 | val cheeses: Array by lazy {
12 | val cheeseList = mutableListOf()
13 | val reader = BufferedReader(InputStreamReader(context.assets.open("cheeselist.txt")))
14 | try {
15 | reader.forEachLine {
16 | if (!TextUtils.isEmpty(it))
17 | cheeseList.add(it)
18 | }
19 | } finally {
20 | reader.close()
21 | }
22 | cheeseList.toTypedArray();
23 | }
24 |
25 |
26 | private val RANDOM = Random(System.currentTimeMillis())
27 |
28 | fun randomCheese(): String = cheeses[RANDOM.nextInt(cheeses.size)]
29 |
30 | companion object {
31 | @Volatile
32 | private var instance: CheeseData? = null
33 |
34 | fun getInstance(context: Context) = instance ?: synchronized(this) {
35 | instance ?: CheeseData(context).also {
36 | instance = it
37 | }
38 | }
39 | }
40 |
41 |
42 | }
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/java/danbroid/searchview/CheeseSuggestionsProvider.kt:
--------------------------------------------------------------------------------
1 | package danbroid.searchview
2 |
3 | import android.content.SearchRecentSuggestionsProvider
4 |
5 | class CheeseSuggestionsProvider : SearchRecentSuggestionsProvider() {
6 |
7 | companion object {
8 | val AUTHORITY = CheeseSuggestionsProvider::class.java.name
9 | val MODE = SearchRecentSuggestionsProvider.DATABASE_MODE_2LINES or SearchRecentSuggestionsProvider.DATABASE_MODE_QUERIES
10 | }
11 |
12 | init {
13 | setupSuggestions(AUTHORITY, MODE)
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/java/danbroid/searchview/activities/CustomSuggestionLayoutActivity.kt:
--------------------------------------------------------------------------------
1 | package danbroid.searchview.activities
2 |
3 | import android.app.SearchManager
4 | import android.content.Context
5 | import android.database.Cursor
6 | import android.database.MatrixCursor
7 | import android.os.AsyncTask
8 | import android.os.Bundle
9 | import android.provider.BaseColumns
10 | import android.text.TextUtils
11 | import android.view.*
12 | import android.widget.ImageView
13 | import android.widget.TextView
14 | import android.widget.Toast
15 | import androidx.appcompat.widget.SearchView
16 | import androidx.cursoradapter.widget.CursorAdapter
17 | import danbroid.searchview.BaseActivity
18 | import danbroid.searchview.R
19 |
20 |
21 | class CustomSuggestionLayoutActivity : BaseActivity() {
22 |
23 | override fun onCreate(savedInstanceState: Bundle?) {
24 | super.onCreate(savedInstanceState)
25 | addNote(
26 | "This has a search-view with a custom suggestion layout.\n" +
27 | "Type in a couple of characters to initiate a search"
28 | )
29 | }
30 |
31 | override fun configureSearchMenu(menuItem: MenuItem) {
32 |
33 |
34 | val searchView = SearchView(this).apply {
35 | setIconifiedByDefault(true)
36 | }.also {
37 | menuItem.actionView = it
38 | }
39 |
40 |
41 | searchView.suggestionsAdapter = CustomSuggestionsAdapter(this)
42 |
43 | searchView.setOnSuggestionListener(object : SearchView.OnSuggestionListener {
44 | override fun onSuggestionSelect(position: Int): Boolean {
45 | return false
46 | }
47 |
48 | override fun onSuggestionClick(position: Int): Boolean {
49 | log.debug("onSuggestionClick() position:$position")
50 |
51 | val info = with(searchView.suggestionsAdapter.cursor) {
52 | moveToPosition(position)
53 | "TITLE: ${getString(1)} SUBTITLE: ${getString(2)}"
54 | }
55 |
56 | //Do something with the selected cheese
57 | Toast.makeText(this@CustomSuggestionLayoutActivity, info, Toast.LENGTH_SHORT).show()
58 | closeSearchView()
59 |
60 |
61 | //return true to cancel the default behaviour which will submit an Intent.ACTION_SEARCH
62 | //at the activity
63 | return true
64 | }
65 | })
66 |
67 | searchView.setOnQueryTextListener(
68 | object : SearchView.OnQueryTextListener {
69 |
70 | var search: SearchTask? = null
71 |
72 | override fun onQueryTextSubmit(query: String?): Boolean {
73 | log.trace("onQueryTextSubmit() $query")
74 | return false
75 | }
76 |
77 | override fun onQueryTextChange(query: String): Boolean {
78 | log.trace("onQueryTextChange() $query")
79 | if (query.length < 3) return true
80 |
81 | search?.cancel(true)
82 |
83 | search = SearchTask {
84 | searchView.suggestionsAdapter.swapCursor(it)
85 | }
86 |
87 | return false
88 | }
89 | })
90 |
91 | }
92 |
93 | }
94 |
95 | private val log = org.slf4j.LoggerFactory.getLogger(CustomSuggestionLayoutActivity::class.java)
96 |
97 | class SearchTask(val resultsReceiver: (Cursor) -> (Unit)) : AsyncTask() {
98 |
99 | init {
100 | execute()
101 | }
102 |
103 | override fun doInBackground(vararg params: Void?): Cursor {
104 | log.trace("performing a background search ...")
105 | Thread.sleep(500)
106 | val cursor = MatrixCursor(arrayOf(
107 | BaseColumns._ID,
108 | SearchManager.SUGGEST_COLUMN_TEXT_1,
109 | SearchManager.SUGGEST_COLUMN_TEXT_2
110 | ))
111 | for (n in 1..20)
112 | cursor.addRow(arrayOf(
113 | n,
114 | "Title: $n",
115 | "Subtitle for $n"
116 | ))
117 | return cursor
118 | }
119 |
120 | override fun onPostExecute(result: Cursor) {
121 | log.trace("finished search")
122 | resultsReceiver(result)
123 | }
124 | }
125 |
126 | class CustomSuggestionsAdapter(context: Context) : CursorAdapter(context, null, 0) {
127 |
128 | val inflater by lazy {
129 | LayoutInflater.from(context)
130 | }
131 |
132 | override fun newView(context: Context, cursor: Cursor, parent: ViewGroup): View =
133 | inflater.inflate(R.layout.search_dropdown, parent, false)
134 |
135 |
136 | override fun bindView(view: View, context: Context, cursor: Cursor) {
137 | val title = cursor.getString(1)
138 | val subTitle = cursor.getString(2)
139 | val text1 = view.findViewById(android.R.id.text1)
140 | val text2 = view.findViewById(android.R.id.text2)
141 |
142 | text1.text = title
143 | text2.text = subTitle
144 | text2.visibility = if (TextUtils.isEmpty(subTitle)) View.GONE else View.VISIBLE
145 |
146 | val icon = view.findViewById(android.R.id.icon1)
147 | icon.setImageResource(R.drawable.ic_sentiment_satisfied)
148 | icon.visibility = View.VISIBLE
149 | }
150 |
151 | }
152 |
153 |
--------------------------------------------------------------------------------
/app/src/main/java/danbroid/searchview/activities/DarkDropDownActivity.kt:
--------------------------------------------------------------------------------
1 | package danbroid.searchview.activities
2 |
3 | import android.os.Bundle
4 | import android.view.MenuItem
5 | import android.widget.Toast
6 | import androidx.appcompat.widget.SearchView
7 | import danbroid.searchview.BaseActivity
8 |
9 |
10 | class DarkDropDownActivity : BaseActivity() {
11 |
12 | override fun onCreate(savedInstanceState: Bundle?) {
13 | super.onCreate(savedInstanceState)
14 |
15 |
16 | addNote(
17 | "This activity uses the CheeseRecentSuggestions provider to provide search suggestions.\n" +
18 | "You can add new suggestions to its database using the button below."
19 | )
20 |
21 | addButton("Add a suggestion") {
22 |
23 | val suggestion = cheeseData.randomCheese()
24 |
25 | Toast.makeText(this, "Adding a new suggestion: $suggestion", Toast.LENGTH_SHORT).show()
26 |
27 | suggestions.saveRecentQuery(
28 | suggestion,
29 | "(DarkDropDownActivity)"
30 | )
31 | }
32 |
33 | addButton("Clear suggestion history") {
34 | suggestions.clearHistory()
35 | }
36 | }
37 |
38 | override fun configureSearchMenu(menuItem: MenuItem) {
39 |
40 | //Creating the search view with the themedContext to create a dark search view
41 |
42 | SearchView(themedContext).apply {
43 | setIconifiedByDefault(true)
44 | setSearchableInfo(searchManager.getSearchableInfo(componentName))
45 | isSubmitButtonEnabled = true
46 |
47 | setOnQueryTextListener(object : SearchView.OnQueryTextListener {
48 | override fun onQueryTextSubmit(query: String): Boolean {
49 | log.trace("onQueryTextSubmit() $query")
50 | return false
51 | }
52 |
53 | override fun onQueryTextChange(newText: String): Boolean {
54 | isSubmitButtonEnabled = newText.length > 2
55 | return false
56 | }
57 |
58 | })
59 | }.also {
60 | menuItem.actionView = it
61 | }
62 |
63 | }
64 |
65 | }
66 |
67 | private val log =
68 | org.slf4j.LoggerFactory.getLogger(DarkDropDownActivity::class.java)
69 |
--------------------------------------------------------------------------------
/app/src/main/java/danbroid/searchview/activities/LightDropDownActivity.kt:
--------------------------------------------------------------------------------
1 | package danbroid.searchview.activities
2 |
3 | import android.os.Bundle
4 | import android.view.MenuItem
5 | import android.widget.Toast
6 | import androidx.appcompat.widget.SearchView
7 | import danbroid.searchview.BaseActivity
8 |
9 |
10 | private val log by lazy {
11 | org.slf4j.LoggerFactory.getLogger(LightDropDownActivity::class.java)
12 | }
13 |
14 | class LightDropDownActivity : BaseActivity() {
15 |
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 |
19 | addButton("Add a suggestion") {
20 |
21 | val suggestion = cheeseData.randomCheese()
22 |
23 | Toast.makeText(this, "Adding a new suggestion: $suggestion", Toast.LENGTH_SHORT).show()
24 |
25 | suggestions.saveRecentQuery(
26 | suggestion,
27 | "(LightDropDownActivity)"
28 | )
29 | }
30 |
31 | addButton("Clear suggestion history") {
32 | suggestions.clearHistory()
33 | }
34 | }
35 |
36 | override fun configureSearchMenu(menuItem: MenuItem) {
37 |
38 | //Note that we are using the activity as the context rather than the themedContext
39 |
40 | SearchView(this).apply {
41 | setIconifiedByDefault(true)
42 | setSearchableInfo(searchManager.getSearchableInfo(componentName))
43 | isSubmitButtonEnabled = true
44 |
45 | setOnQueryTextListener(object : SearchView.OnQueryTextListener {
46 | override fun onQueryTextSubmit(query: String): Boolean {
47 | log.trace("onQueryTextSubmit() $query")
48 | return false
49 | }
50 |
51 | override fun onQueryTextChange(newText: String): Boolean {
52 | isSubmitButtonEnabled = newText.length > 2
53 | return false
54 | }
55 |
56 | })
57 | }.also {
58 | menuItem.actionView = it
59 | }
60 |
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/danbroid/searchview/activities/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package danbroid.searchview.activities
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.view.MenuItem
6 | import danbroid.searchview.BaseActivity
7 |
8 |
9 | class MainActivity : BaseActivity() {
10 |
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 |
14 | addButton("Light Suggestion DropDown") {
15 | startActivity(Intent(this, LightDropDownActivity::class.java))
16 | }
17 |
18 | addButton("Dark Suggestion DropDown") {
19 | startActivity(Intent(this, DarkDropDownActivity::class.java))
20 | }
21 |
22 | addButton("Custom Suggestion DropDown") {
23 | startActivity(Intent(this, CustomSuggestionLayoutActivity::class.java))
24 | }
25 |
26 | addButton("Search Dialog") {
27 | startActivity(Intent(this, SearchDialogActivity::class.java))
28 | }
29 |
30 | /*
31 | addButton("Floating Search") {
32 | startActivity(Intent(this, FloatingSearchActivity::class.java))
33 | }*/
34 | }
35 |
36 | override fun configureSearchMenu(menuItem: MenuItem) {
37 | menuItem.isVisible = false
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/java/danbroid/searchview/activities/SearchDialogActivity.kt:
--------------------------------------------------------------------------------
1 | package danbroid.searchview.activities
2 |
3 | import android.os.Bundle
4 | import android.view.MenuItem
5 | import danbroid.searchview.BaseActivity
6 | import danbroid.searchview.R
7 |
8 |
9 | class SearchDialogActivity : BaseActivity() {
10 |
11 | override fun configureSearchMenu(menuItem: MenuItem) {
12 | }
13 |
14 | override fun onOptionsItemSelected(item: MenuItem): Boolean =
15 | when (item.itemId) {
16 | R.id.action_search -> {
17 | onSearchRequested()
18 | true
19 | }
20 | else -> super.onOptionsItemSelected(item)
21 | }
22 |
23 | override fun startSearch(initialQuery: String?, selectInitialQuery: Boolean, appSearchData: Bundle?, globalSearch: Boolean) {
24 | log.trace("startSearch() initalQuery: $initialQuery selectInitialQuery: $selectInitialQuery appSearchData: $appSearchData globalSearch: $globalSearch")
25 | super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch)
26 | }
27 |
28 | }
29 |
30 | private val log =
31 | org.slf4j.LoggerFactory.getLogger(SearchDialogActivity::class.java)
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_search.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_sentiment_satisfied.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/search_dropdown.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
23 |
24 |
26 |
36 |
37 |
47 |
48 |
58 |
59 |
60 |
62 |
74 |
75 |
77 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6d4c41
4 | #C06d4c41
5 | #40241a
6 | #ffca28
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6D4C41
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Search View Demo
3 | Settings
4 | Demo 1
5 | Search
6 | About
7 | Demo 2
8 | Demo 3
9 | Demo4
10 | Demo5
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
16 |
17 |
21 |
22 |
25 |
26 |
27 |
47 |
48 |
53 |
54 |
55 |
58 |
59 |
60 |
63 |
64 |
67 |
68 |
69 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/searchable.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
14 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | buildscript {
3 | ext.kotlin_version = '1.3.20'
4 | repositories {
5 | google()
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.4.0-beta02'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | jcenter()
18 | maven { url 'https://jitpack.io' }
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
26 | defaultTasks ':app:installRunDebug'
27 |
--------------------------------------------------------------------------------
/docs/demo1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/docs/demo1.png
--------------------------------------------------------------------------------
/docs/demo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/docs/demo2.png
--------------------------------------------------------------------------------
/docs/demo3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/docs/demo3.png
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 | KEYSTORE_PASSWORD=""
22 |
23 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danbrough/Android-SearchView-Demo/0e3fe6fbd8a9143a61dd8aa66dc7d3a1bc661ce9/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------