From 4565079f29a918a71b13fab39ff97f6e13bb1f0d Mon Sep 17 00:00:00 2001 From: Amine Date: Wed, 7 Jun 2017 08:41:04 +0200 Subject: [PATCH] More filtering with the search toolbar. --- CHANGELOG.md | 4 +- app/build.gradle | 4 +- .../bou/readerforselfoss/HomeActivity.kt | 59 ++++++++++-------- .../api/selfoss/SelfossApi.kt | 16 ++--- .../api/selfoss/SelfossService.kt | 1 + .../res/drawable-hdpi/ic_action_search.png | Bin 0 -> 680 bytes .../res/drawable-mdpi/ic_action_search.png | Bin 0 -> 442 bytes .../res/drawable-xhdpi/ic_action_search.png | Bin 0 -> 634 bytes .../res/drawable-xxhdpi/ic_action_search.png | Bin 0 -> 1235 bytes .../res/drawable-xxxhdpi/ic_action_search.png | Bin 0 -> 3382 bytes app/src/main/res/menu/home_menu.xml | 6 ++ app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-nl/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 14 files changed, 56 insertions(+), 37 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_action_search.png create mode 100644 app/src/main/res/drawable-mdpi/ic_action_search.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_action_search.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_action_search.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_action_search.png diff --git a/CHANGELOG.md b/CHANGELOG.md index c081d23..5bd3df8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ -**1.5.0.3 to 1.5.0.9** +**1.5.1** - Added a drawer for filtering sources and tags. -- Fixes to the drawer. +- You can now search for items from the toolbar. **1.5.0.2** diff --git a/app/build.gradle b/app/build.gradle index fd17230..7641028 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,8 +25,8 @@ android { applicationId "apps.amine.bou.readerforselfoss" minSdkVersion 16 targetSdkVersion 25 - versionCode 1509 - versionName "1.5.0.9" + versionCode 1510 + versionName "1.5.1" // Enabling multidex support. multiDexEnabled true diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt index 39688ea..dc652d1 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt @@ -5,24 +5,19 @@ import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.graphics.Color -import android.graphics.drawable.Drawable import android.graphics.drawable.GradientDrawable import android.net.Uri import android.os.Bundle import android.preference.PreferenceManager import android.support.design.widget.CoordinatorLayout +import android.support.v4.view.MenuItemCompat import android.support.v4.widget.SwipeRefreshLayout import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.GridLayoutManager -import android.support.v7.widget.RecyclerView -import android.support.v7.widget.StaggeredGridLayoutManager -import android.support.v7.widget.Toolbar +import android.support.v7.widget.* import android.support.v7.widget.helper.ItemTouchHelper -import android.util.DisplayMetrics import android.view.Menu import android.view.MenuItem import android.view.View -import android.widget.ImageView import android.widget.Toast import apps.amine.bou.readerforselfoss.adapters.ItemCardAdapter import apps.amine.bou.readerforselfoss.adapters.ItemListAdapter @@ -37,7 +32,6 @@ import apps.amine.bou.readerforselfoss.utils.longHash import com.anupcowkur.reservoir.Reservoir import com.anupcowkur.reservoir.ReservoirGetCallback import com.anupcowkur.reservoir.ReservoirPutCallback -import com.bumptech.glide.Glide import com.crashlytics.android.answers.Answers import com.crashlytics.android.answers.InviteEvent import com.github.stkent.amplify.prompt.DefaultLayoutPromptView @@ -49,15 +43,12 @@ import com.google.firebase.remoteconfig.FirebaseRemoteConfig import com.google.gson.reflect.TypeToken import com.mikepenz.aboutlibraries.Libs import com.mikepenz.aboutlibraries.LibsBuilder -import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.materialdrawer.Drawer import com.mikepenz.materialdrawer.DrawerBuilder import com.mikepenz.materialdrawer.holder.BadgeStyle import com.mikepenz.materialdrawer.model.DividerDrawerItem -import com.mikepenz.materialdrawer.model.SecondaryDrawerItem import com.mikepenz.materialdrawer.model.PrimaryDrawerItem -import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader -import com.mikepenz.materialdrawer.util.DrawerImageLoader +import com.mikepenz.materialdrawer.model.SecondaryDrawerItem import com.roughike.bottombar.BottomBar import com.roughike.bottombar.BottomBarTab import retrofit2.Call @@ -65,9 +56,7 @@ import retrofit2.Callback import retrofit2.Response import java.lang.Exception - -class HomeActivity : AppCompatActivity() { - +class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { private val MENU_PREFERENCES = 12302 private val REQUEST_INVITE = 13231 @@ -105,6 +94,7 @@ class HomeActivity : AppCompatActivity() { private var drawer: Drawer? = null private var maybeTagFilter: Tag? = null private var maybeSourceFilter: Sources? = null + private var maybeSearchFilter: String? = null data class DrawerData(val tags: List?, val sources: List?) @@ -471,16 +461,16 @@ class HomeActivity : AppCompatActivity() { private fun getElementsAccordingToTab() { when (elementsShown) { - UNREAD_SHOWN -> getUnRead(maybeTagFilter, maybeSourceFilter) - READ_SHOWN -> getRead(maybeTagFilter, maybeSourceFilter) - FAV_SHOWN -> getStarred(maybeTagFilter, maybeSourceFilter) - else -> getUnRead(maybeTagFilter, maybeSourceFilter) + UNREAD_SHOWN -> getUnRead() + READ_SHOWN -> getRead() + FAV_SHOWN -> getStarred() + else -> getUnRead() } } - private fun getUnRead(maybeTagFilter: Tag? = null, maybeSourceFilter: Sources? = null) { + private fun getUnRead() { elementsShown = UNREAD_SHOWN - api!!.unreadItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong()).enqueue(object : Callback> { + api!!.unreadItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong(), maybeSearchFilter).enqueue(object : Callback> { override fun onResponse(call: Call>, response: Response>) { handleItemsResponse(response) } @@ -507,9 +497,9 @@ class HomeActivity : AppCompatActivity() { mSwipeRefreshLayout!!.isRefreshing = false } - private fun getRead(maybeTagFilter: Tag? = null, maybeSourceFilter: Sources? = null) { + private fun getRead() { elementsShown = READ_SHOWN - api!!.readItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong()).enqueue(object : Callback> { + api!!.readItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong(), maybeSearchFilter).enqueue(object : Callback> { override fun onResponse(call: Call>, response: Response>) { handleItemsResponse(response) } @@ -521,9 +511,9 @@ class HomeActivity : AppCompatActivity() { }) } - private fun getStarred(maybeTagFilter: Tag? = null, maybeSourceFilter: Sources? = null) { + private fun getStarred() { elementsShown = FAV_SHOWN - api!!.starredItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong()).enqueue(object : Callback> { + api!!.starredItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong(), maybeSearchFilter).enqueue(object : Callback> { override fun onResponse(call: Call>, response: Response>) { handleItemsResponse(response) } @@ -563,6 +553,11 @@ class HomeActivity : AppCompatActivity() { override fun onCreateOptionsMenu(menu: Menu): Boolean { val inflater = menuInflater inflater.inflate(R.menu.home_menu, menu) + + val searchItem = menu.findItem(R.id.action_search) + val searchView = MenuItemCompat.getActionView(searchItem) as SearchView + searchView.setOnQueryTextListener(this) + return true } @@ -690,4 +685,18 @@ class HomeActivity : AppCompatActivity() { val dpWidth = displayMetrics.widthPixels / displayMetrics.density return (dpWidth / 300).toInt() } + + override fun onQueryTextChange(p0: String?): Boolean { + if (p0.isNullOrBlank()) { + maybeSearchFilter = null + getElementsAccordingToTab() + } + return false + } + + override fun onQueryTextSubmit(p0: String?): Boolean { + maybeSearchFilter = p0 + getElementsAccordingToTab() + return false + } } diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt index baced67..a4be878 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossApi.kt @@ -72,17 +72,17 @@ class SelfossApi(c: Context) { return service.loginToSelfoss(config.userLogin, config.userPassword) } - fun readItems(tag: String?, sourceId: Long?): Call> = - getItems("read", tag, sourceId) + fun readItems(tag: String?, sourceId: Long?, search: String?): Call> = + getItems("read", tag, sourceId, search) - fun unreadItems(tag: String?, sourceId: Long?): Call> = - getItems("unread", tag, sourceId) + fun unreadItems(tag: String?, sourceId: Long?, search: String?): Call> = + getItems("unread", tag, sourceId, search) - fun starredItems(tag: String?, sourceId: Long?): Call> = - getItems("starred", tag, sourceId) + fun starredItems(tag: String?, sourceId: Long?, search: String?): Call> = + getItems("starred", tag, sourceId, search) - private fun getItems(type: String, tag: String?, sourceId: Long?): Call> { - return service.getItems(type, tag, sourceId, userName, password) + private fun getItems(type: String, tag: String?, sourceId: Long?, search: String?): Call> { + return service.getItems(type, tag, sourceId, search, userName, password) } fun markItem(itemId: String): Call { diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossService.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossService.kt index 3b48401..4b0f2f0 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossService.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/api/selfoss/SelfossService.kt @@ -19,6 +19,7 @@ internal interface SelfossService { fun getItems(@Query("type") type: String, @Query("tag") tag: String?, @Query("source") source: Long?, + @Query("search") search: String?, @Query("username") username: String, @Query("password") password: String): Call> diff --git a/app/src/main/res/drawable-hdpi/ic_action_search.png b/app/src/main/res/drawable-hdpi/ic_action_search.png new file mode 100644 index 0000000000000000000000000000000000000000..45c099ab81cefef3615fdab3b12c56f610bc494e GIT binary patch literal 680 zcmV;Z0$2TsP)0wLmIZ zSPnG{RFbjK!vjG`9+0Jig^oz(>C?jlZAh7y8d1)RRGOvG!vhPUmYt(w(f1x|W-~oJ zP>fV@Q6tSF=c!nFc)*^@X*LAOJY#xzfDefOK`l(Cf`wgBv;ILVNV?PmH=veYgSKzT zwM-I--$KpWPS1)g3@O@sD6nh`Qs^7dyD_%{YWZJiz97}2RHQ&yG7zm%VIY1Eb-)j3 zjmk`9LvRvOJ_3Qff$9&q0`W&Aha87?VpwqW1>Ax77M32`A0Unxs4k@(5br^A5U7qg z3B=QYcrFlMKt#TE6I$f11L9U7j>J;z3PYPE*g(-x8Q4n36Jy0g!2?|cl3mGQ_ka`- zKOo?V(!oA9sz8J%$_D%3t|AaWB;bkM!9F^z2rX)HftQ2b0}RlCE?k~iJ5=TeKm*2) z(HwsQi1~-o1cx$G#y&=j;|Jpm4I2=fkTUc*I>j{Vfl&{PdSKK86kz}jv(&e@p@UEW O0000As=7=}ZIB1OTWbP(#;b}Q6Hqz=W}{snPRI!OmXaB=nz*tugT7wO>Y;!wv98AaN$ zSQi~^p^EVhz5xkJa^;IU7sN!5Mh!jb0*?E zu&n!Gt{bb(U7RE01xepFLyi*C0{7roMZ$|R>u!TYew#JnE%>oXw6k07*qoM6N<$g0us{$N&HU literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_action_search.png b/app/src/main/res/drawable-xhdpi/ic_action_search.png new file mode 100644 index 0000000000000000000000000000000000000000..079c9a383fa9b73010e723540b5e9d3c79b44b3e GIT binary patch literal 634 zcmV-=0)_pFP)Y#%-b*os4 zNNa6;fh!!3lq4iqUUDz+5eUiU-IvSda`!4h5L9%g!U9+T3t#~(fCaDs7Qh1XqY5}c z2k?ObFcEuS9CyTdr4nEPePA9W+vehYtLOr1KrhI)^+Y*^6Ho_+5fvH(9^e8^pdt3I zI6jWJW+=)ljDQv}LzNhb<3`N2hB$A8uAhnH?W217r6a`oj%|6e7@atev6VOK;o|$t%Ch8dblmt}KAV*bi z-9m$AO+P_ETAdf zYd}T7L<*{*SU^L%*N^Tk;6?X7z|;LJaIX6};6&$<;2*G~^S{8o&VPdw)lZ-Le89EN zGeY6uXH(ZX!Nu0raaMTc5-6<;jFt##OVZZLxH2>au7C~T0QibH=Mne>-hiXBtPL)P z)VrvhW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png b/app/src/main/res/drawable-xxxhdpi/ic_action_search.png new file mode 100644 index 0000000000000000000000000000000000000000..aa17f3137460c22cdf44fa2194351ff9064837a5 GIT binary patch literal 3382 zcmai%`9Bkm=1iESNDDU20B{zZCD}0 z+*egUN3GO2BrEhK&PR$hthaQ}F#6WZAtiG8i7XW^2&(lnz$9QO&vImRwkEBlt_TraVyD+t%HN=r+JtNvr5I#_b+^W^|4i0iC+2A-Hov7w8YYD&WBST5^opXolDgwRFIymY6qOd*>8?|AUo8!4CU? zHwxB23MJ@{_JPHLf#LKfJx;w0ezq#|@O~nw;WZte%qRKT4P0|uj_t#sq8s_ag>Nv? zM;hu*s{AMi=8k!_9m$xyt9hvn*!}QM1i!&`?dwRRILHYR_OKpDEBL~cr4fGf#OZgN zDn%M&(?{c1o;W@Hu01$wt=*K+o;#q(*XyLuh!L?tV)RfEkm)*-W20>T%fR| zG2bkSmyetatW@qkcAeq>%KmGEPQLnbKPLLn<6-5DNGNTqK`(iY&Au>9)f#*I!P!UC z$$UmVVgV}o5cfBSMMDwdmR@L(=v>1Pwl6N`#fQ{{Cbq{C%-FUXMeG+4J303lT_XAJ z@v3(dgnw-==uUC|;!^RfB$RZj&hCyL&r_XfJGfWkiIxv)M9(v3GUpE9LSH zI8TNjYyY^5J_N=2>pf5vEGm63_`mB0gtNVS^Wb3Z33^YGs8L_|f>&{{*5xNxjMV_t zM^>bT<=BOZ0JQ6^Niu*@tVdso96xyN%yV-&zp_P$mLV?!pq97ZB*?OsZLOoN$=}joI1{k z@Y;^H_T-+_@Rnq-f*bD69oZ98#>H7Ba619*pfu}|Zq-bDp6TsMCwZTtXY-AkIHUDu zmjil#KL=wy|9l8lIX{8`?7SabgpheAqDHiLOLHUAxhOu>2-`2ZH-RlrvtAsnfa(Mc zW2VxgzNjmRi@X8)))()#RJB|wg&Kn%(z}~e_=g)kTJg)~_wLgYD(`@+0j(Olc49?C zFRzyBCYYD!>6hxS%gf2@mmZJ#Uec4;f(Y`$MIiX9YaPE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*JI2bAP zWa|7ow{&D$0ZqpOkYC|o$0Cz5Bp}xWvV?#YU|+7GNcvx{qI%lDEnN50d`4^!Sji(j z--KTP4nJP0(nxwTpCCZY$Q8PV!7h%(*u#SzFu+Sjb4JglEl|2?6Yf>tras}}a7^xO z`s<6N&j`ijVq73gniQ*M01=c{WmJz^zU~ z4Or4z4j77%0sE97&)PSpTTDikvGIyYGipqq#GCEube(>k5#8@<0Oj3WZALXKyghL( zH?9X<*W$ZhjhM@wTB`T5Nzmu?$ip36da_j|OSlKI*t|NT2rIKk7CH7ZwB@hlco@un t46k4sDc+O literal 0 HcmV?d00001 diff --git a/app/src/main/res/menu/home_menu.xml b/app/src/main/res/menu/home_menu.xml index f9d4199..bdf0335 100644 --- a/app/src/main/res/menu/home_menu.xml +++ b/app/src/main/res/menu/home_menu.xml @@ -2,6 +2,12 @@ + + Pas de tags chargés Pas de sources chargés Chargement … + Rechercher \ No newline at end of file diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index ddf1f08..41990e5 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -114,4 +114,5 @@ No tags loaded No sources loaded Loading … + Zoeken \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 644a88c..08e6bd6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -116,4 +116,5 @@ No tags loaded No sources loaded Loading … + Search \ No newline at end of file