diff --git a/app/src/main/java/com/anytypeio/anytype/di/common/ComponentManager.kt b/app/src/main/java/com/anytypeio/anytype/di/common/ComponentManager.kt index 0cb90410aa..b3a91cb379 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/common/ComponentManager.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/common/ComponentManager.kt @@ -5,7 +5,6 @@ import com.anytypeio.anytype.core_models.Id import com.anytypeio.anytype.di.feature.AddFileRelationModule import com.anytypeio.anytype.di.feature.AddObjectRelationModule import com.anytypeio.anytype.di.feature.AddObjectRelationValueModule -import com.anytypeio.anytype.di.feature.ArchiveModule import com.anytypeio.anytype.di.feature.AuthModule import com.anytypeio.anytype.di.feature.CreateAccountModule import com.anytypeio.anytype.di.feature.CreateBookmarkModule @@ -232,12 +231,6 @@ class ComponentManager( .build() } - val archiveComponent = ComponentMap { - main.archiveComponentBuilder() - .module(ArchiveModule) - .build() - } - val objectIconPickerComponent = DependentComponentMap { ctx -> editorComponent .get(ctx) diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ArchiveDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ArchiveDI.kt deleted file mode 100644 index 6641d0ec41..0000000000 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ArchiveDI.kt +++ /dev/null @@ -1,65 +0,0 @@ -package com.anytypeio.anytype.di.feature - -import com.anytypeio.anytype.analytics.base.Analytics -import com.anytypeio.anytype.core_utils.di.scope.PerScreen -import com.anytypeio.anytype.domain.event.interactor.InterceptEvents -import com.anytypeio.anytype.domain.objects.SetObjectIsArchived -import com.anytypeio.anytype.domain.page.CloseBlock -import com.anytypeio.anytype.domain.page.OpenPage -import com.anytypeio.anytype.presentation.editor.DocumentExternalEventReducer -import com.anytypeio.anytype.presentation.editor.archive.ArchiveViewModelFactory -import com.anytypeio.anytype.presentation.editor.editor.Orchestrator -import com.anytypeio.anytype.presentation.editor.render.DefaultBlockViewRenderer -import com.anytypeio.anytype.presentation.editor.selection.SelectionStateHolder -import com.anytypeio.anytype.ui.archive.ArchiveFragment -import dagger.Module -import dagger.Provides -import dagger.Subcomponent - -@Subcomponent( - modules = [ - ArchiveModule::class, - EditorUseCaseModule::class, - EditorUseCaseModule.Bindings::class, - EditorSessionModule::class - ] -) -@PerScreen -interface ArchiveSubComponent { - - @Subcomponent.Builder - interface Builder { - fun module(module: ArchiveModule): Builder - fun build(): ArchiveSubComponent - } - - fun inject(fragment: ArchiveFragment) -} - -@Module -object ArchiveModule { - - @JvmStatic - @Provides - fun provideArchiveViewModelFactory( - openPage: OpenPage, - closePage: CloseBlock, - setObjectIsArchived: SetObjectIsArchived, - interceptEvents: InterceptEvents, - renderer: DefaultBlockViewRenderer, - selectionStateHolder: SelectionStateHolder, - documentExternalEventReducer: DocumentExternalEventReducer, - interactor: Orchestrator, - analytics: Analytics - ): ArchiveViewModelFactory = ArchiveViewModelFactory( - openPage = openPage, - closePage = closePage, - setObjectIsArchived = setObjectIsArchived, - interceptEvents = interceptEvents, - renderer = renderer, - selectionStateHolder = selectionStateHolder, - reducer = documentExternalEventReducer, - orchestrator = interactor, - analytics = analytics - ) -} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt b/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt index 5a3da66849..2464d5b17e 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt @@ -3,7 +3,6 @@ package com.anytypeio.anytype.di.main import com.anytypeio.anytype.app.AndroidApplication import com.anytypeio.anytype.di.common.ComponentDependencies import com.anytypeio.anytype.di.common.ComponentDependenciesKey -import com.anytypeio.anytype.di.feature.ArchiveSubComponent import com.anytypeio.anytype.di.feature.AuthSubComponent import com.anytypeio.anytype.di.feature.CreateBookmarkSubComponent import com.anytypeio.anytype.di.feature.CreateObjectSubComponent @@ -78,7 +77,6 @@ interface MainComponent : fun inject(app: AndroidApplication) fun editorComponentBuilder(): EditorSubComponent.Builder - fun archiveComponentBuilder(): ArchiveSubComponent.Builder fun createBookmarkBuilder(): CreateBookmarkSubComponent.Builder fun linkToObjectBuilder(): LinkToObjectSubComponent.Builder fun moveToBuilder(): MoveToSubComponent.Builder diff --git a/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt b/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt index c9ba80d205..6d582439cc 100644 --- a/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt +++ b/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt @@ -9,7 +9,6 @@ import com.anytypeio.anytype.core_models.Id import com.anytypeio.anytype.presentation.navigation.AppNavigation import com.anytypeio.anytype.presentation.settings.EditorSettings import com.anytypeio.anytype.presentation.widgets.collection.Subscription -import com.anytypeio.anytype.ui.archive.ArchiveFragment import com.anytypeio.anytype.ui.auth.Keys import com.anytypeio.anytype.ui.auth.account.CreateAccountFragment.Companion.ARGS_CODE import com.anytypeio.anytype.ui.auth.account.DeletedAccountFragment @@ -203,13 +202,6 @@ class Navigator : AppNavigation { ) } - override fun openArchive(target: String) { - navController?.navigate( - R.id.archiveFragment, - bundleOf(ArchiveFragment.ID_KEY to target) - ) - } - override fun openObjectSet(target: String, isPopUpToDashboard: Boolean) { if (isPopUpToDashboard) { navController?.navigate( diff --git a/app/src/main/java/com/anytypeio/anytype/ui/archive/ArchiveFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/archive/ArchiveFragment.kt deleted file mode 100644 index b8f964f3c5..0000000000 --- a/app/src/main/java/com/anytypeio/anytype/ui/archive/ArchiveFragment.kt +++ /dev/null @@ -1,133 +0,0 @@ -package com.anytypeio.anytype.ui.archive - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.TextView -import androidx.fragment.app.viewModels -import androidx.recyclerview.widget.LinearLayoutManager -import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_ui.features.archive.ArchiveAdapter -import com.anytypeio.anytype.core_ui.tools.FirstItemInvisibilityDetector -import com.anytypeio.anytype.core_utils.ext.hideSoftInput -import com.anytypeio.anytype.core_utils.ext.invisible -import com.anytypeio.anytype.core_utils.ext.visible -import com.anytypeio.anytype.databinding.FragmentArchiveBinding -import com.anytypeio.anytype.di.common.componentManager -import com.anytypeio.anytype.presentation.editor.archive.ArchiveViewModel -import com.anytypeio.anytype.presentation.editor.archive.ArchiveViewModelFactory -import com.anytypeio.anytype.presentation.editor.archive.ArchiveViewState -import com.anytypeio.anytype.ui.base.NavigationFragment -import com.google.android.material.bottomsheet.BottomSheetBehavior -import javax.inject.Inject - -open class ArchiveFragment : NavigationFragment(R.layout.fragment_archive) { - - @Inject - lateinit var factory: ArchiveViewModelFactory - - private val vm by viewModels { factory } - - private val archiveAdapter by lazy { - ArchiveAdapter( - blocks = mutableListOf(), - onClickListener = { vm.onPageClicked(it) } - ) - } - - private val titleVisibilityDetector by lazy { - FirstItemInvisibilityDetector { isVisible -> - if (isVisible) { - binding.topToolbar.title.invisible() - } else { - binding.topToolbar.title.visible() - } - } - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - vm.state.observe(viewLifecycleOwner) { render(it) } - vm.navigation.observe(viewLifecycleOwner, navObserver) - - BottomSheetBehavior.from(binding.sheet).apply { - state = BottomSheetBehavior.STATE_EXPANDED - isHideable = true - addBottomSheetCallback( - object : BottomSheetBehavior.BottomSheetCallback() { - override fun onSlide(bottomSheet: View, slideOffset: Float) {} - override fun onStateChanged(bottomSheet: View, newState: Int) { - if (newState == BottomSheetBehavior.STATE_HIDDEN) { - activity?.hideSoftInput() - vm.onBottomSheetHidden() - } - } - } - ) - } - - binding.topToolbar.menu.invisible() - - with(binding.bottomMenu) { - update(COUNTER_INIT) - findViewById(R.id.btnRestore).setOnClickListener { - vm.onPutBackClicked() - } - } - - binding.recycler.apply { - layoutManager = LinearLayoutManager(requireContext()) - setHasFixedSize(true) - adapter = archiveAdapter - addOnScrollListener(titleVisibilityDetector) - } - } - - private fun render(state: ArchiveViewState) { - when (state) { - ArchiveViewState.Loading -> {} - is ArchiveViewState.Success -> { - archiveAdapter.update(state.blocks) - binding.bottomMenu.update(state.selections) - } - } - } - - override fun onStart() { - vm.onStart(extractDocumentId()) - super.onStart() - } - - override fun onStop() { - vm.onStop() - super.onStop() - } - - override fun injectDependencies() { - componentManager().archiveComponent.get(extractDocumentId()).inject(this) - } - - override fun releaseDependencies() { - componentManager().archiveComponent.release(extractDocumentId()) - } - - private fun extractDocumentId(): String = - requireArguments() - .getString(ID_KEY) - ?: throw IllegalStateException("Document id missing") - - - override fun inflateBinding( - inflater: LayoutInflater, - container: ViewGroup? - ): FragmentArchiveBinding = FragmentArchiveBinding.inflate( - inflater, container, false - ) - - companion object { - const val ID_KEY = "args.id" - const val COUNTER_INIT = 0 - } -} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/base/NavigationRouter.kt b/app/src/main/java/com/anytypeio/anytype/ui/base/NavigationRouter.kt index a6d4e26984..d145967c64 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/base/NavigationRouter.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/base/NavigationRouter.kt @@ -34,7 +34,6 @@ class NavigationRouter( command.id, command.editorSettings ) - is AppNavigation.Command.OpenArchive -> navigation.openArchive(command.target) is AppNavigation.Command.OpenObjectSet -> navigation.openObjectSet( command.target, command.isPopUpToDashboard diff --git a/app/src/main/java/com/anytypeio/anytype/ui/menu/AnytypeContextMenu.kt b/app/src/main/java/com/anytypeio/anytype/ui/menu/AnytypeContextMenu.kt deleted file mode 100644 index 5569f61adb..0000000000 --- a/app/src/main/java/com/anytypeio/anytype/ui/menu/AnytypeContextMenu.kt +++ /dev/null @@ -1,259 +0,0 @@ -package com.anytypeio.anytype.ui.menu - -import android.animation.ValueAnimator -import android.content.Context -import android.content.res.ColorStateList -import android.graphics.Point -import android.text.Editable -import android.text.Spanned -import android.view.Gravity -import android.view.MotionEvent -import android.view.View -import android.view.ViewTreeObserver -import android.widget.PopupWindow -import android.widget.TextView -import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_ui.extensions.color -import com.anytypeio.anytype.core_ui.menu.ContextMenuType -import com.anytypeio.anytype.core_utils.ext.PopupExtensions.calculateContentBounds -import com.anytypeio.anytype.core_utils.ext.PopupExtensions.calculateRectInWindow -import com.anytypeio.anytype.core_utils.ext.PopupExtensions.lerp -import com.anytypeio.anytype.presentation.editor.editor.Markup -import java.lang.ref.WeakReference - -class AnytypeContextMenu constructor( - context: Context, - anchorView: TextView, - parent: View, - type: ContextMenuType, - private val onMarkupActionClicked: (Markup.Type) -> Unit, - private val dismissOnTouchOutside: Boolean = false -) : PopupWindow.OnDismissListener { - - companion object { - const val DEFAULT_X = 20 - const val WIDTH_CHANGE_IGNORE = -1 - const val HEIGHT_CHANGE_IGNORE = -1 - const val ANIM_DURATION = 150L - } - - private val contextRef: WeakReference - private val anchorViewRef: WeakReference - private val parentViewRef: WeakReference - - private var scrollListener: ViewTreeObserver.OnScrollChangedListener? = null - - private val isShowable: Boolean - get() = !isDismissed && contextRef.get() != null && popupWindowRef.get() != null && anchorViewRef.get() != null - private var isDismissed: Boolean = false - private var popupWindowRef: WeakReference - private var popupWindowCurrentLocation = Point() - - /** - * We need to add this bottom padding below selected content, - * because of [android.widget.Editor.SelectionHandleView] - */ - private var bottomAllowance: Int = 0 - - /** - * Callback for all touch events being dispatched to the popup - * window. - */ - private var onTouchListener = View.OnTouchListener { v, event -> - if (!isShowable) return@OnTouchListener false - when { - (!dismissOnTouchOutside && event.action == MotionEvent.ACTION_OUTSIDE) -> { - v.performClick() - return@OnTouchListener true - } - else -> return@OnTouchListener false - } - } - - init { - - scrollListener = ViewTreeObserver.OnScrollChangedListener { - updatePosition() - } - anchorView.viewTreeObserver?.addOnScrollChangedListener( - scrollListener - ) - - val popupWindow = ContextPopupWindow( - context = context, - onContextMenuButtonClicked = this::onContextMenuButtonClicked, - onDismissListener = this, - onTouchInterceptor = onTouchListener, - type = type, - editable = anchorView.text as Editable, - textRange = IntRange(anchorView.selectionStart, anchorView.selectionEnd), - tintColor = ColorStateList.valueOf(context.color(R.color.context_menu_selected_item)), - textDefaultColor = context.color(R.color.white) - ) - contextRef = WeakReference(context) - anchorViewRef = WeakReference(anchorView) - parentViewRef = WeakReference(parent) - popupWindowRef = WeakReference(popupWindow) - bottomAllowance = context.resources - .getDimensionPixelSize(R.dimen.popup_context_menu_bottom_allowance) - } - - private fun cleanup() { - anchorViewRef.get()?.viewTreeObserver?.removeOnScrollChangedListener(scrollListener) - scrollListener = null - } - - private fun updatePosition() { - val anchorView = anchorViewRef.get() - val popupWindow = popupWindowRef.get() - val parentView = parentViewRef.get() - if (anchorView != null && popupWindow != null && parentView != null) { - if (popupWindow.isShowing) { - val updatedLocation = getUpdatedCoordinates( - parentView = parentView, - anchorView = anchorView, - bottomAllowance = bottomAllowance, - popupWindow = popupWindow - ) - if (updatedLocation != popupWindowCurrentLocation) { - popupWindowCurrentLocation = updatedLocation - popupWindow.update( - DEFAULT_X, - popupWindowCurrentLocation.y, - WIDTH_CHANGE_IGNORE, - HEIGHT_CHANGE_IGNORE - ) - } - } - } - } - - private fun onContextMenuButtonClicked(click: ContextMenuButtonClick) { - when (click) { - ContextMenuButtonClick.Copy -> anchorViewRef.get() - ?.onTextContextMenuItem(android.R.id.copy) - ContextMenuButtonClick.Cut -> anchorViewRef.get() - ?.onTextContextMenuItem(android.R.id.cut) - ContextMenuButtonClick.Paste -> anchorViewRef.get() - ?.onTextContextMenuItem(android.R.id.paste) - ContextMenuButtonClick.Bold -> onMarkupActionClicked(Markup.Type.BOLD) - ContextMenuButtonClick.Italic -> onMarkupActionClicked(Markup.Type.ITALIC) - ContextMenuButtonClick.Stroke -> onMarkupActionClicked(Markup.Type.STRIKETHROUGH) - ContextMenuButtonClick.Code -> onMarkupActionClicked(Markup.Type.KEYBOARD) - ContextMenuButtonClick.Color -> onMarkupActionClicked(Markup.Type.TEXT_COLOR) - ContextMenuButtonClick.Background -> onMarkupActionClicked(Markup.Type.BACKGROUND_COLOR) - ContextMenuButtonClick.Link -> onMarkupActionClicked(Markup.Type.LINK) - } - } - - override fun onDismiss() { - isDismissed = true - } - - fun showAtLocation() { - val anchorView = anchorViewRef.get() - val popupWindow = popupWindowRef.get() - val parentView = parentViewRef.get() - if (anchorView != null && popupWindow != null && parentView != null) { - if (popupWindow.isShowing) { - val contentView = popupWindow.contentView - contentView?.handler?.removeCallbacksAndMessages(null) - contentView.post { - val updatedLocation = getUpdatedCoordinates( - parentView = parentView, - anchorView = anchorView, - bottomAllowance = bottomAllowance, - popupWindow = popupWindow - ) - popupWindow.updateMarkupButtons( - textRange = IntRange( - anchorView.selectionStart, - anchorView.selectionEnd - ), - spanned = anchorView.text as Spanned - ) - if (updatedLocation != popupWindowCurrentLocation) { - val currY = popupWindowCurrentLocation.y - popupWindowCurrentLocation = updatedLocation - ValueAnimator.ofFloat(0f, 1f).apply { - addUpdateListener { animation -> - val v = animation.animatedValue as Float - val y = lerp(currY, updatedLocation.y, v) - popupWindow.update( - DEFAULT_X, - y, - WIDTH_CHANGE_IGNORE, - HEIGHT_CHANGE_IGNORE - ) - } - duration = ANIM_DURATION - start() - } - } - } - } else { - with(popupWindow) { - popupWindowCurrentLocation = getUpdatedCoordinates( - parentView = parentView, - anchorView = anchorView, - bottomAllowance = bottomAllowance, - popupWindow = this - ) - updateMarkupButtons( - textRange = IntRange( - anchorView.selectionStart, - anchorView.selectionEnd - ), - spanned = anchorView.text as Spanned - ) - showAtLocation( - anchorView, - Gravity.NO_GRAVITY, - DEFAULT_X, - popupWindowCurrentLocation.y - ) - runShowAnimation() - } - } - } - } - - private fun getUpdatedCoordinates( - parentView: View, - anchorView: TextView, - popupWindow: ContextPopupWindow, - bottomAllowance: Int - ): Point { - val windowPointOnScreen = getWindowPointOnScreen(parentView) - val contentRect = calculateContentBounds(anchorView, bottomAllowance) - val parentRect = calculateRectInWindow(parentView) - return popupWindow.refreshCoordinates( - selectedContentBounds = contentRect, - viewPortOnScreen = parentRect, - windowTopOnScreen = windowPointOnScreen.y, - windowLeftOnScreen = windowPointOnScreen.x - ) - } - - private fun getWindowPointOnScreen(parentView: View): Point { - val tempCoords = IntArray(2) - var windowLeftOnScreen = 0 - var windowTopOnScreen = 0 - parentView.rootView?.let { - it.getLocationOnScreen(tempCoords) - val rootViewLeftOnScreen = tempCoords[0] - val rootViewTopOnScreen = tempCoords[1] - it.getLocationInWindow(tempCoords) - val rootViewLeftOnWindow = tempCoords[0] - val rootViewTopOnWindow = tempCoords[1] - windowLeftOnScreen = rootViewLeftOnScreen - rootViewLeftOnWindow - windowTopOnScreen = rootViewTopOnScreen - rootViewTopOnWindow - } - return Point(windowLeftOnScreen, windowTopOnScreen) - } - - fun finish() { - popupWindowRef.get()?.dismiss() - cleanup() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/menu/ContextPopupWindow.kt b/app/src/main/java/com/anytypeio/anytype/ui/menu/ContextPopupWindow.kt deleted file mode 100644 index cae9595b1f..0000000000 --- a/app/src/main/java/com/anytypeio/anytype/ui/menu/ContextPopupWindow.kt +++ /dev/null @@ -1,380 +0,0 @@ -package com.anytypeio.anytype.ui.menu - -import android.animation.AnimatorSet -import android.animation.ObjectAnimator -import android.content.Context -import android.content.res.ColorStateList -import android.graphics.Color -import android.graphics.Point -import android.graphics.Rect -import android.graphics.drawable.ColorDrawable -import android.text.Editable -import android.text.Spanned -import android.util.AttributeSet -import android.view.Gravity -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.* -import com.anytypeio.anytype.R -import com.anytypeio.anytype.core_ui.common.Span -import com.anytypeio.anytype.core_ui.menu.ContextMenuType -import com.anytypeio.anytype.core_utils.ext.invisible -import com.anytypeio.anytype.core_utils.ext.visible -import com.anytypeio.anytype.ext.isSpanInRange - -class ContextPopupWindow @JvmOverloads constructor( - type: ContextMenuType, - context: Context, - attrs: AttributeSet? = null, - defStyle: Int = 0, - defStyleRes: Int = 0, - onDismissListener: OnDismissListener, - onTouchInterceptor: View.OnTouchListener, - editable: Editable, - textRange: IntRange, - private val onContextMenuButtonClicked: (ContextMenuButtonClick) -> Unit, - private val gravity: Int = Gravity.NO_GRAVITY, - private val tintColor: ColorStateList, - private val textDefaultColor: Int -) : PopupWindow(context, attrs, defStyle, defStyleRes) { - - companion object { - val HEADER = listOf( - R.id.btnCopy, - R.id.btnCut, - R.id.btnPaste, - R.id.btnItalic, - R.id.btnLink, - R.id.btnCode, - R.id.btnColor, - R.id.btnStroke, - R.id.btnBackground - ) - val HIGHLIGHT = listOf( - R.id.btnCopy, - R.id.btnCut, - R.id.btnPaste, - R.id.btnBold, - R.id.btnLink, - R.id.btnCode, - R.id.btnColor, - R.id.btnStroke, - R.id.btnBackground - ) - val DEFAULT = listOf( - R.id.btnCopy, - R.id.btnCut, - R.id.btnPaste, - R.id.btnBold, - R.id.btnItalic, - R.id.btnLink, - R.id.btnCode, - R.id.btnColor, - R.id.btnStroke, - R.id.btnBackground - ) - } - - private var popupHeight: Int - private var popupMargin: Int - private var mShowAnimation: AnimatorSet? - - init { - contentView = LayoutInflater.from(context).inflate(R.layout.popup_context_menu, null) - width = ViewGroup.LayoutParams.WRAP_CONTENT - height = ViewGroup.LayoutParams.WRAP_CONTENT - setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) - isOutsideTouchable = true - isTouchable = true - isClippingEnabled = false - isFocusable = false - setOnDismissListener(onDismissListener) - setTouchInterceptor(onTouchInterceptor) - popupHeight = context.resources - .getDimensionPixelSize(R.dimen.popup_context_menu_height) - popupMargin = context.resources - .getDimensionPixelSize(R.dimen.popup_context_menu_margin) - mShowAnimation = createEnterAnimation(contentView) - when (type) { - ContextMenuType.TEXT -> init(contentView, DEFAULT, editable, textRange) - ContextMenuType.HEADER -> init(contentView, HEADER, editable, textRange) - ContextMenuType.HIGHLIGHT -> init(contentView, HIGHLIGHT, editable, textRange) - } - } - - private fun init(view: View, ids: List, editable: Editable, textRange: IntRange) { - view.findViewById(R.id.btnCopy).apply { - if (this.id in ids) { - visible() - view.findViewById(R.id.divCopy).visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Copy) - } - } - view.findViewById(R.id.btnCut).apply { - if (this.id in ids) { - visible() - view.findViewById(R.id.divCut).visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Cut) - } - } - view.findViewById(R.id.btnPaste).apply { - if (this.id in ids) { - visible() - view.findViewById(R.id.divPaste).visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Paste) - } - } - view.findViewById(R.id.btnBold).apply { - if (this.id in ids) { - visible() - view.findViewById(R.id.divBold).visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Bold) - } - if (editable.isSpanInRange( - textRange = textRange, - type = Span.Bold::class.java - ) - ) { - imageTintList = tintColor - } - } - view.findViewById(R.id.btnItalic).apply { - if (this.id in ids) { - visible() - view.findViewById(R.id.divItalic).visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Italic) - } - if (editable.isSpanInRange( - textRange = textRange, - type = Span.Italic::class.java - ) - ) { - imageTintList = tintColor - } - } - view.findViewById(R.id.btnStroke).apply { - if (this.id in ids) { - visible() - view.findViewById(R.id.divStroke).visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Stroke) - } - if (editable.isSpanInRange( - textRange = textRange, - type = Span.Strikethrough::class.java - ) - ) { - imageTintList = tintColor - } - } - view.findViewById(R.id.btnCode).apply { - if (this.id in ids) { - visible() - view.findViewById(R.id.divCode).visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Code) - } - if (editable.isSpanInRange( - textRange = textRange, - type = Span.Keyboard::class.java - ) - ) { - imageTintList = tintColor - } - } - view.findViewById(R.id.btnLink).apply { - if (this.id in ids) { - visible() - view.findViewById(R.id.divLink).visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Link) - } - if (editable.isSpanInRange( - textRange = textRange, - type = Span.Url::class.java - ) - ) { - imageTintList = tintColor - } - } - view.findViewById(R.id.btnColor).apply { - if (this.id in ids) { - visible() - view.findViewById(R.id.divColor).visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Color) - } - if (editable.isSpanInRange( - textRange = textRange, - type = Span.TextColor::class.java - ) - ) { - setTextColor(tintColor) - } - } - view.findViewById(R.id.btnBackground).apply { - if (this.id in ids) { - visible() - } - setOnClickListener { - onContextMenuButtonClicked(ContextMenuButtonClick.Background) - } - if (editable.isSpanInRange( - textRange = textRange, - type = Span.Highlight::class.java - ) - ) { - setTextColor(tintColor) - } - } - - val arrowRight = view.findViewById(R.id.arrowRightContainer) - arrowRight.setOnClickListener { - view.findViewById(R.id.scrollContainer) - .fullScroll(HorizontalScrollView.FOCUS_RIGHT) - } - view.findViewById(R.id.scrollContainer) - .setOnScrollChangeListener { _, scrollX, _, oldScrollX, _ -> - if (scrollX != oldScrollX) { - if (scrollX == 0) arrowRight.visible() else arrowRight.invisible() - } else { - arrowRight.visible() - } - } - } - - private fun createEnterAnimation(view: View): AnimatorSet? { - val animation = AnimatorSet() - animation.playTogether( - ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f) - .setDuration(200) - ) - return animation - } - - /** - * Get the coordinates of this popup for positioning on the screen.. - * - * @param viewPortOnScreen portion of screen we can draw in. - * @param selectedContentBounds This is the area of the interesting content that this popup - * should avoid obstructing - * @param windowLeftOnScreen parent window X margins - * @param windowTopOnScreen parent window Y margins - * - * @return x and y coordinates of popup window - */ - fun refreshCoordinates( - viewPortOnScreen: Rect, - selectedContentBounds: Rect, - windowLeftOnScreen: Int, - windowTopOnScreen: Int - ): Point { - - val availableHeightAboveContent = selectedContentBounds.top - viewPortOnScreen.top - val availableHeightBelowContent = viewPortOnScreen.bottom - selectedContentBounds.bottom - val margin = popupMargin * 2 - val toolbarHeightWithVerticalMargin = popupHeight + margin - - val y = if (availableHeightAboveContent >= toolbarHeightWithVerticalMargin) { - // There is enough space at the top of the content. - selectedContentBounds.top - toolbarHeightWithVerticalMargin - } else if (availableHeightBelowContent >= toolbarHeightWithVerticalMargin) { - // There is enough space at the bottom of the content. - selectedContentBounds.bottom - } else if (availableHeightBelowContent >= popupHeight) { - // Just enough space to fit the toolbar with no vertical margins. - selectedContentBounds.bottom - popupMargin - } else { - // Not enough space. Prefer to position as high as possible. - viewPortOnScreen.top.coerceAtLeast(selectedContentBounds.top - toolbarHeightWithVerticalMargin) - } - return Point(0, 0.coerceAtLeast(y - windowTopOnScreen)) - } - - fun runShowAnimation() { - mShowAnimation?.start() - } - - /** - * Updates buttons state, when markup changed in text - */ - fun updateMarkupButtons(textRange: IntRange, spanned: Spanned) { - contentView.findViewById(R.id.btnBold).apply { - imageTintList = if (spanned.isSpanInRange( - textRange = textRange, - type = Span.Bold::class.java - ) - ) tintColor else null - } - contentView.findViewById(R.id.btnItalic).apply { - imageTintList = if (spanned.isSpanInRange( - textRange = textRange, - type = Span.Italic::class.java - ) - ) tintColor else null - } - contentView.findViewById(R.id.btnStroke).apply { - imageTintList = if (spanned.isSpanInRange( - textRange = textRange, - type = Span.Strikethrough::class.java - ) - ) tintColor else null - } - contentView.findViewById(R.id.btnCode).apply { - imageTintList = if (spanned.isSpanInRange( - textRange = textRange, - type = Span.Keyboard::class.java - ) - ) tintColor else null - } - contentView.findViewById(R.id.btnLink).apply { - imageTintList = if (spanned.isSpanInRange( - textRange = textRange, - type = Span.Url::class.java - ) - ) tintColor else null - } - contentView.findViewById(R.id.btnColor).apply { - if (spanned.isSpanInRange( - textRange = textRange, - type = Span.TextColor::class.java - ) - ) setTextColor(tintColor) else setTextColor(textDefaultColor) - } - contentView.findViewById(R.id.btnBackground).apply { - if (spanned.isSpanInRange( - textRange = textRange, - type = Span.Highlight::class.java - ) - ) setTextColor(tintColor) else setTextColor(textDefaultColor) - } - } -} - -sealed class ContextMenuButtonClick { - object Copy : ContextMenuButtonClick() - object Cut : ContextMenuButtonClick() - object Paste : ContextMenuButtonClick() - object Bold : ContextMenuButtonClick() - object Italic : ContextMenuButtonClick() - object Stroke : ContextMenuButtonClick() - object Code : ContextMenuButtonClick() - object Color : ContextMenuButtonClick() - object Background : ContextMenuButtonClick() - object Link : ContextMenuButtonClick() -} diff --git a/app/src/main/java/com/anytypeio/anytype/ui/profile/SelectProfileAdapter.kt b/app/src/main/java/com/anytypeio/anytype/ui/profile/SelectProfileAdapter.kt deleted file mode 100644 index af32778078..0000000000 --- a/app/src/main/java/com/anytypeio/anytype/ui/profile/SelectProfileAdapter.kt +++ /dev/null @@ -1,108 +0,0 @@ -package com.anytypeio.anytype.ui.profile - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import com.anytypeio.anytype.core_utils.ui.ViewType -import com.anytypeio.anytype.databinding.ItemSelectProfileAddProfileBinding -import com.anytypeio.anytype.databinding.ItemSelectProfileProfileBinding - -class SelectProfileAdapter( - private val models: MutableList, - private val onAddProfileClicked: () -> Unit, - private val onProfileClicked: (Model.Profile) -> Unit -) : RecyclerView.Adapter() { - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return LayoutInflater.from(parent.context).let { inflater -> - when (viewType) { - PROFILE_HOLDER -> { - ViewHolder.ProfileViewHolder( - ItemSelectProfileProfileBinding.inflate( - inflater, parent, false - ) - ) - } - ADD_PROFILE_HOLDER -> { - ViewHolder.AddProfileViewHolder( - ItemSelectProfileAddProfileBinding.inflate( - inflater, parent, false - ) - ) - } - else -> throw IllegalStateException("Unexpected type: $viewType") - } - } - } - - override fun getItemViewType(position: Int) = models[position].getViewType() - override fun getItemCount(): Int = models.size - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - when (holder) { - is ViewHolder.ProfileViewHolder -> holder.bind( - model = models[position], - onClick = onProfileClicked - ) - is ViewHolder.AddProfileViewHolder -> holder.bind( - onClick = onAddProfileClicked - ) - } - } - - fun update(update: List) { - models.apply { - clear() - addAll(update) - } - notifyDataSetChanged() - } - - sealed class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { - - class ProfileViewHolder(val binding: ItemSelectProfileProfileBinding) : - ViewHolder(binding.root) { - - fun bind( - model: Model, - onClick: (Model.Profile) -> Unit - ) { - check(model is Model.Profile) - binding.apply { - root.isSelected = model.active - name.text = model.name - status.text = model.status - root.setOnClickListener { onClick(model) } - } - } - } - - class AddProfileViewHolder(val binding: ItemSelectProfileAddProfileBinding) : - ViewHolder(binding.root) { - fun bind(onClick: () -> Unit) { - itemView.setOnClickListener { onClick() } - } - } - } - - sealed class Model : ViewType { - data class Profile( - val id: String, - val name: String, - val status: String, - val active: Boolean = false - ) : Model() { - override fun getViewType() = PROFILE_HOLDER - } - - object AddProfile : Model() { - override fun getViewType() = ADD_PROFILE_HOLDER - } - } - - companion object { - const val PROFILE_HOLDER = 0 - const val ADD_PROFILE_HOLDER = 1 - } -} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/profile/SelectProfileDialog.kt b/app/src/main/java/com/anytypeio/anytype/ui/profile/SelectProfileDialog.kt deleted file mode 100644 index 44662ce8fc..0000000000 --- a/app/src/main/java/com/anytypeio/anytype/ui/profile/SelectProfileDialog.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.anytypeio.anytype.ui.profile - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.recyclerview.widget.LinearLayoutManager -import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment -import com.anytypeio.anytype.databinding.DialogSelectProfileBinding - -class SelectProfileDialog : BaseBottomSheetFragment() { - - private val selectProfileAdapter by lazy { - SelectProfileAdapter( - models = mutableListOf( - SelectProfileAdapter.Model.Profile( - name = "Konstantin Ivanov", - id = "id", - status = "20/100 peers", - active = true - ), - SelectProfileAdapter.Model.Profile( - name = "Evgenii Kozlov", - id = "id", - status = "20/100 peers" - ), - SelectProfileAdapter.Model.AddProfile - ), - onProfileClicked = {}, - onAddProfileClicked = {} - ) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - binding.selectProfileRecycler.apply { - layoutManager = LinearLayoutManager(requireContext()) - adapter = selectProfileAdapter - } - } - - override fun injectDependencies() {} - override fun releaseDependencies() {} - - override fun inflateBinding( - inflater: LayoutInflater, - container: ViewGroup? - ): DialogSelectProfileBinding = DialogSelectProfileBinding.inflate( - inflater, container, false - ) -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 79081d5546..fe929bf3f7 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -4,20 +4,20 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/dashboard_background" - android:orientation="vertical"> + android:orientation="vertical" + tools:context=".ui.settings.system.SettingsActivity"> + android:padding="@dimen/dp_16" + android:gravity="center" + android:text="@string/settings_screen" /> - + android:layout_height="wrap_content" /> \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_select_profile.xml b/app/src/main/res/layout/dialog_select_profile.xml index a906014667..dd9c9704af 100644 --- a/app/src/main/res/layout/dialog_select_profile.xml +++ b/app/src/main/res/layout/dialog_select_profile.xml @@ -19,6 +19,5 @@ android:layout_height="match_parent" android:layout_marginStart="10dp" android:layout_marginTop="8dp" - android:layout_marginEnd="10dp" - tools:listitem="@layout/item_select_profile_profile" /> + android:layout_marginEnd="10dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_archive.xml b/app/src/main/res/layout/fragment_archive.xml deleted file mode 100644 index 452399a227..0000000000 --- a/app/src/main/res/layout/fragment_archive.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_choose_pin_code.xml b/app/src/main/res/layout/fragment_choose_pin_code.xml index 7d56e74e94..87d510f18b 100644 --- a/app/src/main/res/layout/fragment_choose_pin_code.xml +++ b/app/src/main/res/layout/fragment_choose_pin_code.xml @@ -51,10 +51,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="16dp" - android:alpha="0.5" android:text="@string/do_it_later" - android:textSize="18sp" - android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> diff --git a/app/src/main/res/layout/fragment_create_account.xml b/app/src/main/res/layout/fragment_create_account.xml index 8e7ef76407..2e2f039619 100644 --- a/app/src/main/res/layout/fragment_create_account.xml +++ b/app/src/main/res/layout/fragment_create_account.xml @@ -40,9 +40,6 @@ android:gravity="center" android:scaleType="center" android:src="@drawable/ic_add_photo" - android:textColor="@color/white" - android:textSize="36sp" - android:textStyle="bold" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml deleted file mode 100644 index 002b5eb546..0000000000 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ /dev/null @@ -1,313 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_date_picker.xml b/app/src/main/res/layout/fragment_date_picker.xml index 59e9b75927..a2fac09351 100644 --- a/app/src/main/res/layout/fragment_date_picker.xml +++ b/app/src/main/res/layout/fragment_date_picker.xml @@ -27,11 +27,11 @@ android:paddingBottom="16dp"> + android:text="@string/choose" + android:textColor="@color/glyph_active" /> diff --git a/app/src/main/res/layout/fragment_debug_settings.xml b/app/src/main/res/layout/fragment_debug_settings.xml index 7cddc7810b..8277edb367 100644 --- a/app/src/main/res/layout/fragment_debug_settings.xml +++ b/app/src/main/res/layout/fragment_debug_settings.xml @@ -7,39 +7,31 @@ -