mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 08:09:12 +01:00
Add education sheet for key transparency.
This commit is contained in:
@@ -367,6 +367,7 @@ import org.thoughtcrime.securesms.util.toMillis
|
||||
import org.thoughtcrime.securesms.util.viewModel
|
||||
import org.thoughtcrime.securesms.util.views.Stub
|
||||
import org.thoughtcrime.securesms.util.visible
|
||||
import org.thoughtcrime.securesms.verify.VerifyAutomaticallyEducationSheet
|
||||
import org.thoughtcrime.securesms.verify.VerifyIdentityActivity
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaperDimLevelUtil
|
||||
@@ -661,6 +662,7 @@ class ConversationFragment :
|
||||
presentGroupConversationSubtitle(createGroupSubtitleString(viewModel.titleViewParticipantsSnapshot))
|
||||
presentActionBarMenu()
|
||||
presentStoryRing()
|
||||
presentVerifyAutomaticallySheet()
|
||||
|
||||
observeConversationThread()
|
||||
|
||||
@@ -1414,6 +1416,12 @@ class ConversationFragment :
|
||||
}
|
||||
}
|
||||
|
||||
private fun presentVerifyAutomaticallySheet() {
|
||||
if (RemoteConfig.keyTransparency && !SignalStore.uiHints.hasSeenVerifyAutomaticallySheet() && viewModel.recipientSnapshot?.isIndividual == true) {
|
||||
VerifyAutomaticallyEducationSheet.show(parentFragmentManager)
|
||||
}
|
||||
}
|
||||
|
||||
private fun presentInputReadyState(inputReadyState: InputReadyState) {
|
||||
presentConversationTitle(inputReadyState.conversationRecipient)
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ public class UiHintValues extends SignalStoreValues {
|
||||
private static final String HAS_SEEN_LINK_DEVICE_QR_EDUCATION_SHEET = "uihints.has_seen_link_device_qr_education_sheet";
|
||||
private static final String HAS_DISMISSED_SAVE_STORAGE_WARNING = "uihints.has_dismissed_save_storage_warning";
|
||||
private static final String HAS_SEEN_PINNED_MESSAGE_SHEET = "uihints.has_seen_pinned_message_sheet";
|
||||
private static final String HAS_SEEN_VERIFY_AUTO_SHEET = "uihints.has_seen_verify_auto_sheet";
|
||||
|
||||
UiHintValues(@NonNull KeyValueStore store) {
|
||||
super(store);
|
||||
@@ -232,4 +233,12 @@ public class UiHintValues extends SignalStoreValues {
|
||||
private int getSeenPinnedSheetCount() {
|
||||
return getInteger(HAS_SEEN_PINNED_MESSAGE_SHEET, 0);
|
||||
}
|
||||
|
||||
public boolean hasSeenVerifyAutomaticallySheet() {
|
||||
return getBoolean(HAS_SEEN_VERIFY_AUTO_SHEET, false);
|
||||
}
|
||||
|
||||
public void setSeenVerifyAutomaticallySheet() {
|
||||
putBoolean(HAS_SEEN_VERIFY_AUTO_SHEET, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1233,5 +1233,18 @@ object RemoteConfig {
|
||||
defaultValue = false,
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
/**
|
||||
* Whether or not to show any UI related to key transparency
|
||||
*/
|
||||
@JvmStatic
|
||||
@get:JvmName("keyTransparency")
|
||||
val keyTransparency: Boolean by remoteBoolean(
|
||||
key = "android.keyTransparency",
|
||||
active = false,
|
||||
defaultValue = false,
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package org.thoughtcrime.securesms.verify
|
||||
|
||||
import android.content.DialogInterface
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import org.signal.core.ui.compose.BottomSheets
|
||||
import org.signal.core.ui.compose.Buttons
|
||||
import org.signal.core.ui.compose.DayNightPreviews
|
||||
import org.signal.core.ui.compose.Previews
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.compose.ComposeBottomSheetDialogFragment
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.util.BottomSheetUtil
|
||||
|
||||
/**
|
||||
* Education sheet explaining that conversations now have auto verification
|
||||
*/
|
||||
class VerifyAutomaticallyEducationSheet : ComposeBottomSheetDialogFragment() {
|
||||
|
||||
override val peekHeightPercentage: Float = 0.75f
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
fun show(fragmentManager: FragmentManager) {
|
||||
VerifyAutomaticallyEducationSheet().show(fragmentManager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
super.onDismiss(dialog)
|
||||
SignalStore.uiHints.setSeenVerifyAutomaticallySheet()
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun SheetContent() {
|
||||
VerifyEducationSheet(
|
||||
onVerify = {}, // TODO(michelle): Plug in to verify fragment
|
||||
onLearnMore = {} // TODO(michelle): Update with support url
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun VerifyEducationSheet(
|
||||
onVerify: () -> Unit = {},
|
||||
onLearnMore: () -> Unit = {}
|
||||
) {
|
||||
return Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
BottomSheets.Handle()
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.image_verify_successful),
|
||||
contentDescription = null,
|
||||
tint = Color.Unspecified,
|
||||
modifier = Modifier.padding(top = 24.dp, bottom = 8.dp)
|
||||
)
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.VerifyAutomaticallyEducationSheet__title),
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.padding(vertical = 12.dp, horizontal = 32.dp),
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.VerifyAutomaticallyEducationSheet__body),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.padding(horizontal = 32.dp),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 24.dp).padding(top = 60.dp, bottom = 28.dp)
|
||||
) {
|
||||
TextButton(
|
||||
onClick = onLearnMore
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.VerifyAutomaticallyEducationSheet__learn_more)
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
Buttons.LargeTonal(
|
||||
onClick = onVerify
|
||||
) {
|
||||
Text(stringResource(id = R.string.VerifyAutomaticallyEducationSheet__verify))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DayNightPreviews
|
||||
@Composable
|
||||
fun VerifyAutomaticallyEducationSheetPreview() {
|
||||
Previews.BottomSheetContentPreview {
|
||||
VerifyEducationSheet()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user