"Fix" Google signin style
This commit is contained in:
parent
e55ab9116b
commit
1536cb7365
30
g-services/src/main/res/drawable/ic_google_g.xml
Normal file
30
g-services/src/main/res/drawable/ic_google_g.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="46dp"
|
||||||
|
android:height="46dp"
|
||||||
|
android:viewportWidth="46"
|
||||||
|
android:viewportHeight="46">
|
||||||
|
<path
|
||||||
|
android:pathData="m45.265,23.521c0,-1.624 -0.146,-3.186 -0.416,-4.685L23.278,18.836L23.278,27.695L35.604,27.695c-0.531,2.863 -2.145,5.288 -4.57,6.912v5.747h7.402c4.331,-3.987 6.829,-9.859 6.829,-16.834z"
|
||||||
|
android:strokeWidth="2.54476"
|
||||||
|
android:fillColor="#4285f4"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m23.278,45.903c6.184,0 11.368,-2.051 15.157,-5.549l-7.402,-5.747c-2.051,1.374 -4.674,2.186 -7.756,2.186 -5.965,0 -11.014,-4.029 -12.815,-9.442h-7.652v5.934C6.58,40.77 14.325,45.903 23.278,45.903Z"
|
||||||
|
android:strokeWidth="2.54476"
|
||||||
|
android:fillColor="#34a853"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M10.463,27.352C10.005,25.977 9.745,24.509 9.745,23c0,-1.51 0.26,-2.977 0.718,-4.352L10.463,12.715L2.811,12.715C1.26,15.806 0.375,19.304 0.375,23c0,3.696 0.885,7.194 2.436,10.285z"
|
||||||
|
android:strokeWidth="2.54476"
|
||||||
|
android:fillColor="#fbbc05"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
<path
|
||||||
|
android:pathData="m23.278,9.206c3.363,0 6.382,1.156 8.755,3.425l6.569,-6.569C34.636,2.367 29.451,0.097 23.278,0.097c-8.953,0 -16.698,5.132 -20.467,12.617l7.652,5.934c1.801,-5.413 6.85,-9.442 12.815,-9.442z"
|
||||||
|
android:strokeWidth="2.54476"
|
||||||
|
android:fillColor="#ea4335"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:strokeColor="#00000000"/>
|
||||||
|
</vector>
|
||||||
@ -1,16 +1,28 @@
|
|||||||
package de.mm20.launcher2.ui.settings.accounts
|
package de.mm20.launcher2.ui.settings.accounts
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.LinearProgressIndicator
|
import androidx.compose.material3.LinearProgressIndicator
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
@ -104,7 +116,10 @@ fun AccountsSettingsScreen() {
|
|||||||
if (account != null) {
|
if (account != null) {
|
||||||
viewModel.signOut(AccountType.Microsoft)
|
viewModel.signOut(AccountType.Microsoft)
|
||||||
} else {
|
} else {
|
||||||
viewModel.signIn(context as AppCompatActivity, AccountType.Microsoft)
|
viewModel.signIn(
|
||||||
|
context as AppCompatActivity,
|
||||||
|
AccountType.Microsoft
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -115,25 +130,70 @@ fun AccountsSettingsScreen() {
|
|||||||
item {
|
item {
|
||||||
PreferenceCategory(title = stringResource(R.string.preference_category_services_google)) {
|
PreferenceCategory(title = stringResource(R.string.preference_category_services_google)) {
|
||||||
val account by viewModel.googleUser.observeAsState()
|
val account by viewModel.googleUser.observeAsState()
|
||||||
Preference(
|
if (account == null) {
|
||||||
title = if (account != null) {
|
Box(modifier = Modifier
|
||||||
stringResource(R.string.preference_signin_logout)
|
.padding(start = 56.dp)
|
||||||
} else {
|
.padding(16.dp)) {
|
||||||
stringResource(R.string.preference_google_signin)
|
GoogleSigninButton(
|
||||||
},
|
onClick = {
|
||||||
summary = account?.let {
|
viewModel.signIn(
|
||||||
stringResource(R.string.preference_signin_user, it.userName)
|
context as AppCompatActivity,
|
||||||
} ?: stringResource(R.string.preference_google_signin_summary),
|
AccountType.Google
|
||||||
onClick = {
|
)
|
||||||
if (account != null) {
|
}
|
||||||
viewModel.signOut(AccountType.Google)
|
)
|
||||||
} else {
|
|
||||||
viewModel.signIn(context as AppCompatActivity, AccountType.Google)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
} else {
|
||||||
|
Preference(
|
||||||
|
title = stringResource(R.string.preference_signin_logout),
|
||||||
|
summary = account?.userName?.let {
|
||||||
|
stringResource(R.string.preference_signin_user, it)
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
viewModel.signOut(AccountType.Google)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun GoogleSigninButton(
|
||||||
|
onClick: () -> Unit,
|
||||||
|
) {
|
||||||
|
Surface(
|
||||||
|
modifier = Modifier.height(40.dp),
|
||||||
|
shadowElevation = 1.dp,
|
||||||
|
color = Color.White,
|
||||||
|
shape = RoundedCornerShape(2.dp),
|
||||||
|
onClick = onClick
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(40.dp)
|
||||||
|
.background(Color.White),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
modifier = Modifier.size(18.dp),
|
||||||
|
painter = painterResource(id = R.drawable.ic_google_g),
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.padding(start = 13.dp, end = 8.dp),
|
||||||
|
text = stringResource(id = R.string.preference_google_signin),
|
||||||
|
fontFamily = FontFamily.SansSerif,
|
||||||
|
color = Color(0f, 0f, 0f, 0.54f),
|
||||||
|
fontSize = 14.sp,
|
||||||
|
fontWeight = FontWeight.Medium
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user