mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
Improve edit permissions screen
This commit is contained in:
@@ -31,6 +31,7 @@ import com.greenart7c3.nostrsigner.BuildConfig
|
||||
import com.greenart7c3.nostrsigner.LocalPreferences
|
||||
import com.greenart7c3.nostrsigner.NostrSigner
|
||||
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity
|
||||
import com.greenart7c3.nostrsigner.database.NotificationEntity
|
||||
import com.greenart7c3.nostrsigner.models.Account
|
||||
import com.greenart7c3.nostrsigner.models.BunkerRequest
|
||||
@@ -149,6 +150,17 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
||||
|
||||
val permission = database.applicationDao().getByKey(bunkerRequest.localKey)
|
||||
if (permission != null && permission.application.isConnected && type == SignerType.CONNECT) {
|
||||
database.applicationDao()
|
||||
.addHistory(
|
||||
HistoryEntity(
|
||||
0,
|
||||
permission.application.key,
|
||||
type.toString().toLowerCase(Locale.current),
|
||||
amberEvent?.kind,
|
||||
System.currentTimeMillis(),
|
||||
true,
|
||||
),
|
||||
)
|
||||
IntentUtils.sendBunkerResponse(
|
||||
acc,
|
||||
bunkerRequest.localKey,
|
||||
|
||||
@@ -83,14 +83,12 @@ import java.time.format.DateTimeFormatter
|
||||
import java.time.format.FormatStyle
|
||||
|
||||
fun convertLongToDateTime(longValue: Long): String {
|
||||
// Convert the Long timestamp to LocalDateTime
|
||||
val dateTime =
|
||||
LocalDateTime.ofInstant(
|
||||
Instant.ofEpochMilli(longValue),
|
||||
ZoneId.systemDefault(),
|
||||
)
|
||||
|
||||
// Format the LocalDateTime with local format
|
||||
val formatter =
|
||||
DateTimeFormatter.ofLocalizedDateTime(
|
||||
FormatStyle.SHORT,
|
||||
@@ -102,7 +100,6 @@ fun convertLongToDateTime(longValue: Long): String {
|
||||
|
||||
@Composable
|
||||
fun ActivityDialog(
|
||||
account: Account,
|
||||
database: AppDatabase,
|
||||
key: String,
|
||||
onClose: () -> Unit,
|
||||
@@ -150,7 +147,7 @@ fun ActivityDialog(
|
||||
}
|
||||
LazyColumn(
|
||||
Modifier
|
||||
.fillMaxHeight(0.9f)
|
||||
.fillMaxHeight()
|
||||
.fillMaxWidth(),
|
||||
) {
|
||||
items(activities.size) {
|
||||
@@ -169,7 +166,7 @@ fun ActivityDialog(
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
) {
|
||||
Text(
|
||||
permission.toString(),
|
||||
if (permission.type == "connect") "Connect" else permission.toString(),
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 18.sp,
|
||||
maxLines = 1,
|
||||
@@ -185,7 +182,7 @@ fun ActivityDialog(
|
||||
IconButton(onClick = { }) {
|
||||
Icon(
|
||||
if (activity.accepted) Icons.Default.Check else Icons.Default.Close,
|
||||
contentDescription = null,
|
||||
contentDescription = if (activity.accepted) stringResource(R.string.accepted) else stringResource(R.string.rejected),
|
||||
tint = if (activity.accepted) Color.Green else Color.Red,
|
||||
)
|
||||
}
|
||||
@@ -427,7 +424,6 @@ fun EditPermission(
|
||||
|
||||
if (showActivityDialog) {
|
||||
ActivityDialog(
|
||||
account = account,
|
||||
database = database,
|
||||
key = selectedPackage,
|
||||
onClose = {
|
||||
@@ -531,33 +527,36 @@ fun EditPermission(
|
||||
},
|
||||
)
|
||||
|
||||
if (applicationData.secret.isNotEmpty()) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Button(
|
||||
onClick = {
|
||||
editRelaysDialog = true
|
||||
},
|
||||
Modifier.padding(6.dp),
|
||||
) {
|
||||
Text(stringResource(R.string.relays))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Button(
|
||||
onClick = {
|
||||
showActivityDialog = true
|
||||
},
|
||||
Modifier.padding(6.dp),
|
||||
if (applicationData.secret.isNotEmpty()) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Button(
|
||||
onClick = {
|
||||
editRelaysDialog = true
|
||||
},
|
||||
Modifier.padding(6.dp),
|
||||
) {
|
||||
Text(stringResource(R.string.relays))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Text(stringResource(R.string.activity))
|
||||
Button(
|
||||
onClick = {
|
||||
showActivityDialog = true
|
||||
},
|
||||
Modifier.padding(6.dp),
|
||||
) {
|
||||
Text(stringResource(R.string.activity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,4 +120,6 @@
|
||||
<string name="notification_type">Notification Type</string>
|
||||
<string name="select_the_type_of_notification_you_want_to_receive">Select the type of notification you want to receive</string>
|
||||
<string name="activity">Activity</string>
|
||||
<string name="accepted">Accepted</string>
|
||||
<string name="rejected">Rejected</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user