From ac0cf8afa90f456b37c8d17d1151e7572445454a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Tue, 18 Jun 2024 20:13:00 +0200 Subject: [PATCH] Revert "add lock layout function (szkolny-eu/szkolny-android#199)" This reverts commit 2fd7038d0c0b43f2d39333d2e556bde066cd28b6. --- .../edziennik/config/ConfigUI.kt | 1 - .../edziennik/ui/home/HomeFragment.kt | 89 +++++++------------ .../ui/settings/cards/SettingsThemeCard.kt | 10 --- app/src/main/res/values-de/strings.xml | 2 - app/src/main/res/values-en/strings.xml | 2 - app/src/main/res/values/strings.xml | 2 - 6 files changed, 33 insertions(+), 73 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/config/ConfigUI.kt b/app/src/main/java/pl/szczodrzynski/edziennik/config/ConfigUI.kt index aacb005f..a8a6ba33 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/config/ConfigUI.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/config/ConfigUI.kt @@ -15,7 +15,6 @@ class ConfigUI(base: Config) { var appBackground by base.config("appBg", null) var headerBackground by base.config("headerBg", null) - var lockLayout by base.config(false) var miniMenuVisible by base.config(false) var miniMenuButtons by base.config> { setOf( diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/HomeFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/HomeFragment.kt index ac529fc1..ed8e7519 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/HomeFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/home/HomeFragment.kt @@ -136,7 +136,6 @@ class HomeFragment : Fragment(), CoroutineScope { Toast.makeText(activity, R.string.main_menu_mark_as_read_success, Toast.LENGTH_SHORT).show() }) ) - b.configureCards.onClick { HomeConfigDialog(activity, reloadOnDismiss = true).show() } @@ -169,78 +168,56 @@ class HomeFragment : Fragment(), CoroutineScope { else -> null } as HomeCard? } - //if (App.devMode) // items += HomeDebugCard(100, app, activity, this, app.profile) if (app.profile.archived) items.add(0, HomeArchiveCard(101, app, activity, this, app.profile)) val status = app.availabilityManager.check(app.profile, cacheOnly = true)?.status - val lockLayout = app.config.ui.lockLayout val update = app.config.update - if (update != null && update.versionCode > BuildConfig.VERSION_CODE || status?.userMessage != null) { items.add(0, HomeAvailabilityCard(102, app, activity, this, app.profile)) } val adapter = HomeCardAdapter(items) - b.list.adapter = adapter - b.list.layoutManager = LinearLayoutManager(activity) - - val itemTouchHelper = - ItemTouchHelper(CardItemTouchHelperCallback(adapter, b.refreshLayout)) - + val itemTouchHelper = ItemTouchHelper(CardItemTouchHelperCallback(adapter, b.refreshLayout)) adapter.itemTouchHelper = itemTouchHelper - - if (!lockLayout) { - b.list.setAccessibilityDelegateCompat(object : - RecyclerViewAccessibilityDelegate(b.list) { - override fun getItemDelegate(): AccessibilityDelegateCompat { - return object : ItemDelegate(this) { - override fun onInitializeAccessibilityNodeInfo( - host: View, - info: AccessibilityNodeInfoCompat - ) { - super.onInitializeAccessibilityNodeInfo(host, info) - val position: Int = b.list.getChildLayoutPosition(host) - if (position != 0) { - info.addAction( - AccessibilityActionCompat( - R.id.move_card_up_action, - host.resources.getString(R.string.card_action_move_up) - ) - ) - } - if (position != adapter.itemCount - 1) { - info.addAction( - AccessibilityActionCompat( - R.id.move_card_down_action, - host.resources.getString(R.string.card_action_move_down) - ) - ) - } + b.list.layoutManager = LinearLayoutManager(activity) + b.list.adapter = adapter + b.list.setAccessibilityDelegateCompat(object : RecyclerViewAccessibilityDelegate(b.list) { + override fun getItemDelegate(): AccessibilityDelegateCompat { + return object : ItemDelegate(this) { + override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfoCompat) { + super.onInitializeAccessibilityNodeInfo(host, info) + val position: Int = b.list.getChildLayoutPosition(host) + if (position != 0) { + info.addAction(AccessibilityActionCompat( + R.id.move_card_up_action, + host.resources.getString(R.string.card_action_move_up) + )) } + if (position != adapter.itemCount - 1) { + info.addAction(AccessibilityActionCompat( + R.id.move_card_down_action, + host.resources.getString(R.string.card_action_move_down) + )) + } + } - override fun performAccessibilityAction( - host: View, - action: Int, - args: Bundle? - ): Boolean { - val fromPosition: Int = b.list.getChildLayoutPosition(host) - if (action == R.id.move_card_down_action) { - swapCards(fromPosition, fromPosition + 1, adapter) - return true - } else if (action == R.id.move_card_up_action) { - swapCards(fromPosition, fromPosition - 1, adapter) - return true - } - return super.performAccessibilityAction(host, action, args) + override fun performAccessibilityAction(host: View, action: Int, args: Bundle?): Boolean { + val fromPosition: Int = b.list.getChildLayoutPosition(host) + if (action == R.id.move_card_down_action) { + swapCards(fromPosition, fromPosition + 1, adapter) + return true + } else if (action == R.id.move_card_up_action) { + swapCards(fromPosition, fromPosition - 1, adapter) + return true } + return super.performAccessibilityAction(host, action, args) } } - }) - - itemTouchHelper.attachToRecyclerView(b.list) - } + } + }) + itemTouchHelper.attachToRecyclerView(b.list) } } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/cards/SettingsThemeCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/cards/SettingsThemeCard.kt index 2d8df22f..ccf884fa 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/cards/SettingsThemeCard.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/settings/cards/SettingsThemeCard.kt @@ -74,16 +74,6 @@ class SettingsThemeCard(util: SettingsUtil) : SettingsCard(util) { ) { _, it -> configGlobal.ui.miniMenuVisible = it activity.navView.drawer.miniDrawerVisiblePortrait = it - }, - - util.createPropertyItem( - text = R.string.settings_ui_lock_layout_text, - subText = R.string.settings_ui_lock_layout_subtext, - icon = CommunityMaterial.Icon.cmd_axis_lock, - value = configGlobal.ui.lockLayout - ) { _, it -> - configGlobal.ui.lockLayout = it - activity.recreate() } ) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 6895c0c7..ab676839 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -1227,6 +1227,4 @@ Liste der Szkolny-Entwickler Lehrer Addressbuch herunterladen… - Sperren des Startbildschirm-Layouts - Sie können keine Elemente auf dem Startbildschirm bearbeiten diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 411b3176..0fd6ed3d 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -1434,6 +1434,4 @@ Agenda settings Share notes All lessons: - Lock home screen layout - You will not be able to edit items on the home screen diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cd3f799b..1cc5258b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1554,6 +1554,4 @@ Wszystkie lekcje: Wyświetl nazwę przedmiotu zamiast rodzaju Odśwież wybrany tydzień - Zablokuj układ ekranu głównego - Nie będzie można edytować przedmiotów na ekranie głównym