Secure backup

This commit is contained in:
Benoit Marty 2023-10-27 11:14:00 +02:00 committed by Benoit Marty
parent bf905dd79b
commit 9807ebf649
115 changed files with 4698 additions and 393 deletions

View file

@ -31,10 +31,13 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.atomic.atoms.RedIndicatorAtom
import io.element.android.libraries.designsystem.components.preferences.components.PreferenceIcon
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
import io.element.android.libraries.designsystem.preview.PreviewGroup
import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator
import io.element.android.libraries.designsystem.theme.components.Text
@ -52,16 +55,18 @@ fun PreferenceText(
modifier: Modifier = Modifier,
enabled: Boolean = true,
subtitle: String? = null,
subtitleAnnotated: AnnotatedString? = null,
currentValue: String? = null,
loadingCurrentValue: Boolean = false,
icon: ImageVector? = null,
@DrawableRes iconResourceId: Int? = null,
showIconAreaIfNoIcon: Boolean = false,
showIconBadge: Boolean = false,
showEndBadge: Boolean = false,
tintColor: Color? = null,
onClick: () -> Unit = {},
) {
val minHeight = if (subtitle == null) preferenceMinHeightOnlyTitle else preferenceMinHeight
val minHeight = if (subtitle == null && subtitleAnnotated == null) preferenceMinHeightOnlyTitle else preferenceMinHeight
Row(
modifier = modifier
@ -95,6 +100,12 @@ fun PreferenceText(
text = subtitle,
color = tintColor ?: enabled.toSecondaryEnabledColor(),
)
} else if (subtitleAnnotated != null) {
Text(
style = ElementTheme.typography.fontBodyMdRegular,
text = subtitleAnnotated,
color = tintColor ?: enabled.toSecondaryEnabledColor(),
)
}
}
if (currentValue != null) {
@ -116,32 +127,63 @@ fun PreferenceText(
strokeWidth = 2.dp
)
}
if (showEndBadge) {
val endBadgeStartPadding = if (currentValue != null || loadingCurrentValue) 8.dp else 16.dp
RedIndicatorAtom(
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(start = endBadgeStartPadding)
)
}
}
}
@Preview(group = PreviewGroup.Preferences)
@Composable
internal fun PreferenceTextPreview() = ElementThemedPreview { ContentToPreview() }
internal fun PreferenceTextLightPreview() = ElementPreviewLight {
ContentToPreview(showEndBadge = false)
}
@Preview(group = PreviewGroup.Preferences)
@Composable
internal fun PreferenceTextDarkPreview() = ElementPreviewDark {
ContentToPreview(showEndBadge = false)
}
@Preview(group = PreviewGroup.Preferences)
@Composable
internal fun PreferenceTextWithEndBadgeLightPreview() = ElementPreviewLight {
ContentToPreview(showEndBadge = true)
}
@Preview(group = PreviewGroup.Preferences)
@Composable
internal fun PreferenceTextWithEndBadgeDarkPreview() = ElementPreviewDark {
ContentToPreview(showEndBadge = true)
}
@Composable
private fun ContentToPreview() {
private fun ContentToPreview(showEndBadge: Boolean) {
Column(
verticalArrangement = Arrangement.spacedBy(2.dp)
) {
PreferenceText(
title = "Title",
iconResourceId = CommonDrawables.ic_compound_chat_problem,
showEndBadge = showEndBadge,
)
PreferenceText(
title = "Title",
subtitle = "Some content",
iconResourceId = CommonDrawables.ic_compound_chat_problem,
showEndBadge = showEndBadge,
)
PreferenceText(
title = "Title",
subtitle = "Some content",
iconResourceId = CommonDrawables.ic_compound_chat_problem,
currentValue = "123",
showEndBadge = showEndBadge,
)
PreferenceText(
title = "Title",
@ -149,31 +191,37 @@ private fun ContentToPreview() {
iconResourceId = CommonDrawables.ic_compound_chat_problem,
currentValue = "123",
enabled = false,
showEndBadge = showEndBadge,
)
PreferenceText(
title = "Title",
subtitle = "Some content",
iconResourceId = CommonDrawables.ic_compound_chat_problem,
loadingCurrentValue = true,
showEndBadge = showEndBadge,
)
PreferenceText(
title = "Title",
iconResourceId = CommonDrawables.ic_compound_chat_problem,
currentValue = "123",
showEndBadge = showEndBadge,
)
PreferenceText(
title = "Title",
iconResourceId = CommonDrawables.ic_compound_chat_problem,
loadingCurrentValue = true,
showEndBadge = showEndBadge,
)
PreferenceText(
title = "Title no icon with icon area",
showIconAreaIfNoIcon = true,
loadingCurrentValue = true,
showEndBadge = showEndBadge,
)
PreferenceText(
title = "Title no icon",
loadingCurrentValue = true,
showEndBadge = showEndBadge,
)
}
}

View file

@ -0,0 +1,28 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.designsystem.modifiers
import androidx.compose.foundation.clickable
import androidx.compose.ui.Modifier
fun Modifier.clickableIfNotNull(onClick: (() -> Unit)? = null): Modifier = then(
if (onClick != null) {
Modifier.clickable { onClick() }
} else {
Modifier
}
)

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="42dp"
android:height="42dp"
android:viewportWidth="42"
android:viewportHeight="42">
<path
android:pathData="M12.25,26.644C10.675,26.644 9.341,26.097 8.247,25.003C7.153,23.909 6.606,22.575 6.606,21C6.606,19.425 7.153,18.091 8.247,16.997C9.341,15.903 10.675,15.356 12.25,15.356C13.825,15.356 15.159,15.903 16.253,16.997C17.347,18.091 17.894,19.425 17.894,21C17.894,22.575 17.347,23.909 16.253,25.003C15.159,26.097 13.825,26.644 12.25,26.644ZM12.25,31.5C14.613,31.5 16.691,30.829 18.484,29.487C20.278,28.146 21.452,26.381 22.006,24.194H23.406L25.594,26.381C25.74,26.527 25.885,26.629 26.031,26.688C26.177,26.746 26.337,26.775 26.513,26.775C26.688,26.775 26.848,26.746 26.994,26.688C27.14,26.629 27.285,26.527 27.431,26.381L30.188,23.625L32.944,26.381C33.09,26.527 33.235,26.629 33.381,26.688C33.527,26.746 33.688,26.775 33.862,26.775C34.037,26.775 34.198,26.746 34.344,26.688C34.49,26.629 34.635,26.527 34.781,26.381L39.331,21.831C39.477,21.685 39.579,21.54 39.638,21.394C39.696,21.248 39.725,21.087 39.725,20.913C39.725,20.737 39.696,20.577 39.638,20.431C39.579,20.285 39.477,20.14 39.331,19.994L37.45,18.112C37.304,17.967 37.158,17.865 37.013,17.806C36.867,17.748 36.706,17.719 36.531,17.719H22.006C21.335,15.619 20.162,13.891 18.484,12.534C16.807,11.178 14.729,10.5 12.25,10.5C9.333,10.5 6.854,11.521 4.813,13.563C2.771,15.604 1.75,18.083 1.75,21C1.75,23.917 2.771,26.396 4.813,28.438C6.854,30.479 9.333,31.5 12.25,31.5Z"
android:fillColor="@android:color/white"/>
</vector>

View file

@ -0,0 +1,25 @@
<!--
~ Copyright (c) 2023 New Vector Ltd
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M7,14C6.45,14 5.979,13.804 5.588,13.413C5.196,13.021 5,12.55 5,12C5,11.45 5.196,10.979 5.588,10.587C5.979,10.196 6.45,10 7,10C7.55,10 8.021,10.196 8.413,10.587C8.804,10.979 9,11.45 9,12C9,12.55 8.804,13.021 8.413,13.413C8.021,13.804 7.55,14 7,14ZM7,18C5.333,18 3.917,17.417 2.75,16.25C1.583,15.083 1,13.667 1,12C1,10.333 1.583,8.917 2.75,7.75C3.917,6.583 5.333,6 7,6C8.117,6 9.129,6.275 10.038,6.825C10.946,7.375 11.667,8.1 12.2,9H20.575C20.708,9 20.837,9.025 20.962,9.075C21.087,9.125 21.2,9.2 21.3,9.3L23.3,11.3C23.4,11.4 23.471,11.508 23.513,11.625C23.554,11.742 23.575,11.867 23.575,12C23.575,12.133 23.554,12.258 23.513,12.375C23.471,12.492 23.4,12.6 23.3,12.7L20.125,15.875C20.042,15.958 19.942,16.025 19.825,16.075C19.708,16.125 19.592,16.158 19.475,16.175C19.358,16.192 19.242,16.183 19.125,16.15C19.008,16.117 18.9,16.058 18.8,15.975L17.5,15L16.075,16.075C15.992,16.142 15.9,16.192 15.8,16.225C15.7,16.258 15.6,16.275 15.5,16.275C15.4,16.275 15.296,16.258 15.188,16.225C15.079,16.192 14.983,16.142 14.9,16.075L13.375,15H12.2C11.667,15.9 10.946,16.625 10.038,17.175C9.129,17.725 8.117,18 7,18ZM7,16C7.933,16 8.754,15.717 9.462,15.15C10.171,14.583 10.642,13.867 10.875,13H14L15.45,14.025L17.5,12.5L19.275,13.875L21.15,12L20.15,11H10.875C10.642,10.133 10.171,9.417 9.462,8.85C8.754,8.283 7.933,8 7,8C5.9,8 4.958,8.392 4.175,9.175C3.392,9.958 3,10.9 3,12C3,13.1 3.392,14.042 4.175,14.825C4.958,15.608 5.9,16 7,16Z"
android:fillColor="@android:color/white"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="42dp"
android:height="42dp"
android:viewportWidth="42"
android:viewportHeight="42">
<path
android:pathData="M34.65,38.413L21.612,25.375C20.767,27.388 19.476,28.912 17.741,29.947C16.005,30.983 14.175,31.5 12.25,31.5C9.333,31.5 6.854,30.48 4.813,28.438C2.771,26.396 1.75,23.917 1.75,21C1.75,19.075 2.246,17.26 3.237,15.554C4.229,13.847 5.731,12.498 7.744,11.507L3.588,7.35C3.325,7.088 3.194,6.782 3.194,6.432C3.194,6.082 3.325,5.775 3.588,5.513C3.85,5.25 4.164,5.119 4.528,5.119C4.893,5.119 5.206,5.25 5.469,5.513L36.531,36.532C36.794,36.794 36.918,37.108 36.903,37.472C36.889,37.837 36.75,38.15 36.487,38.413C36.225,38.675 35.919,38.807 35.569,38.807C35.219,38.807 34.912,38.675 34.65,38.413ZM39.725,20.913C39.725,21.088 39.696,21.248 39.638,21.394C39.579,21.54 39.477,21.686 39.331,21.832L34.781,26.382C34.635,26.528 34.497,26.63 34.366,26.688C34.234,26.746 34.067,26.775 33.862,26.775C33.658,26.775 33.491,26.746 33.359,26.688C33.228,26.63 33.09,26.528 32.944,26.382L30.188,23.625L28.744,25.069L21.438,17.719H36.531C36.706,17.719 36.867,17.748 37.013,17.807C37.158,17.865 37.304,17.967 37.45,18.113L39.331,19.994C39.477,20.14 39.579,20.286 39.638,20.432C39.696,20.577 39.725,20.738 39.725,20.913ZM12.25,26.644C13.825,26.644 15.116,26.134 16.122,25.113C17.128,24.092 17.704,22.94 17.85,21.657L16.888,20.672C16.246,20.016 15.531,19.301 14.744,18.528C13.956,17.756 13.242,17.041 12.6,16.385L11.637,15.4C10.354,15.517 9.195,16.086 8.159,17.107C7.124,18.128 6.606,19.425 6.606,21C6.606,22.575 7.153,23.91 8.247,25.003C9.341,26.097 10.675,26.644 12.25,26.644Z"
android:fillColor="@android:color/white"/>
</vector>