Skip to content

Commit 74686f2

Browse files
committed
Formatting update after the recent spotless change
1 parent 9b60bed commit 74686f2

File tree

22 files changed

+770
-648
lines changed

22 files changed

+770
-648
lines changed

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/importing/gpm/webflow/GoogleImporterScriptLoader.kt

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ import com.duckduckgo.autofill.impl.importing.takeout.store.BookmarkImportConfig
2121
import com.duckduckgo.common.utils.DispatcherProvider
2222
import com.duckduckgo.di.scopes.FragmentScope
2323
import com.squareup.anvil.annotations.ContributesBinding
24+
import kotlinx.coroutines.withContext
2425
import java.io.BufferedReader
2526
import javax.inject.Inject
26-
import kotlinx.coroutines.withContext
2727

2828
interface GoogleImporterScriptLoader {
2929
suspend fun getScriptForPasswordImport(): String
30+
3031
suspend fun getScriptForBookmarkImport(): String
3132
}
3233

@@ -36,33 +37,30 @@ class GoogleImporterScriptLoaderImpl @Inject constructor(
3637
private val passwordConfigStore: AutofillImportPasswordConfigStore,
3738
private val bookmarkConfigStore: BookmarkImportConfigStore,
3839
) : GoogleImporterScriptLoader {
39-
4040
private lateinit var contentScopeJS: String
4141

42-
override suspend fun getScriptForPasswordImport(): String {
43-
return withContext(dispatchers.io()) {
42+
override suspend fun getScriptForPasswordImport(): String =
43+
withContext(dispatchers.io()) {
4444
getContentScopeJS()
4545
.replace(CONTENT_SCOPE_PLACEHOLDER, getContentScopeScriptJson(loadSettingsJsonPassword()))
4646
.replace(USER_UNPROTECTED_DOMAINS_PLACEHOLDER, getUnprotectedDomainsJson())
4747
.replace(USER_PREFERENCES_PLACEHOLDER, getUserPreferencesJson())
4848
}
49-
}
5049

51-
override suspend fun getScriptForBookmarkImport(): String {
52-
return withContext(dispatchers.io()) {
50+
override suspend fun getScriptForBookmarkImport(): String =
51+
withContext(dispatchers.io()) {
5352
getContentScopeJS()
5453
.replace(CONTENT_SCOPE_PLACEHOLDER, getContentScopeScriptJson(loadSettingsJsonBookmark()))
5554
.replace(USER_UNPROTECTED_DOMAINS_PLACEHOLDER, getUnprotectedDomainsJson())
5655
.replace(USER_PREFERENCES_PLACEHOLDER, getUserPreferencesJson())
5756
}
58-
}
5957

6058
/**
6159
* This enables the password import hints feature in C-S-S.
6260
* These settings are for enabling it; the check for whether it should be enabled or not is done elsewhere.
6361
*/
64-
private fun getContentScopeScriptJson(settingsJson: String): String {
65-
return """{
62+
private fun getContentScopeScriptJson(settingsJson: String): String =
63+
"""{
6664
"features":{
6765
"autofillImport" : {
6866
"state": "enabled",
@@ -72,20 +70,15 @@ class GoogleImporterScriptLoaderImpl @Inject constructor(
7270
},
7371
"unprotectedTemporary":[]
7472
}
75-
73+
7674
""".trimMargin()
77-
}
7875

79-
private suspend fun loadSettingsJsonPassword(): String {
80-
return passwordConfigStore.getConfig().javascriptConfigGooglePasswords
81-
}
76+
private suspend fun loadSettingsJsonPassword(): String = passwordConfigStore.getConfig().javascriptConfigGooglePasswords
8277

83-
private suspend fun loadSettingsJsonBookmark(): String {
84-
return bookmarkConfigStore.getConfig().javascriptConfigGoogleTakeout
85-
}
78+
private suspend fun loadSettingsJsonBookmark(): String = bookmarkConfigStore.getConfig().javascriptConfigGoogleTakeout
8679

87-
private fun getUserPreferencesJson(): String {
88-
return """
80+
private fun getUserPreferencesJson(): String =
81+
"""
8982
{
9083
"platform":{
9184
"name":"android"
@@ -94,7 +87,6 @@ class GoogleImporterScriptLoaderImpl @Inject constructor(
9487
"javascriptInterface": ''
9588
}
9689
""".trimMargin()
97-
}
9890

9991
private fun getUnprotectedDomainsJson(): String = "[]"
10092

@@ -113,7 +105,9 @@ class GoogleImporterScriptLoaderImpl @Inject constructor(
113105

114106
private fun loadJs(resourceName: String): String = readResource(resourceName).use { it?.readText() }.orEmpty()
115107

116-
private fun readResource(resourceName: String): BufferedReader? {
117-
return javaClass.classLoader?.getResource(resourceName)?.openStream()?.bufferedReader()
118-
}
108+
private fun readResource(resourceName: String): BufferedReader? =
109+
javaClass.classLoader
110+
?.getResource(resourceName)
111+
?.openStream()
112+
?.bufferedReader()
119113
}

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/importing/gpm/webflow/ImportGooglePasswordsWebFlowFragment.kt

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ import com.duckduckgo.common.utils.FragmentViewModelFactory
7171
import com.duckduckgo.common.utils.plugins.PluginPoint
7272
import com.duckduckgo.di.scopes.FragmentScope
7373
import com.duckduckgo.user.agent.api.UserAgentProvider
74-
import javax.inject.Inject
7574
import kotlinx.coroutines.flow.launchIn
7675
import kotlinx.coroutines.flow.onEach
7776
import kotlinx.coroutines.launch
7877
import kotlinx.coroutines.withContext
7978
import logcat.LogPriority.WARN
8079
import logcat.logcat
80+
import javax.inject.Inject
8181

8282
@InjectWith(FragmentScope::class)
8383
class ImportGooglePasswordsWebFlowFragment :
@@ -88,7 +88,6 @@ class ImportGooglePasswordsWebFlowFragment :
8888
NoOpEmailProtectionUserPromptListener,
8989
NoOpAutofillEventListener,
9090
GooglePasswordBlobConsumer.Callback {
91-
9291
@Inject
9392
lateinit var userAgentProvider: UserAgentProvider
9493

@@ -175,8 +174,7 @@ class ImportGooglePasswordsWebFlowFragment :
175174
// no-op
176175
}
177176
}
178-
}
179-
.launchIn(lifecycleScope)
177+
}.launchIn(lifecycleScope)
180178
}
181179

182180
private fun observeCommands() {
@@ -197,8 +195,7 @@ class ImportGooglePasswordsWebFlowFragment :
197195
showCredentialChooserDialog(command.originalUrl, command.credentials, command.triggerType)
198196
}
199197
}
200-
}
201-
.launchIn(lifecycleScope)
198+
}.launchIn(lifecycleScope)
202199
}
203200

204201
private suspend fun injectReauthenticationCredentials(
@@ -213,11 +210,12 @@ class ImportGooglePasswordsWebFlowFragment :
213210
return@withContext
214211
}
215212

216-
val credentials = LoginCredentials(
217-
domain = url,
218-
username = username,
219-
password = password,
220-
)
213+
val credentials =
214+
LoginCredentials(
215+
domain = url,
216+
username = username,
217+
password = password,
218+
)
221219

222220
logcat { "Injecting re-authentication credentials" }
223221
browserAutofill.injectCredentials(credentials)
@@ -230,16 +228,18 @@ class ImportGooglePasswordsWebFlowFragment :
230228
}
231229

232230
private fun exitFlowAsSuccess() {
233-
val resultBundle = Bundle().also {
234-
it.putParcelable(RESULT_KEY_DETAILS, ImportGooglePasswordResult.Success)
235-
}
231+
val resultBundle =
232+
Bundle().also {
233+
it.putParcelable(RESULT_KEY_DETAILS, ImportGooglePasswordResult.Success)
234+
}
236235
setFragmentResult(RESULT_KEY, resultBundle)
237236
}
238237

239238
private fun exitFlowAsImpossibleToImport(reason: UserCannotImportReason) {
240-
val resultBundle = Bundle().also {
241-
it.putParcelable(RESULT_KEY_DETAILS, ImportGooglePasswordResult.Error(reason))
242-
}
239+
val resultBundle =
240+
Bundle().also {
241+
it.putParcelable(RESULT_KEY_DETAILS, ImportGooglePasswordResult.Error(reason))
242+
}
243243
setFragmentResult(RESULT_KEY, resultBundle)
244244
}
245245

@@ -367,12 +367,13 @@ class ImportGooglePasswordsWebFlowFragment :
367367
return@withContext
368368
}
369369

370-
val dialog = credentialAutofillDialogFactory.autofillSelectCredentialsDialog(
371-
url,
372-
credentials,
373-
triggerType,
374-
CUSTOM_FLOW_TAB_ID,
375-
)
370+
val dialog =
371+
credentialAutofillDialogFactory.autofillSelectCredentialsDialog(
372+
url,
373+
credentials,
374+
triggerType,
375+
CUSTOM_FLOW_TAB_ID,
376+
)
376377
dialog.show(childFragmentManager, SELECT_CREDENTIALS_FRAGMENT_TAG)
377378
}
378379
}

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/importing/takeout/processor/TakeoutBookmarkImporter.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,37 @@ import com.duckduckgo.savedsites.api.service.ImportSavedSitesResult
2323
import com.duckduckgo.savedsites.api.service.SavedSitesImporter
2424
import com.duckduckgo.savedsites.api.service.SavedSitesImporter.ImportFolder
2525
import com.squareup.anvil.annotations.ContributesBinding
26+
import kotlinx.coroutines.withContext
2627
import java.io.File
2728
import javax.inject.Inject
28-
import kotlinx.coroutines.withContext
2929

3030
/**
3131
* Interface for importing bookmarks with flexible destination handling.
3232
* Supports both root-level imports and folder-based imports while preserving structure.
3333
*/
3434
interface TakeoutBookmarkImporter {
35-
3635
/**
3736
* Imports bookmarks from a temporary HTML file to the specified destination. The file will be deleted after import.
3837
* @param tempFileUri URI of the temporary HTML file containing bookmark content (in Netscape format)
3938
* @param destination Where to import the bookmarks (Root or named Folder within bookmarks root)
4039
* @return ImportSavedSitesResult indicating success with imported items or error
4140
*/
42-
suspend fun importBookmarks(tempFileUri: Uri, destination: ImportFolder): ImportSavedSitesResult
41+
suspend fun importBookmarks(
42+
tempFileUri: Uri,
43+
destination: ImportFolder,
44+
): ImportSavedSitesResult
4345
}
4446

4547
@ContributesBinding(AppScope::class)
4648
class RealTakeoutBookmarkImporter @Inject constructor(
4749
private val savedSitesImporter: SavedSitesImporter,
4850
private val dispatchers: DispatcherProvider,
4951
) : TakeoutBookmarkImporter {
50-
51-
override suspend fun importBookmarks(tempFileUri: Uri, destination: ImportFolder): ImportSavedSitesResult {
52-
return withContext(dispatchers.io()) {
52+
override suspend fun importBookmarks(
53+
tempFileUri: Uri,
54+
destination: ImportFolder,
55+
): ImportSavedSitesResult =
56+
withContext(dispatchers.io()) {
5357
try {
5458
savedSitesImporter.import(tempFileUri, destination)
5559
} catch (exception: Exception) {
@@ -58,7 +62,6 @@ class RealTakeoutBookmarkImporter @Inject constructor(
5862
cleanupTempFile(tempFileUri)
5963
}
6064
}
61-
}
6265

6366
private fun cleanupTempFile(tempFileUri: Uri) {
6467
runCatching {

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/importing/takeout/store/BookmarkImportConfigStore.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import com.duckduckgo.di.scopes.AppScope
2222
import com.squareup.anvil.annotations.ContributesBinding
2323
import com.squareup.moshi.JsonAdapter
2424
import com.squareup.moshi.Moshi
25-
import javax.inject.Inject
2625
import kotlinx.coroutines.withContext
2726
import org.json.JSONObject
27+
import javax.inject.Inject
2828

2929
interface BookmarkImportConfigStore {
3030
suspend fun getConfig(): BookmarkImportSettings
@@ -43,18 +43,18 @@ class BookmarkImportConfigStoreImpl @Inject constructor(
4343
private val dispatchers: DispatcherProvider,
4444
private val moshi: Moshi,
4545
) : BookmarkImportConfigStore {
46-
4746
private val jsonAdapter: JsonAdapter<ImportConfigJson> by lazy {
4847
moshi.adapter(ImportConfigJson::class.java)
4948
}
5049

51-
override suspend fun getConfig(): BookmarkImportSettings {
52-
return withContext(dispatchers.io()) {
53-
val config = autofillFeature.canImportBookmarksFromGoogleTakeout().getSettings()?.let {
54-
runCatching {
55-
jsonAdapter.fromJson(it)
56-
}.getOrNull()
57-
}
50+
override suspend fun getConfig(): BookmarkImportSettings =
51+
withContext(dispatchers.io()) {
52+
val config =
53+
autofillFeature.canImportBookmarksFromGoogleTakeout().getSettings()?.let {
54+
runCatching {
55+
jsonAdapter.fromJson(it)
56+
}.getOrNull()
57+
}
5858

5959
BookmarkImportSettings(
6060
canImportFromGoogleTakeout = autofillFeature.canImportBookmarksFromGoogleTakeout().isEnabled(),
@@ -63,7 +63,6 @@ class BookmarkImportConfigStoreImpl @Inject constructor(
6363
javascriptConfigGoogleTakeout = config?.javascriptConfig?.toString() ?: JAVASCRIPT_CONFIG_DEFAULT,
6464
)
6565
}
66-
}
6766

6867
companion object {
6968
internal const val JAVASCRIPT_CONFIG_DEFAULT = "\"{}\""

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/importing/takeout/webflow/ImportGoogleBookmarkResult.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@ import android.os.Parcelable
2020
import kotlinx.parcelize.Parcelize
2121

2222
sealed interface ImportGoogleBookmarkResult : Parcelable {
23-
2423
@Parcelize
25-
data class Success(val importedCount: Int) : ImportGoogleBookmarkResult
24+
data class Success(
25+
val importedCount: Int,
26+
) : ImportGoogleBookmarkResult
2627

2728
@Parcelize
28-
data class UserCancelled(val stage: String) : ImportGoogleBookmarkResult
29+
data class UserCancelled(
30+
val stage: String,
31+
) : ImportGoogleBookmarkResult
2932

3033
@Parcelize
31-
data class Error(val reason: UserCannotImportReason) : ImportGoogleBookmarkResult
34+
data class Error(
35+
val reason: UserCannotImportReason,
36+
) : ImportGoogleBookmarkResult
3237

3338
companion object {
3439
const val RESULT_KEY = "importBookmarkResult"

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/importing/takeout/webflow/ImportGoogleBookmarksWebFlowActivity.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import com.duckduckgo.navigation.api.GlobalActivityStarter.ActivityParams
3232
@InjectWith(ActivityScope::class)
3333
@ContributeToActivityStarter(AutofillImportViaGoogleTakeoutScreen::class)
3434
class ImportGoogleBookmarksWebFlowActivity : DuckDuckGoActivity() {
35-
3635
val binding: ActivityImportGoogleBookmarksWebflowBinding by viewBinding()
3736

3837
override fun onCreate(savedInstanceState: Bundle?) {
@@ -60,12 +59,13 @@ class ImportGoogleBookmarksWebFlowActivity : DuckDuckGoActivity() {
6059
}
6160

6261
fun exitUserCancelled(stage: String) {
63-
val result = Bundle().apply {
64-
putParcelable(
65-
ImportGoogleBookmarkResult.Companion.RESULT_KEY_DETAILS,
66-
ImportGoogleBookmarkResult.UserCancelled(stage),
67-
)
68-
}
62+
val result =
63+
Bundle().apply {
64+
putParcelable(
65+
ImportGoogleBookmarkResult.Companion.RESULT_KEY_DETAILS,
66+
ImportGoogleBookmarkResult.UserCancelled(stage),
67+
)
68+
}
6969
exitWithResult(result)
7070
}
7171
}

0 commit comments

Comments
 (0)