diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7e9f2ab00..76dc8bfcf 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -153,9 +153,14 @@
+ android:exported="false">
+
+
+
+
+
{ viewModelProvider.get() }
override fun onCreate(savedInstanceState: Bundle?) {
- AppComponent.buildOrGet(this).inject(this)
installSplashScreen()
+ AppComponent.buildOrGet(this).inject(this)
super.onCreate(savedInstanceState)
val binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
diff --git a/app/src/main/kotlin/com/blacksquircle/ui/application/fragment/TwoPaneFragment.kt b/app/src/main/kotlin/com/blacksquircle/ui/application/fragment/TwoPaneFragment.kt
deleted file mode 100644
index 24d019e9e..000000000
--- a/app/src/main/kotlin/com/blacksquircle/ui/application/fragment/TwoPaneFragment.kt
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2025 Squircle CE contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.blacksquircle.ui.application.fragment
-
-import android.content.Context
-import android.os.Bundle
-import android.view.View
-import android.view.ViewGroup
-import androidx.activity.OnBackPressedCallback
-import androidx.core.graphics.ColorUtils
-import androidx.core.view.GravityCompat
-import androidx.core.view.doOnLayout
-import androidx.drawerlayout.widget.DrawerLayout.DrawerListener
-import androidx.fragment.app.Fragment
-import androidx.navigation.fragment.findNavController
-import com.blacksquircle.ui.R
-import com.blacksquircle.ui.application.navigation.AppScreen
-import com.blacksquircle.ui.application.viewmodel.MainViewModel
-import com.blacksquircle.ui.core.delegate.viewBinding
-import com.blacksquircle.ui.core.extensions.activityViewModels
-import com.blacksquircle.ui.core.extensions.getColorAttr
-import com.blacksquircle.ui.core.extensions.navigateTo
-import com.blacksquircle.ui.core.extensions.postponeEnterTransition
-import com.blacksquircle.ui.core.extensions.setFadeTransition
-import com.blacksquircle.ui.core.navigation.BackPressedHandler
-import com.blacksquircle.ui.core.navigation.DrawerHandler
-import com.blacksquircle.ui.databinding.FragmentTwoPaneBinding
-import com.blacksquircle.ui.internal.di.AppComponent
-import javax.inject.Inject
-import javax.inject.Provider
-
-internal class TwoPaneFragment : Fragment(R.layout.fragment_two_pane), DrawerHandler {
-
- @Inject
- lateinit var mainViewModelProvider: Provider
-
- private val viewModel by activityViewModels { mainViewModelProvider.get() }
-
- private val navController by lazy { findNavController() }
- private val binding by viewBinding(FragmentTwoPaneBinding::bind)
-
- private val drawerListener = object : DrawerListener {
- override fun onDrawerStateChanged(newState: Int) = Unit
- override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
- binding.fragmentEditor.translationX = slideOffset * drawerView.width
- }
- override fun onDrawerOpened(drawerView: View) {
- binding.fragmentEditor.translationX = drawerView.width.toFloat()
- }
- override fun onDrawerClosed(drawerView: View) {
- binding.fragmentEditor.translationX = 0f
- }
- }
-
- private var editorBackPressedHandler: BackPressedHandler? = null
- private var explorerBackPressedHandler: BackPressedHandler? = null
-
- override fun onAttach(context: Context) {
- AppComponent.buildOrGet(context).inject(this)
- super.onAttach(context)
- }
-
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- setFadeTransition(binding.root as ViewGroup)
- postponeEnterTransition(view)
-
- editorBackPressedHandler = childFragmentManager
- .findFragmentById(R.id.fragment_editor) as? BackPressedHandler
- explorerBackPressedHandler = childFragmentManager
- .findFragmentById(R.id.fragment_explorer) as? BackPressedHandler
-
- val alphaFiftyPercent = 0x80
- val scrimColor = ColorUtils.setAlphaComponent(
- requireContext().getColorAttr(android.R.attr.colorBackground),
- alphaFiftyPercent,
- )
- binding.drawerLayout?.setScrimColor(scrimColor)
- binding.drawerLayout?.addDrawerListener(drawerListener)
- binding.drawerLayout?.doOnLayout {
- if (binding.drawerLayout?.isOpen == true) {
- drawerListener.onDrawerOpened(binding.fragmentExplorer)
- } else {
- drawerListener.onDrawerClosed(binding.fragmentExplorer)
- }
- }
-
- requireActivity().onBackPressedDispatcher.addCallback(
- viewLifecycleOwner,
- object : OnBackPressedCallback(true) {
- override fun handleOnBackPressed() {
- if (binding.drawerLayout?.isOpen == true) {
- if (explorerBackPressedHandler?.handleOnBackPressed() == false) {
- closeDrawer()
- }
- } else {
- if (editorBackPressedHandler?.handleOnBackPressed() == false) {
- if (viewModel.confirmExit) {
- navController.navigateTo(AppScreen.ConfirmExit)
- } else {
- activity?.finish()
- }
- }
- }
- }
- },
- )
- }
-
- override fun openDrawer() {
- binding.drawerLayout?.openDrawer(GravityCompat.START)
- }
-
- override fun closeDrawer() {
- binding.drawerLayout?.closeDrawer(GravityCompat.START)
- }
-}
\ No newline at end of file
diff --git a/app/src/main/kotlin/com/blacksquircle/ui/application/navigation/AppScreen.kt b/app/src/main/kotlin/com/blacksquircle/ui/application/navigation/AppScreen.kt
deleted file mode 100644
index a387b9522..000000000
--- a/app/src/main/kotlin/com/blacksquircle/ui/application/navigation/AppScreen.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2025 Squircle CE contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.blacksquircle.ui.application.navigation
-
-import com.blacksquircle.ui.core.navigation.Screen
-
-internal sealed class AppScreen(route: String) : Screen(route) {
-
- data object ConfirmExit : AppScreen("blacksquircle://exit")
-}
\ No newline at end of file
diff --git a/app/src/main/kotlin/com/blacksquircle/ui/application/viewmodel/MainViewModel.kt b/app/src/main/kotlin/com/blacksquircle/ui/application/viewmodel/MainViewModel.kt
index e23cdf469..31bd7b451 100644
--- a/app/src/main/kotlin/com/blacksquircle/ui/application/viewmodel/MainViewModel.kt
+++ b/app/src/main/kotlin/com/blacksquircle/ui/application/viewmodel/MainViewModel.kt
@@ -19,12 +19,8 @@ package com.blacksquircle.ui.application.viewmodel
import android.content.Intent
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
-import com.blacksquircle.ui.core.mvi.ViewEvent
import com.blacksquircle.ui.core.storage.keyvalue.SettingsManager
import com.blacksquircle.ui.feature.editor.api.interactor.EditorInteractor
-import kotlinx.coroutines.channels.Channel
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
@@ -33,13 +29,8 @@ internal class MainViewModel @Inject constructor(
private val editorInteractor: EditorInteractor,
) : ViewModel() {
- private val _viewEvent = Channel(Channel.BUFFERED)
- val viewEvent: Flow = _viewEvent.receiveAsFlow()
-
val fullScreenMode: Boolean
get() = settingsManager.fullScreenMode
- val confirmExit: Boolean
- get() = settingsManager.confirmExit
fun handleIntent(intent: Intent?) {
viewModelScope.launch {
diff --git a/app/src/main/kotlin/com/blacksquircle/ui/internal/di/AppComponent.kt b/app/src/main/kotlin/com/blacksquircle/ui/internal/di/AppComponent.kt
index ff41baa2d..6fe4a8d56 100644
--- a/app/src/main/kotlin/com/blacksquircle/ui/internal/di/AppComponent.kt
+++ b/app/src/main/kotlin/com/blacksquircle/ui/internal/di/AppComponent.kt
@@ -18,7 +18,6 @@ package com.blacksquircle.ui.internal.di
import android.content.Context
import com.blacksquircle.ui.application.activity.MainActivity
-import com.blacksquircle.ui.application.fragment.TwoPaneFragment
import com.blacksquircle.ui.core.internal.CoreApiDepsProvider
import com.blacksquircle.ui.core.internal.CoreModule
import com.blacksquircle.ui.feature.editor.api.internal.EditorApiDepsProvider
@@ -60,7 +59,6 @@ internal interface AppComponent :
ThemesApiDepsProvider {
fun inject(activity: MainActivity)
- fun inject(fragment: TwoPaneFragment)
@Component.Factory
interface Factory {
diff --git a/app/src/main/res/layout-sw600dp-land/fragment_two_pane.xml b/app/src/main/res/layout-sw600dp-land/fragment_two_pane.xml
deleted file mode 100644
index 120b08a17..000000000
--- a/app/src/main/res/layout-sw600dp-land/fragment_two_pane.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index d2f368a71..0c6f0baf7 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -22,5 +22,5 @@
android:layout_height="match_parent"
android:id="@+id/nav_host"
android:name="androidx.navigation.fragment.NavHostFragment"
- app:navGraph="@navigation/app_nav_graph"
+ app:navGraph="@navigation/app_graph"
app:defaultNavHost="true" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_two_pane.xml b/app/src/main/res/layout/fragment_two_pane.xml
deleted file mode 100644
index 47a7a7fb6..000000000
--- a/app/src/main/res/layout/fragment_two_pane.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/navigation/app_nav_graph.xml b/app/src/main/res/navigation/app_graph.xml
similarity index 69%
rename from app/src/main/res/navigation/app_nav_graph.xml
rename to app/src/main/res/navigation/app_graph.xml
index b0d3ff20a..fb887b7f6 100644
--- a/app/src/main/res/navigation/app_nav_graph.xml
+++ b/app/src/main/res/navigation/app_graph.xml
@@ -17,25 +17,8 @@
-
-
-
-
-
-
+ android:id="@+id/app_graph"
+ app:startDestination="@id/editor_graph">
Neu starten
- Ja
- Nein
- Verlassen
- Sind Sie sicher, dass Sie die App verlassen wollen? Alle Änderungen werden im Cache gespeichert
App kann aktualisiert werden
Installation des Updates fehlgeschlagen
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index c5c1776c1..6c7c414e6 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -16,10 +16,6 @@
-->
Restart
- Yes
- No
- Exit
- Are you sure you want to exit? All changes will be saved into a cache
App is ready to update
Update installation failed
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 2a2292338..e981f07a9 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -16,10 +16,6 @@
-->
Reinicio
- Aceptar
- Rechazar
- Salir
- ¿Seguro que quieres salir? Se guardarán todos los cambios en la caché
La app tiene una actualización disponible
No se pudo instalar la actualización
diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml
index fb5b32efe..6a8391bc5 100644
--- a/app/src/main/res/values-fi/strings.xml
+++ b/app/src/main/res/values-fi/strings.xml
@@ -16,10 +16,6 @@
-->
Käynnistä uudelleen
- Kyllä
- Ei
- Poistu
- Oletko varma, että haluat poistua? Kaikki muutokset tallennetaan välimuistiin
Sovellus on valmis päivitettäväksi
Päivityksen asennus epäonnistui
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index ea31ba57c..649e5f422 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -16,10 +16,6 @@
-->
Redémarrer
- Oui
- Non
- Quitter
- Êtes-vous sûr de vouloir quitter? Toutes les modifications seront enregistrées dans un cache
L\'application est prête à être mise à jour
L\'installation de la mise à jour a échoué
diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml
index e981b7255..e26f47b6b 100644
--- a/app/src/main/res/values-pl/strings.xml
+++ b/app/src/main/res/values-pl/strings.xml
@@ -16,10 +16,6 @@
-->
Zrestartuj
- Tak
- Nie
- Wyjdź
- Czy na pewno chcesz wyjść? Wszystkie zmiany zostaną zapisane w pamięci podręcznej
Aplikacja jest gotowa do uaktualnienia
Aktualizacja nie powiodła się
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index 30855ae6b..304e6cda4 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -16,10 +16,6 @@
-->
Reiniciar
- Sim
- Não
- Sair
- Você tem certeza que deseja sair? Todas as mudanças serão salvas no cache
O app está pronto para ser atualizado
A atualização falhou
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index e1c8983f4..5e53fe9de 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -16,10 +16,6 @@
-->
Обновить
- Да
- Нет
- Выход
- Вы уверены что хотите выйти? Изменения будут сохранены в кеш
Обновление загружено
Произошла ошибка при установке пакета
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index ac22f94d6..d4d827863 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -16,10 +16,6 @@
-->
Yeniden Başlat
- Evet
- Hayır
- Çıkış yap
- Çıkmak istediğinizden emin misiniz? Kayıt edilmeyen tüm değişiklikler kaybolacaktır
Uygulama güncellenmeye hazır
Güncelleme başarılı bir şekilde kurulamadı
diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml
index 7b9c1d341..50f450cec 100644
--- a/app/src/main/res/values-uk/strings.xml
+++ b/app/src/main/res/values-uk/strings.xml
@@ -16,10 +16,6 @@
-->
Перезавантажити
- Так
- Ні
- Вихід
- Ви дійсно бажаєте вийти? Всі зміни будуть збережені в кеш
Додаток готовий до оновлення
Не вдалося встановити оновлення
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 41831c83e..8b88e9107 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -16,10 +16,6 @@
-->
重新啟動
- 確定
- 取消
- 離開
- 確定要離開嗎?所有更改將會保存在快取中
應用程式已經準備好更新
更新失敗
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index b07e28a12..9ec3a047a 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -16,10 +16,6 @@
-->
重启
- 退出
- 取消
- 退出应用
- 确定要退出本应用吗?所有更改将会保存到缓存中
应用已准备好新版本
新版本安装失败
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e048aab54..48551494d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -20,11 +20,6 @@
Squircle CE
Restart
- Yes
- No
-
- Exit
- Are you sure you want to exit? All changes will be saved into a cache
App is ready to update
Update installation failed
diff --git a/common-core/src/main/kotlin/com/blacksquircle/ui/core/extensions/JsonExtensions.kt b/common-core/src/main/kotlin/com/blacksquircle/ui/core/extensions/JsonExtensions.kt
index 9c7ea42fa..f6684e63b 100644
--- a/common-core/src/main/kotlin/com/blacksquircle/ui/core/extensions/JsonExtensions.kt
+++ b/common-core/src/main/kotlin/com/blacksquircle/ui/core/extensions/JsonExtensions.kt
@@ -17,14 +17,6 @@
package com.blacksquircle.ui.core.extensions
import android.net.Uri
-import com.google.gson.Gson
fun String.encodeUri(): String = Uri.encode(this)
-fun String.decodeUri(): String = Uri.decode(this)
-
-fun Any.toJsonEncoded(): String {
- return Gson().toJson(this).encodeUri()
-}
-inline fun String.fromJsonEncoded(): T {
- return Gson().fromJson(this.decodeUri(), T::class.java)
-}
\ No newline at end of file
+fun String.decodeUri(): String = Uri.decode(this)
\ No newline at end of file
diff --git a/common-core/src/main/kotlin/com/blacksquircle/ui/core/extensions/NavigationExtensions.kt b/common-core/src/main/kotlin/com/blacksquircle/ui/core/extensions/NavigationExtensions.kt
index a9b2e9b54..b6f83d716 100644
--- a/common-core/src/main/kotlin/com/blacksquircle/ui/core/extensions/NavigationExtensions.kt
+++ b/common-core/src/main/kotlin/com/blacksquircle/ui/core/extensions/NavigationExtensions.kt
@@ -27,8 +27,10 @@ import androidx.navigation.NavOptions
import androidx.navigation.Navigator
import com.blacksquircle.ui.core.navigation.Screen
+data class NavAction(val id: Int, val args: Bundle? = null)
+
fun NavController.navigateTo(
- screen: Screen<*>,
+ screen: Screen,
options: NavOptions? = null,
extras: Navigator.Extras? = null,
) {
@@ -46,6 +48,13 @@ fun NavController.navigateTo(
navigatorExtras = extras
)
+ is NavAction -> navigate(
+ resId = screen.route.id,
+ args = screen.route.args,
+ navOptions = options,
+ navigatorExtras = extras
+ )
+
is Int -> navigate(
resId = screen.route,
args = null,
@@ -53,7 +62,7 @@ fun NavController.navigateTo(
navigatorExtras = extras
)
- else -> throw IllegalArgumentException("Can't handle route type")
+ else -> throw IllegalArgumentException("Route is not supported")
}
}
diff --git a/common-core/src/main/kotlin/com/blacksquircle/ui/core/mvi/ViewEvent.kt b/common-core/src/main/kotlin/com/blacksquircle/ui/core/mvi/ViewEvent.kt
index 992d7b396..2a3511509 100644
--- a/common-core/src/main/kotlin/com/blacksquircle/ui/core/mvi/ViewEvent.kt
+++ b/common-core/src/main/kotlin/com/blacksquircle/ui/core/mvi/ViewEvent.kt
@@ -23,6 +23,6 @@ abstract class ViewEvent {
data class Toast(val message: String) : ViewEvent()
data class NewIntent(val intent: Intent) : ViewEvent()
- data class Navigation(val screen: Screen<*>) : ViewEvent()
+ data class Navigation(val screen: Screen) : ViewEvent()
data class PopBackStack(val data: Any? = null) : ViewEvent()
}
\ No newline at end of file
diff --git a/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/BackPressedHandler.kt b/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/BackPressedHandler.kt
deleted file mode 100644
index ee7da5399..000000000
--- a/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/BackPressedHandler.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2025 Squircle CE contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.blacksquircle.ui.core.navigation
-
-interface BackPressedHandler {
- /**
- * Вернёт true если событие было обработано дочерним фрагментом.
- */
- fun handleOnBackPressed(): Boolean
-}
\ No newline at end of file
diff --git a/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/DrawerHandler.kt b/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/DrawerHandler.kt
deleted file mode 100644
index b53806b96..000000000
--- a/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/DrawerHandler.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2025 Squircle CE contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.blacksquircle.ui.core.navigation
-
-interface DrawerHandler {
- fun openDrawer()
- fun closeDrawer()
-}
\ No newline at end of file
diff --git a/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/Screen.kt b/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/Screen.kt
index e647acfa5..7e14b1a41 100644
--- a/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/Screen.kt
+++ b/common-core/src/main/kotlin/com/blacksquircle/ui/core/navigation/Screen.kt
@@ -16,9 +16,10 @@
package com.blacksquircle.ui.core.navigation
-abstract class Screen(val route: T) {
- object Settings : Screen("blacksquircle://settings")
- object Fonts : Screen("blacksquircle://fonts")
- object Themes : Screen("blacksquircle://themes")
- object AddServer : Screen("blacksquircle://settings/cloud/add")
+abstract class Screen(val route: Any) {
+ object Explorer : Screen("blacksquircle://explorer")
+ object Settings : Screen("blacksquircle://settings")
+ object Fonts : Screen("blacksquircle://fonts")
+ object Themes : Screen("blacksquircle://themes")
+ object AddServer : Screen("blacksquircle://settings/cloud/add")
}
\ No newline at end of file
diff --git a/common-ui/src/main/res/values-de/strings.xml b/common-ui/src/main/res/values-de/strings.xml
index 52decd46e..8d43734a7 100644
--- a/common-ui/src/main/res/values-de/strings.xml
+++ b/common-ui/src/main/res/values-de/strings.xml
@@ -23,6 +23,8 @@
Löschen
Continue
Auswählen
+ Ja
+ Nein
Farbauswahl
\ No newline at end of file
diff --git a/common-ui/src/main/res/values-en/strings.xml b/common-ui/src/main/res/values-en/strings.xml
index e1982a1ea..72d5b71d7 100644
--- a/common-ui/src/main/res/values-en/strings.xml
+++ b/common-ui/src/main/res/values-en/strings.xml
@@ -22,5 +22,7 @@
Continue
Select
Selected
+ Yes
+ No
Color Picker
diff --git a/common-ui/src/main/res/values-es/strings.xml b/common-ui/src/main/res/values-es/strings.xml
new file mode 100644
index 000000000..a4db3a9fe
--- /dev/null
+++ b/common-ui/src/main/res/values-es/strings.xml
@@ -0,0 +1,20 @@
+
+
+
+ Aceptar
+ Rechazar
+
\ No newline at end of file
diff --git a/common-ui/src/main/res/values-fi/strings.xml b/common-ui/src/main/res/values-fi/strings.xml
index 0c440731f..130add0b2 100644
--- a/common-ui/src/main/res/values-fi/strings.xml
+++ b/common-ui/src/main/res/values-fi/strings.xml
@@ -20,4 +20,6 @@
Tallenna
Poista
Jatkaa
+ Kyllä
+ Ei
diff --git a/common-ui/src/main/res/values-fr/strings.xml b/common-ui/src/main/res/values-fr/strings.xml
index 0518275eb..61bd26ef6 100644
--- a/common-ui/src/main/res/values-fr/strings.xml
+++ b/common-ui/src/main/res/values-fr/strings.xml
@@ -21,5 +21,7 @@
Supprimer
Continuer
Sélectionner
+ Oui
+ Non
Sélecteur de Couleurs
diff --git a/common-ui/src/main/res/values-pl/strings.xml b/common-ui/src/main/res/values-pl/strings.xml
index a6c8c3fe4..61f11102d 100644
--- a/common-ui/src/main/res/values-pl/strings.xml
+++ b/common-ui/src/main/res/values-pl/strings.xml
@@ -20,4 +20,6 @@
Zapisz
Usuń
Kontynuuj
+ Tak
+ Nie
diff --git a/common-ui/src/main/res/values-pt/strings.xml b/common-ui/src/main/res/values-pt/strings.xml
index 5867032ad..875b7b089 100644
--- a/common-ui/src/main/res/values-pt/strings.xml
+++ b/common-ui/src/main/res/values-pt/strings.xml
@@ -21,5 +21,7 @@
Deletar
Continuar
Selecionar
+ Sim
+ Não
Paleta de cores
diff --git a/common-ui/src/main/res/values-ru/strings.xml b/common-ui/src/main/res/values-ru/strings.xml
index 762a86679..74992a950 100644
--- a/common-ui/src/main/res/values-ru/strings.xml
+++ b/common-ui/src/main/res/values-ru/strings.xml
@@ -22,5 +22,7 @@
Продолжить
Выбрать
Выбрано
+ Да
+ Нет
Выберите цвет
diff --git a/common-ui/src/main/res/values-tr/strings.xml b/common-ui/src/main/res/values-tr/strings.xml
index 09a650cc2..5637a3387 100644
--- a/common-ui/src/main/res/values-tr/strings.xml
+++ b/common-ui/src/main/res/values-tr/strings.xml
@@ -20,5 +20,7 @@
Kaydet
Sil
Devam et
+ Evet
+ Hayır
Renk Seç
diff --git a/common-ui/src/main/res/values-uk/strings.xml b/common-ui/src/main/res/values-uk/strings.xml
index 65c7eac33..0222be2c6 100644
--- a/common-ui/src/main/res/values-uk/strings.xml
+++ b/common-ui/src/main/res/values-uk/strings.xml
@@ -21,5 +21,7 @@
Видалити
Продовжити
Вибрати
+ Так
+ Ні
Вибір кольору
diff --git a/common-ui/src/main/res/values-zh-rTW/strings.xml b/common-ui/src/main/res/values-zh-rTW/strings.xml
index c2a5b8640..85bdc4c8e 100644
--- a/common-ui/src/main/res/values-zh-rTW/strings.xml
+++ b/common-ui/src/main/res/values-zh-rTW/strings.xml
@@ -21,5 +21,7 @@
刪除
繼續
選擇
+ 確定
+ 取消
顏色選擇器
diff --git a/common-ui/src/main/res/values-zh/strings.xml b/common-ui/src/main/res/values-zh/strings.xml
index 363347ef1..0dbc4fc1a 100644
--- a/common-ui/src/main/res/values-zh/strings.xml
+++ b/common-ui/src/main/res/values-zh/strings.xml
@@ -21,5 +21,7 @@
删除
继续
选择
+ 退出
+ 取消
颜色选择器
diff --git a/common-ui/src/main/res/values/strings.xml b/common-ui/src/main/res/values/strings.xml
index 1e94bdb13..0d9650543 100644
--- a/common-ui/src/main/res/values/strings.xml
+++ b/common-ui/src/main/res/values/strings.xml
@@ -24,6 +24,8 @@
Continue
Select
Selected
+ Yes
+ No
untitled
Ctrl
diff --git a/app/src/main/kotlin/com/blacksquircle/ui/application/dialog/ConfirmExitDialog.kt b/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/dialog/ConfirmExitDialog.kt
similarity index 78%
rename from app/src/main/kotlin/com/blacksquircle/ui/application/dialog/ConfirmExitDialog.kt
rename to feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/dialog/ConfirmExitDialog.kt
index e65858d20..8512b713c 100644
--- a/app/src/main/kotlin/com/blacksquircle/ui/application/dialog/ConfirmExitDialog.kt
+++ b/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/dialog/ConfirmExitDialog.kt
@@ -14,13 +14,14 @@
* limitations under the License.
*/
-package com.blacksquircle.ui.application.dialog
+package com.blacksquircle.ui.feature.editor.ui.dialog
import android.app.Dialog
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
-import com.blacksquircle.ui.R
+import com.blacksquircle.ui.feature.editor.R
+import com.blacksquircle.ui.ds.R as UiR
internal class ConfirmExitDialog : DialogFragment() {
@@ -28,9 +29,9 @@ internal class ConfirmExitDialog : DialogFragment() {
return AlertDialog.Builder(requireContext())
.setTitle(R.string.dialog_title_exit)
.setMessage(R.string.dialog_message_exit)
- .setNegativeButton(R.string.action_no, null)
- .setPositiveButton(R.string.action_yes) { _, _ ->
- requireActivity().finish()
+ .setNegativeButton(UiR.string.common_no, null)
+ .setPositiveButton(UiR.string.common_yes) { _, _ ->
+ activity?.finish()
}
.create()
}
diff --git a/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/fragment/EditorFragment.kt b/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/fragment/EditorFragment.kt
index 2ae3d77f8..95c431d2d 100644
--- a/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/fragment/EditorFragment.kt
+++ b/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/fragment/EditorFragment.kt
@@ -20,6 +20,7 @@ import android.content.Context
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
+import androidx.activity.addCallback
import androidx.core.view.doOnPreDraw
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
@@ -35,8 +36,6 @@ import com.blacksquircle.ui.core.contract.OpenFileContract
import com.blacksquircle.ui.core.delegate.viewBinding
import com.blacksquircle.ui.core.extensions.*
import com.blacksquircle.ui.core.mvi.ViewEvent
-import com.blacksquircle.ui.core.navigation.BackPressedHandler
-import com.blacksquircle.ui.core.navigation.DrawerHandler
import com.blacksquircle.ui.core.navigation.Screen
import com.blacksquircle.ui.editorkit.*
import com.blacksquircle.ui.editorkit.plugin.autocomplete.codeCompletion
@@ -62,6 +61,7 @@ import com.blacksquircle.ui.feature.editor.ui.adapter.TabController
import com.blacksquircle.ui.feature.editor.ui.manager.KeyboardManager
import com.blacksquircle.ui.feature.editor.ui.manager.ToolbarManager
import com.blacksquircle.ui.feature.editor.ui.mvi.*
+import com.blacksquircle.ui.feature.editor.ui.navigation.EditorScreen
import com.blacksquircle.ui.feature.editor.ui.viewmodel.EditorViewModel
import com.blacksquircle.ui.feature.shortcuts.api.model.Keybinding
import com.blacksquircle.ui.feature.shortcuts.api.model.Shortcut
@@ -72,7 +72,7 @@ import javax.inject.Provider
import com.blacksquircle.ui.ds.R as UiR
internal class EditorFragment : Fragment(R.layout.fragment_editor),
- BackPressedHandler, ToolbarManager.Listener, KeyboardManager.Listener {
+ ToolbarManager.Listener, KeyboardManager.Listener {
@Inject
lateinit var viewModelProvider: Provider
@@ -80,7 +80,6 @@ internal class EditorFragment : Fragment(R.layout.fragment_editor),
private val viewModel by activityViewModels { viewModelProvider.get() }
private val binding by viewBinding(FragmentEditorBinding::bind)
- private val drawerHandler by lazy { parentFragment as DrawerHandler }
private val toolbarManager by lazy { ToolbarManager(this) }
private val keyboardManager by lazy { KeyboardManager(this) }
private val tabController by lazy { TabController() }
@@ -172,6 +171,16 @@ internal class EditorFragment : Fragment(R.layout.fragment_editor),
}
viewModel.obtainEvent(EditorIntent.LoadSettings)
+
+ requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
+ if (toolbarManager.mode != ToolbarManager.Mode.DEFAULT) {
+ onCloseFindButton()
+ } else if (viewModel.confirmExit) {
+ navController.navigateTo(EditorScreen.ConfirmExit)
+ } else {
+ activity?.finish()
+ }
+ }
}
override fun onPause() {
@@ -179,14 +188,6 @@ internal class EditorFragment : Fragment(R.layout.fragment_editor),
saveFile(local = false, unselected = false)
}
- override fun handleOnBackPressed(): Boolean {
- if (toolbarManager.mode != ToolbarManager.Mode.DEFAULT) {
- onCloseFindButton()
- return true
- }
- return false
- }
-
private fun observeViewModel() {
viewModel.toolbarViewState.flowWithLifecycle(viewLifecycleOwner.lifecycle)
.onEach { state ->
@@ -297,7 +298,7 @@ internal class EditorFragment : Fragment(R.layout.fragment_editor),
// region TOOLBAR
override fun onDrawerButton() {
- drawerHandler.openDrawer()
+ navController.navigateTo(Screen.Explorer)
}
override fun onNewButton(): Boolean {
diff --git a/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/navigation/EditorScreen.kt b/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/navigation/EditorScreen.kt
index 6f5dbdabd..eb162ee4b 100644
--- a/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/navigation/EditorScreen.kt
+++ b/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/navigation/EditorScreen.kt
@@ -18,8 +18,9 @@ package com.blacksquircle.ui.feature.editor.ui.navigation
import com.blacksquircle.ui.core.extensions.encodeUri
import com.blacksquircle.ui.core.navigation.Screen
+import com.blacksquircle.ui.feature.editor.R
-internal sealed class EditorScreen(route: String) : Screen(route) {
+internal sealed class EditorScreen(route: Any) : Screen(route) {
class ForceSyntaxDialog(languageName: String) : EditorScreen(
route = "blacksquircle://editor/syntax?languageName=${languageName.encodeUri()}",
@@ -30,4 +31,5 @@ internal sealed class EditorScreen(route: String) : Screen(route) {
data object GotoLine : EditorScreen("blacksquircle://editor/goto")
data object InsertColor : EditorScreen("blacksquircle://editor/insertcolor")
+ data object ConfirmExit : EditorScreen(R.id.confirmExitDialog)
}
\ No newline at end of file
diff --git a/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/viewmodel/EditorViewModel.kt b/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/viewmodel/EditorViewModel.kt
index 57d2f9d70..bc9ff02f2 100644
--- a/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/viewmodel/EditorViewModel.kt
+++ b/feature-editor/impl/src/main/kotlin/com/blacksquircle/ui/feature/editor/ui/viewmodel/EditorViewModel.kt
@@ -74,6 +74,10 @@ internal class EditorViewModel @Inject constructor(
private val _settings = MutableStateFlow>>(emptyList())
val settings: StateFlow>> = _settings.asStateFlow()
+ // FIXME private
+ val confirmExit: Boolean
+ get() = settingsManager.confirmExit
+
private val documents = mutableListOf()
private var selectedPosition = -1
private var toolbarMode = ToolbarManager.Mode.DEFAULT
diff --git a/feature-editor/impl/src/main/res/navigation/editor_graph.xml b/feature-editor/impl/src/main/res/navigation/editor_graph.xml
index 53d2323a0..c052d587d 100644
--- a/feature-editor/impl/src/main/res/navigation/editor_graph.xml
+++ b/feature-editor/impl/src/main/res/navigation/editor_graph.xml
@@ -19,7 +19,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/editor_graph"
- app:startDestination="@id/forceSyntaxDialog">
+ app:startDestination="@id/editorFragment">
+
+
+
+
\ No newline at end of file
diff --git a/feature-editor/impl/src/main/res/values-de/strings.xml b/feature-editor/impl/src/main/res/values-de/strings.xml
index 85258bd8b..3595f5bee 100644
--- a/feature-editor/impl/src/main/res/values-de/strings.xml
+++ b/feature-editor/impl/src/main/res/values-de/strings.xml
@@ -45,7 +45,8 @@
Gehe zu Zeile…
Syntax Highlighting
-
+ Verlassen
+ Sind Sie sicher, dass Sie die App verlassen wollen? Alle Änderungen werden im Cache gespeichert
Sind Sie sicher, dass Sie die Datei schließen wollen? Alle ungespeicherten Änderungen werden verworfen
Keine geöffneten Dateien
diff --git a/feature-editor/impl/src/main/res/values-en/strings.xml b/feature-editor/impl/src/main/res/values-en/strings.xml
index 47e6f24f4..6ac1b4dab 100644
--- a/feature-editor/impl/src/main/res/values-en/strings.xml
+++ b/feature-editor/impl/src/main/res/values-en/strings.xml
@@ -41,6 +41,8 @@
Tools
Go to Line…
Syntax Highlighting
+ Exit
+ Are you sure you want to exit? All changes will be saved into a cache
Are you sure you want to close this file? All unsaved changes will be discarded
No open files
File not found
diff --git a/feature-editor/impl/src/main/res/values-es/strings.xml b/feature-editor/impl/src/main/res/values-es/strings.xml
new file mode 100644
index 000000000..0742b7cc6
--- /dev/null
+++ b/feature-editor/impl/src/main/res/values-es/strings.xml
@@ -0,0 +1,20 @@
+
+
+
+ Salir
+ ¿Seguro que quieres salir? Se guardarán todos los cambios en la caché
+
\ No newline at end of file
diff --git a/feature-editor/impl/src/main/res/values-fi/strings.xml b/feature-editor/impl/src/main/res/values-fi/strings.xml
new file mode 100644
index 000000000..0690c42a4
--- /dev/null
+++ b/feature-editor/impl/src/main/res/values-fi/strings.xml
@@ -0,0 +1,20 @@
+
+
+
+ Poistu
+ Oletko varma, että haluat poistua? Kaikki muutokset tallennetaan välimuistiin
+
\ No newline at end of file
diff --git a/feature-editor/impl/src/main/res/values-fr/strings.xml b/feature-editor/impl/src/main/res/values-fr/strings.xml
index 44d1431bb..75883bb67 100644
--- a/feature-editor/impl/src/main/res/values-fr/strings.xml
+++ b/feature-editor/impl/src/main/res/values-fr/strings.xml
@@ -45,7 +45,8 @@
Aller à la ligne…
Syntax Highlighting
-
+ Quitter
+ Êtes-vous sûr de vouloir quitter? Toutes les modifications seront enregistrées dans un cache
Voulez-vous vraiment fermer ce fichier? Toutes les modifications non enregistrées seront supprimées
Aucun fichier ouvert
diff --git a/feature-editor/impl/src/main/res/values-pl/strings.xml b/feature-editor/impl/src/main/res/values-pl/strings.xml
new file mode 100644
index 000000000..28681e954
--- /dev/null
+++ b/feature-editor/impl/src/main/res/values-pl/strings.xml
@@ -0,0 +1,20 @@
+
+
+
+ Wyjdź
+ Czy na pewno chcesz wyjść? Wszystkie zmiany zostaną zapisane w pamięci podręcznej
+
\ No newline at end of file
diff --git a/feature-editor/impl/src/main/res/values-pt/strings.xml b/feature-editor/impl/src/main/res/values-pt/strings.xml
index 5889d6d55..b2195baf1 100644
--- a/feature-editor/impl/src/main/res/values-pt/strings.xml
+++ b/feature-editor/impl/src/main/res/values-pt/strings.xml
@@ -45,7 +45,8 @@
Ir para a linha…
Syntax Highlighting
-
+ Sair
+ Você tem certeza que deseja sair? Todas as mudanças serão salvas no cache
Você tem certeza de que quer fechar este arquivo? Todas as mudanças serão discartadas
Nenhum arquivo aberto
diff --git a/feature-editor/impl/src/main/res/values-ru/strings.xml b/feature-editor/impl/src/main/res/values-ru/strings.xml
index 45d77ab6c..61710cfbf 100644
--- a/feature-editor/impl/src/main/res/values-ru/strings.xml
+++ b/feature-editor/impl/src/main/res/values-ru/strings.xml
@@ -41,6 +41,8 @@
Инструменты
Перейти к строке…
Подсветка синтаксиса
+ Выход
+ Вы уверены что хотите выйти? Изменения будут сохранены в кеш
Вы уверены что хотите закрыть этот файл? Все несохраненные изменения будут сброшены
Нет файлов
Файл не найден
diff --git a/feature-editor/impl/src/main/res/values-tr/strings.xml b/feature-editor/impl/src/main/res/values-tr/strings.xml
index 8e2e3d13a..c1a1a374b 100644
--- a/feature-editor/impl/src/main/res/values-tr/strings.xml
+++ b/feature-editor/impl/src/main/res/values-tr/strings.xml
@@ -41,6 +41,8 @@
Araçlar
Satıra Git…
Sözdizimi\'ni Vurgula
+ Çıkış yap
+ Çıkmak istediğinizden emin misiniz? Kayıt edilmeyen tüm değişiklikler kaybolacaktır
Oturumunuzu kapatmak istediğinize emin misiniz? Kaydedilmemiş değişiklikler kaybedilecek
Dosya açılmadı
Dosya Bulunamadı
diff --git a/feature-editor/impl/src/main/res/values-uk/strings.xml b/feature-editor/impl/src/main/res/values-uk/strings.xml
index 5b1670040..2276adb0e 100644
--- a/feature-editor/impl/src/main/res/values-uk/strings.xml
+++ b/feature-editor/impl/src/main/res/values-uk/strings.xml
@@ -41,6 +41,8 @@
Інструменти
Перейти до рядка…
Підсвічування синтаксису
+ Вихід
+ Ви дійсно бажаєте вийти? Всі зміни будуть збережені в кеш
Ви впевнені, що хочете закрити цей файл? Усі незбережені зміни буде втрачено
Немає відкритих файлів
Файл не знайдено
diff --git a/feature-editor/impl/src/main/res/values-zh-rTW/strings.xml b/feature-editor/impl/src/main/res/values-zh-rTW/strings.xml
index d8fc7a1a6..72bf422a7 100644
--- a/feature-editor/impl/src/main/res/values-zh-rTW/strings.xml
+++ b/feature-editor/impl/src/main/res/values-zh-rTW/strings.xml
@@ -41,6 +41,8 @@
工具
跳到行
語法重點標示
+ 離開
+ 確定要離開嗎?所有更改將會保存在快取中
確定要關閉該檔案嗎?所有未儲存的更改將會遺失
還沒有開啟任何檔案
檔案不存在
diff --git a/feature-editor/impl/src/main/res/values-zh/strings.xml b/feature-editor/impl/src/main/res/values-zh/strings.xml
index a89f0e3c7..17b04b1fc 100644
--- a/feature-editor/impl/src/main/res/values-zh/strings.xml
+++ b/feature-editor/impl/src/main/res/values-zh/strings.xml
@@ -41,6 +41,8 @@
工具
跳转到行
语法高亮
+ 退出应用
+ 确定要退出本应用吗?所有更改将会保存到缓存中
确定要关闭该文件吗?所有未保存的更改将会丢失
还没有打开任何文件
文件不存在
diff --git a/feature-editor/impl/src/main/res/values/strings.xml b/feature-editor/impl/src/main/res/values/strings.xml
index cc4c4b40c..20089b601 100644
--- a/feature-editor/impl/src/main/res/values/strings.xml
+++ b/feature-editor/impl/src/main/res/values/strings.xml
@@ -46,7 +46,8 @@
Go to Line…
Syntax Highlighting
-
+ Exit
+ Are you sure you want to exit? All changes will be saved into a cache
Are you sure you want to close this file? All unsaved changes will be discarded
No open files
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/data/mapper/FileMapper.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/data/mapper/FileMapper.kt
new file mode 100644
index 000000000..33667ba47
--- /dev/null
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/data/mapper/FileMapper.kt
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2025 Squircle CE contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.blacksquircle.ui.feature.explorer.data.mapper
+
+import android.os.Bundle
+import androidx.core.os.bundleOf
+import com.blacksquircle.ui.filesystem.base.model.FileModel
+
+internal object FileMapper {
+
+ private const val ARG_FILE_URI = "fileUri"
+ private const val ARG_FILESYSTEM_UUID = "filesystemUuid"
+ private const val ARG_SIZE = "size"
+ private const val ARG_LAST_MODIFIED = "lastModified"
+ private const val ARG_DIRECTORY = "directory"
+ private const val ARG_PERMISSION = "permission"
+
+ fun toBundle(fileModel: FileModel): Bundle {
+ return bundleOf(
+ ARG_FILE_URI to fileModel.fileUri,
+ ARG_FILESYSTEM_UUID to fileModel.filesystemUuid,
+ ARG_SIZE to fileModel.size,
+ ARG_LAST_MODIFIED to fileModel.lastModified,
+ ARG_DIRECTORY to fileModel.directory,
+ ARG_PERMISSION to fileModel.permission,
+ )
+ }
+
+ fun fromBundle(bundle: Bundle): FileModel {
+ return FileModel(
+ fileUri = bundle.getString(ARG_FILE_URI).orEmpty(),
+ filesystemUuid = bundle.getString(ARG_FILESYSTEM_UUID).orEmpty(),
+ size = bundle.getLong(ARG_SIZE),
+ lastModified = bundle.getLong(ARG_LAST_MODIFIED),
+ directory = bundle.getBoolean(ARG_DIRECTORY),
+ permission = bundle.getInt(ARG_PERMISSION),
+ )
+ }
+}
\ No newline at end of file
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/data/repository/ExplorerRepositoryImpl.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/data/repository/ExplorerRepositoryImpl.kt
index 635541ee1..b7e82796f 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/data/repository/ExplorerRepositoryImpl.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/data/repository/ExplorerRepositoryImpl.kt
@@ -103,8 +103,7 @@ internal class ExplorerRepositoryImpl(
)
update(progress)
- delay(10000L)
- // filesystem.createFile(fileModel)
+ filesystem.createFile(fileModel)
delay(100)
}
}
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/internal/ExplorerComponent.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/internal/ExplorerComponent.kt
index d19ea9a6d..4a4561fe5 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/internal/ExplorerComponent.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/internal/ExplorerComponent.kt
@@ -23,9 +23,9 @@ import com.blacksquircle.ui.feature.editor.api.internal.EditorApiDepsProvider
import com.blacksquircle.ui.feature.editor.api.internal.EditorApiProvider
import com.blacksquircle.ui.feature.explorer.api.internal.ExplorerApiDepsProvider
import com.blacksquircle.ui.feature.explorer.api.internal.ExplorerApiProvider
-import com.blacksquircle.ui.feature.explorer.ui.dialog.ProgressDialog
+import com.blacksquircle.ui.feature.explorer.ui.dialog.TaskDialog
import com.blacksquircle.ui.feature.explorer.ui.fragment.ExplorerFragment
-import com.blacksquircle.ui.feature.explorer.ui.service.FileService
+import com.blacksquircle.ui.feature.explorer.ui.service.TaskService
import com.blacksquircle.ui.feature.servers.api.internal.ServersApiDepsProvider
import com.blacksquircle.ui.feature.servers.api.internal.ServersApiProvider
import dagger.Component
@@ -44,9 +44,9 @@ import dagger.Component
)
internal interface ExplorerComponent {
- fun inject(dialog: ProgressDialog)
+ fun inject(dialog: TaskDialog)
+ fun inject(service: TaskService)
fun inject(fragment: ExplorerFragment)
- fun inject(service: FileService)
@Component.Factory
interface Factory {
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/AuthDialog.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/AuthDialog.kt
index 2f824514c..65b56b14c 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/AuthDialog.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/AuthDialog.kt
@@ -64,4 +64,8 @@ internal class AuthDialog : DialogFragment() {
}
}
}
+
+ companion object {
+ const val ARG_AUTH_METHOD = "authMethod"
+ }
}
\ No newline at end of file
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/DeleteDialog.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/DeleteDialog.kt
index 951c6118a..f3cfa68ec 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/DeleteDialog.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/DeleteDialog.kt
@@ -25,7 +25,6 @@ import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.fragment.app.DialogFragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
-import com.blacksquircle.ui.core.extensions.decodeUri
import com.blacksquircle.ui.core.extensions.sendFragmentResult
import com.blacksquircle.ui.ds.SquircleTheme
import com.blacksquircle.ui.feature.explorer.ui.fragment.ExplorerFragment
@@ -45,7 +44,7 @@ internal class DeleteDialog : DialogFragment() {
setContent {
SquircleTheme {
DeleteScreen(
- fileName = navArgs.fileName.decodeUri(),
+ fileName = navArgs.fileName,
fileCount = navArgs.fileCount,
onConfirmClicked = {
sendFragmentResult(ExplorerFragment.KEY_DELETE_FILE)
@@ -58,4 +57,9 @@ internal class DeleteDialog : DialogFragment() {
}
}
}
+
+ companion object {
+ const val ARG_FILE_NAME = "fileName"
+ const val ARG_FILE_COUNT = "fileCount"
+ }
}
\ No newline at end of file
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/PropertiesDialog.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/PropertiesDialog.kt
index f7338398b..b9fee7ce6 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/PropertiesDialog.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/PropertiesDialog.kt
@@ -25,9 +25,8 @@ import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.fragment.app.DialogFragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
-import com.blacksquircle.ui.core.extensions.fromJsonEncoded
import com.blacksquircle.ui.ds.SquircleTheme
-import com.blacksquircle.ui.filesystem.base.model.FileModel
+import com.blacksquircle.ui.feature.explorer.data.mapper.FileMapper
internal class PropertiesDialog : DialogFragment() {
@@ -44,7 +43,7 @@ internal class PropertiesDialog : DialogFragment() {
setContent {
SquircleTheme {
PropertiesScreen(
- fileModel = navArgs.data.fromJsonEncoded(),
+ fileModel = FileMapper.fromBundle(navArgs.fileModel),
onCancelClicked = {
navController.popBackStack()
}
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/RenameDialog.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/RenameDialog.kt
index 886f5e3a8..39209e9cf 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/RenameDialog.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/RenameDialog.kt
@@ -26,7 +26,6 @@ import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
-import com.blacksquircle.ui.core.extensions.decodeUri
import com.blacksquircle.ui.core.extensions.sendFragmentResult
import com.blacksquircle.ui.ds.SquircleTheme
import com.blacksquircle.ui.feature.explorer.ui.fragment.ExplorerFragment
@@ -46,7 +45,7 @@ internal class RenameDialog : DialogFragment() {
setContent {
SquircleTheme {
RenameScreen(
- currentFileName = navArgs.fileName.decodeUri(),
+ currentFileName = navArgs.fileName,
onConfirmClicked = { fileName ->
sendFragmentResult(
resultKey = ExplorerFragment.KEY_RENAME_FILE,
@@ -63,4 +62,8 @@ internal class RenameDialog : DialogFragment() {
}
}
}
+
+ companion object {
+ const val ARG_FILE_NAME = "fileName"
+ }
}
\ No newline at end of file
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/ProgressDialog.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/TaskDialog.kt
similarity index 87%
rename from feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/ProgressDialog.kt
rename to feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/TaskDialog.kt
index cd45fbc1b..069129058 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/ProgressDialog.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/TaskDialog.kt
@@ -40,32 +40,32 @@ import com.blacksquircle.ui.feature.explorer.R
import com.blacksquircle.ui.feature.explorer.internal.ExplorerComponent
import com.blacksquircle.ui.feature.explorer.ui.mvi.ExplorerViewEvent
import com.blacksquircle.ui.feature.explorer.ui.navigation.ExplorerScreen
-import com.blacksquircle.ui.feature.explorer.ui.service.FileService
-import com.blacksquircle.ui.feature.explorer.ui.viewmodel.ProgressViewModel
+import com.blacksquircle.ui.feature.explorer.ui.service.TaskService
+import com.blacksquircle.ui.feature.explorer.ui.viewmodel.TaskViewModel
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import javax.inject.Inject
-internal class ProgressDialog : DialogFragment() {
+internal class TaskDialog : DialogFragment() {
@Inject
- lateinit var viewModelFactory: ProgressViewModel.Factory
+ lateinit var viewModelFactory: TaskViewModel.Factory
private val navController by lazy { findNavController() }
- private val navArgs by navArgs()
- private val viewModel by viewModels {
+ private val navArgs by navArgs()
+ private val viewModel by viewModels {
viewModelFactory.create(navArgs.taskId)
}
private val notificationPermission = NotificationPermission(this) { result ->
when (result) {
PermissionResult.DENIED,
PermissionResult.DENIED_FOREVER -> {
- navController.navigateTo(ExplorerScreen.NotificationDeniedForever)
+ navController.navigateTo(ExplorerScreen.NotificationDeniedScreen)
}
PermissionResult.GRANTED -> {
- val intent = Intent(requireContext(), FileService::class.java).apply {
- action = FileService.ACTION_START_TASK
- putExtra(FileService.ARG_TASK_ID, navArgs.taskId)
+ val intent = Intent(requireContext(), TaskService::class.java).apply {
+ action = TaskService.ACTION_START_TASK
+ putExtra(TaskService.ARG_TASK_ID, navArgs.taskId)
}
ContextCompat.startForegroundService(requireContext(), intent)
navController.popBackStack()
@@ -87,7 +87,7 @@ internal class ProgressDialog : DialogFragment() {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
SquircleTheme {
- ProgressScreen(viewModel)
+ TaskScreen(viewModel)
}
}
}
@@ -103,7 +103,7 @@ internal class ProgressDialog : DialogFragment() {
.onEach { event ->
when (event) {
is ViewEvent.PopBackStack -> {
- while (navController.currentDestination?.id != R.id.progressDialog) {
+ while (navController.currentDestination?.id != R.id.taskDialog) {
navController.popBackStack()
}
navController.popBackStack()
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/ProgressScreen.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/TaskScreen.kt
similarity index 95%
rename from feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/ProgressScreen.kt
rename to feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/TaskScreen.kt
index 51a3a7fce..4ba1c15f6 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/ProgressScreen.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/TaskScreen.kt
@@ -41,16 +41,16 @@ import com.blacksquircle.ui.ds.dialog.AlertDialog
import com.blacksquircle.ui.ds.progress.LinearProgress
import com.blacksquircle.ui.feature.explorer.R
import com.blacksquircle.ui.feature.explorer.domain.model.TaskType
-import com.blacksquircle.ui.feature.explorer.ui.viewmodel.ProgressViewModel
+import com.blacksquircle.ui.feature.explorer.ui.viewmodel.TaskViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import java.text.SimpleDateFormat
import java.util.Locale
@Composable
-internal fun ProgressScreen(viewModel: ProgressViewModel) {
+internal fun TaskScreen(viewModel: TaskViewModel) {
val viewState by viewModel.viewState.collectAsStateWithLifecycle()
- ProgressScreen(
+ TaskScreen(
viewState = viewState,
onBackClicked = viewModel::onBackClicked,
onCancelClicked = viewModel::onCancelClicked,
@@ -59,8 +59,8 @@ internal fun ProgressScreen(viewModel: ProgressViewModel) {
}
@Composable
-private fun ProgressScreen(
- viewState: ProgressViewState,
+private fun TaskScreen(
+ viewState: TaskViewState,
onBackClicked: () -> Unit = {},
onCancelClicked: () -> Unit = {},
onRunInBackgroundClicked: () -> Unit = {},
@@ -156,8 +156,8 @@ private fun ProgressScreen(
@Composable
private fun ProgressScreenPreview() {
PreviewBackground {
- ProgressScreen(
- viewState = ProgressViewState(
+ TaskScreen(
+ viewState = TaskViewState(
type = TaskType.COMPRESS,
count = 3,
totalCount = 5,
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/ProgressViewState.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/TaskViewState.kt
similarity index 96%
rename from feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/ProgressViewState.kt
rename to feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/TaskViewState.kt
index 51762f586..4ce4dab55 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/ProgressViewState.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/dialog/TaskViewState.kt
@@ -21,7 +21,7 @@ import com.blacksquircle.ui.core.mvi.ViewState
import com.blacksquircle.ui.feature.explorer.domain.model.TaskType
@Immutable
-internal data class ProgressViewState(
+internal data class TaskViewState(
val type: TaskType,
val count: Int = -1,
val totalCount: Int = -1,
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/fragment/ExplorerFragment.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/fragment/ExplorerFragment.kt
index 3e8e2431b..1b8208b77 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/fragment/ExplorerFragment.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/fragment/ExplorerFragment.kt
@@ -24,6 +24,7 @@ import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.widget.AdapterView
+import androidx.activity.addCallback
import androidx.appcompat.widget.SearchView
import androidx.core.view.MenuProvider
import androidx.core.view.isVisible
@@ -43,8 +44,6 @@ import com.blacksquircle.ui.core.contract.StoragePermission
import com.blacksquircle.ui.core.delegate.viewBinding
import com.blacksquircle.ui.core.extensions.*
import com.blacksquircle.ui.core.mvi.ViewEvent
-import com.blacksquircle.ui.core.navigation.BackPressedHandler
-import com.blacksquircle.ui.core.navigation.DrawerHandler
import com.blacksquircle.ui.core.navigation.Screen
import com.blacksquircle.ui.feature.explorer.R
import com.blacksquircle.ui.feature.explorer.api.model.FilesystemModel
@@ -73,7 +72,7 @@ import javax.inject.Inject
import javax.inject.Provider
import com.blacksquircle.ui.ds.R as UiR
-internal class ExplorerFragment : Fragment(R.layout.fragment_explorer), BackPressedHandler {
+internal class ExplorerFragment : Fragment(R.layout.fragment_explorer) {
@Inject
lateinit var viewModelProvider: Provider
@@ -85,7 +84,7 @@ internal class ExplorerFragment : Fragment(R.layout.fragment_explorer), BackPres
when (result) {
PermissionResult.DENIED,
PermissionResult.DENIED_FOREVER -> {
- navController.navigateTo(ExplorerScreen.StorageDeniedForever)
+ navController.navigateTo(ExplorerScreen.StorageDeniedScreen)
}
PermissionResult.GRANTED -> {
viewModel.obtainEvent(ExplorerIntent.Refresh)
@@ -269,6 +268,14 @@ internal class ExplorerFragment : Fragment(R.layout.fragment_explorer), BackPres
binding.toolbar.setNavigationOnClickListener {
viewModel.obtainEvent(ExplorerIntent.UnselectAll)
}
+
+ requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
+ if (tracker.hasSelection()) {
+ viewModel.obtainEvent(ExplorerIntent.UnselectAll)
+ } else {
+ navController.popBackStack()
+ }
+ }
}
override fun onDestroyView() {
@@ -276,14 +283,6 @@ internal class ExplorerFragment : Fragment(R.layout.fragment_explorer), BackPres
tracker.clearSelection()
}
- override fun handleOnBackPressed(): Boolean {
- if (tracker.hasSelection()) {
- viewModel.obtainEvent(ExplorerIntent.UnselectAll)
- return true
- }
- return false
- }
-
private fun observeViewModel() {
viewModel.toolbarViewState.flowWithLifecycle(viewLifecycleOwner.lifecycle)
.onEach { state ->
@@ -349,7 +348,7 @@ internal class ExplorerFragment : Fragment(R.layout.fragment_explorer), BackPres
binding.errorView.actionPrimary.setText(R.string.action_authenticate)
binding.errorView.actionPrimary.setOnClickListener {
navController.navigateTo(
- ExplorerScreen.AuthDialog(action.authMethod)
+ ExplorerScreen.AuthDialogScreen(action.authMethod)
)
}
}
@@ -387,9 +386,6 @@ internal class ExplorerFragment : Fragment(R.layout.fragment_explorer), BackPres
event.fileModel.path.clipText(context)
context?.showToast(R.string.message_done)
}
- is ExplorerViewEvent.CloseDrawer -> {
- (parentFragment as? DrawerHandler)?.closeDrawer()
- }
}
}
.launchIn(viewLifecycleOwner.lifecycleScope)
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/mvi/ExplorerViewEvent.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/mvi/ExplorerViewEvent.kt
index fc7dfcd4e..3bd748165 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/mvi/ExplorerViewEvent.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/mvi/ExplorerViewEvent.kt
@@ -25,5 +25,4 @@ internal sealed class ExplorerViewEvent : ViewEvent() {
data class CopyPath(val fileModel: FileModel) : ExplorerViewEvent()
data object SelectAll : ExplorerViewEvent()
data object RunInBackground : ExplorerViewEvent()
- data object CloseDrawer : ExplorerViewEvent()
}
\ No newline at end of file
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/navigation/ExplorerScreen.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/navigation/ExplorerScreen.kt
index c427a087c..3d0ca2530 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/navigation/ExplorerScreen.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/navigation/ExplorerScreen.kt
@@ -16,37 +16,54 @@
package com.blacksquircle.ui.feature.explorer.ui.navigation
-import com.blacksquircle.ui.core.extensions.encodeUri
-import com.blacksquircle.ui.core.extensions.toJsonEncoded
+import androidx.core.os.bundleOf
+import com.blacksquircle.ui.core.extensions.NavAction
import com.blacksquircle.ui.core.navigation.Screen
+import com.blacksquircle.ui.feature.explorer.R
+import com.blacksquircle.ui.feature.explorer.data.mapper.FileMapper
+import com.blacksquircle.ui.feature.explorer.ui.dialog.AuthDialog
+import com.blacksquircle.ui.feature.explorer.ui.dialog.DeleteDialog
+import com.blacksquircle.ui.feature.explorer.ui.dialog.RenameDialog
+import com.blacksquircle.ui.feature.explorer.ui.fragment.ExplorerFragmentDirections
import com.blacksquircle.ui.filesystem.base.model.AuthMethod
import com.blacksquircle.ui.filesystem.base.model.FileModel
-internal sealed class ExplorerScreen(route: String) : Screen(route) {
+internal sealed class ExplorerScreen(route: Any) : Screen(route) {
- class DeleteDialog(fileName: String, fileCount: Int) : ExplorerScreen(
- route = "blacksquircle://explorer/delete?fileName=${fileName.encodeUri()}&fileCount=$fileCount",
+ data class DeleteDialogScreen(val fileName: String, val fileCount: Int) : ExplorerScreen(
+ route = NavAction(
+ id = R.id.deleteDialog,
+ args = bundleOf(
+ DeleteDialog.ARG_FILE_NAME to fileName,
+ DeleteDialog.ARG_FILE_COUNT to fileCount,
+ )
+ )
)
- class RenameDialog(fileName: String) : ExplorerScreen(
- route = "blacksquircle://explorer/rename?fileName=${fileName.encodeUri()}",
- )
- class ProgressDialog(taskId: String) : ExplorerScreen(
- route = "blacksquircle://explorer/progress/$taskId",
- )
- class PropertiesDialog(fileModel: FileModel) : ExplorerScreen(
- route = "blacksquircle://explorer/properties?data=${fileModel.toJsonEncoded()}",
- )
- class AuthDialog(authMethod: AuthMethod) : ExplorerScreen(
- route = "blacksquircle://explorer/authenticate?authMethod=${authMethod.value}"
+
+ data class RenameDialogScreen(val fileName: String) : ExplorerScreen(
+ route = NavAction(
+ id = R.id.renameDialog,
+ args = bundleOf(RenameDialog.ARG_FILE_NAME to fileName)
+ )
)
- data object CreateDialog : ExplorerScreen("blacksquircle://explorer/create")
- data object CompressDialog : ExplorerScreen("blacksquircle://explorer/compress")
+ data class TaskDialogScreen(val taskId: String) : ExplorerScreen(
+ route = "blacksquircle://explorer/tasks/$taskId"
+ )
- data object StorageDeniedForever : ExplorerScreen(
- route = "blacksquircle://explorer/storage_denied_forever"
+ data class PropertiesDialogScreen(val fileModel: FileModel) : ExplorerScreen(
+ route = ExplorerFragmentDirections.toPropertiesDialog(FileMapper.toBundle(fileModel))
)
- data object NotificationDeniedForever : ExplorerScreen(
- route = "blacksquircle://explorer/notification_denied_forever"
+
+ data class AuthDialogScreen(val authMethod: AuthMethod) : ExplorerScreen(
+ route = NavAction(
+ id = R.id.authDialog,
+ args = bundleOf(AuthDialog.ARG_AUTH_METHOD to authMethod.value)
+ )
)
+
+ data object CreateDialogScreen : ExplorerScreen(route = NavAction(R.id.createDialog))
+ data object CompressDialogScreen : ExplorerScreen(route = NavAction(R.id.compressDialog))
+ data object StorageDeniedScreen : ExplorerScreen(route = NavAction(R.id.storageDeniedDialog))
+ data object NotificationDeniedScreen : ExplorerScreen(route = NavAction(R.id.notificationDeniedDialog))
}
\ No newline at end of file
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/service/FileService.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/service/TaskService.kt
similarity index 95%
rename from feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/service/FileService.kt
rename to feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/service/TaskService.kt
index ca4140b9b..bcf7e83b1 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/service/FileService.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/service/TaskService.kt
@@ -38,7 +38,7 @@ import kotlinx.coroutines.flow.onEach
import javax.inject.Inject
import com.blacksquircle.ui.ds.R as UiR
-internal class FileService : ComponentService() {
+internal class TaskService : ComponentService() {
@Inject
lateinit var taskManager: TaskManager
@@ -141,7 +141,7 @@ internal class FileService : ComponentService() {
PendingIntent.getService(
this,
0,
- Intent(this, FileService::class.java).apply {
+ Intent(this, TaskService::class.java).apply {
action = ACTION_CANCEL_TASK
putExtra(ARG_TASK_ID, task.id)
},
@@ -154,8 +154,8 @@ internal class FileService : ComponentService() {
companion object {
- const val ACTION_START_TASK = "ACTION_START_TASK"
- const val ACTION_CANCEL_TASK = "ACTION_CANCEL_TASK"
+ const val ACTION_START_TASK = "com.blacksquircle.ui.ACTION_START_TASK"
+ const val ACTION_CANCEL_TASK = "com.blacksquircle.ui.ACTION_CANCEL_TASK"
const val ARG_TASK_ID = "ARG_TASK_ID"
private const val CHANNEL_ID = "file-explorer"
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/ExplorerViewModel.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/ExplorerViewModel.kt
index eb59be414..ca3a00ea4 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/ExplorerViewModel.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/ExplorerViewModel.kt
@@ -279,7 +279,7 @@ internal class ExplorerViewModel @Inject constructor(
selection.replaceList(emptyList())
refreshActionBar()
- val screen = ExplorerScreen.CreateDialog
+ val screen = ExplorerScreen.CreateDialogScreen
_viewEvent.send(ViewEvent.Navigation(screen))
}
}
@@ -291,7 +291,7 @@ internal class ExplorerViewModel @Inject constructor(
selection.replaceList(emptyList())
refreshActionBar()
- val screen = ExplorerScreen.RenameDialog(buffer.first().name)
+ val screen = ExplorerScreen.RenameDialogScreen(buffer.first().name)
_viewEvent.send(ViewEvent.Navigation(screen))
}
}
@@ -303,7 +303,7 @@ internal class ExplorerViewModel @Inject constructor(
selection.replaceList(emptyList())
refreshActionBar()
- val screen = ExplorerScreen.DeleteDialog(buffer.first().name, buffer.size)
+ val screen = ExplorerScreen.DeleteDialogScreen(buffer.first().name, buffer.size)
_viewEvent.send(ViewEvent.Navigation(screen))
}
}
@@ -325,7 +325,7 @@ internal class ExplorerViewModel @Inject constructor(
viewModelScope.launch {
try {
val fileModel = selection.first()
- val screen = ExplorerScreen.PropertiesDialog(fileModel)
+ val screen = ExplorerScreen.PropertiesDialogScreen(fileModel)
_viewEvent.send(ViewEvent.Navigation(screen))
} catch (e: Throwable) {
Timber.e(e, e.message)
@@ -351,7 +351,7 @@ internal class ExplorerViewModel @Inject constructor(
selection.replaceList(emptyList())
refreshActionBar()
- val screen = ExplorerScreen.CompressDialog
+ val screen = ExplorerScreen.CompressDialogScreen
_viewEvent.send(ViewEvent.Navigation(screen))
}
}
@@ -360,7 +360,7 @@ internal class ExplorerViewModel @Inject constructor(
viewModelScope.launch {
val fileModel = event.fileModel ?: selection.first()
_viewEvent.send(ExplorerViewEvent.OpenFileWith(fileModel))
- _viewEvent.send(ExplorerViewEvent.CloseDrawer)
+ _viewEvent.send(ViewEvent.PopBackStack())
initialState()
}
}
@@ -372,7 +372,7 @@ internal class ExplorerViewModel @Inject constructor(
FileType.DEFAULT,
FileType.TEXT -> {
editorInteractor.openFile(event.fileModel)
- _viewEvent.send(ExplorerViewEvent.CloseDrawer)
+ _viewEvent.send(ViewEvent.PopBackStack())
}
else -> openFileAs(ExplorerIntent.OpenFileWith(event.fileModel))
}
@@ -397,7 +397,7 @@ internal class ExplorerViewModel @Inject constructor(
)
val taskId = explorerRepository.createFile(child)
- val screen = ExplorerScreen.ProgressDialog(taskId)
+ val screen = ExplorerScreen.TaskDialogScreen(taskId)
_viewEvent.send(ViewEvent.Navigation(screen))
initialState()
@@ -430,7 +430,7 @@ internal class ExplorerViewModel @Inject constructor(
)
val taskId = explorerRepository.renameFile(originalFile, renamedFile)
- val screen = ExplorerScreen.ProgressDialog(taskId)
+ val screen = ExplorerScreen.TaskDialogScreen(taskId)
_viewEvent.send(ViewEvent.Navigation(screen))
initialState()
@@ -449,7 +449,7 @@ internal class ExplorerViewModel @Inject constructor(
_viewEvent.send(ViewEvent.PopBackStack()) // close dialog
val taskId = explorerRepository.deleteFiles(buffer.toList())
- val screen = ExplorerScreen.ProgressDialog(taskId)
+ val screen = ExplorerScreen.TaskDialogScreen(taskId)
_viewEvent.send(ViewEvent.Navigation(screen))
initialState()
@@ -466,7 +466,7 @@ internal class ExplorerViewModel @Inject constructor(
private fun cutFile() {
viewModelScope.launch {
val taskId = explorerRepository.cutFiles(buffer.toList(), breadcrumbs.last())
- val screen = ExplorerScreen.ProgressDialog(taskId)
+ val screen = ExplorerScreen.TaskDialogScreen(taskId)
_viewEvent.send(ViewEvent.Navigation(screen))
initialState()
@@ -483,7 +483,7 @@ internal class ExplorerViewModel @Inject constructor(
private fun copyFile() {
viewModelScope.launch {
val taskId = explorerRepository.copyFiles(buffer.toList(), breadcrumbs.last())
- val screen = ExplorerScreen.ProgressDialog(taskId)
+ val screen = ExplorerScreen.TaskDialogScreen(taskId)
_viewEvent.send(ViewEvent.Navigation(screen))
initialState()
@@ -512,7 +512,7 @@ internal class ExplorerViewModel @Inject constructor(
val child = parent.copy(parent.path + "/" + event.fileName)
val taskId = explorerRepository.compressFiles(buffer.toList(), child)
- val screen = ExplorerScreen.ProgressDialog(taskId)
+ val screen = ExplorerScreen.TaskDialogScreen(taskId)
_viewEvent.send(ViewEvent.Navigation(screen))
initialState()
@@ -529,7 +529,7 @@ internal class ExplorerViewModel @Inject constructor(
private fun extractFile(event: ExplorerIntent.ExtractFile) {
viewModelScope.launch {
val taskId = explorerRepository.extractFiles(event.fileModel, breadcrumbs.last())
- val screen = ExplorerScreen.ProgressDialog(taskId)
+ val screen = ExplorerScreen.TaskDialogScreen(taskId)
_viewEvent.send(ViewEvent.Navigation(screen))
initialState()
diff --git a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/ProgressViewModel.kt b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/TaskViewModel.kt
similarity index 92%
rename from feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/ProgressViewModel.kt
rename to feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/TaskViewModel.kt
index 97573c9b6..15269bf8b 100644
--- a/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/ProgressViewModel.kt
+++ b/feature-explorer/impl/src/main/kotlin/com/blacksquircle/ui/feature/explorer/ui/viewmodel/TaskViewModel.kt
@@ -23,7 +23,7 @@ import com.blacksquircle.ui.core.extensions.onEach
import com.blacksquircle.ui.core.mvi.ViewEvent
import com.blacksquircle.ui.feature.explorer.data.manager.TaskManager
import com.blacksquircle.ui.feature.explorer.domain.model.TaskStatus
-import com.blacksquircle.ui.feature.explorer.ui.dialog.ProgressViewState
+import com.blacksquircle.ui.feature.explorer.ui.dialog.TaskViewState
import com.blacksquircle.ui.feature.explorer.ui.mvi.ExplorerViewEvent
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
@@ -33,7 +33,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
-internal class ProgressViewModel @AssistedInject constructor(
+internal class TaskViewModel @AssistedInject constructor(
private val taskManager: TaskManager,
@Assisted private val taskId: String,
) : ViewModel() {
@@ -49,7 +49,7 @@ internal class ProgressViewModel @AssistedInject constructor(
}
}
.map(viewModelScope) { task ->
- ProgressViewState(
+ TaskViewState(
type = task.type,
count = (task.status as? TaskStatus.Progress)?.count ?: -1,
totalCount = (task.status as? TaskStatus.Progress)?.totalCount ?: -1,
@@ -76,6 +76,6 @@ internal class ProgressViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory {
- fun create(@Assisted taskId: String): ProgressViewModel
+ fun create(@Assisted taskId: String): TaskViewModel
}
}
\ No newline at end of file
diff --git a/feature-explorer/impl/src/main/res/navigation/explorer_graph.xml b/feature-explorer/impl/src/main/res/navigation/explorer_graph.xml
index 35cd347d5..8b34aa36d 100644
--- a/feature-explorer/impl/src/main/res/navigation/explorer_graph.xml
+++ b/feature-explorer/impl/src/main/res/navigation/explorer_graph.xml
@@ -17,36 +17,38 @@
+ app:startDestination="@id/explorerFragment">
+
+
+
+
+
+ android:label="StorageDeniedDialog" />
+ android:label="NotificationDeniedDialog" />
+ android:label="CreateDialog" />