mirror of https://github.com/tasks/tasks
Add e-mail disclosure dialog
parent
29519c24cc
commit
f68ef7cbe5
@ -0,0 +1,82 @@
|
||||
package org.tasks.compose
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.ContentAlpha
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.google.android.material.composethemeadapter.MdcTheme
|
||||
import org.tasks.BuildConfig
|
||||
import org.tasks.R
|
||||
import org.tasks.sync.AddAccountDialog.Platform
|
||||
|
||||
@Composable
|
||||
fun AddAccountDialog(
|
||||
hasTasksAccount: Boolean,
|
||||
selected: (Platform) -> Unit,
|
||||
) {
|
||||
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
|
||||
if (!hasTasksAccount) {
|
||||
SyncAccount(
|
||||
title = R.string.tasks_org,
|
||||
description = R.string.tasks_org_description,
|
||||
icon = R.drawable.ic_round_icon,
|
||||
onClick = { selected(Platform.TASKS_ORG) }
|
||||
)
|
||||
}
|
||||
SyncAccount(
|
||||
title = R.string.gtasks_GPr_header,
|
||||
description = R.string.google_tasks_selection_description,
|
||||
icon = R.drawable.ic_google,
|
||||
onClick = { selected(Platform.GOOGLE_TASKS) }
|
||||
)
|
||||
if (BuildConfig.DEBUG) {
|
||||
SyncAccount(
|
||||
title = R.string.microsoft,
|
||||
description = R.string.microsoft_selection_description,
|
||||
icon = R.drawable.ic_microsoft_tasks,
|
||||
onClick = { selected(Platform.MICROSOFT) }
|
||||
)
|
||||
}
|
||||
SyncAccount(
|
||||
title = R.string.davx5,
|
||||
description = R.string.davx5_selection_description,
|
||||
icon = R.drawable.ic_davx5_icon_green_bg,
|
||||
onClick = { selected(Platform.DAVX5) }
|
||||
)
|
||||
SyncAccount(
|
||||
title = R.string.caldav,
|
||||
description = R.string.caldav_selection_description,
|
||||
icon = R.drawable.ic_webdav_logo,
|
||||
tint = MaterialTheme.colors.onSurface.copy(
|
||||
alpha = ContentAlpha.medium
|
||||
),
|
||||
onClick = { selected(Platform.CALDAV) }
|
||||
)
|
||||
SyncAccount(
|
||||
title = R.string.etesync,
|
||||
description = R.string.etesync_selection_description,
|
||||
icon = R.drawable.ic_etesync,
|
||||
onClick = { selected(Platform.ETESYNC) }
|
||||
)
|
||||
SyncAccount(
|
||||
title = R.string.decsync,
|
||||
description = R.string.decsync_selection_description,
|
||||
icon = R.drawable.ic_decsync,
|
||||
onClick = { selected(Platform.DECSYNC_CC) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true, widthDp = 320)
|
||||
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES, widthDp = 320)
|
||||
@Composable
|
||||
fun AddAccountDialogPreview() {
|
||||
MdcTheme {
|
||||
AddAccountDialog(hasTasksAccount = false, selected = {})
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package org.tasks.compose
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.ContentAlpha
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.google.android.material.composethemeadapter.MdcTheme
|
||||
import org.tasks.R
|
||||
import org.tasks.auth.SignInActivity
|
||||
|
||||
@Composable
|
||||
fun SignInDialog(
|
||||
selected: (SignInActivity.Platform) -> Unit,
|
||||
help: () -> Unit,
|
||||
cancel: () -> Unit,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.background(MaterialTheme.colors.surface)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.sign_in_to_tasks),
|
||||
style = MaterialTheme.typography.h6,
|
||||
modifier = Modifier.padding(16.dp),
|
||||
)
|
||||
SyncAccount(
|
||||
title = R.string.sign_in_with_google,
|
||||
description = R.string.google_play_subscribers,
|
||||
icon = R.drawable.ic_google,
|
||||
onClick = { selected(SignInActivity.Platform.GOOGLE) }
|
||||
)
|
||||
SyncAccount(
|
||||
title = R.string.sign_in_with_github,
|
||||
description = R.string.github_sponsors,
|
||||
icon = R.drawable.ic_octocat,
|
||||
tint = MaterialTheme.colors.onSurface.copy(
|
||||
alpha = ContentAlpha.medium
|
||||
),
|
||||
onClick = { selected(SignInActivity.Platform.GITHUB) }
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
) {
|
||||
TextButton(onClick = help) {
|
||||
Text(text = stringResource(id = R.string.help))
|
||||
}
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
TextButton(onClick = cancel) {
|
||||
Text(text = stringResource(id = R.string.cancel))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ConsentDialog(
|
||||
agree: (Boolean) -> Unit,
|
||||
) {
|
||||
Column(Modifier.background(MaterialTheme.colors.surface)) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.sign_in_to_tasks),
|
||||
style = MaterialTheme.typography.h6,
|
||||
modifier = Modifier.padding(16.dp),
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.sign_in_to_tasks_disclosure),
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
)
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.End,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
) {
|
||||
TextButton(onClick = { agree(false) }) {
|
||||
Text(text = stringResource(id = R.string.consent_deny))
|
||||
}
|
||||
TextButton(onClick = { agree(true) }) {
|
||||
Text(text = stringResource(id = R.string.consent_agree))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(widthDp = 320)
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES, widthDp = 320)
|
||||
@Composable
|
||||
fun SignInDialogPreview() {
|
||||
MdcTheme {
|
||||
SignInDialog(selected = {}, help = {}, cancel = {})
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(widthDp = 320)
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES, widthDp = 320)
|
||||
@Composable
|
||||
fun DisclosurePreview() {
|
||||
MdcTheme {
|
||||
ConsentDialog(agree = {})
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?attr/listPreferredItemHeight"
|
||||
android:mode="twoLine"
|
||||
android:paddingStart="@dimen/keyline_first"
|
||||
android:paddingTop="@dimen/list_item_spacing"
|
||||
android:paddingEnd="@dimen/keyline_first"
|
||||
android:paddingBottom="@dimen/list_item_spacing">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginEnd="@dimen/keyline_first"
|
||||
app:tint="@null" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toEndOf="@id/image_view"
|
||||
android:textAppearance="?attr/textAppearanceListItem" />
|
||||
|
||||
<TextView
|
||||
android:id="@id/text2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/text1"
|
||||
android:layout_alignStart="@id/text1"
|
||||
android:textAppearance="?attr/textAppearanceListItemSecondary" />
|
||||
|
||||
</TwoLineListItem>
|
Loading…
Reference in New Issue