Drawer: move settings access and add sign out action (#2171)
This commit is contained in:
parent
ae3c453f35
commit
724c1132b6
|
@ -13,6 +13,7 @@ Improvements 🙌:
|
|||
- Create home shortcut for any room (#1525)
|
||||
- Add a menu item to open the setting in room list and in room (#2171)
|
||||
- Add a menu item in the timeline as a shortcut to invite user (#2171)
|
||||
- Drawer: move settings access and add sign out action (#2171)
|
||||
|
||||
Bugfix 🐛:
|
||||
- Improve support for image/audio/video/file selection with intent changes (#1376)
|
||||
|
|
|
@ -23,6 +23,7 @@ import im.vector.app.core.extensions.observeK
|
|||
import im.vector.app.core.extensions.replaceChildFragment
|
||||
import im.vector.app.core.platform.VectorBaseFragment
|
||||
import im.vector.app.features.grouplist.GroupListFragment
|
||||
import im.vector.app.features.workers.signout.SignOutUiWorker
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import kotlinx.android.synthetic.main.fragment_home_drawer.*
|
||||
|
@ -53,10 +54,16 @@ class HomeDrawerFragment @Inject constructor(
|
|||
homeDrawerUserIdView.text = user.userId
|
||||
}
|
||||
}
|
||||
// Settings
|
||||
homeDrawerHeaderSettingsView.debouncedClicks {
|
||||
sharedActionViewModel.post(HomeActivitySharedAction.CloseDrawer)
|
||||
navigator.openSettings(requireActivity())
|
||||
}
|
||||
// Sign out
|
||||
homeDrawerHeaderSignoutView.debouncedClicks {
|
||||
sharedActionViewModel.post(HomeActivitySharedAction.CloseDrawer)
|
||||
SignOutUiWorker(requireActivity()).perform()
|
||||
}
|
||||
|
||||
// Debug menu
|
||||
homeDrawerHeaderDebugView.debouncedClicks {
|
||||
|
|
|
@ -259,8 +259,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
|
|||
findPreference<VectorPreference>("SETTINGS_SIGN_OUT_KEY")!!
|
||||
.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
activity?.let {
|
||||
SignOutUiWorker(requireActivity())
|
||||
.perform(requireContext())
|
||||
SignOutUiWorker(requireActivity()).perform()
|
||||
}
|
||||
|
||||
false
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
|
||||
package im.vector.app.features.workers.signout
|
||||
|
||||
import android.content.Context
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.cannotLogoutSafely
|
||||
import im.vector.app.core.extensions.vectorComponent
|
||||
import im.vector.app.features.MainActivity
|
||||
|
@ -28,11 +26,8 @@ import im.vector.app.features.MainActivityArgs
|
|||
|
||||
class SignOutUiWorker(private val activity: FragmentActivity) {
|
||||
|
||||
lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
|
||||
fun perform(context: Context) {
|
||||
activeSessionHolder = context.vectorComponent().activeSessionHolder()
|
||||
val session = activeSessionHolder.getActiveSession()
|
||||
fun perform() {
|
||||
val session = activity.vectorComponent().activeSessionHolder().getSafeActiveSession() ?: return
|
||||
if (session.cannotLogoutSafely()) {
|
||||
// The backup check on logout flow has to be displayed if there are keys in the store, and the keys backup state is not Ready
|
||||
val signOutDialog = SignOutBottomSheetDialogFragment.newInstance()
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="18"
|
||||
android:viewportHeight="18">
|
||||
<path
|
||||
android:pathData="M14.89,6.83C15.05,7.25 15.46,7.53 15.91,7.53C16.51,7.53 17,8.02 17,8.62V9.38C17,9.98 16.51,10.47 15.91,10.47C15.46,10.47 15.05,10.75 14.89,11.17C14.8768,11.2031 14.8635,11.2366 14.8502,11.2704C14.8031,11.3901 14.7546,11.5131 14.7,11.63C14.51,12.04 14.6,12.52 14.92,12.84C15.35,13.26 15.35,13.95 14.92,14.38L14.38,14.92C13.96,15.35 13.27,15.35 12.84,14.92C12.53,14.6 12.04,14.51 11.63,14.7C11.48,14.77 11.33,14.83 11.17,14.89C10.75,15.05 10.47,15.46 10.47,15.91C10.47,16.51 9.98,17 9.38,17H8.62C8.02,17 7.53,16.51 7.53,15.91C7.53,15.46 7.25,15.05 6.83,14.89C6.7969,14.8768 6.7634,14.8635 6.7296,14.8502C6.61,14.8031 6.4869,14.7546 6.37,14.7C5.96,14.51 5.48,14.6 5.16,14.92C4.74,15.35 4.05,15.35 3.62,14.92L3.08,14.38C2.65,13.96 2.65,13.27 3.08,12.84C3.4,12.53 3.49,12.04 3.3,11.63C3.23,11.48 3.17,11.33 3.11,11.17C2.95,10.75 2.54,10.47 2.09,10.47C1.49,10.47 1,9.98 1,9.38V8.62C1,8.02 1.49,7.53 2.09,7.53C2.54,7.53 2.95,7.25 3.11,6.83C3.1416,6.729 3.1811,6.632 3.221,6.534C3.2444,6.4767 3.2679,6.419 3.29,6.36C3.48,5.95 3.39,5.47 3.07,5.15C2.64,4.73 2.64,4.04 3.07,3.61L3.62,3.08C4.04,2.65 4.73,2.65 5.16,3.08C5.47,3.4 5.96,3.49 6.37,3.3C6.52,3.23 6.67,3.16 6.83,3.11C7.25,2.95 7.53,2.54 7.53,2.09C7.53,1.49 8.02,1 8.62,1H9.38C9.98,1 10.47,1.49 10.47,2.09C10.47,2.55 10.75,2.95 11.17,3.11C11.2031,3.1232 11.2366,3.1365 11.2704,3.1498C11.3901,3.1969 11.5131,3.2454 11.63,3.3C12.04,3.49 12.52,3.4 12.84,3.08C13.26,2.65 13.95,2.65 14.38,3.08L14.92,3.62C15.35,4.04 15.35,4.73 14.92,5.16C14.6,5.47 14.51,5.96 14.7,6.37C14.77,6.52 14.83,6.67 14.89,6.83ZM9,13C6.79,13 5,11.21 5,9C5,6.79 6.79,5 9,5C11.21,5 13,6.79 13,9C13,11.21 11.21,13 9,13Z"
|
||||
android:fillColor="#000000"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
|
@ -0,0 +1,18 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="18"
|
||||
android:viewportHeight="18">
|
||||
<path
|
||||
android:pathData="M9,2L14.8586,1.1631C15.461,1.077 16,1.5445 16,2.153V15.847C16,16.4555 15.461,16.923 14.8586,16.8369L9,16V2Z"
|
||||
android:fillColor="#000000"/>
|
||||
<group>
|
||||
<clip-path
|
||||
android:pathData="M3,2L10,2A1,1 0,0 1,11 3L11,15A1,1 0,0 1,10 16L3,16A1,1 0,0 1,2 15L2,3A1,1 0,0 1,3 2z"/>
|
||||
<path
|
||||
android:pathData="M3,2L10,2A1,1 0,0 1,11 3L11,15A1,1 0,0 1,10 16L3,16A1,1 0,0 1,2 15L2,3A1,1 0,0 1,3 2z"
|
||||
android:strokeWidth="3"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#000000"/>
|
||||
</group>
|
||||
</vector>
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?riotx_background"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
|
@ -42,11 +43,12 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="@dimen/layout_horizontal_margin"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="?riotx_text_primary"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintEnd_toStartOf="@id/homeDrawerHeaderSettingsView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/homeDrawerHeaderAvatarView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/homeDrawerHeaderAvatarView"
|
||||
tools:text="@sample/matrix.json/data/displayName" />
|
||||
|
@ -55,39 +57,71 @@
|
|||
android:id="@+id/homeDrawerUserIdView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/layout_horizontal_margin"
|
||||
android:layout_marginBottom="17dp"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="?riotx_text_secondary"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/homeDrawerHeaderSettingsView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/homeDrawerHeaderAvatarView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/homeDrawerUsernameView"
|
||||
tools:text="@sample/matrix.json/data/mxid" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/homeDrawerHeaderSettingsView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:contentDescription="@string/room_sliding_menu_settings"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_settings_x"
|
||||
android:tint="?riotx_text_secondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/homeDrawerGroupListContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="?riotx_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/homeDrawerBottomSeparator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/homeDrawerHeader" />
|
||||
|
||||
<View
|
||||
android:id="@+id/homeDrawerBottomSeparator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/vctr_list_divider_color"
|
||||
app:layout_constraintBottom_toTopOf="@+id/homeDrawerHeaderSettingsView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/homeDrawerHeaderSettingsView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:drawablePadding="9dp"
|
||||
android:gravity="center_vertical"
|
||||
android:minWidth="120dp"
|
||||
android:minHeight="52dp"
|
||||
android:padding="16dp"
|
||||
android:text="@string/settings"
|
||||
android:textSize="14sp"
|
||||
android:tint="?riotx_android_secondary"
|
||||
app:drawableStartCompat="@drawable/ic_settings_18dp"
|
||||
app:drawableTint="?riotx_android_secondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/homeDrawerHeaderSignoutView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:drawablePadding="9dp"
|
||||
android:gravity="center_vertical"
|
||||
android:minWidth="120dp"
|
||||
android:minHeight="52dp"
|
||||
android:padding="16dp"
|
||||
android:text="@string/logout"
|
||||
android:textSize="14sp"
|
||||
android:tint="?riotx_android_secondary"
|
||||
app:drawableStartCompat="@drawable/ic_signout_18dp"
|
||||
app:drawableTint="?riotx_android_secondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue