mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 02:46:29 -06:00
add lock layout function (szkolny-eu/szkolny-android#199)
This commit is contained in:
parent
28c9dba00d
commit
2fd7038d0c
@ -15,6 +15,7 @@ class ConfigUI(base: Config) {
|
||||
var appBackground by base.config<String?>("appBg", null)
|
||||
var headerBackground by base.config<String?>("headerBg", null)
|
||||
|
||||
var lockLayout by base.config<Boolean>(false)
|
||||
var miniMenuVisible by base.config<Boolean>(false)
|
||||
var miniMenuButtons by base.config<Set<NavTarget>> {
|
||||
setOf(
|
||||
|
@ -136,6 +136,7 @@ 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()
|
||||
}
|
||||
@ -168,43 +169,63 @@ 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)
|
||||
val itemTouchHelper = ItemTouchHelper(CardItemTouchHelperCallback(adapter, b.refreshLayout))
|
||||
adapter.itemTouchHelper = itemTouchHelper
|
||||
b.list.layoutManager = LinearLayoutManager(activity)
|
||||
b.list.adapter = adapter
|
||||
b.list.setAccessibilityDelegateCompat(object : RecyclerViewAccessibilityDelegate(b.list) {
|
||||
b.list.layoutManager = LinearLayoutManager(activity)
|
||||
|
||||
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) {
|
||||
override fun onInitializeAccessibilityNodeInfo(
|
||||
host: View,
|
||||
info: AccessibilityNodeInfoCompat
|
||||
) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info)
|
||||
val position: Int = b.list.getChildLayoutPosition(host)
|
||||
if (position != 0) {
|
||||
info.addAction(AccessibilityActionCompat(
|
||||
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(
|
||||
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 {
|
||||
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)
|
||||
@ -218,6 +239,8 @@ class HomeFragment : Fragment(), CoroutineScope {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
itemTouchHelper.attachToRecyclerView(b.list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,16 @@ 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()
|
||||
}
|
||||
)
|
||||
|
||||
|
11
app/src/main/res/drawable/ic_note_legacy.xml
Normal file
11
app/src/main/res/drawable/ic_note_legacy.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="48"
|
||||
android:viewportHeight="48"
|
||||
android:tint="?colorOnBackground"
|
||||
android:autoMirrored="true">
|
||||
<path
|
||||
android:fillColor="?colorOnBackground"
|
||||
android:pathData="M15,34.2Q15.75,34.2 16.3,33.675Q16.85,33.15 16.85,32.4Q16.85,31.65 16.3,31.1Q15.75,30.55 15,30.55Q14.25,30.55 13.725,31.1Q13.2,31.65 13.2,32.4Q13.2,33.15 13.725,33.675Q14.25,34.2 15,34.2ZM15,25.8Q15.75,25.8 16.3,25.275Q16.85,24.75 16.85,24Q16.85,23.25 16.3,22.7Q15.75,22.15 15,22.15Q14.25,22.15 13.725,22.7Q13.2,23.25 13.2,24Q13.2,24.75 13.725,25.275Q14.25,25.8 15,25.8ZM15,17.35Q15.75,17.35 16.3,16.825Q16.85,16.3 16.85,15.55Q16.85,14.8 16.3,14.25Q15.75,13.7 15,13.7Q14.25,13.7 13.725,14.25Q13.2,14.8 13.2,15.55Q13.2,16.3 13.725,16.825Q14.25,17.35 15,17.35ZM21.45,34.25H34.15V30.6H21.45ZM21.45,25.8H34.15V22.15H21.45ZM21.45,17.4H34.15V13.75H21.45ZM9,42.65Q7.55,42.65 6.45,41.55Q5.35,40.45 5.35,39V9Q5.35,7.55 6.45,6.45Q7.55,5.35 9,5.35H39Q40.45,5.35 41.55,6.45Q42.65,7.55 42.65,9V39Q42.65,40.45 41.55,41.55Q40.45,42.65 39,42.65ZM9,39H39Q39,39 39,39Q39,39 39,39V9Q39,9 39,9Q39,9 39,9H9Q9,9 9,9Q9,9 9,9V39Q9,39 9,39Q9,39 9,39ZM9,9Q9,9 9,9Q9,9 9,9V39Q9,39 9,39Q9,39 9,39Q9,39 9,39Q9,39 9,39V9Q9,9 9,9Q9,9 9,9Z"/>
|
||||
</vector>
|
@ -18,7 +18,7 @@
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled"
|
||||
app:icon="@drawable/ic_note"
|
||||
app:icon="@drawable/ic_note_legacy"
|
||||
app:iconTint="?colorOnPrimaryContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -29,7 +29,7 @@
|
||||
android:drawablePadding="8dp"
|
||||
android:text="@{text}"
|
||||
android:textAppearance="@style/AppTheme.MaterialAlertDialog.TitleText"
|
||||
app:drawableStartCompat="@drawable/ic_note"
|
||||
app:drawableStartCompat="@drawable/ic_note_legacy"
|
||||
tools:layout_height="28sp"
|
||||
tools:text="@string/notes_list_dialog_title" />
|
||||
|
||||
|
@ -1227,4 +1227,6 @@
|
||||
<string name="settings_about_contributors_subtext">Liste der Szkolny-Entwickler</string>
|
||||
<string name="menu_teachers">Lehrer</string>
|
||||
<string name="edziennik_progress_endpoint_addressbook">Addressbuch herunterladen…</string>
|
||||
<string name="settings_ui_lock_layout_text">Sperren des Startbildschirm-Layouts</string>
|
||||
<string name="settings_ui_lock_layout_subtext">Sie können keine Elemente auf dem Startbildschirm bearbeiten</string>
|
||||
</resources>
|
||||
|
@ -1434,4 +1434,6 @@
|
||||
<string name="menu_agenda_config">Agenda settings</string>
|
||||
<string name="registration_config_note_sharing_title">Share notes</string>
|
||||
<string name="home_timetable_all_lessons">All lessons:</string>
|
||||
<string name="settings_ui_lock_layout_text">Lock home screen layout</string>
|
||||
<string name="settings_ui_lock_layout_subtext">You will not be able to edit items on the home screen</string>
|
||||
</resources>
|
||||
|
@ -1554,4 +1554,6 @@
|
||||
<string name="home_timetable_all_lessons">Wszystkie lekcje:</string>
|
||||
<string name="agenda_config_subject_important">Wyświetl nazwę przedmiotu zamiast rodzaju</string>
|
||||
<string name="menu_timetable_sync">Odśwież wybrany tydzień</string>
|
||||
<string name="settings_ui_lock_layout_text">Zablokuj układ ekranu głównego</string>
|
||||
<string name="settings_ui_lock_layout_subtext">Nie będzie można edytować przedmiotów na ekranie głównym</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user