Rename ButtonStyle

This commit is contained in:
Andrew 2024-06-17 17:52:56 +09:30
parent 081df3f7c6
commit 5841ab0218
4 changed files with 12 additions and 16 deletions

View File

@ -10,6 +10,7 @@ import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsignal.database.LokiAPIDatabaseProtocol import org.session.libsignal.database.LokiAPIDatabaseProtocol
import org.session.libsignal.utilities.hexEncodedPublicKey import org.session.libsignal.utilities.hexEncodedPublicKey
import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.ApplicationContext
import org.thoughtcrime.securesms.crypto.KeyPairUtilities
import org.thoughtcrime.securesms.dependencies.ConfigFactory import org.thoughtcrime.securesms.dependencies.ConfigFactory
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -40,9 +41,9 @@ class LoadingManager @Inject constructor(
database.clearReceivedMessageHashValues() database.clearReceivedMessageHashValues()
// RestoreActivity handles seed this way // RestoreActivity handles seed this way
val keyPairGenerationResult = org.thoughtcrime.securesms.crypto.KeyPairUtilities.generate(seed) val keyPairGenerationResult = KeyPairUtilities.generate(seed)
val x25519KeyPair = keyPairGenerationResult.x25519KeyPair val x25519KeyPair = keyPairGenerationResult.x25519KeyPair
org.thoughtcrime.securesms.crypto.KeyPairUtilities.store(context, seed, keyPairGenerationResult.ed25519KeyPair, x25519KeyPair) KeyPairUtilities.store(context, seed, keyPairGenerationResult.ed25519KeyPair, x25519KeyPair)
configFactory.keyPairChanged() configFactory.keyPairChanged()
val userHexEncodedPublicKey = x25519KeyPair.hexEncodedPublicKey val userHexEncodedPublicKey = x25519KeyPair.hexEncodedPublicKey
val registrationID = org.session.libsignal.utilities.KeyHelper.generateRegistrationId(false) val registrationID = org.session.libsignal.utilities.KeyHelper.generateRegistrationId(false)

View File

@ -4,9 +4,7 @@ import android.app.Application
import android.content.ClipData import android.content.ClipData
import android.content.ClipboardManager import android.content.ClipboardManager
import android.content.Context import android.content.Context
import android.graphics.Bitmap
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel
import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import org.session.libsession.utilities.AppTextSecurePreferences import org.session.libsession.utilities.AppTextSecurePreferences
import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.TextSecurePreferences
@ -14,8 +12,6 @@ import org.session.libsignal.crypto.MnemonicCodec
import org.session.libsignal.utilities.hexEncodedPrivateKey import org.session.libsignal.utilities.hexEncodedPrivateKey
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
import org.thoughtcrime.securesms.crypto.MnemonicUtilities import org.thoughtcrime.securesms.crypto.MnemonicUtilities
import org.thoughtcrime.securesms.util.QRCodeUtilities
import org.thoughtcrime.securesms.util.toPx
import javax.inject.Inject import javax.inject.Inject
@HiltViewModel @HiltViewModel

View File

@ -96,7 +96,7 @@ fun Button(
type: ButtonType, type: ButtonType,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
enabled: Boolean = true, enabled: Boolean = true,
size: ButtonSize = ButtonSize.Large, size: ButtonStyle = ButtonStyle.Large,
elevation: ButtonElevation? = type.elevation, elevation: ButtonElevation? = type.elevation,
shape: Shape = MaterialTheme.shapes.small, shape: Shape = MaterialTheme.shapes.small,
border: BorderStroke? = type.border(color, enabled), border: BorderStroke? = type.border(color, enabled),
@ -134,7 +134,7 @@ fun Button(
type: ButtonType, type: ButtonType,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
enabled: Boolean = true, enabled: Boolean = true,
size: ButtonSize = ButtonSize.Large, size: ButtonStyle = ButtonStyle.Large,
elevation: ButtonElevation? = type.elevation, elevation: ButtonElevation? = type.elevation,
shape: Shape = MaterialTheme.shapes.small, shape: Shape = MaterialTheme.shapes.small,
border: BorderStroke? = type.border(color, enabled), border: BorderStroke? = type.border(color, enabled),
@ -163,14 +163,14 @@ fun Button(
} }
@Composable fun SlimOutlineButton(onClick: () -> Unit, modifier: Modifier = Modifier, color: Color = LocalColors.current.text, enabled: Boolean = true, content: @Composable () -> Unit) { @Composable fun SlimOutlineButton(onClick: () -> Unit, modifier: Modifier = Modifier, color: Color = LocalColors.current.text, enabled: Boolean = true, content: @Composable () -> Unit) {
Button(onClick, color, ButtonType.Outline, modifier, enabled, ButtonSize.Slim) { content() } Button(onClick, color, ButtonType.Outline, modifier, enabled, ButtonStyle.Slim) { content() }
} }
/** /**
* Courtesy [SlimOutlineButton] implementation for buttons that just display text. * Courtesy [SlimOutlineButton] implementation for buttons that just display text.
*/ */
@Composable fun SlimOutlineButton(text: String, modifier: Modifier = Modifier, color: Color = LocalColors.current.text, enabled: Boolean = true, onClick: () -> Unit) { @Composable fun SlimOutlineButton(text: String, modifier: Modifier = Modifier, color: Color = LocalColors.current.text, enabled: Boolean = true, onClick: () -> Unit) {
Button(text, onClick, color, ButtonType.Outline, modifier, enabled, ButtonSize.Slim) Button(text, onClick, color, ButtonType.Outline, modifier, enabled, ButtonStyle.Slim)
} }
@Composable @Composable
@ -179,13 +179,13 @@ fun SlimOutlineCopyButton(
color: Color = LocalColors.current.text, color: Color = LocalColors.current.text,
onClick: () -> Unit onClick: () -> Unit
) { ) {
OutlineCopyButton(modifier, ButtonSize.Slim, color, onClick) OutlineCopyButton(modifier, ButtonStyle.Slim, color, onClick)
} }
@Composable @Composable
fun OutlineCopyButton( fun OutlineCopyButton(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
size: ButtonSize = ButtonSize.Large, size: ButtonStyle = ButtonStyle.Large,
color: Color = LocalColors.current.buttonOutline, color: Color = LocalColors.current.buttonOutline,
onClick: () -> Unit onClick: () -> Unit
) { ) {

View File

@ -13,7 +13,7 @@ import androidx.compose.ui.unit.dp
import org.thoughtcrime.securesms.ui.baseBold import org.thoughtcrime.securesms.ui.baseBold
import org.thoughtcrime.securesms.ui.extraSmallBold import org.thoughtcrime.securesms.ui.extraSmallBold
interface ButtonSize { interface ButtonStyle {
@OptIn(ExperimentalMaterialApi::class) @OptIn(ExperimentalMaterialApi::class)
@SuppressLint("ComposableNaming") @SuppressLint("ComposableNaming")
@Composable fun applyButtonConstraints(content: @Composable () -> Unit) { @Composable fun applyButtonConstraints(content: @Composable () -> Unit) {
@ -34,14 +34,13 @@ interface ButtonSize {
val textStyle: TextStyle val textStyle: TextStyle
val minHeight: Dp val minHeight: Dp
object Large: ButtonSize { object Large: ButtonStyle {
override val textStyle = baseBold.copy(textAlign = TextAlign.Center) override val textStyle = baseBold.copy(textAlign = TextAlign.Center)
override val minHeight = 41.dp override val minHeight = 41.dp
} }
object Slim: ButtonSize { object Slim: ButtonStyle {
override val textStyle = extraSmallBold.copy(textAlign = TextAlign.Center) override val textStyle = extraSmallBold.copy(textAlign = TextAlign.Center)
override val minHeight = 29.dp override val minHeight = 29.dp
} }
} }