Allow user to sort by status (#660)

This commit is contained in:
Quentin Hibon
2020-11-20 02:05:21 +01:00
committed by GitHub
parent dc0b8deccf
commit bfddc42f5e
16 changed files with 262 additions and 107 deletions

View File

@@ -104,6 +104,11 @@ class ListHabitsMenu @Inject constructor(
return true
}
R.id.actionSortStatus -> {
behavior.onSortByStatus()
return true
}
else -> return false
}
}

View File

@@ -21,7 +21,7 @@ package org.isoron.uhabits.activities.habits.list.views;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.*;
import android.view.*;
import androidx.recyclerview.widget.RecyclerView;
@@ -83,7 +83,8 @@ public class HabitCardListAdapter
cache.setListener(this);
cache.setCheckmarkCount(
ListHabitsRootViewKt.MAX_CHECKMARK_COUNT);
cache.setOrder(preferences.getDefaultOrder());
cache.setSecondaryOrder(preferences.getDefaultSecondaryOrder());
cache.setPrimaryOrder(preferences.getDefaultPrimaryOrder());
setHasStableIds(true);
}
@@ -160,7 +161,7 @@ public class HabitCardListAdapter
public boolean isSortable()
{
return cache.getOrder() == HabitList.Order.BY_POSITION;
return cache.getPrimaryOrder() == HabitList.Order.BY_POSITION;
}
/**
@@ -313,16 +314,22 @@ public class HabitCardListAdapter
}
@Override
public void setOrder(HabitList.Order order)
public void setPrimaryOrder(HabitList.Order order)
{
cache.setOrder(order);
preferences.setDefaultOrder(order);
cache.setPrimaryOrder(order);
preferences.setDefaultPrimaryOrder(order);
}
@Override
public HabitList.Order getOrder()
public void setSecondaryOrder(HabitList.Order order) {
cache.setSecondaryOrder(order);
preferences.setDefaultSecondaryOrder(order);
}
@Override
public HabitList.Order getPrimaryOrder()
{
return cache.getOrder();
return cache.getPrimaryOrder();
}
/**

View File

@@ -65,6 +65,10 @@
<item
android:id="@+id/actionSortScore"
android:title="@string/by_score"/>
<item
android:id="@+id/actionSortStatus"
android:title="@string/by_status"/>
</menu>
</item>
</menu>

View File

@@ -159,6 +159,7 @@
<string name="by_name">By name</string>
<string name="by_color">By color</string>
<string name="by_score">By score</string>
<string name="by_status">By status</string>
<string name="export">Export</string>
<string name="long_press_to_edit">Press-and-hold to change the value</string>
<string name="change_value">Change value</string>