mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
Allow user to sort by status (#660)
This commit is contained in:
@@ -104,6 +104,11 @@ class ListHabitsMenu @Inject constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.actionSortStatus -> {
|
||||
behavior.onSortByStatus()
|
||||
return true
|
||||
}
|
||||
|
||||
else -> return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user