Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add split screen support #171

Draft
wants to merge 2 commits into
base: sc
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/ui-strings/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3417,6 +3417,10 @@
<string name="labs_enable_client_info_recording_summary">Record the client name, version, and url to recognise sessions more easily in session manager.</string>
<string name="labs_enable_voice_broadcast_title">Enable voice broadcast (under active development)</string>
<string name="labs_enable_voice_broadcast_summary">Be able to record and send voice broadcast in room timeline.</string>
<string name="labs_enable_tablet_mode_title">Enable tablet mode (split screen)</string>
<string name="labs_enable_tablet_mode_summary">Allow Chats to be opened in split window.</string>
<string name="labs_enable_multichat_title">Enable multiwindow chats</string>
<string name="labs_enable_multichat_summary">Allow Multiple Chats to be opened in split windows (need tablet mode enabled).</string>
Sinofine marked this conversation as resolved.
Show resolved Hide resolved

<!-- Note to translators: %s will be replaces with selected space name -->
<string name="home_empty_space_no_rooms_title">%s\nis looking a little empty.</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ class DefaultNavigator @Inject constructor(

val args = TimelineArgs(roomId = roomId, eventId = eventId, isInviteAlreadyAccepted = isInviteAlreadyAccepted, openAtFirstUnread = openAtFirstUnread, openAnonymously = openAnonymously)
val intent = RoomDetailActivity.newIntent(context, args, false)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && vectorPreferences.isTabletModeEnabled()) {
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
if (vectorPreferences.isMultiChatEnabled()){
intent.flags = intent.flags or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
} else {
intent.flags = intent.flags or Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
}
startActivity(context, intent, buildTask)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ class VectorPreferences @Inject constructor(
const val SETTINGS_UNVERIFIED_SESSIONS_ALERT_LAST_SHOWN_MILLIS = "SETTINGS_UNVERIFIED_SESSIONS_ALERT_LAST_SHOWN_MILLIS_"
const val SETTINGS_NEW_LOGIN_ALERT_SHOWN_FOR_DEVICE = "SETTINGS_NEW_LOGIN_ALERT_SHOWN_FOR_DEVICE_"

const val SETTINGS_LABS_ENABLE_TABLET_MODE = "SETTINGS_LABS_ENABLE_TABLET_MODE"
const val SETTINGS_LABS_ENABLE_MULTICHAT = "SETTINGS_LABS_ENABLE_MULTICHAT"

// Possible values for TAKE_PHOTO_VIDEO_MODE
const val TAKE_PHOTO_VIDEO_MODE_ALWAYS_ASK = 0
const val TAKE_PHOTO_VIDEO_MODE_PHOTO = 1
Expand Down Expand Up @@ -1558,4 +1561,13 @@ class VectorPreferences @Inject constructor(
putBoolean(SETTINGS_NEW_LOGIN_ALERT_SHOWN_FOR_DEVICE + deviceId, true)
}
}

fun isTabletModeEnabled(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_TABLET_MODE, false)
}


fun isMultiChatEnabled(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_MULTICHAT, false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,17 @@ class VectorSettingsLabsFragment :
pref.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && vectorFeatures.isVoiceBroadcastEnabled()
}

findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_ENABLE_TABLET_MODE)?.let { pref ->
pref.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
Sinofine marked this conversation as resolved.
Show resolved Hide resolved
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
onTabletModePreferenceClicked()
true
}
}

configureUnreadNotificationsAsTabPreference()
configureEnableClientInfoRecordingPreference()
configureMultiChatPreference()
}

private fun configureUnreadNotificationsAsTabPreference() {
Expand All @@ -132,6 +141,12 @@ class VectorSettingsLabsFragment :
}
}

private fun configureMultiChatPreference() {
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_ENABLE_MULTICHAT)?.let { pref ->
pref.isEnabled = vectorPreferences.isTabletModeEnabled()
}
}

/**
* Intercept the click to display a user friendly dialog when their homeserver do not support threads.
*/
Expand Down Expand Up @@ -180,6 +195,10 @@ class VectorSettingsLabsFragment :
configureUnreadNotificationsAsTabPreference()
}

private fun onTabletModePreferenceClicked() {
configureMultiChatPreference()
}

private fun configureEnableClientInfoRecordingPreference() {
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_CLIENT_INFO_RECORDING_KEY)?.onPreferenceChangeListener =
OnPreferenceChangeListener { _, newValue ->
Expand Down
12 changes: 12 additions & 0 deletions vector/src/main/res/xml/vector_settings_labs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@
android:title="@string/url_previews_in_encrypted_rooms"
android:summary="@string/url_previews_in_encrypted_rooms_summary" />

<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_LABS_ENABLE_TABLET_MODE"
android:summary="@string/labs_enable_tablet_mode_summary"
android:title="@string/labs_enable_tablet_mode_title" />

<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_LABS_ENABLE_MULTICHAT"
android:summary="@string/labs_enable_multichat_summary"
android:title="@string/labs_enable_multichat_title" />

</im.vector.app.core.preference.VectorPreferenceCategory>

<im.vector.app.core.preference.VectorPreferenceCategory
Expand Down