Make single overview page optional

Allow tabbed layout like element
This commit is contained in:
SpiritCroc 2020-08-06 17:18:12 +02:00
parent 2712ff9d84
commit f0f7ef4dd8
8 changed files with 64 additions and 19 deletions

View File

@ -90,8 +90,12 @@ class HomeDetailFragment @Inject constructor(
withState(viewModel) {
// Update the navigation view if needed (for when we restore the tabs)
//bottomNavigationView.selectedItemId = it.displayMode.toMenuId()
bottomNavigationView.visibility = View.GONE
if (it.displayMode == RoomListDisplayMode.ALL) {
bottomNavigationView.visibility = View.GONE
} else {
bottomNavigationView.selectedItemId = it.displayMode.toMenuId()
bottomNavigationView.visibility = View.VISIBLE
}
}
viewModel.selectSubscribe(this, HomeDetailViewState::groupSummary) { groupSummary ->
@ -131,6 +135,14 @@ class HomeDetailFragment @Inject constructor(
super.onResume()
// update notification tab if needed
checkNotificationTabStatus()
// Recreate if single-mode overview status changed
withState(viewModel) {
if ((it.displayMode == RoomListDisplayMode.ALL) != vectorPreferences.singleOverview()) {
Timber.i("Restart due to single-overview setting change")
startActivity(activity?.intent)
activity?.finish()
}
}
}
private fun checkNotificationTabStatus() {

View File

@ -30,6 +30,7 @@ import im.vector.matrix.rx.rx
import im.vector.riotx.core.extensions.exhaustive
import im.vector.riotx.core.platform.VectorViewModel
import im.vector.riotx.core.utils.DataSource
import im.vector.riotx.features.home.RoomListDisplayMode
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
import javax.inject.Inject
@ -217,6 +218,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
val favourites = ArrayList<RoomSummary>()
val directChats = ArrayList<RoomSummary>(rooms.size)
val groupRooms = ArrayList<RoomSummary>(rooms.size)
val normalPriority = ArrayList<RoomSummary>(rooms.size)
val lowPriorities = ArrayList<RoomSummary>()
val serverNotices = ArrayList<RoomSummary>()
@ -229,15 +231,25 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
tags.contains(RoomTag.ROOM_TAG_SERVER_NOTICE) -> serverNotices.add(room)
tags.contains(RoomTag.ROOM_TAG_FAVOURITE) -> favourites.add(room)
tags.contains(RoomTag.ROOM_TAG_LOW_PRIORITY) -> lowPriorities.add(room)
//room.isDirect -> directChats.add(room)
else -> groupRooms.add(room)
room.isDirect -> {
directChats.add(room)
normalPriority.add(room)
}
else -> {
groupRooms.add(room)
normalPriority.add(room)
}
}
}
return RoomSummaries().apply {
put(RoomCategory.INVITE, invites)
put(RoomCategory.FAVOURITE, favourites)
put(RoomCategory.DIRECT, directChats)
put(RoomCategory.GROUP, groupRooms)
if (displayMode == RoomListDisplayMode.ALL) {
put(RoomCategory.COMBINED, normalPriority)
} else {
put(RoomCategory.DIRECT, directChats)
put(RoomCategory.GROUP, groupRooms)
}
put(RoomCategory.LOW_PRIORITY, lowPriorities)
put(RoomCategory.SERVER_NOTICE, serverNotices)
}

View File

@ -36,6 +36,7 @@ data class RoomListViewState(
val isFavouriteRoomsExpanded: Boolean = true,
val isDirectRoomsExpanded: Boolean = true,
val isGroupRoomsExpanded: Boolean = true,
val isCombinedRoomsExpanded: Boolean = true,
val isLowPriorityRoomsExpanded: Boolean = true,
val isServerNoticeRoomsExpanded: Boolean = true
) : MvRxState {
@ -48,6 +49,7 @@ data class RoomListViewState(
RoomCategory.FAVOURITE -> isFavouriteRoomsExpanded
RoomCategory.DIRECT -> isDirectRoomsExpanded
RoomCategory.GROUP -> isGroupRoomsExpanded
RoomCategory.COMBINED -> isCombinedRoomsExpanded
RoomCategory.LOW_PRIORITY -> isLowPriorityRoomsExpanded
RoomCategory.SERVER_NOTICE -> isServerNoticeRoomsExpanded
}
@ -59,6 +61,7 @@ data class RoomListViewState(
RoomCategory.FAVOURITE -> copy(isFavouriteRoomsExpanded = !isFavouriteRoomsExpanded)
RoomCategory.DIRECT -> copy(isDirectRoomsExpanded = !isDirectRoomsExpanded)
RoomCategory.GROUP -> copy(isGroupRoomsExpanded = !isGroupRoomsExpanded)
RoomCategory.COMBINED -> copy(isCombinedRoomsExpanded = !isCombinedRoomsExpanded)
RoomCategory.LOW_PRIORITY -> copy(isLowPriorityRoomsExpanded = !isLowPriorityRoomsExpanded)
RoomCategory.SERVER_NOTICE -> copy(isServerNoticeRoomsExpanded = !isServerNoticeRoomsExpanded)
}
@ -78,8 +81,8 @@ enum class RoomCategory(@StringRes val titleRes: Int) {
INVITE(R.string.invitations_header),
FAVOURITE(R.string.bottom_action_favourites),
DIRECT(R.string.bottom_action_people_x),
//GROUP(R.string.bottom_action_rooms),
GROUP(R.string.normal_priority_header),
GROUP(R.string.bottom_action_rooms),
COMBINED(R.string.normal_priority_header),
LOW_PRIORITY(R.string.low_priority_header),
SERVER_NOTICE(R.string.system_alerts_header)
}

View File

@ -96,6 +96,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
private const val SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY = "SETTINGS_SHOW_AVATAR_DISPLAY_NAME_CHANGES_MESSAGES_KEY"
private const val SETTINGS_VIBRATE_ON_MENTION_KEY = "SETTINGS_VIBRATE_ON_MENTION_KEY"
private const val SETTINGS_SEND_MESSAGE_WITH_ENTER = "SETTINGS_SEND_MESSAGE_WITH_ENTER"
const val SETTINGS_SINGLE_OVERVIEW = "SETTINGS_SINGLE_OVERVIEW"
// Help
private const val SETTINGS_SHOULD_SHOW_HELP_ON_ROOM_LIST_KEY = "SETTINGS_SHOULD_SHOW_HELP_ON_ROOM_LIST_KEY"
@ -812,4 +813,8 @@ class VectorPreferences @Inject constructor(private val context: Context) {
fun useFlagSecure(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_SECURITY_USE_FLAG_SECURE, false)
}
fun singleOverview(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_SINGLE_OVERVIEW, true)
}
}

View File

@ -37,18 +37,19 @@ class SharedPreferencesUiStateRepository @Inject constructor(
}
override fun getDisplayMode(): RoomListDisplayMode {
return RoomListDisplayMode.ALL
/*
return when (sharedPreferences.getInt(KEY_DISPLAY_MODE, VALUE_DISPLAY_MODE_CATCHUP)) {
VALUE_DISPLAY_MODE_PEOPLE -> RoomListDisplayMode.PEOPLE
VALUE_DISPLAY_MODE_ROOMS -> RoomListDisplayMode.ROOMS
else -> if (vectorPreferences.labAddNotificationTab()) {
RoomListDisplayMode.NOTIFICATIONS
} else {
RoomListDisplayMode.PEOPLE
return if (vectorPreferences.singleOverview()) {
RoomListDisplayMode.ALL
} else {
when (sharedPreferences.getInt(KEY_DISPLAY_MODE, VALUE_DISPLAY_MODE_CATCHUP)) {
VALUE_DISPLAY_MODE_PEOPLE -> RoomListDisplayMode.PEOPLE
VALUE_DISPLAY_MODE_ROOMS -> RoomListDisplayMode.ROOMS
else -> if (vectorPreferences.labAddNotificationTab()) {
RoomListDisplayMode.NOTIFICATIONS
} else {
RoomListDisplayMode.PEOPLE
}
}
}
*/
}
override fun storeDisplayMode(displayMode: RoomListDisplayMode) {

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="settings_single_overview">Vereinte Chat-Übersicht</string>
<string name="settings_single_overview_summary">Zeige sowohl Direktnachrichten als auch Gruppenchats in einer gemeinsamen Übersicht</string>
<string name="settings_dark_theme">Nacht-Design</string>
<string name="sc_light_theme">SC Hell</string>
<string name="sc_theme">SC Schwarz</string>

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="settings_single_overview">Combined chat overview</string>
<string name="settings_single_overview_summary">View both direct messages and rooms on one page</string>
<string name="settings_dark_theme">Night Theme</string>
<string name="sc_light_theme">SC Light</string>
<string name="sc_theme">SC Black</string>

View File

@ -39,6 +39,12 @@
android:title="@string/bubble_style"
app:iconSpaceReserved="false" />
<im.vector.riotx.core.preference.VectorSwitchPreference
android:defaultValue="true"
android:key="SETTINGS_SINGLE_OVERVIEW"
android:summary="@string/settings_single_overview_summary"
android:title="@string/settings_single_overview" />
<im.vector.riotx.core.preference.VectorPreference
android:dialogTitle="@string/font_size"
android:key="SETTINGS_INTERFACE_TEXT_SIZE_KEY"
@ -188,4 +194,4 @@
</im.vector.riotx.core.preference.VectorPreferenceCategory>
</androidx.preference.PreferenceScreen>
</androidx.preference.PreferenceScreen>