Skip to content

Commit 01db7c0

Browse files
authored
Merge pull request #629 from Aga-C/add-widget-sorting
Added sorting to the widget (#624)
2 parents a734f5d + 7376a4d commit 01db7c0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,7 @@ class MainActivity : SimpleActivity() {
12751275
private fun displaySortChecklistDialog() {
12761276
SortChecklistDialog(this) {
12771277
getPagerAdapter().refreshChecklist(view_pager.currentItem)
1278+
updateWidgets()
12781279
}
12791280
}
12801281
}

app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.widget.RemoteViewsService
99
import com.simplemobiletools.commons.extensions.adjustAlpha
1010
import com.simplemobiletools.commons.extensions.setText
1111
import com.simplemobiletools.commons.extensions.setTextSize
12+
import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM
1213
import com.simplemobiletools.commons.helpers.WIDGET_TEXT_COLOR
1314
import com.simplemobiletools.notes.pro.R
1415
import com.simplemobiletools.notes.pro.R.id.widget_text_holder
@@ -129,6 +130,13 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
129130

130131
// checklist title can be null only because of the glitch in upgrade to 6.6.0, remove this check in the future
131132
checklistItems = checklistItems.filter { it.title != null }.toMutableList() as ArrayList<ChecklistItem>
133+
val sorting = context.config?.sorting ?: 0
134+
if (sorting and SORT_BY_CUSTOM == 0) {
135+
checklistItems.sort()
136+
if (context?.config?.moveDoneChecklistItems == true) {
137+
checklistItems.sortBy { it.isDone }
138+
}
139+
}
132140
}
133141
}
134142

0 commit comments

Comments
 (0)