-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(browse): more than 2 columns #17781
base: main
Are you sure you want to change the base?
Conversation
Prep for a variable column count * replace `setColumn1` with `setColumn(0` Issue 17780
Important Maintainers: This PR contains Strings changes
|
|
||
for (column in columnCollection.columns) { | ||
Timber.d("setting up column %s", column) | ||
TextView(this).apply { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want a custom layout?
// setup back button handling | ||
requireActivity().onBackPressedDispatcher.addCallback(onCloseDialogCallback) | ||
requireActivity().onBackPressedDispatcher.addCallback(discardChangesCallback) | ||
|
||
// stop the back button closing the dialog, and use the back dispatcher | ||
this.isCancelable = false | ||
dialog?.setOnKeyListener { _: DialogInterface?, keyCode: Int, e: KeyEvent? -> | ||
if (keyCode == KeyEvent.KEYCODE_BACK) { | ||
requireActivity().onBackPressedDispatcher.onBackPressed() | ||
true | ||
} | ||
false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels janky, improvements requested
runBlocking { | ||
var oldColumns: MutableList<CardBrowserColumn?> = mutableListOf() | ||
|
||
// save the current columns | ||
BrowserColumnCollection | ||
.update(sharedPrefs(), cardsOrNotes) { cols -> | ||
oldColumns = cols.toMutableList() | ||
cols.clear() | ||
cols.addAll(CardBrowserColumn.entries) | ||
true | ||
}?.apply { | ||
withCol { backend.setActiveBrowserColumns(backendKeys) } | ||
} | ||
|
||
// obtain a sample row | ||
sampleRow = withCol { browserRowForId(id.cardOrNoteId) } | ||
Timber.d("got sample row") | ||
|
||
// restore the past values | ||
BrowserColumnCollection | ||
.update(sharedPrefs(), cardsOrNotes) { cols -> | ||
cols.clear() | ||
cols.addAll(oldColumns) | ||
true | ||
}?.apply { | ||
withCol { backend.setActiveBrowserColumns(backendKeys) } | ||
} | ||
} | ||
|
||
return sampleRow | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't great, patches to make this more 'Kotlin' would be fantastic
// TODO: 4, 2, 1 on other | ||
setPaddingRelative( | ||
start = 3.dp, | ||
top = 1.dp, | ||
end = 3.dp, | ||
bottom = 1.dp, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work, but open for review
View(context).apply { | ||
layoutParams = | ||
LinearLayout.LayoutParams( | ||
0.5.dp.toPx(context), | ||
LinearLayout.LayoutParams.MATCH_PARENT, | ||
) | ||
setBackgroundResource(getResFromAttr(context, R.attr.cardBrowserDivider)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise: should these be layouts?
AnkiDroid/src/main/java/com/ichi2/anki/browser/BrowserMultiColumnAdapter.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/browser/BrowserMultiColumnAdapter.kt
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
c84c591
to
cc173fb
Compare
We introduce BrowserColumnSelectionFragment: a full screen dialog which allows a user to select and reorder the available columns in the Browse window There are two headings: 'displayed' & 'available' Headings are implemented as RecyclerView items, so dragging feels natural. Headings may not be dragged. It has two primary functions: * Drag to reorder * +/- to quickly add/remove from 'displayed' A 'preview' is obtained from the first row of the Browse window If there are no rows, there is no preview Issue 17780
A user can long press the column headings or edit them from the options to add/remove multiple columns Issue 17780
If a user is editing options and changes 'cards/notes' then they should be editing columns for their provided selection If a user saves columns, then reverts the switch, columns should not be updated Issue 17780
cc173fb
to
a072fbc
Compare
Purpose / Description
Anki Desktop allows more than 2 columns in the Browse screen. Let's do the same for AnkiDroid
Fixes
Approach
The settings screen allows a user to reorder and 'select' usable columns
A full-screen dialog fragment with two headings: 'displayed' & 'available'
Headings are implemented as RecyclerView items, so dragging feels natural. Headings may not be dragged.
It has two primary functions:
A 'preview' is obtained from the first row of the Browse window. If there are no rows, there is no preview
How Has This Been Tested?
Unit tested, and tested on an API 32 emulator
Checklist