Skip to content
Closed
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 @@ -410,6 +410,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"
const val KEY_BUBBLE_WEB_FULLSCREEN = "bubble_web_fullscreen"
const val KEY_SIM_NAMES_APPLY_ON_BOOT = "sim_names_apply_on_boot"
const val KEY_POWER_SAVING_APPLY_ON_BOOT = "power_saving_apply_on_boot"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,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 @@ -146,8 +147,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 @@ -161,8 +161,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 @@ -346,6 +346,7 @@ class FeatureSettingsActivity : AppCompatActivity() {
"Dynamic night light" ->
(if (viewModel.isUseUsageAccess.value) !viewModel.isUsageStatsPermissionGranted.value else !isAccessibilityEnabled) ||
!isWriteSecureSettingsEnabled
"Smart pixels" -> !isAccessibilityEnabled
"Snooze system notifications" -> !isNotificationListenerEnabled
"Screen locked security" ->
!isAccessibilityEnabled ||
Expand Down Expand Up @@ -758,6 +759,7 @@ class FeatureSettingsActivity : AppCompatActivity() {
"Dynamic night light" ->
(if (viewModel.isUseUsageAccess.value) !viewModel.isUsageStatsPermissionGranted.value else !isAccessibilityEnabled) ||
!isWriteSecureSettingsEnabled
"Smart pixels" -> !isAccessibilityEnabled
"Snooze system notifications" -> !isNotificationListenerEnabled
"Screen locked security" ->
!isAccessibilityEnabled ||
Expand Down Expand Up @@ -1239,6 +1241,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 @@ -17,10 +17,13 @@ import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import com.sameerasw.essentials.data.repository.SettingsRepository
import com.sameerasw.essentials.ui.components.linkActions.LinkPickerScreen
import com.sameerasw.essentials.ui.theme.EssentialsTheme
import com.sameerasw.essentials.viewmodels.LocationReachedViewModel

class LinkPickerActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -33,9 +36,7 @@ class LinkPickerActivity : AppCompatActivity() {
}
window.setBackgroundDrawableResource(android.R.color.transparent)

val locationViewModel =
com.sameerasw.essentials.viewmodels
.LocationReachedViewModel(application)
val locationViewModel = LocationReachedViewModel(application)
if (locationViewModel.handleIntent(intent)) {
val settingsIntent =
Intent(this, FeatureSettingsActivity::class.java).apply {
Expand Down Expand Up @@ -64,17 +65,16 @@ class LinkPickerActivity : AppCompatActivity() {
enableEdgeToEdge()

setContent {
val viewModel: com.sameerasw.essentials.viewmodels.MainViewModel =
androidx.lifecycle.viewmodel.compose
.viewModel()
val context = androidx.compose.ui.platform.LocalContext.current
androidx.compose.runtime.LaunchedEffect(Unit) {
viewModel.check(context)
}
val isPitchBlackThemeEnabled by viewModel.isPitchBlackThemeEnabled
val context = LocalContext.current
val settingsRepository = remember(context) { SettingsRepository(context) }
val isPitchBlackThemeEnabled =
settingsRepository.getBoolean(SettingsRepository.KEY_PITCH_BLACK_THEME_ENABLED)
val disableLinkPreview =
settingsRepository.getBoolean(SettingsRepository.KEY_DISABLE_LINK_PREVIEW)
EssentialsTheme(pitchBlackTheme = isPitchBlackThemeEnabled) {
LinkPickerScreen(
uri = uri,
disableLinkPreview = disableLinkPreview,
onFinish = { finish() },
modifier = Modifier.fillMaxSize(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import com.sameerasw.essentials.domain.registry.FeatureRegistry
import com.sameerasw.essentials.domain.registry.PermissionRegistry
import com.sameerasw.essentials.translation.TranslationManager
import com.sameerasw.essentials.translation.ui.TranslationSessionSheet
import com.sameerasw.essentials.ui.components.CategoryExpandableSection
import com.sameerasw.essentials.ui.components.EssentialsFloatingToolbar
import com.sameerasw.essentials.ui.components.MadebySameeraswCard
import com.sameerasw.essentials.ui.components.dialogs.AboutSection
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import android.net.Uri
import android.text.Html
import android.util.Log
import android.widget.Toast
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
Expand All @@ -32,20 +31,14 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
Expand All @@ -58,15 +51,12 @@ import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.FilledIconButton
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.FilledTonalIconButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LoadingIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.ToggleButton
Expand All @@ -87,12 +77,10 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
Expand All @@ -102,14 +90,9 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.core.content.edit
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.expandHorizontally
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkHorizontally
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
Expand All @@ -130,7 +113,6 @@ import com.sameerasw.essentials.utils.WindowingUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.BufferedReader
import java.io.InputStreamReader
Expand Down Expand Up @@ -202,6 +184,7 @@ private fun cleanTrackingParams(uri: Uri): Uri {
@Composable
fun LinkPickerScreen(
uri: Uri,
disableLinkPreview: Boolean = false,
onFinish: () -> Unit,
modifier: Modifier = Modifier,
demo: Boolean = false,
Expand All @@ -224,7 +207,7 @@ fun LinkPickerScreen(

// Preview data state
var linkPreviewData by remember { mutableStateOf<LinkPreviewData?>(null) }
var isLoadingPreview by remember { mutableStateOf(true) }
var isLoadingPreview by remember { mutableStateOf(!disableLinkPreview) }

// App lists
var baseOpenWithApps by remember { mutableStateOf<List<ResolvedAppInfo>>(emptyList()) }
Expand All @@ -235,7 +218,7 @@ fun LinkPickerScreen(

LaunchedEffect(currentUri) {
isLoadingApps = true
isLoadingPreview = true
isLoadingPreview = !disableLinkPreview
linkPreviewData = null

withContext(Dispatchers.IO) {
Expand All @@ -253,7 +236,7 @@ fun LinkPickerScreen(
}

// Fetch preview data asynchronously and smoothly update when ready
val preview = fetchLinkPreviewData(currentUri)
val preview = if (!disableLinkPreview) fetchLinkPreviewData(currentUri) else null
withContext(Dispatchers.Main) {
linkPreviewData = preview
isLoadingPreview = false
Expand Down Expand Up @@ -645,10 +628,14 @@ fun LinkPickerScreen(
},
shape = RoundedCornerShape(16.dp),
color = MaterialTheme.colorScheme.surfaceBright,
modifier = Modifier.fillMaxSize().maskClip(RoundedCornerShape(16.dp)),
modifier = Modifier
.fillMaxSize()
.maskClip(RoundedCornerShape(16.dp)),
) {
Row(
modifier = Modifier.fillMaxSize().padding(horizontal = 10.dp),
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
) {
Expand Down Expand Up @@ -837,7 +824,8 @@ fun LinkPickerScreen(
height = topBlurHeightPx,
direction = BlurDirection.TOP,
showGradientOverlay = false,
).progressiveBlur(
)
.progressiveBlur(
blurRadius = 40f,
height = bottomBlurHeightPx,
direction = BlurDirection.BOTTOM,
Expand Down
Loading
Loading