Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.webkit.CookieManager
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.IntentCompat
Expand Down Expand Up @@ -317,6 +318,10 @@ class AutofillInternalSettingsActivity : DuckDuckGoActivity() {
importCsvLauncher.launch(intent)
}

binding.importPasswordsGoogleLogoutButton.setClickListener {
clearGoogleCookies()
}

binding.importPasswordsResetImportedFlagButton.setClickListener {
lifecycleScope.launch(dispatchers.io()) {
autofillStore.hasDismissedMainAppSettingsPromo = false
Expand Down Expand Up @@ -651,6 +656,21 @@ class AutofillInternalSettingsActivity : DuckDuckGoActivity() {
return LoginCredentials(username = username, password = password, domain = domain)
}

private fun clearGoogleCookies() {
val cookieManager = CookieManager.getInstance()
val domain = ".google.com"

cookieManager.getCookie(domain)?.let { cookies ->
cookies.split(";").forEach { cookie ->
val cookieName = cookie.substringBefore("=").trim()
cookieManager.setCookie(domain, "$cookieName=; Max-Age=0; Path=/")
}
}
cookieManager.flush()

Toast.makeText(this, R.string.autofillDevSettingsGoogleLogoutSuccess, Toast.LENGTH_SHORT).show()
}

companion object {
fun intent(context: Context): Intent {
return Intent(context, AutofillInternalSettingsActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@
android:layout_height="wrap_content"
app:primaryText="@string/autofillDevSettingsImportPasswordsImportPasswordsCsvTitle" />

<com.duckduckgo.common.ui.view.listitem.TwoLineListItem
android:id="@+id/importPasswordsGoogleLogoutButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:primaryText="@string/autofillDevSettingsImportPasswordsGoogleLogoutTitle"
app:secondaryText="@string/autofillDevSettingsImportPasswordsGoogleInstruction" />

<com.duckduckgo.common.ui.view.listitem.TwoLineListItem
android:id="@+id/importPasswordsResetImportedFlagButton"
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<string name="autofillDevSettingsImportPasswordsExportPasswordsOurAppTitle">Launch Google Passwords (normal tab)</string>
<string name="autofillDevSettingsImportPasswordsExportPasswordsImportFlowTitle">Launch Google Passwords (import flow)</string>
<string name="autofillDevSettingsImportPasswordsImportPasswordsCsvTitle">Import CSV</string>
<string name="autofillDevSettingsImportPasswordsGoogleLogoutTitle">Google Account Logout</string>
<string name="autofillDevSettingsImportPasswordsGoogleInstruction">Tap to clear all Google cookies</string>
<string name="autofillDevSettingsGoogleLogoutSuccess">Google cookies cleared</string>
<string name="autofillDevSettingsImportGooglePasswordsSuccessMessage" instruction="Placeholder is the number of passwords we were able to import">%1$d passwords imported from Google</string>
<string name="autofillDevSettingsResetGooglePasswordsImportFlagTitle">Clear Previous Google Imports interactions</string>
<string name="autofillDevSettingsResetGooglePasswordsImportFlagInstruction">Tap to forget whether we\'ve previously imported, what we chose when previously prompted etc…</string>
Expand Down
Loading