From 4db2c4b1b199fb0d624b18deea73fbf7fff0d65d Mon Sep 17 00:00:00 2001 From: Mike Scamell Date: Mon, 2 Sep 2024 15:41:18 +0100 Subject: [PATCH] make specific page url always visible as we have a whole screen for this setting we've decided to make the specific page url always visible when the user selects specific page then we highlight all the text making it easier for them to delete it we'll fix the fact that the url does not populate in the branch feature/mike/show-on-app-launch/add-persistence as this is where changes around observing state were made --- .../showonapplaunch/ShowOnAppLaunchActivity.kt | 9 +++++---- .../com/duckduckgo/common/ui/view/text/DaxTextInput.kt | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/duckduckgo/app/generalsettings/showonapplaunch/ShowOnAppLaunchActivity.kt b/app/src/main/java/com/duckduckgo/app/generalsettings/showonapplaunch/ShowOnAppLaunchActivity.kt index e16968f9370b..1fecd374406e 100644 --- a/app/src/main/java/com/duckduckgo/app/generalsettings/showonapplaunch/ShowOnAppLaunchActivity.kt +++ b/app/src/main/java/com/duckduckgo/app/generalsettings/showonapplaunch/ShowOnAppLaunchActivity.kt @@ -18,8 +18,6 @@ package com.duckduckgo.app.generalsettings.showonapplaunch import android.os.Bundle import android.view.MenuItem -import androidx.core.view.isGone -import androidx.core.view.isVisible import androidx.lifecycle.Lifecycle import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope @@ -30,6 +28,7 @@ import com.duckduckgo.app.generalsettings.showonapplaunch.ShowOnAppLaunchViewMod import com.duckduckgo.app.generalsettings.showonapplaunch.ShowOnAppLaunchViewModel.ShowOnAppLaunchOption.NewTabPage import com.duckduckgo.app.generalsettings.showonapplaunch.ShowOnAppLaunchViewModel.ShowOnAppLaunchOption.SpecificPage import com.duckduckgo.common.ui.DuckDuckGoActivity +import com.duckduckgo.common.ui.view.showKeyboard import com.duckduckgo.common.ui.viewbinding.viewBinding import com.duckduckgo.di.scopes.ActivityScope import kotlinx.coroutines.flow.launchIn @@ -93,8 +92,10 @@ class ShowOnAppLaunchActivity : DuckDuckGoActivity() { is SpecificPage -> { binding.specificPageCheckListItem.setChecked(true) with(binding.specificPageUrlInput) { - isVisible = true text = viewState.selectedOption.url + isEditable = true + setSelectAllOnFocus(true) + showKeyboard() } } } @@ -106,6 +107,6 @@ class ShowOnAppLaunchActivity : DuckDuckGoActivity() { binding.lastOpenedTabCheckListItem.setChecked(false) binding.newTabCheckListItem.setChecked(false) binding.specificPageCheckListItem.setChecked(false) - binding.specificPageUrlInput.isGone = true + binding.specificPageUrlInput.isEditable = false } } diff --git a/common/common-ui/src/main/java/com/duckduckgo/common/ui/view/text/DaxTextInput.kt b/common/common-ui/src/main/java/com/duckduckgo/common/ui/view/text/DaxTextInput.kt index 0c6b4b1d13c3..0d84b843644e 100644 --- a/common/common-ui/src/main/java/com/duckduckgo/common/ui/view/text/DaxTextInput.kt +++ b/common/common-ui/src/main/java/com/duckduckgo/common/ui/view/text/DaxTextInput.kt @@ -71,6 +71,7 @@ interface TextInput { @DrawableRes endIconRes: Int, contentDescription: String? = null, ) + fun setSelectAllOnFocus(boolean: Boolean) fun removeEndIcon() @@ -257,6 +258,10 @@ class DaxTextInput @JvmOverloads constructor( } } + override fun setSelectAllOnFocus(boolean: Boolean) { + binding.internalEditText.setSelectAllOnFocus(boolean) + } + override fun removeEndIcon() { binding.internalInputLayout.apply { endIconMode = END_ICON_NONE