Skip to content
Draft
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
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ android {
jvmArgs '-XX:+TieredCompilation', '-XX:TieredStopAtLevel=1'
}
}

buildFeatures {
compose true
}

composeOptions {
kotlinCompilerExtensionVersion = "_"
}
}

static def isValidSigningConfig(signingConfig) {
Expand Down Expand Up @@ -424,6 +432,7 @@ dependencies {
}

implementation AndroidX.appCompat
implementation AndroidX.activity.compose
implementation Google.android.material
implementation AndroidX.constraintLayout
implementation AndroidX.recyclerView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,11 @@ open class BrowserActivity : DuckDuckGoActivity() {
super.onDestroy()
}

override fun onNewIntent(intent: Intent?) {
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
logcat(INFO) { "onNewIntent: $intent" }

intent?.sanitize()
intent.sanitize()

dataClearerForegroundAppRestartPixel.registerIntent(intent)

Expand Down Expand Up @@ -782,7 +782,9 @@ open class BrowserActivity : DuckDuckGoActivity() {
}

fun launchBookmarks() {
startBookmarksActivityForResult.launch(globalActivityStarter.startIntent(this, BookmarksScreenNoParams))
globalActivityStarter.startIntent(this, BookmarksScreenNoParams)?.let { intent ->
startBookmarksActivityForResult.launch(intent)
} ?: logcat(ERROR) { "Could not create intent to launch bookmarks" }
}

fun launchDownloads() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,12 @@ class SystemSearchActivity : DuckDuckGoActivity() {
}
}

override fun onNewIntent(newIntent: Intent?) {
super.onNewIntent(newIntent)
dataClearerForegroundAppRestartPixel.registerIntent(newIntent)
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
dataClearerForegroundAppRestartPixel.registerIntent(intent)
viewModel.resetViewState()
newIntent?.let {
sendLaunchPixels(it)
handleVoiceSearchLaunch(it)
}
sendLaunchPixels(intent)
handleVoiceSearchLaunch(intent)
}

private fun sendLaunchPixels(intent: Intent) {
Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,11 @@ fladle {
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
compilerOptions.freeCompilerArgs.addAll(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:experimentalStrongSkipping=true",
)
}

apply plugin: 'android-reporting'
25 changes: 25 additions & 0 deletions common/common-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ android {
baseline file("lint-baseline.xml")
abortOnError = !project.hasProperty("abortOnError") || project.property("abortOnError") != "false"
}

buildFeatures {
compose true
}

composeOptions {
kotlinCompilerExtensionVersion = "_"
}
}

dependencies {
Expand All @@ -57,6 +65,23 @@ dependencies {
implementation "androidx.core:core-ktx:_"
implementation "androidx.localbroadcastmanager:localbroadcastmanager:_"

api(platform("io.coil-kt.coil3:coil-bom:_"))
api("io.coil-kt.coil3:coil-compose")
api("io.coil-kt.coil3:coil-network-okhttp")

// Compose
api(platform(AndroidX.compose.bom))
api(AndroidX.compose.foundation)
api(AndroidX.compose.foundation.layout)
api(AndroidX.compose.material3)
api(AndroidX.compose.runtime)
api(AndroidX.compose.ui)
api(AndroidX.compose.ui.tooling)

api("org.jetbrains.kotlinx:kotlinx-collections-immutable:_")

api lintChecks("com.slack.lint.compose:compose-lint-checks:_")

// Lottie
implementation "com.airbnb.android:lottie:_"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* 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.common.ui.compose.component.core.button

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.duckduckgo.common.ui.compose.component.core.text.DaxTextPrimary
import com.duckduckgo.common.ui.compose.theme.DuckDuckGoTheme
import com.duckduckgo.mobile.android.R

@Composable
internal fun DaxButton(
onClick: () -> Unit,
colors: ButtonColors,
modifier: Modifier = Modifier,
enabled: Boolean = true,
height: androidx.compose.ui.unit.Dp = dimensionResource(R.dimen.buttonSmallHeight),
contentPadding: PaddingValues = PaddingValues(
horizontal = dimensionResource(R.dimen.buttonSmallSidePadding),
vertical = dimensionResource(R.dimen.buttonSmallTopPadding),
),
content: @Composable RowScope.() -> Unit,
) {
Button(
onClick = onClick,
modifier = modifier.height(height),
colors = colors,
enabled = enabled,
shape = DuckDuckGoTheme.shapes.small,
contentPadding = contentPadding,
content = content,
)
}

@Composable
internal fun DaxButtonLarge(
onClick: () -> Unit,
colors: ButtonColors,
modifier: Modifier = Modifier,
enabled: Boolean = true,
content: @Composable RowScope.() -> Unit,
) {
DaxButton(
onClick = onClick,
colors = colors,
modifier = modifier,
enabled = enabled,
height = dimensionResource(R.dimen.buttonLargeHeight),
contentPadding = PaddingValues(
horizontal = dimensionResource(R.dimen.buttonLargeSidePadding),
vertical = dimensionResource(R.dimen.buttonLargeTopPadding),
),
content = content,
)
}

@Composable
internal fun DaxButtonText(
text: String,
modifier: Modifier = Modifier
) {
DaxTextPrimary(
text = text,
style = DuckDuckGoTheme.typography.button,
modifier = modifier,
)
}

@Composable
internal fun PreviewBox(
content: @Composable () -> Unit
) {
Box(
modifier = Modifier
.background(DuckDuckGoTheme.colors.background)
.padding(16.dp),
) {
content()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*
* 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.common.ui.compose.component.core.button

import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.PreviewLightDark
import com.duckduckgo.common.ui.compose.component.core.text.DaxTextPrimary
import com.duckduckgo.common.ui.compose.theme.DuckDuckGoTheme

@Composable
fun DaxButtonDestructive(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
) {
DaxButton(
onClick = onClick,
colors = destructiveColors(),
modifier = modifier,
enabled = enabled
) {
DaxButtonText(text)
}
}

@Composable
fun DaxButtonDestructiveLarge(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
) {
DaxButtonLarge(
onClick = onClick,
colors = destructiveColors(),
modifier = modifier,
enabled = enabled
) {
DaxButtonText(text)
}
}

@Composable
fun DaxButtonGhostDestructive(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
) {
DaxButton(
onClick = onClick,
colors = ghostDestructiveColors(),
modifier = modifier,
enabled = enabled
) {
DaxButtonText(text)
}
}

@Composable
fun DaxButtonGhostDestructiveLarge(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
) {
DaxButtonLarge(
onClick = onClick,
colors = ghostDestructiveColors(),
modifier = modifier,
enabled = enabled
) {
DaxButtonText(text)
}
}

@Composable
private fun destructiveColors(): ButtonColors = ButtonDefaults.buttonColors(
containerColor = DuckDuckGoTheme.colors.destructive,
contentColor = DuckDuckGoTheme.colors.text.primaryInverted,
disabledContainerColor = DuckDuckGoTheme.colors.containerDisabled,
disabledContentColor = DuckDuckGoTheme.colors.textDisabled
)

@Composable
private fun ghostDestructiveColors(): ButtonColors = ButtonDefaults.buttonColors(
containerColor = Color.Transparent,
contentColor = DuckDuckGoTheme.colors.destructive,
disabledContainerColor = Color.Transparent,
disabledContentColor = DuckDuckGoTheme.colors.textDisabled
)

@PreviewLightDark
@Composable
private fun DaxButtonDestructivePreview() {
DuckDuckGoTheme {
PreviewBox {
DaxButtonDestructive(
text = "Destructive",
onClick = { }
)
}
}
}

@PreviewLightDark
@Composable
private fun DaxButtonDestructiveLargePreview() {
DuckDuckGoTheme {
PreviewBox {
DaxButtonDestructiveLarge(
text = "Destructive Large",
onClick = { }
)
}
}
}

@PreviewLightDark
@Composable
private fun DaxButtonGhostDestructivePreview() {
DuckDuckGoTheme {
PreviewBox {
DaxButtonGhostDestructive(
text = "Ghost Destructive",
onClick = { }
)
}
}
}
Loading
Loading