diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index ba519f0a79..b07d4b4aac 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -12,6 +12,21 @@ import android.os.Bundle import android.text.SpannableString import android.widget.Toast import androidx.activity.viewModels +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Divider +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +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.text.style.TextAlign +import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.core.view.isVisible import androidx.lifecycle.Lifecycle @@ -20,6 +35,7 @@ import androidx.lifecycle.repeatOnLifecycle import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.google.accompanist.themeadapter.appcompat.AppCompatTheme import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.collect @@ -74,6 +90,8 @@ import org.thoughtcrime.securesms.permissions.Permissions import org.thoughtcrime.securesms.preferences.SettingsActivity import org.thoughtcrime.securesms.showMuteDialog import org.thoughtcrime.securesms.showSessionDialog +import org.thoughtcrime.securesms.ui.AppTheme +import org.thoughtcrime.securesms.ui.h8 import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities import org.thoughtcrime.securesms.util.DateUtils import org.thoughtcrime.securesms.util.IP2Country @@ -202,7 +220,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } // Set up empty state view - binding.createNewPrivateChatButton.setOnClickListener { showNewConversation() } + binding.emptyStateContainer.setContent { EmptyView() } + IP2Country.configureIfNeeded(this@HomeActivity) startObservingUpdates() @@ -313,6 +332,34 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } } + @Composable + private fun EmptyView() { + AppTheme { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .padding(horizontal = 50.dp) + .padding(bottom = 12.dp) + ) { + Spacer(modifier = Modifier.weight(1f)) + Icon( + painter = painterResource(id = R.drawable.emoji_tada), + contentDescription = null, + tint = Color.Unspecified + ) + Text("Account Created", style = MaterialTheme.typography.h4, textAlign = TextAlign.Center) + Text("Welcome to Session", color = MaterialTheme.colors.secondary, textAlign = TextAlign.Center) + Divider(modifier = Modifier.padding(vertical = 16.dp)) + Text("You don't have any conversations yet", + style = MaterialTheme.typography.h8, + textAlign = TextAlign.Center, + modifier = Modifier.padding(bottom = 12.dp)) + Text("Hit the plus button to start a chat, create a group, or join an official communitiy!", textAlign = TextAlign.Center) + Spacer(modifier = Modifier.weight(2f)) + } + } + } + override fun onInputFocusChanged(hasFocus: Boolean) { if (hasFocus) { setSearchShown(true) diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Themes.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Themes.kt index 64bbd21d8d..9a23f29190 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Themes.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Themes.kt @@ -5,15 +5,23 @@ import androidx.annotation.AttrRes import androidx.appcompat.view.ContextThemeWrapper import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box +import androidx.compose.material.LocalContentColor import androidx.compose.material.MaterialTheme +import androidx.compose.material.Shapes +import androidx.compose.material.Typography import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.remember import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import com.google.accompanist.themeadapter.appcompat.AppCompatTheme +import androidx.compose.ui.unit.TextUnit +import androidx.compose.ui.unit.sp +import com.google.accompanist.themeadapter.appcompat.createAppCompatTheme import com.google.android.material.color.MaterialColors import network.loki.messenger.R @@ -44,6 +52,58 @@ fun AppTheme( } } +@Composable +fun AppCompatTheme( + context: Context = LocalContext.current, + readColors: Boolean = true, + typography: Typography = sessionTypography, + shapes: Shapes = MaterialTheme.shapes, + content: @Composable () -> Unit +) { + val themeParams = remember(context.theme) { + context.createAppCompatTheme( + readColors = readColors, + readTypography = false + ) + } + + MaterialTheme( + colors = themeParams.colors ?: MaterialTheme.colors, + typography = typography, + shapes = shapes, + ) { + // We update the LocalContentColor to match our onBackground. This allows the default + // content color to be more appropriate to the theme background + CompositionLocalProvider( + LocalContentColor provides MaterialTheme.colors.onBackground, + content = content + ) + } +} + +fun boldStyle(size: TextUnit) = TextStyle.Default.copy( + fontWeight = FontWeight.Bold, + fontSize = size +) + +fun defaultStyle(size: TextUnit) = TextStyle.Default.copy(fontSize = size) + +val sessionTypography = Typography( + h1 = boldStyle(36.sp), + h2 = boldStyle(32.sp), + h3 = boldStyle(29.sp), + h4 = boldStyle(26.sp), + h5 = boldStyle(23.sp), + h6 = boldStyle(20.sp), +) + +val Typography.base get() = defaultStyle(14.sp) +val Typography.small get() = defaultStyle(12.sp) + +val Typography.h7 get() = boldStyle(18.sp) +val Typography.h8 get() = boldStyle(16.sp) +val Typography.h9 get() = boldStyle(14.sp) + fun Context.getColorFromTheme(@AttrRes attr: Int, defaultValue: Int = 0x0): Color = MaterialColors.getColor(this, attr, defaultValue).let(::Color) diff --git a/app/src/main/res/drawable/emoji_tada.xml b/app/src/main/res/drawable/emoji_tada.xml new file mode 100644 index 0000000000..ce0f30067d --- /dev/null +++ b/app/src/main/res/drawable/emoji_tada.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index bf308612c5..43fe642aaf 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -158,32 +158,11 @@ tools:itemCount="6" tools:listitem="@layout/view_global_search_result" /> - - - - -