Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Fix issue 2572 - GitHub Backups Requirements Card #2575

Merged
merged 8 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

<activity
android:name=".ui.RootActivity"
android:screenOrientation="portrait"
android:exported="true"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" >
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden">
ILIYANGERMANOV marked this conversation as resolved.
Show resolved Hide resolved
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down Expand Up @@ -88,8 +88,8 @@
<receiver
android:name=".ui.widget.WalletBalanceWidgetReceiver"
android:enabled="@bool/glance_appwidget_available"
android:label="@string/wallet_balance"
android:exported="true">
android:exported="true"
android:label="@string/wallet_balance">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package com.ivy.wallet.backup.github.ui

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.provider.Settings
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import com.ivy.design.l0_system.Orange
import com.ivy.wallet.R
import com.ivy.wallet.ui.theme.Red3Dark

@Composable
fun GitHubBackupRequirementsCard(
modifier: Modifier = Modifier,
) {
Card(
modifier = modifier,
shape = RoundedCornerShape(16.dp),
colors = CardDefaults.cardColors(
containerColor = Orange,
contentColor = Red3Dark,
)
) {
Column(
modifier = Modifier.padding(horizontal = 16.dp, vertical = 16.dp),
) {
Row(
verticalAlignment = Alignment.CenterVertically,
) {
Spacer(modifier = Modifier.width(4.dp))
WarningIcon()
Spacer(modifier = Modifier.width(16.dp))
Text(
modifier = Modifier,
text = "Warning",
style = MaterialTheme.typography.bodyMedium,
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Start,
)
}
Spacer(modifier = Modifier.height(16.dp))
WarningCardInfo()
}
}
}

@Composable
private fun WarningCardInfo() {
val text = buildAnnotatedString {
append(
"To ensure Ivy Wallet can automatically backup your data you must do the below:" +
"\n" +
"\n" +
"1. Disable "
)

withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
append("\"BATTERY OPTIMIZATION\"")
}

append(
" for this app in the app's settings.\n" +
"2. In some mobile models like Xiaomi and Vivo the "
)

withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
append("\"AUTOSTART\"")
}

append(" settings must be activated.")
}

Text(
modifier = Modifier,
text = text,
style = MaterialTheme.typography.labelMedium,
textAlign = TextAlign.Start,
fontWeight = FontWeight.Normal,
)

Spacer(modifier = Modifier.height(16.dp))

val context = LocalContext.current
Button(
onClick = {
openAppSettings(context)
}
) {
Text(text = "App's Settings")
}
}

private fun openAppSettings(context: Context) {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri: Uri = Uri.fromParts("package", context.packageName, null)
intent.data = uri
context.startActivity(intent)
}

@Composable
private fun WarningIcon(
modifier: Modifier = Modifier,
) {
Image(
modifier = modifier,
painter = painterResource(id = R.drawable.ic_add_due_date),
contentDescription = null,
contentScale = ContentScale.Fit,
colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -59,6 +60,7 @@ fun GitHubBackupScreen() {
val nav = navigation()

Scaffold(
modifier = Modifier.systemBarsPadding(),
topBar = {
CenterAlignedTopAppBar(
title = {
Expand Down Expand Up @@ -192,6 +194,10 @@ private fun Content(
GitHubBackupStatus(viewModel = viewModel)
}

if (enabled) {
GitHubBackupRequirementsCard()
}

// Scroll fix
Spacer(modifier = Modifier.height(320.dp))
}
Expand Down