mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Remove manual theming and fix background colors
This commit is contained in:
parent
9721dbbd9e
commit
96157d65a6
@ -19,6 +19,7 @@ import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.UiState
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||
import org.thoughtcrime.securesms.ui.setContentWithTheme
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
@ -45,7 +46,7 @@ class DisappearingMessagesActivity: PassphraseRequiredActionBarActivity() {
|
||||
|
||||
setUpToolbar()
|
||||
|
||||
binding.container.setContent { DisappearingMessagesScreen() }
|
||||
binding.container.setContentWithTheme { DisappearingMessagesScreen() }
|
||||
|
||||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
@ -87,8 +88,6 @@ class DisappearingMessagesActivity: PassphraseRequiredActionBarActivity() {
|
||||
@Composable
|
||||
fun DisappearingMessagesScreen() {
|
||||
val uiState by viewModel.uiState.collectAsState(UiState())
|
||||
SessionMaterialTheme {
|
||||
DisappearingMessages(uiState, callbacks = viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,14 +14,11 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.primarySurface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
@ -50,7 +47,6 @@ import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColors
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||
import org.thoughtcrime.securesms.ui.components.AppBar
|
||||
import org.thoughtcrime.securesms.ui.components.BorderlessButtonWithIcon
|
||||
import org.thoughtcrime.securesms.ui.components.MaybeScanQrCode
|
||||
@ -59,6 +55,7 @@ import org.thoughtcrime.securesms.ui.components.SessionButtonText
|
||||
import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField
|
||||
import org.thoughtcrime.securesms.ui.components.SessionTabRow
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.onCreateView
|
||||
|
||||
class NewMessageFragment : Fragment() {
|
||||
|
||||
@ -79,9 +76,7 @@ class NewMessageFragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View = ComposeView(requireContext()).apply {
|
||||
setContent {
|
||||
SessionMaterialTheme {
|
||||
): View = onCreateView {
|
||||
val uiState by viewModel.state.collectAsState(State())
|
||||
NewMessage(
|
||||
uiState,
|
||||
@ -92,8 +87,6 @@ class NewMessageFragment : Fragment() {
|
||||
onHelp = { requireContext().showOpenUrlDialog("https://sessionapp.zendesk.com/hc/en-us/articles/4439132747033-How-do-Session-ID-usernames-work") }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createPrivateChat(hexEncodedPublicKey: String) {
|
||||
val recipient = Recipient.from(requireContext(), Address.fromSerialized(hexEncodedPublicKey), false)
|
||||
@ -130,7 +123,7 @@ private fun NewMessage(
|
||||
) {
|
||||
val pagerState = rememberPagerState { TITLES.size }
|
||||
|
||||
Column(modifier = Modifier.background(MaterialTheme.colors.primarySurface)) {
|
||||
Column(modifier = Modifier.background(LocalColors.current.backgroundSecondary)) {
|
||||
AppBar(stringResource(R.string.messageNew), onClose = onClose, onBack = onBack)
|
||||
SessionTabRow(pagerState, TITLES)
|
||||
HorizontalPager(pagerState) {
|
||||
|
@ -77,6 +77,7 @@ import org.thoughtcrime.securesms.ui.baseMonospace
|
||||
import org.thoughtcrime.securesms.ui.blackAlpha40
|
||||
import org.thoughtcrime.securesms.ui.components.SessionButtonText
|
||||
import org.thoughtcrime.securesms.ui.destructiveButtonColors
|
||||
import org.thoughtcrime.securesms.ui.setComposeContent
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
@ -103,9 +104,7 @@ class MessageDetailActivity : PassphraseRequiredActionBarActivity() {
|
||||
|
||||
viewModel.timestamp = intent.getLongExtra(MESSAGE_TIMESTAMP, -1L)
|
||||
|
||||
ComposeView(this)
|
||||
.apply { setContent { MessageDetailsScreen() } }
|
||||
.let(::setContentView)
|
||||
setComposeContent { MessageDetailsScreen() }
|
||||
|
||||
lifecycleScope.launch {
|
||||
viewModel.eventFlow.collect {
|
||||
@ -122,7 +121,6 @@ class MessageDetailActivity : PassphraseRequiredActionBarActivity() {
|
||||
@Composable
|
||||
private fun MessageDetailsScreen() {
|
||||
val state by viewModel.stateFlow.collectAsState()
|
||||
SessionMaterialTheme {
|
||||
MessageDetails(
|
||||
state = state,
|
||||
onReply = if (state.canReply) { { setResultAndFinish(ON_REPLY) } } else null,
|
||||
@ -132,7 +130,6 @@ class MessageDetailActivity : PassphraseRequiredActionBarActivity() {
|
||||
onAttachmentNeedsDownload = viewModel::onAttachmentNeedsDownload,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setResultAndFinish(code: Int) {
|
||||
Bundle().apply { putLong(MESSAGE_TIMESTAMP, viewModel.timestamp) }
|
||||
|
@ -26,6 +26,7 @@ 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.platform.ComposeView
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@ -105,6 +106,7 @@ import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.h8
|
||||
import org.thoughtcrime.securesms.ui.setContentWithTheme
|
||||
import org.thoughtcrime.securesms.ui.small
|
||||
import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
||||
import org.thoughtcrime.securesms.util.IP2Country
|
||||
@ -206,7 +208,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
binding.sessionToolbar.disableClipping()
|
||||
// Set up seed reminder view
|
||||
lifecycleScope.launchWhenStarted {
|
||||
binding.seedReminderView.setContent {
|
||||
binding.seedReminderView.setContentWithTheme {
|
||||
if (!textSecurePreferences.getHasViewedSeed()) SeedReminder()
|
||||
}
|
||||
}
|
||||
@ -223,7 +225,9 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
}
|
||||
|
||||
// Set up empty state view
|
||||
binding.emptyStateContainer.setContent { EmptyView(ApplicationContext.getInstance(this).newAccount) }
|
||||
binding.emptyStateContainer.setContentWithTheme {
|
||||
EmptyView(ApplicationContext.getInstance(this).newAccount)
|
||||
}
|
||||
|
||||
IP2Country.configureIfNeeded(this@HomeActivity)
|
||||
|
||||
@ -371,18 +375,17 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
|
||||
@Composable
|
||||
private fun SeedReminder() {
|
||||
SessionMaterialTheme {
|
||||
Column {
|
||||
// Color Strip
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.height(4.dp)
|
||||
.background(MaterialTheme.colors.secondary)
|
||||
.background(LocalColors.current.primary)
|
||||
)
|
||||
Row(
|
||||
Modifier
|
||||
.background(MaterialTheme.colors.surface)
|
||||
.background(LocalColors.current.backgroundSecondary)
|
||||
.padding(
|
||||
horizontal = LocalDimensions.current.marginSmall,
|
||||
vertical = LocalDimensions.current.marginExtraSmall
|
||||
@ -413,11 +416,9 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EmptyView(newAccount: Boolean) {
|
||||
SessionMaterialTheme {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
@ -459,7 +460,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
Spacer(modifier = Modifier.weight(2f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInputFocusChanged(hasFocus: Boolean) {
|
||||
setSearchShown(hasFocus || binding.globalSearchInputLayout.query.value.isNotEmpty())
|
||||
|
@ -43,6 +43,7 @@ import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||
import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField
|
||||
import org.thoughtcrime.securesms.ui.components.SessionTabRow
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.setComposeContent
|
||||
import org.thoughtcrime.securesms.util.start
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -75,15 +76,11 @@ class LinkDeviceActivity : BaseActionBarActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
ComposeView(this).apply {
|
||||
setContent {
|
||||
setComposeContent {
|
||||
val state by viewModel.stateFlow.collectAsState()
|
||||
SessionMaterialTheme {
|
||||
LoadAccountScreen(state, viewModel::onChange, viewModel::onContinue, viewModel::onScanQrCode)
|
||||
}
|
||||
}
|
||||
}.let(::setContentView)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
|
@ -34,6 +34,7 @@ import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.h7
|
||||
import org.thoughtcrime.securesms.ui.setComposeContent
|
||||
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -71,9 +72,7 @@ class LoadingActivity: BaseActionBarActivity() {
|
||||
|
||||
ApplicationContext.getInstance(this).newAccount = false
|
||||
|
||||
ComposeView(this)
|
||||
.apply { setContent { LoadingScreen() } }
|
||||
.let(::setContentView)
|
||||
setComposeContent { LoadingScreen() }
|
||||
|
||||
setUpActionBarSessionLogo(true)
|
||||
|
||||
@ -103,7 +102,6 @@ class LoadingActivity: BaseActionBarActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
SessionMaterialTheme {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
ProgressArc(
|
||||
@ -122,7 +120,6 @@ class LoadingActivity: BaseActionBarActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.startLoadingActivity(mnemonic: ByteArray) {
|
||||
Intent(this, LoadingActivity::class.java)
|
||||
|
@ -47,6 +47,7 @@ import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.h8
|
||||
import org.thoughtcrime.securesms.ui.h9
|
||||
import org.thoughtcrime.securesms.ui.setComposeContent
|
||||
import org.thoughtcrime.securesms.ui.small
|
||||
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
|
||||
import javax.inject.Inject
|
||||
@ -63,19 +64,14 @@ class MessageNotificationsActivity : BaseActionBarActivity() {
|
||||
setUpActionBarSessionLogo(true)
|
||||
TextSecurePreferences.setHasSeenWelcomeScreen(this, true)
|
||||
|
||||
ComposeView(this)
|
||||
.apply { setContent { MessageNotificationsScreen() } }
|
||||
.let(::setContentView)
|
||||
setComposeContent { MessageNotificationsScreen() }
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MessageNotificationsScreen() {
|
||||
val state by viewModel.stateFlow.collectAsState()
|
||||
|
||||
SessionMaterialTheme {
|
||||
MessageNotificationsScreen(state, viewModel::setEnabled, ::register)
|
||||
}
|
||||
}
|
||||
|
||||
private fun register() {
|
||||
TextSecurePreferences.setPushEnabled(this, viewModel.stateFlow.value.pushEnabled)
|
||||
|
@ -49,6 +49,7 @@ import org.thoughtcrime.securesms.ui.components.SmallButtons
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.extraSmallMonospace
|
||||
import org.thoughtcrime.securesms.ui.h8
|
||||
import org.thoughtcrime.securesms.ui.setComposeContent
|
||||
|
||||
class RecoveryPasswordActivity : BaseActionBarActivity() {
|
||||
|
||||
@ -58,14 +59,12 @@ class RecoveryPasswordActivity : BaseActionBarActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
supportActionBar!!.title = resources.getString(R.string.sessionRecoveryPassword)
|
||||
|
||||
ComposeView(this).apply {
|
||||
setContent {
|
||||
setComposeContent {
|
||||
RecoveryPasswordScreen(
|
||||
viewModel.seed,
|
||||
{ viewModel.copySeed(context) }
|
||||
{ viewModel.copySeed(this) }
|
||||
) { onHide() }
|
||||
}
|
||||
}.let(::setContentView)
|
||||
}
|
||||
|
||||
private fun onHide() {
|
||||
@ -109,7 +108,6 @@ fun RecoveryPasswordScreen(
|
||||
copySeed:() -> Unit = {},
|
||||
onHide:() -> Unit = {}
|
||||
) {
|
||||
SessionMaterialTheme {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(LocalDimensions.current.marginExtraSmall),
|
||||
modifier = Modifier
|
||||
@ -123,7 +121,6 @@ fun RecoveryPasswordScreen(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RecoveryPasswordCell(seed: String, copySeed:() -> Unit = {}) {
|
||||
|
@ -82,6 +82,7 @@ import org.thoughtcrime.securesms.ui.SessionMaterialTheme
|
||||
import org.thoughtcrime.securesms.ui.components.OutlineButton
|
||||
import org.thoughtcrime.securesms.ui.components.OutlineCopyButton
|
||||
import org.thoughtcrime.securesms.ui.destructiveButtonColors
|
||||
import org.thoughtcrime.securesms.ui.setContentWithTheme
|
||||
import org.thoughtcrime.securesms.util.BitmapDecodingException
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil
|
||||
import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
||||
@ -132,12 +133,10 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
versionTextView.text = String.format(getString(R.string.version_s), "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE} - $gitCommitFirstSixChars)")
|
||||
}
|
||||
|
||||
binding.composeView.setContent {
|
||||
SessionMaterialTheme {
|
||||
binding.composeView.setContentWithTheme {
|
||||
Buttons()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDisplayName(): String =
|
||||
TextSecurePreferences.getProfileName(this) ?: truncateIdForDisplay(hexEncodedPublicKey)
|
||||
|
@ -95,7 +95,7 @@ val primaryYellow = Color(0xFFFAD657)
|
||||
val dangerDark = Color(0xFFFF3A3A)
|
||||
val dangerLight = Color(0xFFE12D19)
|
||||
val disabledDark = Color(0xFFA1A2A1)
|
||||
val disabledLioht = Color(0xFF6D6D6D)
|
||||
val disabledLight = Color(0xFF6D6D6D)
|
||||
|
||||
fun sessionColors(
|
||||
isLight: Boolean,
|
||||
@ -128,7 +128,7 @@ val classicLight = SessionColors(
|
||||
isLight = true,
|
||||
primary = primaryGreen,
|
||||
danger = dangerLight,
|
||||
disabled = disabledLioht,
|
||||
disabled = disabledLight,
|
||||
background = Color.White,
|
||||
backgroundSecondary = classicLight5,
|
||||
text = Color.Black,
|
||||
@ -158,7 +158,7 @@ val oceanLight = SessionColors(
|
||||
isLight = true,
|
||||
primary = primaryBlue,
|
||||
danger = dangerLight,
|
||||
disabled = disabledLioht,
|
||||
disabled = disabledLight,
|
||||
background = oceanLight7,
|
||||
backgroundSecondary = oceanLight6,
|
||||
text = oceanLight1,
|
||||
|
@ -18,3 +18,9 @@ fun Fragment.onCreateView(content: @Composable () -> Unit): ComposeView = Compos
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun ComposeView.setContentWithTheme(content: @Composable () -> Unit) = setContent {
|
||||
SessionMaterialTheme {
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user