Skip to content

Commit 071ef8f

Browse files
authored
Fix/minor fixes (#890)
1 parent 9d5ef41 commit 071ef8f

7 files changed

Lines changed: 51 additions & 37 deletions

File tree

app/src/main/java/com/philkes/notallyx/presentation/activity/main/MainActivity.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,17 @@ class MainActivity : LockedActivity<ActivityMainBinding>() {
424424
private fun deleteForever() {
425425
MaterialAlertDialogBuilder(this)
426426
.setMessage(R.string.delete_selected_notes)
427-
.setPositiveButton(R.string.delete) { _, _ -> baseModel.deleteSelectedBaseNotes() }
427+
.setPositiveButton(R.string.delete) { _, _ ->
428+
val removedNotes = baseModel.actionMode.selectedNotes.values.toList()
429+
baseModel.deleteSelectedBaseNotes()
430+
Snackbar.make(
431+
findViewById(R.id.DrawerLayout),
432+
getQuantityString(R.plurals.deleted_selected_notes, removedNotes.size),
433+
Snackbar.LENGTH_SHORT,
434+
)
435+
.apply { setAction(R.string.undo) { baseModel.saveNotes(removedNotes) } }
436+
.show()
437+
}
428438
.setCancelButton()
429439
.show()
430440
}

app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditActivity.kt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
334334

335335
fun finishAfterDeleteForever() = super.finish()
336336

337-
private fun showActionSelectionDialog(oldAction: EditAction, isBottomBar: Boolean = false) {
337+
private fun showActionSelectionDialog(
338+
oldAction: EditAction,
339+
index: Int,
340+
isBottomBar: Boolean = false,
341+
) {
338342
val actions = EditAction.entries.filter { it != EditAction.RESTORE }
339343
ActionSelectionBottomSheet(
340344
actions,
@@ -348,12 +352,9 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
348352
NotallyXPreferences.DEFAULT_EDIT_NOTE_BOTTOM_ACTION
349353
)
350354
} else {
351-
val currentActions = prefs.editNoteActivityTopActions.value.toMutableList()
352-
val index = currentActions.indexOf(oldAction)
353-
if (
354-
index != -1 &&
355-
index < NotallyXPreferences.DEFAULT_EDIT_NOTE_TOP_ACTIONS.size
356-
) {
355+
val currentActions =
356+
prefs.getSafeEditNoteActivityTopActions().toMutableList()
357+
if (index in currentActions.indices) {
357358
currentActions[index] =
358359
NotallyXPreferences.DEFAULT_EDIT_NOTE_TOP_ACTIONS[index]
359360
prefs.editNoteActivityTopActions.save(currentActions)
@@ -367,8 +368,7 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
367368
prefs.editNoteActivityBottomAction.save(newAction)
368369
} else {
369370
val currentActions = prefs.getSafeEditNoteActivityTopActions().toMutableList()
370-
val index = currentActions.indexOf(oldAction)
371-
if (index != -1) {
371+
if (index in currentActions.indices) {
372372
currentActions[index] = newAction
373373
prefs.editNoteActivityTopActions.save(currentActions)
374374
}
@@ -602,7 +602,7 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
602602
// Try to get the view for long click
603603
post {
604604
button.setOnLongClickListener {
605-
showActionSelectionDialog(action, isBottomBar = true)
605+
showActionSelectionDialog(action, index = 0, isBottomBar = true)
606606
true
607607
}
608608
}
@@ -937,22 +937,21 @@ abstract class EditActivity(private val type: Type) : LockedActivity<ActivityEdi
937937
private fun updateTopActions(topActions: List<EditAction>) {
938938
binding.Toolbar.menu.apply {
939939
clear()
940-
topActions.forEach { action ->
940+
topActions.forEachIndexed { idx, action ->
941941
val (title, icon) =
942942
action.getTitleAndIcon(
943943
notallyModel.pinned,
944944
notallyModel.viewMode.value,
945945
notallyModel.folder,
946946
notallyModel.type,
947947
)
948-
val menuItem =
949-
add(title, icon, MenuItem.SHOW_AS_ACTION_ALWAYS, itemId = action.itemId) {
950-
actionHandler.handleAction(action)
951-
}
948+
add(title, icon, MenuItem.SHOW_AS_ACTION_ALWAYS, itemId = idx) {
949+
actionHandler.handleAction(action)
950+
}
952951
// Try to get the view for long click
953952
binding.Toolbar.post {
954-
findViewById<View>(menuItem.itemId)?.setOnLongClickListener {
955-
showActionSelectionDialog(action)
953+
findViewById<View>(idx)?.setOnLongClickListener {
954+
showActionSelectionDialog(action, idx)
956955
true
957956
}
958957
}

app/src/main/java/com/philkes/notallyx/presentation/viewmodel/BaseNoteModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,10 @@ class BaseNoteModel(private val app: Application) : AndroidViewModel(app) {
942942
}
943943
}
944944

945+
fun saveNotes(notes: List<BaseNote>) {
946+
viewModelScope.launch(Dispatchers.IO) { baseNoteDao.insert(notes) }
947+
}
948+
945949
companion object {
946950
private const val TAG = "BaseNoteModel"
947951

app/src/main/java/com/philkes/notallyx/presentation/viewmodel/preference/Preference.kt

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -401,22 +401,21 @@ enum class BiometricLock(override val textResId: Int) : StaticTextProvider {
401401
override fun getText(context: Context): String = context.getString(textResId)
402402
}
403403

404-
enum class EditAction(override val textResId: Int, val drawableResId: Int, val itemId: Int) :
405-
StaticTextProvider {
406-
SEARCH(R.string.search, R.drawable.search, 1001),
407-
PIN(R.string.pin, R.drawable.pin, 1002),
408-
REMINDERS(R.string.reminders, R.drawable.notifications, 1003),
409-
LABELS(R.string.labels, R.drawable.label, 1004),
410-
CHANGE_COLOR(R.string.change_color, R.drawable.change_color, 1005),
411-
DUPLICATE(R.string.duplicate, R.drawable.content_copy, 1006),
412-
EXPORT(R.string.export, R.drawable.export, 1007),
413-
SHARE(R.string.share, R.drawable.share, 1008),
414-
DELETE(R.string.delete, R.drawable.delete, 1009),
415-
ARCHIVE(R.string.archive, R.drawable.archive, 1010),
416-
TOGGLE_VIEW_MODE(R.string.edit, R.drawable.visibility, 1011),
417-
CONVERT(R.string.convert_to_list_note, R.drawable.convert_to_text, 1012),
418-
DELETE_FOREVER(R.string.delete_forever, R.drawable.delete, 1014),
419-
RESTORE(R.string.restore, R.drawable.restore, 1015);
404+
enum class EditAction(override val textResId: Int, val drawableResId: Int) : StaticTextProvider {
405+
SEARCH(R.string.search, R.drawable.search),
406+
PIN(R.string.pin, R.drawable.pin),
407+
REMINDERS(R.string.reminders, R.drawable.notifications),
408+
LABELS(R.string.labels, R.drawable.label),
409+
CHANGE_COLOR(R.string.change_color, R.drawable.change_color),
410+
DUPLICATE(R.string.duplicate, R.drawable.content_copy),
411+
EXPORT(R.string.export, R.drawable.export),
412+
SHARE(R.string.share, R.drawable.share),
413+
DELETE(R.string.delete, R.drawable.delete),
414+
ARCHIVE(R.string.archive, R.drawable.archive),
415+
TOGGLE_VIEW_MODE(R.string.edit, R.drawable.visibility),
416+
CONVERT(R.string.convert_to_list_note, R.drawable.convert_to_text),
417+
DELETE_FOREVER(R.string.delete_forever, R.drawable.delete),
418+
RESTORE(R.string.restore, R.drawable.restore);
420419

421420
fun getTitleAndIcon(
422421
pinned: Boolean,

app/src/main/res/drawable/edit.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
android:width="24dp"
33
android:height="24dp"
44
android:viewportWidth="24"
5-
android:viewportHeight="24">
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorControlNormal">
67
<path
78
android:fillColor="#000000"
89
android:pathData="M14.06,9.02l0.92,0.92L5.92,19L5,19v-0.92l9.06,-9.06M17.66,3c-0.25,0 -0.51,0.1 -0.7,0.29l-1.83,1.83 3.75,3.75 1.83,-1.83c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.2,-0.2 -0.45,-0.29 -0.71,-0.29zM14.06,6.19L3,17.25L3,21h3.75L17.81,9.94l-3.75,-3.75z" />

app/src/main/res/drawable/home.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
android:width="24dp"
33
android:height="24dp"
44
android:viewportWidth="960"
5-
android:viewportHeight="960">
5+
android:viewportHeight="960"
6+
android:tint="?attr/colorControlNormal">
67
<path
78
android:fillColor="#000000"
89
android:pathData="M240,760L360,760L360,520L600,520L600,760L720,760L720,400L480,220L240,400L240,760ZM160,840L160,360L480,120L800,360L800,840L520,840L520,600L440,600L440,840L160,840ZM480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490Z" />

generate-changelogs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ GITHUB_TOKEN=${3:-$CHANGELOG_GITHUB_TOKEN}
66
echo "Generating CHANGELOG.md entry since $VERSION_NAME to $OUTPUT_FILE"
77
timeout 90s github_changelog_generator -u Crustack -p NotallyX --since-tag "$VERSION_NAME" \
88
--no-pr-wo-labels --no-issues-wo-labels --include-tags-regex '^v\d+(\.\d+)*$' \
9-
--include-labels enhancement,bug --exclude-labels duplicate,question,invalid,wontfix,'already done' \
9+
--include-labels enhancement,bug --exclude-labels duplicate,question,invalid,wontfix,'already done','out of scope' \
1010
--enhancement-label "### Added Features" --bugs-label "### Fixed Bugs" --pr-label "### Added Features" \
1111
--base "$OUTPUT_FILE" --output "$OUTPUT_FILE" --token "$GITHUB_TOKEN"
1212

0 commit comments

Comments
 (0)