mirror of
https://github.com/ProtonMail/protoncore_android.git
synced 2026-05-15 09:50:41 +00:00
feat(account-manager): Add SignOutDialogActivity userid.
This commit is contained in:
@@ -144,6 +144,7 @@ public abstract class me/proton/core/accountmanager/presentation/compose/Hilt_Si
|
||||
|
||||
public final class me/proton/core/accountmanager/presentation/compose/SignOutDialogActivity : me/proton/core/presentation/ui/ProtonActivity {
|
||||
public static final field $stable I
|
||||
public static final field ARG_INPUT Ljava/lang/String;
|
||||
public static final field Companion Lme/proton/core/accountmanager/presentation/compose/SignOutDialogActivity$Companion;
|
||||
public field accountManager Lme/proton/core/accountmanager/domain/AccountManager;
|
||||
public fun <init> ()V
|
||||
@@ -152,7 +153,8 @@ public final class me/proton/core/accountmanager/presentation/compose/SignOutDia
|
||||
}
|
||||
|
||||
public final class me/proton/core/accountmanager/presentation/compose/SignOutDialogActivity$Companion {
|
||||
public final fun start (Landroid/app/Activity;)V
|
||||
public final fun start (Landroid/app/Activity;Lme/proton/core/domain/entity/UserId;)V
|
||||
public static synthetic fun start$default (Lme/proton/core/accountmanager/presentation/compose/SignOutDialogActivity$Companion;Landroid/app/Activity;Lme/proton/core/domain/entity/UserId;ILjava/lang/Object;)V
|
||||
}
|
||||
|
||||
public abstract interface class me/proton/core/accountmanager/presentation/compose/SignOutDialogActivity_GeneratedInjector {
|
||||
@@ -172,6 +174,29 @@ public final class me/proton/core/accountmanager/presentation/compose/SignOutDia
|
||||
public static final fun SignOutDialog (Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;II)V
|
||||
}
|
||||
|
||||
public final class me/proton/core/accountmanager/presentation/compose/entity/SignOutDialogInput : android/os/Parcelable {
|
||||
public static final field $stable I
|
||||
public static final field CREATOR Landroid/os/Parcelable$Creator;
|
||||
public fun <init> (Ljava/lang/String;)V
|
||||
public final fun component1 ()Ljava/lang/String;
|
||||
public final fun copy (Ljava/lang/String;)Lme/proton/core/accountmanager/presentation/compose/entity/SignOutDialogInput;
|
||||
public static synthetic fun copy$default (Lme/proton/core/accountmanager/presentation/compose/entity/SignOutDialogInput;Ljava/lang/String;ILjava/lang/Object;)Lme/proton/core/accountmanager/presentation/compose/entity/SignOutDialogInput;
|
||||
public fun describeContents ()I
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getUserId ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
public fun writeToParcel (Landroid/os/Parcel;I)V
|
||||
}
|
||||
|
||||
public final class me/proton/core/accountmanager/presentation/compose/entity/SignOutDialogInput$Creator : android/os/Parcelable$Creator {
|
||||
public fun <init> ()V
|
||||
public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object;
|
||||
public final fun createFromParcel (Landroid/os/Parcel;)Lme/proton/core/accountmanager/presentation/compose/entity/SignOutDialogInput;
|
||||
public synthetic fun newArray (I)[Ljava/lang/Object;
|
||||
public final fun newArray (I)[Lme/proton/core/accountmanager/presentation/compose/entity/SignOutDialogInput;
|
||||
}
|
||||
|
||||
public final class me/proton/core/accountmanager/presentation/compose/viewmodel/AccountSettingsViewModel : me/proton/core/presentation/viewmodel/ProtonViewModel, me/proton/core/telemetry/presentation/ProductMetricsDelegate {
|
||||
public static final field $stable I
|
||||
public fun <init> (Lme/proton/core/accountmanager/domain/AccountManager;Lme/proton/core/user/domain/usecase/ObserveUser;Lme/proton/core/usersettings/domain/usecase/ObserveUserSettings;Lme/proton/core/telemetry/domain/TelemetryManager;)V
|
||||
|
||||
@@ -22,6 +22,7 @@ import studio.forface.easygradle.dsl.android.*
|
||||
plugins {
|
||||
protonComposeUiLibrary
|
||||
protonDagger
|
||||
id("kotlin-parcelize")
|
||||
}
|
||||
|
||||
publishOption.shouldBePublishedAsLib = true
|
||||
|
||||
+23
-8
@@ -28,7 +28,9 @@ import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.launch
|
||||
import me.proton.core.accountmanager.domain.AccountManager
|
||||
import me.proton.core.accountmanager.presentation.compose.entity.SignOutDialogInput
|
||||
import me.proton.core.compose.theme.ProtonTheme
|
||||
import me.proton.core.domain.entity.UserId
|
||||
import me.proton.core.presentation.ui.ProtonActivity
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -38,6 +40,16 @@ class SignOutDialogActivity : ProtonActivity() {
|
||||
@Inject
|
||||
lateinit var accountManager: AccountManager
|
||||
|
||||
private val input: SignOutDialogInput by lazy {
|
||||
requireNotNull(intent?.extras?.getParcelable(ARG_INPUT))
|
||||
}
|
||||
|
||||
private val userId by lazy {
|
||||
input.userId?.let {
|
||||
UserId(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
@@ -52,25 +64,28 @@ class SignOutDialogActivity : ProtonActivity() {
|
||||
}
|
||||
|
||||
private fun onRemoveAccount() = lifecycleScope.launch {
|
||||
val userId = accountManager.getPrimaryUserId().firstOrNull() ?: return@launch
|
||||
val userId = userId ?: accountManager.getPrimaryUserId().firstOrNull() ?: return@launch
|
||||
accountManager.removeAccount(userId)
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun onDisableAccount() = lifecycleScope.launch {
|
||||
val userId = accountManager.getPrimaryUserId().firstOrNull() ?: return@launch
|
||||
val userId = userId ?: accountManager.getPrimaryUserId().firstOrNull() ?: return@launch
|
||||
accountManager.disableAccount(userId)
|
||||
finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun start(context: Activity) {
|
||||
context.startActivityForResult(getIntent(context), 0)
|
||||
|
||||
const val ARG_INPUT = "arg.signOutDialogInput"
|
||||
|
||||
fun start(context: Activity, userId: UserId? = null) {
|
||||
context.startActivityForResult(getIntent(context, SignOutDialogInput(userId?.id)), 0)
|
||||
}
|
||||
|
||||
private fun getIntent(context: Context): Intent = Intent(
|
||||
context,
|
||||
SignOutDialogActivity::class.java
|
||||
)
|
||||
private fun getIntent(context: Context, input: SignOutDialogInput): Intent =
|
||||
Intent(context, SignOutDialogActivity::class.java).apply {
|
||||
putExtra(ARG_INPUT, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Proton Technologies AG
|
||||
* This file is part of Proton AG and ProtonCore.
|
||||
*
|
||||
* ProtonCore is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ProtonCore is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ProtonCore. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.proton.core.accountmanager.presentation.compose.entity
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class SignOutDialogInput(
|
||||
val userId: String?
|
||||
) : Parcelable
|
||||
Reference in New Issue
Block a user