Add arrows to sort menu
@@ -102,6 +102,7 @@ class ListHabitsActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
invalidateOptionsMenu()
|
||||
return menu.onItemSelected(item)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,13 @@ import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.core.models.HabitList
|
||||
import org.isoron.uhabits.core.preferences.Preferences
|
||||
import org.isoron.uhabits.core.ui.ThemeSwitcher
|
||||
import org.isoron.uhabits.core.ui.screens.habits.list.ListHabitsMenuBehavior
|
||||
import org.isoron.uhabits.inject.ActivityContext
|
||||
import org.isoron.uhabits.inject.ActivityScope
|
||||
import org.isoron.uhabits.utils.StyledResources
|
||||
import javax.inject.Inject
|
||||
|
||||
@ActivityScope
|
||||
@@ -50,6 +52,29 @@ class ListHabitsMenu @Inject constructor(
|
||||
nightModeItem.isChecked = themeSwitcher.isNightMode
|
||||
hideArchivedItem.isChecked = !preferences.showArchived
|
||||
hideCompletedItem.isChecked = !preferences.showCompleted
|
||||
updateArrows(menu)
|
||||
}
|
||||
|
||||
private fun updateArrows(menu: Menu) {
|
||||
val styledResources = StyledResources(activity)
|
||||
val sortManual = menu.findItem(R.id.actionSortManual)
|
||||
val sortName = menu.findItem(R.id.actionSortName)
|
||||
val sortColor = menu.findItem(R.id.actionSortColor)
|
||||
val sortScore = menu.findItem(R.id.actionSortScore)
|
||||
val sortStatus = menu.findItem(R.id.actionSortStatus)
|
||||
val arrowUp = styledResources.getDrawable(R.attr.iconArrowUp)
|
||||
val arrowDown = styledResources.getDrawable(R.attr.iconArrowDown)
|
||||
when (preferences.defaultPrimaryOrder) {
|
||||
HabitList.Order.BY_NAME_ASC -> sortName.icon = arrowDown
|
||||
HabitList.Order.BY_NAME_DESC -> sortName.icon = arrowUp
|
||||
HabitList.Order.BY_COLOR_ASC -> sortColor.icon = arrowDown
|
||||
HabitList.Order.BY_COLOR_DESC -> sortColor.icon = arrowUp
|
||||
HabitList.Order.BY_SCORE_ASC -> sortScore.icon = arrowDown
|
||||
HabitList.Order.BY_SCORE_DESC -> sortScore.icon = arrowUp
|
||||
HabitList.Order.BY_STATUS_ASC -> sortStatus.icon = arrowDown
|
||||
HabitList.Order.BY_STATUS_DESC -> sortStatus.icon = arrowUp
|
||||
HabitList.Order.BY_POSITION -> sortManual.icon = arrowUp
|
||||
}
|
||||
}
|
||||
|
||||
fun onItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#FFFFFF"
|
||||
android:alpha="0.8">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,12l-1.41,-1.41L13,16.17V4h-2v12.17l-5.58,-5.59L4,12l8,8 8,-8z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#333333"
|
||||
android:alpha="0.6">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,12l-1.41,-1.41L13,16.17V4h-2v12.17l-5.58,-5.59L4,12l8,8 8,-8z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#FFFFFF"
|
||||
android:alpha="0.8">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M4,12l1.41,1.41L11,7.83V20h2V7.83l5.58,5.59L20,12l-8,-8 -8,8z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#333333"
|
||||
android:alpha="0.6">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M4,12l1.41,1.41L11,7.83V20h2V7.83l5.58,5.59L20,12l-8,-8 -8,8z"/>
|
||||
</vector>
|
||||
|
After Width: | Height: | Size: 240 B |
|
After Width: | Height: | Size: 237 B |
BIN
uhabits-android/src/main/res/drawable-hdpi/ic_arrow_up_dark.png
Normal file
|
After Width: | Height: | Size: 234 B |
BIN
uhabits-android/src/main/res/drawable-hdpi/ic_arrow_up_light.png
Normal file
|
After Width: | Height: | Size: 246 B |
|
After Width: | Height: | Size: 180 B |
|
After Width: | Height: | Size: 182 B |
BIN
uhabits-android/src/main/res/drawable-mdpi/ic_arrow_up_dark.png
Normal file
|
After Width: | Height: | Size: 177 B |
BIN
uhabits-android/src/main/res/drawable-mdpi/ic_arrow_up_light.png
Normal file
|
After Width: | Height: | Size: 182 B |
|
After Width: | Height: | Size: 317 B |
|
After Width: | Height: | Size: 294 B |
BIN
uhabits-android/src/main/res/drawable-xhdpi/ic_arrow_up_dark.png
Normal file
|
After Width: | Height: | Size: 299 B |
|
After Width: | Height: | Size: 279 B |
|
After Width: | Height: | Size: 574 B |
|
After Width: | Height: | Size: 526 B |
|
After Width: | Height: | Size: 551 B |
|
After Width: | Height: | Size: 475 B |
@@ -41,6 +41,8 @@
|
||||
<attr name="iconUnarchive" format="reference"/>
|
||||
<attr name="dialogIconChangeColor" format="reference"/>
|
||||
<attr name="iconFilter" format="reference"/>
|
||||
<attr name="iconArrowUp" format="reference"/>
|
||||
<attr name="iconArrowDown" format="reference"/>
|
||||
|
||||
<attr name="toolbarPopupTheme" format="reference"/>
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
<item name="iconEdit">@drawable/ic_action_edit_dark</item>
|
||||
<item name="iconFilter">@drawable/ic_action_filter_dark</item>
|
||||
<item name="iconUnarchive">@drawable/ic_action_unarchive_dark</item>
|
||||
<item name="iconArrowUp">@drawable/ic_arrow_up_light</item>
|
||||
<item name="iconArrowDown">@drawable/ic_arrow_down_light</item>
|
||||
<item name="contrast0">@color/white</item>
|
||||
<item name="contrast20">@color/grey_300</item>
|
||||
<item name="contrast40">@color/grey_350</item>
|
||||
@@ -84,6 +86,8 @@
|
||||
<item name="iconEdit">@drawable/ic_action_edit_dark</item>
|
||||
<item name="iconFilter">@drawable/ic_action_filter_dark</item>
|
||||
<item name="iconUnarchive">@drawable/ic_action_unarchive_dark</item>
|
||||
<item name="iconArrowUp">@drawable/ic_arrow_up_dark</item>
|
||||
<item name="iconArrowDown">@drawable/ic_arrow_down_dark</item>
|
||||
<item name="contrast0">@color/grey_900</item>
|
||||
<item name="contrast20">@color/grey_800</item>
|
||||
<item name="contrast40">@color/grey_750</item>
|
||||
|
||||