More filtering with the search toolbar.
This commit is contained in:
parent
3482092cb2
commit
4565079f29
@ -1,8 +1,8 @@
|
|||||||
**1.5.0.3 to 1.5.0.9**
|
**1.5.1**
|
||||||
|
|
||||||
- Added a drawer for filtering sources and tags.
|
- 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**
|
**1.5.0.2**
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ android {
|
|||||||
applicationId "apps.amine.bou.readerforselfoss"
|
applicationId "apps.amine.bou.readerforselfoss"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 1509
|
versionCode 1510
|
||||||
versionName "1.5.0.9"
|
versionName "1.5.1"
|
||||||
|
|
||||||
// Enabling multidex support.
|
// Enabling multidex support.
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
@ -5,24 +5,19 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.preference.PreferenceManager
|
import android.preference.PreferenceManager
|
||||||
import android.support.design.widget.CoordinatorLayout
|
import android.support.design.widget.CoordinatorLayout
|
||||||
|
import android.support.v4.view.MenuItemCompat
|
||||||
import android.support.v4.widget.SwipeRefreshLayout
|
import android.support.v4.widget.SwipeRefreshLayout
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.support.v7.widget.GridLayoutManager
|
import android.support.v7.widget.*
|
||||||
import android.support.v7.widget.RecyclerView
|
|
||||||
import android.support.v7.widget.StaggeredGridLayoutManager
|
|
||||||
import android.support.v7.widget.Toolbar
|
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper
|
import android.support.v7.widget.helper.ItemTouchHelper
|
||||||
import android.util.DisplayMetrics
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import apps.amine.bou.readerforselfoss.adapters.ItemCardAdapter
|
import apps.amine.bou.readerforselfoss.adapters.ItemCardAdapter
|
||||||
import apps.amine.bou.readerforselfoss.adapters.ItemListAdapter
|
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.Reservoir
|
||||||
import com.anupcowkur.reservoir.ReservoirGetCallback
|
import com.anupcowkur.reservoir.ReservoirGetCallback
|
||||||
import com.anupcowkur.reservoir.ReservoirPutCallback
|
import com.anupcowkur.reservoir.ReservoirPutCallback
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.crashlytics.android.answers.Answers
|
import com.crashlytics.android.answers.Answers
|
||||||
import com.crashlytics.android.answers.InviteEvent
|
import com.crashlytics.android.answers.InviteEvent
|
||||||
import com.github.stkent.amplify.prompt.DefaultLayoutPromptView
|
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.google.gson.reflect.TypeToken
|
||||||
import com.mikepenz.aboutlibraries.Libs
|
import com.mikepenz.aboutlibraries.Libs
|
||||||
import com.mikepenz.aboutlibraries.LibsBuilder
|
import com.mikepenz.aboutlibraries.LibsBuilder
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
|
||||||
import com.mikepenz.materialdrawer.Drawer
|
import com.mikepenz.materialdrawer.Drawer
|
||||||
import com.mikepenz.materialdrawer.DrawerBuilder
|
import com.mikepenz.materialdrawer.DrawerBuilder
|
||||||
import com.mikepenz.materialdrawer.holder.BadgeStyle
|
import com.mikepenz.materialdrawer.holder.BadgeStyle
|
||||||
import com.mikepenz.materialdrawer.model.DividerDrawerItem
|
import com.mikepenz.materialdrawer.model.DividerDrawerItem
|
||||||
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem
|
|
||||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem
|
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem
|
||||||
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
|
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem
|
||||||
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
|
||||||
import com.roughike.bottombar.BottomBar
|
import com.roughike.bottombar.BottomBar
|
||||||
import com.roughike.bottombar.BottomBarTab
|
import com.roughike.bottombar.BottomBarTab
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
@ -65,9 +56,7 @@ import retrofit2.Callback
|
|||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
|
class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||||
class HomeActivity : AppCompatActivity() {
|
|
||||||
|
|
||||||
|
|
||||||
private val MENU_PREFERENCES = 12302
|
private val MENU_PREFERENCES = 12302
|
||||||
private val REQUEST_INVITE = 13231
|
private val REQUEST_INVITE = 13231
|
||||||
@ -105,6 +94,7 @@ class HomeActivity : AppCompatActivity() {
|
|||||||
private var drawer: Drawer? = null
|
private var drawer: Drawer? = null
|
||||||
private var maybeTagFilter: Tag? = null
|
private var maybeTagFilter: Tag? = null
|
||||||
private var maybeSourceFilter: Sources? = null
|
private var maybeSourceFilter: Sources? = null
|
||||||
|
private var maybeSearchFilter: String? = null
|
||||||
|
|
||||||
data class DrawerData(val tags: List<Tag>?, val sources: List<Sources>?)
|
data class DrawerData(val tags: List<Tag>?, val sources: List<Sources>?)
|
||||||
|
|
||||||
@ -471,16 +461,16 @@ class HomeActivity : AppCompatActivity() {
|
|||||||
private fun getElementsAccordingToTab() {
|
private fun getElementsAccordingToTab() {
|
||||||
|
|
||||||
when (elementsShown) {
|
when (elementsShown) {
|
||||||
UNREAD_SHOWN -> getUnRead(maybeTagFilter, maybeSourceFilter)
|
UNREAD_SHOWN -> getUnRead()
|
||||||
READ_SHOWN -> getRead(maybeTagFilter, maybeSourceFilter)
|
READ_SHOWN -> getRead()
|
||||||
FAV_SHOWN -> getStarred(maybeTagFilter, maybeSourceFilter)
|
FAV_SHOWN -> getStarred()
|
||||||
else -> getUnRead(maybeTagFilter, maybeSourceFilter)
|
else -> getUnRead()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getUnRead(maybeTagFilter: Tag? = null, maybeSourceFilter: Sources? = null) {
|
private fun getUnRead() {
|
||||||
elementsShown = UNREAD_SHOWN
|
elementsShown = UNREAD_SHOWN
|
||||||
api!!.unreadItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong()).enqueue(object : Callback<List<Item>> {
|
api!!.unreadItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong(), maybeSearchFilter).enqueue(object : Callback<List<Item>> {
|
||||||
override fun onResponse(call: Call<List<Item>>, response: Response<List<Item>>) {
|
override fun onResponse(call: Call<List<Item>>, response: Response<List<Item>>) {
|
||||||
handleItemsResponse(response)
|
handleItemsResponse(response)
|
||||||
}
|
}
|
||||||
@ -507,9 +497,9 @@ class HomeActivity : AppCompatActivity() {
|
|||||||
mSwipeRefreshLayout!!.isRefreshing = false
|
mSwipeRefreshLayout!!.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRead(maybeTagFilter: Tag? = null, maybeSourceFilter: Sources? = null) {
|
private fun getRead() {
|
||||||
elementsShown = READ_SHOWN
|
elementsShown = READ_SHOWN
|
||||||
api!!.readItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong()).enqueue(object : Callback<List<Item>> {
|
api!!.readItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong(), maybeSearchFilter).enqueue(object : Callback<List<Item>> {
|
||||||
override fun onResponse(call: Call<List<Item>>, response: Response<List<Item>>) {
|
override fun onResponse(call: Call<List<Item>>, response: Response<List<Item>>) {
|
||||||
handleItemsResponse(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
|
elementsShown = FAV_SHOWN
|
||||||
api!!.starredItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong()).enqueue(object : Callback<List<Item>> {
|
api!!.starredItems(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong(), maybeSearchFilter).enqueue(object : Callback<List<Item>> {
|
||||||
override fun onResponse(call: Call<List<Item>>, response: Response<List<Item>>) {
|
override fun onResponse(call: Call<List<Item>>, response: Response<List<Item>>) {
|
||||||
handleItemsResponse(response)
|
handleItemsResponse(response)
|
||||||
}
|
}
|
||||||
@ -563,6 +553,11 @@ class HomeActivity : AppCompatActivity() {
|
|||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
val inflater = menuInflater
|
val inflater = menuInflater
|
||||||
inflater.inflate(R.menu.home_menu, menu)
|
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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,4 +685,18 @@ class HomeActivity : AppCompatActivity() {
|
|||||||
val dpWidth = displayMetrics.widthPixels / displayMetrics.density
|
val dpWidth = displayMetrics.widthPixels / displayMetrics.density
|
||||||
return (dpWidth / 300).toInt()
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,17 +72,17 @@ class SelfossApi(c: Context) {
|
|||||||
return service.loginToSelfoss(config.userLogin, config.userPassword)
|
return service.loginToSelfoss(config.userLogin, config.userPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun readItems(tag: String?, sourceId: Long?): Call<List<Item>> =
|
fun readItems(tag: String?, sourceId: Long?, search: String?): Call<List<Item>> =
|
||||||
getItems("read", tag, sourceId)
|
getItems("read", tag, sourceId, search)
|
||||||
|
|
||||||
fun unreadItems(tag: String?, sourceId: Long?): Call<List<Item>> =
|
fun unreadItems(tag: String?, sourceId: Long?, search: String?): Call<List<Item>> =
|
||||||
getItems("unread", tag, sourceId)
|
getItems("unread", tag, sourceId, search)
|
||||||
|
|
||||||
fun starredItems(tag: String?, sourceId: Long?): Call<List<Item>> =
|
fun starredItems(tag: String?, sourceId: Long?, search: String?): Call<List<Item>> =
|
||||||
getItems("starred", tag, sourceId)
|
getItems("starred", tag, sourceId, search)
|
||||||
|
|
||||||
private fun getItems(type: String, tag: String?, sourceId: Long?): Call<List<Item>> {
|
private fun getItems(type: String, tag: String?, sourceId: Long?, search: String?): Call<List<Item>> {
|
||||||
return service.getItems(type, tag, sourceId, userName, password)
|
return service.getItems(type, tag, sourceId, search, userName, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun markItem(itemId: String): Call<SuccessResponse> {
|
fun markItem(itemId: String): Call<SuccessResponse> {
|
||||||
|
@ -19,6 +19,7 @@ internal interface SelfossService {
|
|||||||
fun getItems(@Query("type") type: String,
|
fun getItems(@Query("type") type: String,
|
||||||
@Query("tag") tag: String?,
|
@Query("tag") tag: String?,
|
||||||
@Query("source") source: Long?,
|
@Query("source") source: Long?,
|
||||||
|
@Query("search") search: String?,
|
||||||
@Query("username") username: String,
|
@Query("username") username: String,
|
||||||
@Query("password") password: String): Call<List<Item>>
|
@Query("password") password: String): Call<List<Item>>
|
||||||
|
|
||||||
|
BIN
app/src/main/res/drawable-hdpi/ic_action_search.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 680 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_search.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 442 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_search.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 634 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_search.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_action_search.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
@ -2,6 +2,12 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item android:id="@+id/action_search"
|
||||||
|
android:title="@string/menu_home_search"
|
||||||
|
android:icon="@drawable/ic_action_search"
|
||||||
|
app:showAsAction="ifRoom|collapseActionView"
|
||||||
|
app:actionViewClass="android.support.v7.widget.SearchView" />
|
||||||
|
|
||||||
<item android:id="@+id/readAll"
|
<item android:id="@+id/readAll"
|
||||||
android:icon="@drawable/ic_done_all_white_24dp"
|
android:icon="@drawable/ic_done_all_white_24dp"
|
||||||
android:title="@string/readAll"
|
android:title="@string/readAll"
|
||||||
|
@ -114,4 +114,5 @@
|
|||||||
<string name="no_tags_loaded">Pas de tags chargés</string>
|
<string name="no_tags_loaded">Pas de tags chargés</string>
|
||||||
<string name="no_sources_loaded">Pas de sources chargés</string>
|
<string name="no_sources_loaded">Pas de sources chargés</string>
|
||||||
<string name="drawer_loading">Chargement …</string>
|
<string name="drawer_loading">Chargement …</string>
|
||||||
|
<string name="menu_home_search">Rechercher</string>
|
||||||
</resources>
|
</resources>
|
@ -114,4 +114,5 @@
|
|||||||
<string name="no_tags_loaded">No tags loaded</string>
|
<string name="no_tags_loaded">No tags loaded</string>
|
||||||
<string name="no_sources_loaded">No sources loaded</string>
|
<string name="no_sources_loaded">No sources loaded</string>
|
||||||
<string name="drawer_loading">Loading …</string>
|
<string name="drawer_loading">Loading …</string>
|
||||||
|
<string name="menu_home_search">Zoeken</string>
|
||||||
</resources>
|
</resources>
|
@ -116,4 +116,5 @@
|
|||||||
<string name="no_tags_loaded">No tags loaded</string>
|
<string name="no_tags_loaded">No tags loaded</string>
|
||||||
<string name="no_sources_loaded">No sources loaded</string>
|
<string name="no_sources_loaded">No sources loaded</string>
|
||||||
<string name="drawer_loading">Loading …</string>
|
<string name="drawer_loading">Loading …</string>
|
||||||
|
<string name="menu_home_search">Search</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user