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
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ class SettingsRepository(
const val KEY_TRANSLATION_MODE_DO_NOT_SHOW_WARNING = "translation_mode_do_not_show_warning"

const val KEY_LOCKDOWN_MODE = "lockdown_mode"
const val KEY_DISABLE_LINK_PREVIEW = "disable_link_preview"
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import com.sameerasw.essentials.ui.components.linkActions.LinkPickerScreen
import com.sameerasw.essentials.ui.core.cards.FeatureCard
import com.sameerasw.essentials.ui.core.containers.RoundedCardContainer
import com.sameerasw.essentials.ui.core.sheets.PermissionsBottomSheet
import com.sameerasw.essentials.ui.features.apps.LinkActionsSettingsUI
import com.sameerasw.essentials.ui.features.battery.BatteriesSettingsUI
import com.sameerasw.essentials.ui.features.security.AppLockSettingsUI
import com.sameerasw.essentials.ui.features.system.AlwaysOnDisplaySettingsUI
Expand Down Expand Up @@ -142,8 +143,7 @@ class FeatureSettingsActivity : AppCompatActivity() {
val featureObj = FeatureRegistry.ALL_FEATURES.find { it.id == featureId }
val highlightSetting = intent.getStringExtra("highlight_setting")

if (featureId == "Link actions" || featureId == "URL Shortener") {
val isShortenerDirect = featureId == "URL Shortener"
if (featureId == "URL Shortener") {
setContent {
val viewModel: MainViewModel = viewModel()
val context = LocalContext.current
Expand All @@ -157,8 +157,8 @@ class FeatureSettingsActivity : AppCompatActivity() {
onFinish = { finish() },
modifier = Modifier.fillMaxSize(),
demo = false,
initialTab = if (isShortenerDirect) 2 else 0,
initialOpenShorten = isShortenerDirect,
initialTab = 2,
initialOpenShorten = true,
)
}
}
Expand Down Expand Up @@ -1211,6 +1211,12 @@ class FeatureSettingsActivity : AppCompatActivity() {
onShowMoveSheetChange = { isStandbyMoveSheetVisible = it },
)
}

"Link actions" -> {
LinkActionsSettingsUI(
viewModel = viewModel
)
}
}
}
// Bottom padding for toolbar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import com.sameerasw.essentials.data.repository.SettingsRepository
import com.sameerasw.essentials.ui.components.linkActions.LinkPickerScreen
import com.sameerasw.essentials.ui.theme.EssentialsTheme

Expand Down Expand Up @@ -75,6 +76,7 @@ class LinkPickerActivity : AppCompatActivity() {
EssentialsTheme(pitchBlackTheme = isPitchBlackThemeEnabled) {
LinkPickerScreen(
uri = uri,
disableLinkPreview = SettingsRepository(context).getBoolean(SettingsRepository.KEY_DISABLE_LINK_PREVIEW), // something is wrong with viewmodel and maybe just loading one setting is better than loading whole viewmodel state...
onFinish = { finish() },
modifier = Modifier.fillMaxSize(),
)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -45,11 +46,12 @@ import com.sameerasw.essentials.utils.HapticUtil

@Composable
fun CategoryExpandableSection(
modifier: Modifier = Modifier,
title: String,
itemCount: Int,
isSettingsSection: Boolean = false,
itemCount: Int? = null,
isExpanded: Boolean,
onToggleExpand: () -> Unit,
modifier: Modifier = Modifier,
content: @Composable ColumnScope.() -> Unit,
) {
val view = LocalView.current
Expand All @@ -60,7 +62,6 @@ fun CategoryExpandableSection(

Column(
modifier = modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Row(
modifier =
Expand All @@ -70,7 +71,8 @@ fun CategoryExpandableSection(
.clickable {
HapticUtil.performUIHaptic(view)
onToggleExpand()
}.padding(horizontal = 12.dp, vertical = 8.dp),
}
.padding(if (isSettingsSection) 16.dp else 12.dp, 8.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Expand All @@ -81,22 +83,25 @@ fun CategoryExpandableSection(
Text(
text = title,
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold,
color = MaterialTheme.colorScheme.onSurface,
fontWeight = if (!isSettingsSection) FontWeight.Bold else null,
color = if (isSettingsSection) MaterialTheme.colorScheme.onSurfaceVariant else MaterialTheme.colorScheme.onSurface,
)
Box(
modifier =
Modifier
.clip(CircleShape)
.background(MaterialTheme.colorScheme.surfaceContainerHighest)
.padding(horizontal = 8.dp, vertical = 2.dp),
) {
Text(
text = itemCount.toString(),
style = MaterialTheme.typography.labelSmall,
fontWeight = FontWeight.Bold,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)

if (itemCount != null) {
Box(
modifier =
Modifier
.clip(CircleShape)
.background(MaterialTheme.colorScheme.surfaceContainerHighest)
.padding(horizontal = 8.dp, vertical = 2.dp),
) {
Text(
text = itemCount.toString(),
style = MaterialTheme.typography.labelSmall,
fontWeight = FontWeight.Bold,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}
}

Expand All @@ -115,8 +120,9 @@ fun CategoryExpandableSection(
visible = isExpanded,
enter = expandVertically() + fadeIn(),
exit = shrinkVertically() + fadeOut(),
modifier = Modifier.clip(RoundedCornerShape(24.dp))
) {
RoundedCardContainer(spacing = 2.dp) {
RoundedCardContainer(modifier = Modifier.padding(top = 8.dp)) {
content()
}
}
Expand Down
Loading