Skip to content

Commit f0c110e

Browse files
committed
Add webflow for importing bookmarks from Google
1 parent 3333dc7 commit f0c110e

24 files changed

+1527
-1
lines changed

autofill/autofill-impl/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dependencies {
4747
testImplementation project(':feature-toggles-test')
4848
implementation project(path: ':settings-api') // temporary until we release new settings
4949
implementation project(':library-loader-api')
50+
implementation project(':saved-sites-api')
5051

5152
anvil project(path: ':anvil-compiler')
5253
implementation project(path: ':anvil-annotations')

autofill/autofill-impl/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
android:name=".importing.gpm.webflow.ImportGooglePasswordsWebFlowActivity"
2222
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|navigation|keyboard"
2323
android:exported="false" />
24+
<activity
25+
android:name=".importing.takeout.webflow.ImportGoogleBookmarksWebFlowActivity"
26+
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|navigation|keyboard"
27+
android:exported="false" />
2428
<activity
2529
android:name=".ui.credential.management.AutofillManagementActivity"
2630
android:configChanges="orientation|screenSize"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2025 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.autofill.impl.importing.takeout.webflow
18+
19+
import android.os.Parcelable
20+
import kotlinx.parcelize.Parcelize
21+
22+
sealed interface ImportGoogleBookmarkResult : Parcelable {
23+
24+
@Parcelize
25+
data object Success : ImportGoogleBookmarkResult
26+
27+
@Parcelize
28+
data class UserCancelled(val stage: String) : ImportGoogleBookmarkResult
29+
30+
@Parcelize
31+
data class Error(val reason: ImportGoogleBookmarksWebFlowViewModel.UserCannotImportReason) : ImportGoogleBookmarkResult
32+
33+
companion object {
34+
const val RESULT_KEY = "importBookmarkResult"
35+
const val RESULT_KEY_DETAILS = "importBookmarkResultDetails"
36+
}
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2024 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.autofill.impl.importing.takeout.webflow
18+
19+
import javax.inject.Inject
20+
21+
class ImportGoogleBookmarkUrlToStageMapper @Inject constructor() {
22+
23+
fun getStage(url: String): String {
24+
return when {
25+
url.contains("takeout.google.com") -> {
26+
when {
27+
url.contains("archive") -> "download"
28+
url.contains("transfer") -> "transfer"
29+
url.contains("settings") -> "settings"
30+
else -> "takeout"
31+
}
32+
}
33+
url.contains("accounts.google.com") -> "authentication"
34+
else -> "unknown"
35+
}
36+
}
37+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2025 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.autofill.impl.importing.takeout.webflow
18+
19+
import android.content.Intent
20+
import android.os.Bundle
21+
import androidx.fragment.app.commit
22+
import com.duckduckgo.anvil.annotations.ContributeToActivityStarter
23+
import com.duckduckgo.anvil.annotations.InjectWith
24+
import com.duckduckgo.autofill.impl.R
25+
import com.duckduckgo.autofill.impl.databinding.ActivityImportGoogleBookmarksWebflowBinding
26+
import com.duckduckgo.autofill.impl.importing.takeout.webflow.ImportGoogleBookmark.AutofillImportViaGoogleTakeoutScreen
27+
import com.duckduckgo.common.ui.DuckDuckGoActivity
28+
import com.duckduckgo.common.ui.viewbinding.viewBinding
29+
import com.duckduckgo.di.scopes.ActivityScope
30+
import com.duckduckgo.navigation.api.GlobalActivityStarter.ActivityParams
31+
32+
@InjectWith(ActivityScope::class)
33+
@ContributeToActivityStarter(AutofillImportViaGoogleTakeoutScreen::class)
34+
class ImportGoogleBookmarksWebFlowActivity : DuckDuckGoActivity() {
35+
36+
val binding: ActivityImportGoogleBookmarksWebflowBinding by viewBinding()
37+
38+
override fun onCreate(savedInstanceState: Bundle?) {
39+
super.onCreate(savedInstanceState)
40+
setContentView(binding.root)
41+
configureResultListeners()
42+
launchImportFragment()
43+
}
44+
45+
private fun launchImportFragment() {
46+
supportFragmentManager.commit {
47+
replace(R.id.fragment_container, ImportGoogleBookmarksWebFlowFragment())
48+
}
49+
}
50+
51+
private fun configureResultListeners() {
52+
supportFragmentManager.setFragmentResultListener(ImportGoogleBookmarkResult.Companion.RESULT_KEY, this) { _, result ->
53+
exitWithResult(result)
54+
}
55+
}
56+
57+
private fun exitWithResult(resultBundle: Bundle) {
58+
setResult(RESULT_OK, Intent().putExtras(resultBundle))
59+
finish()
60+
}
61+
62+
fun exitUserCancelled(stage: String) {
63+
val result = Bundle().apply {
64+
putParcelable(
65+
ImportGoogleBookmarkResult.Companion.RESULT_KEY_DETAILS,
66+
ImportGoogleBookmarkResult.UserCancelled(stage),
67+
)
68+
}
69+
exitWithResult(result)
70+
}
71+
}
72+
73+
object ImportGoogleBookmark {
74+
data object AutofillImportViaGoogleTakeoutScreen : ActivityParams {
75+
private fun readResolve(): Any = AutofillImportViaGoogleTakeoutScreen
76+
}
77+
}

0 commit comments

Comments
 (0)