Add hidden tags option (#212)

* Add filter for hidden tags. (#207)

This commit adds the option to configure hidden tags. Articles tagged
with these hidden tags won't appear in the list of articles by default.
To see these articles the user must explicitly filter by those tags.

* Closes #211. Handling hidden tags in the lateral panel.

* Changelog.
This commit is contained in:
Amine Bou 2018-08-02 22:04:15 +02:00 committed by GitHub
parent 361eea9a06
commit f57ec1f6c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 127 additions and 19 deletions

View File

@ -1,5 +1,7 @@
**1.6.x**
- Handling hidden tags.
- Fixed pre-lolipop issue with automatic theme changes.
- Removed all Build config things.

View File

@ -30,16 +30,13 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
repositories {
}
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.1'
defaultConfig {
applicationId "apps.amine.bou.readerforselfoss"
minSdkVersion 16
@ -93,11 +90,8 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.1'
// Espresso-intents for validation and stubbing of Intents
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Android Support
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
@ -143,8 +137,7 @@ dependencies {
// Themes
implementation 'com.52inc:scoops:1.0.0'
implementation'com.jrummyapps:colorpicker:2.1.7'
implementation 'com.jrummyapps:colorpicker:2.1.7'
implementation 'com.github.rubensousa:floatingtoolbar:1.5.1'
// Pager
@ -153,8 +146,8 @@ dependencies {
implementation 'androidx.core:core-ktx:0.3'
// Crash
implementation "ch.acra:acra-http:5.1.3"
implementation "ch.acra:acra-dialog:5.1.3"
implementation 'ch.acra:acra-http:5.1.3'
implementation 'ch.acra:acra-dialog:5.1.3'
}

View File

@ -74,6 +74,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
private val MENU_PREFERENCES = 12302
private val DRAWER_ID_TAGS = 100101L
private val DRAWER_ID_HIDDEN_TAGS = 101100L
private val DRAWER_ID_SOURCES = 100110L
private val DRAWER_ID_FILTERS = 100111L
private val UNREAD_SHOWN = 1
@ -101,6 +102,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
private var displayAccountHeader: Boolean = false
private var infiniteScroll: Boolean = false
private var lastFetchDone: Boolean = false
private var hiddenTags: List<String> = emptyList()
private lateinit var tabNewBadge: TextBadgeItem
@ -186,8 +188,8 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
}
if (sharedPref.getString("acra.user.email", "").isNotEmpty()) {
sharedEditor.remove("acra.user.email");
sharedEditor.commit();
sharedEditor.remove("acra.user.email")
sharedEditor.commit()
}
}
@ -343,14 +345,14 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
// TODO: Make this the only appcolors init
appColors = AppColors(this@HomeActivity)
handleDrawerItems()
sharedPref = PreferenceManager.getDefaultSharedPreferences(this)
editor = settings.edit()
handleSharedPrefs()
handleDrawerItems()
handleThemeUpdate()
reloadLayoutManager()
@ -387,6 +389,11 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
userIdentifier = sharedPref.getString("unique_id", "")
displayAccountHeader = sharedPref.getBoolean("account_header_displaying", false)
infiniteScroll = sharedPref.getBoolean("infinite_loading", false)
hiddenTags = if (sharedPref.getString("hidden_tags", "").isNotEmpty()) {
sharedPref.getString("hidden_tags", "").replace("\\s".toRegex(), "").split(",")
} else {
emptyList()
}
}
private fun handleThemeBinding() {
@ -515,6 +522,52 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
}
}
fun handleHiddenTags(maybeTags: List<Tag>?) {
if (maybeTags == null) {
if (loadedFromCache) {
drawer.addItem(
SecondaryDrawerItem()
.withName(getString(R.string.drawer_error_loading_tags))
.withSelectable(false)
)
}
} else {
val actualTags: List<Tag> = maybeTags.filter { hiddenTags.contains(it.tag) }
tagsBadge = actualTags.map {
val gd = GradientDrawable()
val color = try {
Color.parseColor(it.color)
} catch (e: IllegalArgumentException) {
appColors.colorPrimary
}
gd.setColor(color)
gd.shape = GradientDrawable.RECTANGLE
gd.setSize(30, 30)
gd.cornerRadius = 30F
drawer.addItem(
PrimaryDrawerItem()
.withName(it.tag)
.withIdentifier(it.tag.longHash())
.withIcon(gd)
.withBadge("${it.unread}")
.withBadgeStyle(
BadgeStyle().withTextColor(Color.WHITE)
.withColor(appColors.colorAccent)
)
.withOnDrawerItemClickListener { _, _, _ ->
allItems = ArrayList()
maybeTagFilter = it
getElementsAccordingToTab()
false
}
)
(it.tag.longHash() to it.unread)
}.toMap()
}
}
fun handleSources(maybeSources: List<Sources>?) {
if (maybeSources == null) {
if (loadedFromCache) {
@ -566,6 +619,16 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
.withSelectable(false)
)
handleTags(maybeDrawerData.tags)
if (hiddenTags.isNotEmpty()) {
drawer.addItem(DividerDrawerItem())
drawer.addItem(
SecondaryDrawerItem()
.withName(getString(R.string.drawer_item_hidden_tags))
.withIdentifier(DRAWER_ID_HIDDEN_TAGS)
.withSelectable(false)
)
handleHiddenTags(maybeDrawerData.tags)
}
drawer.addItem(DividerDrawerItem())
drawer.addItem(
SecondaryDrawerItem()
@ -819,6 +882,11 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
}
}
private fun filter(tags: String): Boolean {
val tagsList = tags.replace("\\s".toRegex(), "").split(",")
return tagsList.intersect(hiddenTags).isEmpty()
}
private fun doCallTo(
appendResults: Boolean,
toastMessage: Int,
@ -829,6 +897,9 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
if (response.body() != null) {
if (shouldUpdate) {
items = response.body() as ArrayList<Item>
items = items.filter {
maybeTagFilter != null || filter(it.tags)
} as ArrayList<Item>
if (allItems.isEmpty()) {
allItems = items

View File

@ -181,6 +181,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}
}
});
}
@Override

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Informes d\'error</string>
<string name="pref_debug_debug_logs">Registre de depuració (s\'enviarà automàticament)</string>
<string name="acra_login">Habilita el registre</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Informe de fallos</string>
<string name="pref_debug_debug_logs">Registro de depuración (éstos se enviarán sin diálogo)</string>
<string name="acra_login">Habilitar el registro</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Rapport d\'erreur</string>
<string name="pref_debug_debug_logs">Log de debug (seront envoyés automatiquement)</string>
<string name="acra_login">Activer les logs</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Informes de erros</string>
<string name="pref_debug_debug_logs">Rexistro de depuración (Estes enviaranse automáticamente)</string>
<string name="acra_login">Habilitar o rexistro</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Relatório de erro</string>
<string name="pref_debug_debug_logs">Log de depuração (Serão enviados sem uma caixa de diálogo)</string>
<string name="acra_login">Ativar registro de erros</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -166,4 +166,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -127,6 +127,7 @@
<string name="self_signed_cert_warning">Due to security reasons, self signed certificates are not supported by default. By activating this, I\'ll not be responsible of any security problem you encounter.</string>
<string name="pref_selfoss_category">Selfoss Api</string>
<string name="pref_api_items_number_title">Loaded items number</string>
<string name="pref_hidden_tags">Hidden tags.</string>
<string name="read_debug_title">Read articles appearing as unread ?</string>
<string name="read_debug_off">No log when marking an item as read</string>
<string name="read_debug_on">Api calls will be logged when marking an article as read</string>
@ -169,4 +170,5 @@
<string name="pref_debug_crash_reports">Crash reports</string>
<string name="pref_debug_debug_logs">Debug logging (these will be sent without a dialog)</string>
<string name="acra_login">Enable logging</string>
<string name="drawer_item_hidden_tags">Hidden Tags</string>
</resources>

View File

@ -12,6 +12,14 @@
android:singleLine="true"
android:title="@string/pref_api_items_number_title" />
<EditTextPreference
android:defaultValue=""
android:hint="@string/add_source_hint_tags"
android:key="hidden_tags"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/pref_hidden_tags" />
<SwitchPreference
android:defaultValue="false"
android:key="infinite_loading"