Add "Toggle notifications filter" to tab action
This commit is contained in:
parent
e48d53f93f
commit
db677c5bb8
|
@ -60,6 +60,7 @@ import com.keylesspalace.tusky.components.scheduled.ScheduledTootActivity
|
|||
import com.keylesspalace.tusky.components.search.SearchActivity
|
||||
import com.keylesspalace.tusky.db.AccountEntity
|
||||
import com.keylesspalace.tusky.entity.Account
|
||||
import com.keylesspalace.tusky.fragment.NotificationsFragment
|
||||
import com.keylesspalace.tusky.fragment.SFragment
|
||||
import com.keylesspalace.tusky.interfaces.AccountSelectionListener
|
||||
import com.keylesspalace.tusky.interfaces.ActionButtonActivity
|
||||
|
@ -199,6 +200,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
|||
@SuppressLint("RestrictedApi")
|
||||
if (popup.menu is MenuBuilder) {
|
||||
val menuBuilder = popup.menu as MenuBuilder
|
||||
if (tab.position == notificationTabPosition) {
|
||||
menuBuilder.findItem(R.id.tabToggleNotificationsFilter).isVisible = true
|
||||
}
|
||||
menuBuilder.setOptionalIconsVisible(true)
|
||||
menuBuilder.visibleItems.forEach { item ->
|
||||
val iconMarginPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8f, resources.displayMetrics).toInt()
|
||||
|
@ -220,15 +224,26 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
|||
|
||||
popup.setOnMenuItemClickListener { item ->
|
||||
val fragment = adapter?.getFragment(tab.position)
|
||||
if (fragment is ReselectableFragment) {
|
||||
when (item.itemId) {
|
||||
R.id.tabJumpToTop -> {
|
||||
when (item.itemId) {
|
||||
R.id.tabJumpToTop -> {
|
||||
if (fragment is ReselectableFragment) {
|
||||
(fragment as ReselectableFragment).onReselect()
|
||||
}
|
||||
R.id.tabReset -> {
|
||||
}
|
||||
R.id.tabReset -> {
|
||||
if (fragment is ReselectableFragment) {
|
||||
(fragment as ReselectableFragment).onReset()
|
||||
}
|
||||
}
|
||||
R.id.tabToggleNotificationsFilter -> {
|
||||
if (fragment is NotificationsFragment) {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
prefs.edit().putBoolean("showNotificationsFilter",
|
||||
!prefs.getBoolean("showNotificationsFilter", true))
|
||||
.apply()
|
||||
eventHub.dispatch(PreferenceChangedEvent("showNotificationsFilter"))
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
|
|
@ -9,4 +9,9 @@
|
|||
android:icon="@drawable/ic_reject_24dp"
|
||||
android:title="@string/action_tab_reset" />
|
||||
|
||||
<item android:id="@+id/tabToggleNotificationsFilter"
|
||||
android:icon="@drawable/ic_notifications_24dp"
|
||||
android:title="@string/action_tab_toggle_notifications_filter"
|
||||
android:visible="false" />
|
||||
|
||||
</menu>
|
||||
|
|
|
@ -144,6 +144,7 @@
|
|||
<string name="action_authorize">Authorize Now!</string>
|
||||
<string name="action_tab_jump_to_top">Jump to top</string>
|
||||
<string name="action_tab_reset">Reset tab</string>
|
||||
<string name="action_tab_toggle_notifications_filter">Toggle notifications filter</string>
|
||||
|
||||
<string name="title_hashtags_dialog">Hashtags</string>
|
||||
<string name="title_mentions_dialog">Mentions</string>
|
||||
|
|
Loading…
Reference in New Issue