Skip to content
Open
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 @@ -68,8 +68,8 @@ interface CredentialSavePickerDialog {

companion object {
fun resultKeyUserChoseToSaveCredentials(tabId: String) = "${prefix(tabId, TAG)}/UserChoseToSave"
fun resultKeyShouldPromptToDisableAutofill(tabId: String) =
"${prefix(tabId, TAG)}/ShouldPromptToDisableAutofill"

fun resultKeyShouldPromptToDisableAutofill(tabId: String) = "${prefix(tabId, TAG)}/ShouldPromptToDisableAutofill"

const val TAG = "CredentialSavePickerDialog"
const val KEY_URL = "url"
Expand Down Expand Up @@ -253,15 +253,17 @@ interface CredentialAutofillDialogFactory {
/**
* Creates a dialog which prompts the user to import passwords from Google Passwords
*/
fun autofillImportPasswordsPromoDialog(importSource: AutofillImportLaunchSource, tabId: String, url: String): DialogFragment
fun autofillImportPasswordsPromoDialog(
importSource: AutofillImportLaunchSource,
tabId: String,
url: String,
): DialogFragment
}

private fun prefix(
tabId: String,
tag: String,
): String {
return "$tabId/$tag"
}
): String = "$tabId/$tag"

@Parcelize
enum class AutofillImportLaunchSource(val value: String) : Parcelable {
Expand All @@ -273,3 +275,9 @@ enum class AutofillImportLaunchSource(val value: String) : Parcelable {
Unknown("unknown"),
MainAppSettings("settings"),
}

@Parcelize
enum class AutofillImportBookmarksLaunchSource(val value: String) : Parcelable {
Unknown("unknown"),
AutofillDevSettings("autofill_dev_settings"),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright (c) 2025 DuckDuckGo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.duckduckgo.autofill.impl.importing.takeout.webflow

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import com.duckduckgo.anvil.annotations.InjectWith
import com.duckduckgo.autofill.impl.R
import com.duckduckgo.autofill.impl.databinding.FragmentImportBookmarksResultBinding
import com.duckduckgo.common.ui.DuckDuckGoFragment
import com.duckduckgo.common.ui.view.gone
import com.duckduckgo.common.ui.view.show
import com.duckduckgo.di.scopes.FragmentScope

@InjectWith(FragmentScope::class)
class ImportFinishedFragment : DuckDuckGoFragment() {
private var binding: FragmentImportBookmarksResultBinding? = null
private var onDoneCallback: (() -> Unit)? = null

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
binding = FragmentImportBookmarksResultBinding.inflate(inflater, container, false)
return binding!!.root
}

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
setupUi()
setupToolbar()
}

override fun onDestroyView() {
super.onDestroyView()
binding = null
}

private fun setupUi() {
val success = arguments?.getBoolean(ARG_BOOKMARK_IMPORT_SUCCESS, false) ?: false

if (success) {
setupUiForSuccess()
} else {
setupUiForFailure()
}

binding?.doneButton?.setOnClickListener {
onDoneCallback?.invoke()
}
}

private fun setupUiForSuccess() {
val bookmarkCount = arguments?.getInt(ARG_BOOKMARK_COUNT_SUCCESS, 0) ?: 0

binding?.run {
bookmarksImportResult.setPrimaryText(getString(R.string.importBookmarksFromGoogleSuccessBookmarksCount, bookmarkCount))
bookmarksImportResult.setLeadingIconResource(com.duckduckgo.mobile.android.R.drawable.ic_check_green_24)
importResultTitle.text = getString(R.string.importBookmarksSuccessTitle)
secondaryErrorInfo.gone()
}
}

private fun setupUiForFailure() {
val error = arguments?.getString(ARG_BOOKMARK_FAILURE_MESSAGE) ?: getString(R.string.importBookmarksErrorGenericMessage)

binding?.run {
bookmarksImportResult.setPrimaryText(error)
bookmarksImportResult.setLeadingIconResource(R.drawable.ic_cross_recolorable_red_24)
importResultTitle.text = getString(R.string.importBookmarksErrorTitle)
secondaryErrorInfo.show()
}
}

fun setOnDoneCallback(callback: () -> Unit) {
onDoneCallback = callback
}

private fun setupToolbar() {
val toolbar = activity?.findViewById<Toolbar>(com.duckduckgo.mobile.android.R.id.toolbar)
toolbar?.setNavigationOnClickListener {
onDoneCallback?.invoke()
}
}

companion object {
private const val ARG_BOOKMARK_COUNT_SUCCESS = "bookmark_import_count_success"
private const val ARG_BOOKMARK_IMPORT_SUCCESS = "bookmark_import_success"
private const val ARG_BOOKMARK_FAILURE_MESSAGE = "bookmark_import_failure_message"

fun newInstanceSuccess(bookmarksImported: Int): ImportFinishedFragment = ImportFinishedFragment().apply {
arguments =
Bundle().apply {
putInt(ARG_BOOKMARK_COUNT_SUCCESS, bookmarksImported)
putBoolean(ARG_BOOKMARK_IMPORT_SUCCESS, true)
}
}

fun newInstanceFailure(message: String): ImportFinishedFragment = ImportFinishedFragment().apply {
arguments =
Bundle().apply {
putString(ARG_BOOKMARK_FAILURE_MESSAGE, message)
putBoolean(ARG_BOOKMARK_IMPORT_SUCCESS, false)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ sealed interface UserCannotImportReason : Parcelable {

@Parcelize
data object DownloadError : UserCannotImportReason

@Parcelize
data object Unknown : UserCannotImportReason

@Parcelize
data object WebViewError : UserCannotImportReason
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2025 DuckDuckGo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.duckduckgo.autofill.impl.importing.takeout.webflow

import android.os.Bundle
import android.view.View
import com.duckduckgo.anvil.annotations.InjectWith
import com.duckduckgo.autofill.impl.R
import com.duckduckgo.autofill.impl.databinding.FragmentImportBookmarksProgressBinding
import com.duckduckgo.common.ui.DuckDuckGoFragment
import com.duckduckgo.di.scopes.FragmentScope

@InjectWith(FragmentScope::class)
class ImportGoogleBookmarksAutomationInProgressViewFragment : DuckDuckGoFragment(R.layout.fragment_import_bookmarks_progress) {
private var binding: FragmentImportBookmarksProgressBinding? = null

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentImportBookmarksProgressBinding.bind(view)
}

override fun onDestroyView() {
super.onDestroyView()
binding = null
}

companion object {
fun newInstance(): ImportGoogleBookmarksAutomationInProgressViewFragment = ImportGoogleBookmarksAutomationInProgressViewFragment()
}
}
Loading
Loading