mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 13:57:10 +09:00
DROID-1814 Multispaces | Fix | Wallpaper settings as part of space settings (#473)
This commit is contained in:
parent
b7f1266508
commit
65ad6eec28
9 changed files with 77 additions and 48 deletions
|
@ -44,7 +44,7 @@ import com.anytypeio.anytype.di.feature.ObjectSetModule
|
|||
import com.anytypeio.anytype.di.feature.ObjectSetRecordModule
|
||||
import com.anytypeio.anytype.di.feature.ObjectSetSettingsModule
|
||||
import com.anytypeio.anytype.di.feature.ObjectTypeChangeModule
|
||||
import com.anytypeio.anytype.di.feature.OtherSettingsModule
|
||||
import com.anytypeio.anytype.di.feature.PersonalizationSettingsModule
|
||||
import com.anytypeio.anytype.di.feature.RelationDataViewDateValueModule
|
||||
import com.anytypeio.anytype.di.feature.RelationDataViewTextValueModule
|
||||
import com.anytypeio.anytype.di.feature.RelationDateValueModule
|
||||
|
@ -328,9 +328,9 @@ class ComponentManager(
|
|||
.build()
|
||||
}
|
||||
|
||||
val otherSettingsComponent = Component {
|
||||
main.otherSettingsComponentBuilder()
|
||||
.module(OtherSettingsModule)
|
||||
val personalizationSettingsComponent = Component {
|
||||
main.personalizationSettingsComponentBuilder()
|
||||
.module(PersonalizationSettingsModule)
|
||||
.build()
|
||||
}
|
||||
|
||||
|
|
|
@ -11,27 +11,27 @@ import com.anytypeio.anytype.domain.launch.GetDefaultObjectType
|
|||
import com.anytypeio.anytype.domain.launch.SetDefaultObjectType
|
||||
import com.anytypeio.anytype.domain.misc.AppActionManager
|
||||
import com.anytypeio.anytype.domain.workspace.SpaceManager
|
||||
import com.anytypeio.anytype.presentation.settings.OtherSettingsViewModel
|
||||
import com.anytypeio.anytype.ui.settings.OtherSettingsFragment
|
||||
import com.anytypeio.anytype.presentation.settings.PersonalizationSettingsViewModel
|
||||
import com.anytypeio.anytype.ui.settings.PersonalizationSettingsFragment
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.Subcomponent
|
||||
|
||||
@PerScreen
|
||||
@Subcomponent(modules = [OtherSettingsModule::class])
|
||||
interface OtherSettingsSubComponent {
|
||||
@Subcomponent(modules = [PersonalizationSettingsModule::class])
|
||||
interface PersonalizationSettingsSubComponent {
|
||||
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
fun module(module: OtherSettingsModule): Builder
|
||||
fun build(): OtherSettingsSubComponent
|
||||
fun module(module: PersonalizationSettingsModule): Builder
|
||||
fun build(): PersonalizationSettingsSubComponent
|
||||
}
|
||||
|
||||
fun inject(fragment: OtherSettingsFragment)
|
||||
fun inject(fragment: PersonalizationSettingsFragment)
|
||||
}
|
||||
|
||||
@Module
|
||||
object OtherSettingsModule {
|
||||
object PersonalizationSettingsModule {
|
||||
|
||||
@JvmStatic
|
||||
@PerScreen
|
||||
|
@ -76,7 +76,7 @@ object OtherSettingsModule {
|
|||
appActionManager: AppActionManager,
|
||||
analytics: Analytics,
|
||||
spaceManager: SpaceManager
|
||||
): OtherSettingsViewModel.Factory = OtherSettingsViewModel.Factory(
|
||||
): PersonalizationSettingsViewModel.Factory = PersonalizationSettingsViewModel.Factory(
|
||||
getDefaultObjectType = getDefaultObjectType,
|
||||
setDefaultObjectType = setDefaultObjectType,
|
||||
clearFileCache = clearFileCache,
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.anytypeio.anytype.di.feature.MoveToSubComponent
|
|||
import com.anytypeio.anytype.di.feature.ObjectSearchSubComponent
|
||||
import com.anytypeio.anytype.di.feature.ObjectSetSubComponent
|
||||
import com.anytypeio.anytype.di.feature.ObjectTypeChangeSubComponent
|
||||
import com.anytypeio.anytype.di.feature.OtherSettingsSubComponent
|
||||
import com.anytypeio.anytype.di.feature.PersonalizationSettingsSubComponent
|
||||
import com.anytypeio.anytype.di.feature.SplashDependencies
|
||||
import com.anytypeio.anytype.di.feature.auth.DeletedAccountDependencies
|
||||
import com.anytypeio.anytype.di.feature.home.HomeScreenDependencies
|
||||
|
@ -129,7 +129,7 @@ interface MainComponent :
|
|||
fun profileComponent(): ProfileSubComponent.Builder
|
||||
fun debugSettingsBuilder(): DebugSettingsSubComponent.Builder
|
||||
fun keychainPhraseComponentBuilder(): KeychainPhraseSubComponent.Builder
|
||||
fun otherSettingsComponentBuilder(): OtherSettingsSubComponent.Builder
|
||||
fun personalizationSettingsComponentBuilder(): PersonalizationSettingsSubComponent.Builder
|
||||
fun logoutWarningComponent(): LogoutWarningSubComponent.Builder
|
||||
fun mainSettingsComponent(): MainSettingsSubComponent.Builder
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import androidx.compose.runtime.collectAsState
|
|||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.ui_settings.appearance.AppearanceScreen
|
||||
|
@ -23,10 +22,6 @@ class AppearanceFragment : BaseBottomSheetComposeFragment() {
|
|||
|
||||
private val vm by viewModels<AppearanceViewModel> { factory }
|
||||
|
||||
private val onWallpaperClicked = {
|
||||
safeNavigate(R.id.wallpaperSetScreen)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
@ -37,7 +32,6 @@ class AppearanceFragment : BaseBottomSheetComposeFragment() {
|
|||
setContent {
|
||||
MaterialTheme(typography = typography) {
|
||||
AppearanceScreen(
|
||||
onWallpaperClicked = onWallpaperClicked,
|
||||
light = { throttle { vm.onLight() } },
|
||||
dark = { throttle { vm.onDark() } },
|
||||
system = { throttle { vm.onSystem() } },
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_utils.ext.toast
|
||||
|
@ -12,18 +14,18 @@ import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
|||
import com.anytypeio.anytype.core_utils.ui.proceed
|
||||
import com.anytypeio.anytype.databinding.FragmentUserSettingsBinding
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.presentation.settings.OtherSettingsViewModel
|
||||
import com.anytypeio.anytype.presentation.settings.PersonalizationSettingsViewModel
|
||||
import com.anytypeio.anytype.ui.dashboard.ClearCacheAlertFragment
|
||||
import com.anytypeio.anytype.ui.objects.types.pickers.AppDefaultObjectTypeFragment
|
||||
import javax.inject.Inject
|
||||
|
||||
class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBinding>(),
|
||||
class PersonalizationSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBinding>(),
|
||||
AppDefaultObjectTypeFragment.OnObjectTypeAction {
|
||||
|
||||
@Inject
|
||||
lateinit var factory: OtherSettingsViewModel.Factory
|
||||
lateinit var factory: PersonalizationSettingsViewModel.Factory
|
||||
|
||||
private val vm by viewModels<OtherSettingsViewModel> { factory }
|
||||
private val vm by viewModels<PersonalizationSettingsViewModel> { factory }
|
||||
|
||||
override fun onProceedWithUpdateType(id: Id, key: Key, name: String) {
|
||||
vm.proceedWithUpdateType(type = id, key = key, name = name)
|
||||
|
@ -34,6 +36,7 @@ class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBindin
|
|||
binding.tvDefaultObjectTypeTitle.setOnClickListener { vm.onObjectTypeClicked() }
|
||||
binding.btnDefaultObjectType.setOnClickListener { vm.onObjectTypeClicked() }
|
||||
binding.ivArrowForward.setOnClickListener { vm.onObjectTypeClicked() }
|
||||
binding.btnWallpaper.setOnClickListener { vm.onWallpaperClicked() }
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -42,16 +45,19 @@ class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBindin
|
|||
proceed(vm.defaultObjectTypeName) { binding.objectType.text = it }
|
||||
}
|
||||
|
||||
private fun observe(command: OtherSettingsViewModel.Command) {
|
||||
private fun observe(command: PersonalizationSettingsViewModel.Command) {
|
||||
when (command) {
|
||||
is OtherSettingsViewModel.Command.Exit -> throttle { dismiss() }
|
||||
is OtherSettingsViewModel.Command.NavigateToObjectTypesScreen -> {
|
||||
is PersonalizationSettingsViewModel.Command.Exit -> throttle { dismiss() }
|
||||
is PersonalizationSettingsViewModel.Command.NavigateToObjectTypesScreen -> {
|
||||
AppDefaultObjectTypeFragment.newInstance(
|
||||
excludeTypes = command.excludeTypes
|
||||
).showChildFragment()
|
||||
}
|
||||
is OtherSettingsViewModel.Command.Toast -> toast(command.msg)
|
||||
is OtherSettingsViewModel.Command.ShowClearCacheAlert -> {
|
||||
is PersonalizationSettingsViewModel.Command.NavigateToWallpaperScreen -> {
|
||||
findNavController().navigate(R.id.wallpaperSetScreen)
|
||||
}
|
||||
is PersonalizationSettingsViewModel.Command.Toast -> toast(command.msg)
|
||||
is PersonalizationSettingsViewModel.Command.ShowClearCacheAlert -> {
|
||||
val dialog = ClearCacheAlertFragment.new()
|
||||
dialog.onClearAccepted = { vm.proceedWithClearCache() }
|
||||
dialog.showChildFragment()
|
||||
|
@ -67,10 +73,10 @@ class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBindin
|
|||
)
|
||||
|
||||
override fun injectDependencies() {
|
||||
componentManager().otherSettingsComponent.get().inject(this)
|
||||
componentManager().personalizationSettingsComponent.get().inject(this)
|
||||
}
|
||||
|
||||
override fun releaseDependencies() {
|
||||
componentManager().otherSettingsComponent.release()
|
||||
componentManager().personalizationSettingsComponent.release()
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:context="com.anytypeio.anytype.ui.settings.OtherSettingsFragment">
|
||||
tools:context="com.anytypeio.anytype.ui.settings.PersonalizationSettingsFragment">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sheet_top"
|
||||
|
@ -88,6 +88,35 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnDefaultObjectType" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/btnWallpaper"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@drawable/default_ripple"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/divider">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvWallpeper"
|
||||
style="@style/TextView.UXStyle.Body"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="20dp"
|
||||
android:text="@string/wallpaper" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:src="@drawable/ic_arrow_forward" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider2"
|
||||
android:layout_width="0dp"
|
||||
|
@ -99,6 +128,6 @@
|
|||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnDefaultObjectType" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnWallpaper" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -26,7 +26,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
class OtherSettingsViewModel(
|
||||
class PersonalizationSettingsViewModel(
|
||||
private val getDefaultObjectType: GetDefaultObjectType,
|
||||
private val setDefaultObjectType: SetDefaultObjectType,
|
||||
private val clearFileCache: ClearFileCache,
|
||||
|
@ -64,6 +64,12 @@ class OtherSettingsViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun onWallpaperClicked() {
|
||||
viewModelScope.launch {
|
||||
commands.emit(Command.NavigateToWallpaperScreen)
|
||||
}
|
||||
}
|
||||
|
||||
fun proceedWithClearCache() {
|
||||
viewModelScope.launch {
|
||||
clearFileCache(BaseUseCase.None).collect { status ->
|
||||
|
@ -126,7 +132,7 @@ class OtherSettingsViewModel(
|
|||
data class NavigateToObjectTypesScreen(
|
||||
val excludeTypes: List<Id>
|
||||
) : Command()
|
||||
|
||||
object NavigateToWallpaperScreen: Command()
|
||||
object ShowClearCacheAlert : Command()
|
||||
object Exit : Command()
|
||||
}
|
||||
|
@ -142,7 +148,7 @@ class OtherSettingsViewModel(
|
|||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(
|
||||
modelClass: Class<T>
|
||||
): T = OtherSettingsViewModel(
|
||||
): T = PersonalizationSettingsViewModel(
|
||||
getDefaultObjectType = getDefaultObjectType,
|
||||
setDefaultObjectType = setDefaultObjectType,
|
||||
clearFileCache = clearFileCache,
|
|
@ -214,7 +214,8 @@ open class ObjectSetViewModelTestSetup {
|
|||
spaceView = "etiam",
|
||||
widgets = "eloquentiam",
|
||||
analytics = "quem",
|
||||
device = "elaboraret"
|
||||
device = "elaboraret",
|
||||
network = "network"
|
||||
)
|
||||
spaceManager = SpaceManager.Impl(
|
||||
repo = repo,
|
||||
|
@ -327,7 +328,8 @@ open class ObjectSetViewModelTestSetup {
|
|||
spaceView = "etiam",
|
||||
widgets = "eloquentiam",
|
||||
analytics = "quem",
|
||||
device = "elaboraret"
|
||||
device = "elaboraret",
|
||||
network = "network"
|
||||
)
|
||||
}
|
||||
spaceManager.set(space)
|
||||
|
|
|
@ -45,7 +45,6 @@ import androidx.compose.ui.unit.dp
|
|||
import com.anytypeio.anytype.core_models.ThemeMode
|
||||
import com.anytypeio.anytype.core_ui.foundation.Divider
|
||||
import com.anytypeio.anytype.core_ui.foundation.Dragger
|
||||
import com.anytypeio.anytype.core_ui.foundation.Option
|
||||
import com.anytypeio.anytype.core_ui.foundation.Toolbar
|
||||
import com.anytypeio.anytype.core_ui.views.Caption1Medium
|
||||
import com.anytypeio.anytype.core_ui.views.Caption2Regular
|
||||
|
@ -58,7 +57,6 @@ private const val thirdQuartersFactor = 1.5f
|
|||
|
||||
@Composable
|
||||
fun AppearanceScreen(
|
||||
onWallpaperClicked: () -> Unit,
|
||||
light: () -> Unit,
|
||||
dark: () -> Unit,
|
||||
system: () -> Unit,
|
||||
|
@ -73,12 +71,6 @@ fun AppearanceScreen(
|
|||
Dragger()
|
||||
}
|
||||
Toolbar(stringResource(R.string.appearance))
|
||||
Option(
|
||||
image = R.drawable.ic_wallpaper,
|
||||
text = stringResource(R.string.wallpaper),
|
||||
onClick = onWallpaperClicked
|
||||
)
|
||||
Divider(paddingStart = 60.dp)
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
@ -262,7 +254,7 @@ fun ModeNameText(
|
|||
@Preview()
|
||||
@Composable
|
||||
fun ComposablePreview() {
|
||||
AppearanceScreen({}, {}, {}, {}, ThemeMode.Light)
|
||||
AppearanceScreen({}, {}, {}, ThemeMode.Light)
|
||||
}
|
||||
|
||||
fun drawThirdQuarterBlackRectangle(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue