mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-26 09:47:43 +00:00
Update empty screen
This commit is contained in:
parent
d159a0bcab
commit
9c10209533
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
80
app/src/main/res/drawable/emoji_tada.xml
Normal file
80
app/src/main/res/drawable/emoji_tada.xml
Normal file
@ -0,0 +1,80 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="96dp"
|
||||
android:height="96dp"
|
||||
android:viewportWidth="96"
|
||||
android:viewportHeight="96">
|
||||
<path
|
||||
android:pathData="M5.586,92.452C7.289,94.298 14.301,91.08 19.836,88.5C23.984,86.573 40.581,79.762 48.831,76.23C51.059,75.277 54.299,74.033 56.631,70.965C58.701,68.235 64.191,56.64 53.136,44.895C41.916,32.97 30.359,36.263 26.039,39.322C23.496,41.123 21.426,45.18 20.496,47.243C16.566,55.958 10.964,71.925 8.684,78.202C7.011,82.83 3.899,90.622 5.586,92.452Z"
|
||||
android:fillColor="#FFC107"/>
|
||||
<path
|
||||
android:pathData="M19.386,49.868C19.491,51.173 19.753,53.295 20.653,57.382C21.268,60.188 22.273,63.127 23.091,65.07C25.543,70.912 28.986,73.268 32.473,75.158C38.398,78.368 42.426,78.967 42.426,78.967L37.596,80.94C37.596,80.94 34.671,80.332 30.681,78.368C26.878,76.493 22.918,73.32 20.023,67.11C18.771,64.418 18.043,61.807 17.623,59.737C17.106,57.173 17.023,55.717 17.023,55.717L19.386,49.868Z"
|
||||
android:fillColor="#FF8F00"/>
|
||||
<path
|
||||
android:pathData="M13.453,65.077C13.453,65.077 14.053,69.945 18.073,76.088C22.783,83.272 29.36,84.45 29.36,84.45L24.988,86.25C24.988,86.25 20.105,84.757 15.463,78.42C12.568,74.467 11.758,69.743 11.758,69.743L13.453,65.077Z"
|
||||
android:fillColor="#FF8F00"/>
|
||||
<path
|
||||
android:pathData="M9.291,76.613C9.291,76.613 10.386,80.813 12.786,83.948C15.644,87.69 19.281,88.777 19.281,88.777L15.929,90.262C15.929,90.262 13.386,89.73 10.604,86.205C8.489,83.527 7.889,80.452 7.889,80.452L9.291,76.613Z"
|
||||
android:fillColor="#FF8F00"/>
|
||||
<path
|
||||
android:pathData="M7.469,87.277C7.319,86.94 7.319,86.558 7.477,86.228L26.579,46.612L29.722,58.425L9.622,87.457C9.082,88.268 7.866,88.162 7.469,87.277Z"
|
||||
android:strokeAlpha="0.44"
|
||||
android:fillColor="#FFFDE7"
|
||||
android:fillAlpha="0.44"/>
|
||||
<path
|
||||
android:pathData="M31.237,62.393C40.162,72.832 50.324,71.527 53.707,68.887C57.097,66.24 59.774,57.143 50.887,46.875C41.572,36.12 31.027,39.188 28.589,41.513C26.152,43.838 23.047,52.815 31.237,62.393Z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:startX="55.787"
|
||||
android:startY="46.379"
|
||||
android:endX="33.462"
|
||||
android:endY="59.774"
|
||||
android:type="linear">
|
||||
<item android:offset="0.024" android:color="#FF8F4700"/>
|
||||
<item android:offset="1" android:color="#FF703E2D"/>
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:pathData="M61.888,66.69C58.633,63.96 56.901,64.448 54.576,65.415C51.576,66.66 46.858,67.582 40.453,65.415L42.381,60.772C46.183,62.055 48.936,61.432 51.313,60.03C54.373,58.23 58.558,55.763 65.068,61.23C67.783,63.51 70.566,65.025 72.606,64.335C74.091,63.84 74.878,61.627 75.276,59.865C75.313,59.708 75.373,59.257 75.418,58.86C75.778,56.107 76.378,50.167 80.803,47.13C85.536,43.882 90.508,43.882 90.508,43.882L91.408,52.822C89.121,52.485 87.531,52.95 86.188,53.693C81.133,56.505 85.536,67.305 77.668,70.935C70.101,74.452 63.913,68.385 61.888,66.69Z"
|
||||
android:fillColor="#03A9F4"/>
|
||||
<path
|
||||
android:pathData="M34.048,55.29L30.793,52.373C36.771,45.697 35.195,40.792 34.048,37.222C33.815,36.502 33.598,35.82 33.456,35.167C32.945,32.857 32.84,30.847 32.998,29.093C30.703,26.235 29.691,23.243 29.623,23.04C28.228,18.817 29.278,14.7 31.685,10.837C36.553,3 45.366,3 45.366,3L48.306,10.868C46.07,10.778 38.743,10.89 36.493,14.438C33.651,18.907 35.518,21.667 35.653,21.983C36.201,21.27 36.756,20.7 37.25,20.257C40.843,17.07 43.963,16.612 45.951,16.792C48.186,16.995 50.21,18.12 51.658,19.965C53.241,21.99 53.893,24.622 53.39,27.015C52.903,29.347 51.35,31.32 49.018,32.572C44.945,34.763 41.556,34.463 39.283,33.705C39.298,33.757 39.306,33.818 39.32,33.87C39.403,34.245 39.568,34.77 39.763,35.377C41.09,39.487 43.558,46.013 34.048,55.29ZM39.561,27.142C39.995,27.458 40.453,27.72 40.925,27.907C42.5,28.538 44.218,28.327 46.168,27.278C47.315,26.663 47.451,26.003 47.495,25.785C47.631,25.132 47.405,24.3 46.918,23.677C46.491,23.13 45.995,22.845 45.403,22.785C44.278,22.688 42.756,23.4 41.233,24.757C40.506,25.41 39.951,26.212 39.561,27.142Z"
|
||||
android:fillColor="#F44336"/>
|
||||
<path
|
||||
android:pathData="M47.076,56.513L42.418,56.385C42.418,56.385 44.631,43.89 51.793,41.79C53.136,41.4 54.605,41.002 56.083,40.785C56.96,40.65 58.348,40.447 59.03,40.193C59.188,39.015 58.693,37.515 58.138,35.813C57.703,34.493 57.253,33.135 57.013,31.65C56.548,28.755 57.32,26.198 59.188,24.435C61.468,22.298 65.15,21.615 69.305,22.56C71.675,23.1 73.423,24.263 74.961,25.282C77.158,26.745 78.44,27.487 81.126,25.68C84.373,23.49 80.128,14.917 77.87,9.968L86.293,6.458C87.425,8.933 92.893,21.667 89.285,28.935C88.071,31.38 85.978,33 83.233,33.607C77.263,34.943 73.768,32.618 71.218,30.923C70.01,30.12 68.953,29.49 67.805,29.16C59.833,26.888 70.963,38.618 65.751,43.89C62.623,47.048 54.98,47.88 54.486,48C49.565,49.185 47.076,56.513 47.076,56.513Z"
|
||||
android:fillColor="#F48FB1"/>
|
||||
<path
|
||||
android:pathData="M32.992,29.093C32.849,30.743 32.782,31.725 33.209,33.87C35.272,35.385 39.764,35.385 39.764,35.385C39.569,34.778 39.397,34.252 39.322,33.877C39.307,33.825 39.299,33.765 39.284,33.713C34.717,31.433 32.992,29.093 32.992,29.093Z"
|
||||
android:fillColor="#C92B27"/>
|
||||
<path
|
||||
android:pathData="M23.648,36.48L15.893,32.678L19.755,27.097L25.838,31.125L23.648,36.48Z"
|
||||
android:fillColor="#FFC107"/>
|
||||
<path
|
||||
android:pathData="M12.217,25.95C8.257,25.417 4.222,22.058 3.779,21.675L7.672,17.108C8.849,18.105 11.347,19.778 13.019,20.003L12.217,25.95Z"
|
||||
android:fillColor="#FB8C00"/>
|
||||
<path
|
||||
android:pathData="M19.206,15.953L13.506,14.085C14.158,12.09 14.331,9.937 13.993,7.86L19.918,6.907C20.406,9.922 20.158,13.05 19.206,15.953Z"
|
||||
android:fillColor="#03A9F4"/>
|
||||
<path
|
||||
android:pathData="M60.666,10.212L54.805,11.494L56.497,19.231L62.359,17.949L60.666,10.212Z"
|
||||
android:fillColor="#FB8C00"/>
|
||||
<path
|
||||
android:pathData="M69.344,13.328L65.219,8.97C67.379,6.923 67.874,4.245 67.874,4.215L73.799,5.183C73.724,5.655 72.966,9.9 69.344,13.328Z"
|
||||
android:fillColor="#FFC107"/>
|
||||
<path
|
||||
android:pathData="M76.877,34.798L71.637,36.436L73.426,42.163L78.667,40.525L76.877,34.798Z"
|
||||
android:fillColor="#FB8C00"/>
|
||||
<path
|
||||
android:pathData="M73.162,84.772L67.2,84.067C67.455,81.945 65.872,79.342 65.438,78.765L70.238,75.165C70.598,75.637 73.725,79.965 73.162,84.772Z"
|
||||
android:fillColor="#F44336"/>
|
||||
<path
|
||||
android:pathData="M90.276,77.168C88.034,76.83 85.739,76.695 83.474,76.777L83.271,70.777C85.904,70.688 88.566,70.838 91.169,71.235L90.276,77.168Z"
|
||||
android:fillColor="#FB8C00"/>
|
||||
<path
|
||||
android:pathData="M86.425,81.157L82.209,85.426L88.01,91.154L92.226,86.885L86.425,81.157Z"
|
||||
android:fillColor="#F48FB1"/>
|
||||
<path
|
||||
android:pathData="M74.159,52.455L69.824,47.498L64.868,51.833L69.203,56.79L74.159,52.455Z"
|
||||
android:fillColor="#F44336"/>
|
||||
</vector>
|
@ -158,32 +158,11 @@
|
||||
tools:itemCount="6"
|
||||
tools:listitem="@layout/view_global_search_result" />
|
||||
|
||||
<LinearLayout
|
||||
<androidx.compose.ui.platform.ComposeView
|
||||
android:id="@+id/emptyStateContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="32dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/activity_home_empty_state_message"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/medium_font_size" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/createNewPrivateChatButton"
|
||||
style="@style/Widget.Session.Button.Common.ProminentOutline"
|
||||
android:layout_width="196dp"
|
||||
android:layout_height="@dimen/medium_button_height"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:text="@string/activity_home_empty_state_button_title" />
|
||||
|
||||
</LinearLayout>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/newConversationButton"
|
||||
|
Loading…
x
Reference in New Issue
Block a user