mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-01 19:56:47 +01:00
Support notification tab with unified overview
Closes https://github.com/SchildiChat/SchildiChat-android/issues/27. Change-Id: I828f522264aa8a3cae2becfe52805320235002dd
This commit is contained in:
parent
ed2ed5bef4
commit
6624bd4bad
@ -21,6 +21,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import com.airbnb.mvrx.activityViewModel
|
import com.airbnb.mvrx.activityViewModel
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
@ -97,15 +98,7 @@ class HomeDetailFragment @Inject constructor(
|
|||||||
setupKeysBackupBanner()
|
setupKeysBackupBanner()
|
||||||
setupActiveCallView()
|
setupActiveCallView()
|
||||||
|
|
||||||
withState(viewModel) {
|
loadNavigationView()
|
||||||
// Update the navigation view if needed (for when we restore the tabs)
|
|
||||||
if (it.displayMode == RoomListDisplayMode.ALL) {
|
|
||||||
views.bottomNavigationView.visibility = View.GONE
|
|
||||||
} else {
|
|
||||||
views.bottomNavigationView.selectedItemId = it.displayMode.toMenuId()
|
|
||||||
views.bottomNavigationView.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
viewModel.selectSubscribe(this, HomeDetailViewState::groupSummary) { groupSummary ->
|
viewModel.selectSubscribe(this, HomeDetailViewState::groupSummary) { groupSummary ->
|
||||||
onGroupChange(groupSummary.orNull())
|
onGroupChange(groupSummary.orNull())
|
||||||
@ -140,28 +133,52 @@ class HomeDetailFragment @Inject constructor(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
private fun loadNavigationView() {
|
||||||
super.onResume()
|
|
||||||
// update notification tab if needed
|
|
||||||
checkNotificationTabStatus()
|
|
||||||
// Recreate if single-mode overview status changed
|
|
||||||
withState(viewModel) {
|
withState(viewModel) {
|
||||||
if ((it.displayMode == RoomListDisplayMode.ALL) != vectorPreferences.singleOverview()) {
|
// Update the navigation view if needed (for when we restore the tabs)
|
||||||
Timber.i("Restart due to single-overview setting change")
|
if (!vectorPreferences.enableOverviewTabs()) {
|
||||||
startActivity(activity?.intent)
|
views.bottomNavigationView.isVisible = false
|
||||||
activity?.finish()
|
} else {
|
||||||
|
views.bottomNavigationView.selectedItemId = it.displayMode.toMenuId()
|
||||||
|
views.bottomNavigationView.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
// update notification tab if needed
|
||||||
|
checkNotificationTabStatus()
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkNotificationTabStatus() {
|
private fun checkNotificationTabStatus() {
|
||||||
val wasVisible = views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible
|
val wasVisible = views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible
|
||||||
|
val combinedOverview = vectorPreferences.combinedOverview()
|
||||||
|
val combinedOverviewWasVisible = views.bottomNavigationView.menu.findItem(R.id.bottom_action_all).isVisible
|
||||||
views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible = vectorPreferences.labAddNotificationTab()
|
views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible = vectorPreferences.labAddNotificationTab()
|
||||||
|
views.bottomNavigationView.menu.findItem(R.id.bottom_action_people).isVisible = !combinedOverview
|
||||||
|
views.bottomNavigationView.menu.findItem(R.id.bottom_action_rooms).isVisible = !combinedOverview
|
||||||
|
views.bottomNavigationView.menu.findItem(R.id.bottom_action_all).isVisible = combinedOverview
|
||||||
|
if (combinedOverviewWasVisible != combinedOverview) {
|
||||||
|
// As we hide it check if it's not the current item!
|
||||||
|
withState(viewModel) {
|
||||||
|
val menuId = it.displayMode.toMenuId()
|
||||||
|
if (combinedOverview) {
|
||||||
|
if (menuId == R.id.bottom_action_people || menuId == R.id.bottom_action_rooms) {
|
||||||
|
viewModel.handle(HomeDetailAction.SwitchDisplayMode(RoomListDisplayMode.ALL))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (menuId == R.id.bottom_action_all) {
|
||||||
|
viewModel.handle(HomeDetailAction.SwitchDisplayMode(RoomListDisplayMode.PEOPLE))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (wasVisible && !vectorPreferences.labAddNotificationTab()) {
|
if (wasVisible && !vectorPreferences.labAddNotificationTab()) {
|
||||||
// As we hide it check if it's not the current item!
|
// As we hide it check if it's not the current item!
|
||||||
withState(viewModel) {
|
withState(viewModel) {
|
||||||
if (it.displayMode.toMenuId() == R.id.bottom_action_notification) {
|
if (it.displayMode.toMenuId() == R.id.bottom_action_notification) {
|
||||||
if (vectorPreferences.singleOverview()) {
|
if (combinedOverview) {
|
||||||
viewModel.handle(HomeDetailAction.SwitchDisplayMode(RoomListDisplayMode.ALL))
|
viewModel.handle(HomeDetailAction.SwitchDisplayMode(RoomListDisplayMode.ALL))
|
||||||
} else {
|
} else {
|
||||||
viewModel.handle(HomeDetailAction.SwitchDisplayMode(RoomListDisplayMode.PEOPLE))
|
viewModel.handle(HomeDetailAction.SwitchDisplayMode(RoomListDisplayMode.PEOPLE))
|
||||||
@ -169,6 +186,10 @@ class HomeDetailFragment @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val wasBottomBarVisible = views.bottomNavigationView.isVisible
|
||||||
|
if (wasBottomBarVisible != vectorPreferences.enableOverviewTabs()) {
|
||||||
|
loadNavigationView()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun promptForNewUnknownDevices(uid: String, state: UnknownDevicesState, newest: DeviceInfo) {
|
private fun promptForNewUnknownDevices(uid: String, state: UnknownDevicesState, newest: DeviceInfo) {
|
||||||
@ -269,7 +290,11 @@ class HomeDetailFragment @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupBottomNavigationView() {
|
private fun setupBottomNavigationView() {
|
||||||
|
val combinedOverview = vectorPreferences.combinedOverview()
|
||||||
views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible = vectorPreferences.labAddNotificationTab()
|
views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible = vectorPreferences.labAddNotificationTab()
|
||||||
|
views.bottomNavigationView.menu.findItem(R.id.bottom_action_people).isVisible = !combinedOverview
|
||||||
|
views.bottomNavigationView.menu.findItem(R.id.bottom_action_rooms).isVisible = !combinedOverview
|
||||||
|
views.bottomNavigationView.menu.findItem(R.id.bottom_action_all).isVisible = combinedOverview
|
||||||
views.bottomNavigationView.setOnNavigationItemSelectedListener {
|
views.bottomNavigationView.setOnNavigationItemSelectedListener {
|
||||||
val displayMode = when (it.itemId) {
|
val displayMode = when (it.itemId) {
|
||||||
R.id.bottom_action_people -> RoomListDisplayMode.PEOPLE
|
R.id.bottom_action_people -> RoomListDisplayMode.PEOPLE
|
||||||
@ -333,6 +358,7 @@ class HomeDetailFragment @Inject constructor(
|
|||||||
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_people).render(it.notificationCountPeople, it.notificationHighlightPeople)
|
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_people).render(it.notificationCountPeople, it.notificationHighlightPeople)
|
||||||
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_rooms).render(it.notificationCountRooms, it.notificationHighlightRooms)
|
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_rooms).render(it.notificationCountRooms, it.notificationHighlightRooms)
|
||||||
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_notification).render(it.notificationCountCatchup, it.notificationHighlightCatchup)
|
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_notification).render(it.notificationCountCatchup, it.notificationHighlightCatchup)
|
||||||
|
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_all).render(it.notificationCountCatchup, it.notificationHighlightCatchup)
|
||||||
views.syncStateView.render(it.syncState)
|
views.syncStateView.render(it.syncState)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,6 +377,7 @@ class HomeDetailFragment @Inject constructor(
|
|||||||
private fun RoomListDisplayMode.toMenuId() = when (this) {
|
private fun RoomListDisplayMode.toMenuId() = when (this) {
|
||||||
RoomListDisplayMode.PEOPLE -> R.id.bottom_action_people
|
RoomListDisplayMode.PEOPLE -> R.id.bottom_action_people
|
||||||
RoomListDisplayMode.ROOMS -> R.id.bottom_action_rooms
|
RoomListDisplayMode.ROOMS -> R.id.bottom_action_rooms
|
||||||
|
RoomListDisplayMode.ALL -> R.id.bottom_action_all
|
||||||
else -> R.id.bottom_action_notification
|
else -> R.id.bottom_action_notification
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ import im.vector.app.core.di.DefaultSharedPreferences
|
|||||||
import im.vector.app.features.disclaimer.SHARED_PREF_KEY
|
import im.vector.app.features.disclaimer.SHARED_PREF_KEY
|
||||||
import im.vector.app.features.homeserver.ServerUrlsRepository
|
import im.vector.app.features.homeserver.ServerUrlsRepository
|
||||||
import im.vector.app.features.themes.ThemeUtils
|
import im.vector.app.features.themes.ThemeUtils
|
||||||
import io.realm.annotations.Ignore
|
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -888,9 +887,12 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SC addition
|
// SC addition
|
||||||
fun singleOverview(): Boolean {
|
fun combinedOverview(): Boolean {
|
||||||
return defaultPrefs.getBoolean(SETTINGS_SINGLE_OVERVIEW, true)
|
return defaultPrefs.getBoolean(SETTINGS_SINGLE_OVERVIEW, true)
|
||||||
}
|
}
|
||||||
|
fun enableOverviewTabs(): Boolean {
|
||||||
|
return labAddNotificationTab() || !combinedOverview()
|
||||||
|
}
|
||||||
|
|
||||||
// SC addition
|
// SC addition
|
||||||
private fun roomUnreadKind(key: String): Int {
|
private fun roomUnreadKind(key: String): Int {
|
||||||
|
@ -33,12 +33,6 @@ class VectorSettingsLabsFragment @Inject constructor(
|
|||||||
override fun bindPref() {
|
override fun bindPref() {
|
||||||
// Lab
|
// Lab
|
||||||
|
|
||||||
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB)?.let {
|
|
||||||
if (vectorPreferences.singleOverview()) {
|
|
||||||
it.parent?.removePreference(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val systemDarkThemePreTenPref = findPreference<VectorSwitchPreference>(ThemeUtils.SYSTEM_DARK_THEME_PRE_TEN)
|
val systemDarkThemePreTenPref = findPreference<VectorSwitchPreference>(ThemeUtils.SYSTEM_DARK_THEME_PRE_TEN)
|
||||||
systemDarkThemePreTenPref?.let {
|
systemDarkThemePreTenPref?.let {
|
||||||
if (ThemeUtils.darkThemeDefinitivelyPossible()) {
|
if (ThemeUtils.darkThemeDefinitivelyPossible()) {
|
||||||
|
@ -37,19 +37,26 @@ class SharedPreferencesUiStateRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getDisplayMode(): RoomListDisplayMode {
|
override fun getDisplayMode(): RoomListDisplayMode {
|
||||||
return if (vectorPreferences.singleOverview()) {
|
val result = when (sharedPreferences.getInt(KEY_DISPLAY_MODE, VALUE_DISPLAY_MODE_CATCHUP)) {
|
||||||
RoomListDisplayMode.ALL
|
|
||||||
} else {
|
|
||||||
when (sharedPreferences.getInt(KEY_DISPLAY_MODE, VALUE_DISPLAY_MODE_CATCHUP)) {
|
|
||||||
VALUE_DISPLAY_MODE_PEOPLE -> RoomListDisplayMode.PEOPLE
|
VALUE_DISPLAY_MODE_PEOPLE -> RoomListDisplayMode.PEOPLE
|
||||||
VALUE_DISPLAY_MODE_ROOMS -> RoomListDisplayMode.ROOMS
|
VALUE_DISPLAY_MODE_ROOMS -> RoomListDisplayMode.ROOMS
|
||||||
|
VALUE_DISPLAY_MODE_ALL -> RoomListDisplayMode.ALL
|
||||||
else -> if (vectorPreferences.labAddNotificationTab()) {
|
else -> if (vectorPreferences.labAddNotificationTab()) {
|
||||||
RoomListDisplayMode.NOTIFICATIONS
|
RoomListDisplayMode.NOTIFICATIONS
|
||||||
} else {
|
} else {
|
||||||
RoomListDisplayMode.PEOPLE
|
RoomListDisplayMode.PEOPLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (vectorPreferences.combinedOverview()) {
|
||||||
|
if (result == RoomListDisplayMode.PEOPLE || result == RoomListDisplayMode.ROOMS) {
|
||||||
|
return RoomListDisplayMode.ALL
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (result == RoomListDisplayMode.ALL) {
|
||||||
|
return RoomListDisplayMode.PEOPLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun storeDisplayMode(displayMode: RoomListDisplayMode) {
|
override fun storeDisplayMode(displayMode: RoomListDisplayMode) {
|
||||||
@ -58,6 +65,7 @@ class SharedPreferencesUiStateRepository @Inject constructor(
|
|||||||
when (displayMode) {
|
when (displayMode) {
|
||||||
RoomListDisplayMode.PEOPLE -> VALUE_DISPLAY_MODE_PEOPLE
|
RoomListDisplayMode.PEOPLE -> VALUE_DISPLAY_MODE_PEOPLE
|
||||||
RoomListDisplayMode.ROOMS -> VALUE_DISPLAY_MODE_ROOMS
|
RoomListDisplayMode.ROOMS -> VALUE_DISPLAY_MODE_ROOMS
|
||||||
|
RoomListDisplayMode.ALL -> VALUE_DISPLAY_MODE_ALL
|
||||||
else -> VALUE_DISPLAY_MODE_CATCHUP
|
else -> VALUE_DISPLAY_MODE_CATCHUP
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -68,5 +76,6 @@ class SharedPreferencesUiStateRepository @Inject constructor(
|
|||||||
private const val VALUE_DISPLAY_MODE_CATCHUP = 0
|
private const val VALUE_DISPLAY_MODE_CATCHUP = 0
|
||||||
private const val VALUE_DISPLAY_MODE_PEOPLE = 1
|
private const val VALUE_DISPLAY_MODE_PEOPLE = 1
|
||||||
private const val VALUE_DISPLAY_MODE_ROOMS = 2
|
private const val VALUE_DISPLAY_MODE_ROOMS = 2
|
||||||
|
private const val VALUE_DISPLAY_MODE_ALL = 42
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,12 @@
|
|||||||
android:icon="@drawable/ic_home_bottom_group"
|
android:icon="@drawable/ic_home_bottom_group"
|
||||||
android:title="@string/bottom_action_rooms" />
|
android:title="@string/bottom_action_rooms" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/bottom_action_all"
|
||||||
|
android:enabled="true"
|
||||||
|
android:icon="@drawable/ic_home_bottom_chat"
|
||||||
|
android:title="@string/bottom_action_all" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/bottom_action_notification"
|
android:id="@+id/bottom_action_notification"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user