mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Revert "New color but Sort By Color broken"
This reverts commit 4ce9013e6a.
This commit is contained in:
@@ -30,7 +30,6 @@ public class ColorPickerDialog extends com.android.colorpicker.ColorPickerDialog
|
|||||||
{
|
{
|
||||||
super.setOnColorSelectedListener(c -> {
|
super.setOnColorSelectedListener(c -> {
|
||||||
c = ColorUtils.colorToPaletteIndex(getContext(), c);
|
c = ColorUtils.colorToPaletteIndex(getContext(), c);
|
||||||
c = ColorUtils.StaticColor.getColorByXmlIndex(c).dbIndex;
|
|
||||||
listener.onColorSelected(c);
|
listener.onColorSelected(c);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ public abstract class HabitList implements Iterable<Habit>
|
|||||||
habit.getDescription(),
|
habit.getDescription(),
|
||||||
Integer.toString(freq.getNumerator()),
|
Integer.toString(freq.getNumerator()),
|
||||||
Integer.toString(freq.getDenominator()),
|
Integer.toString(freq.getDenominator()),
|
||||||
ColorUtils.StaticColor.getColorByDbIndex(habit.getColor()).name()
|
ColorUtils.CSV_PALETTE[habit.getColor()]
|
||||||
};
|
};
|
||||||
|
|
||||||
csv.writeNext(cols, false);
|
csv.writeNext(cols, false);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class HabitMatcherBuilder
|
|||||||
private static List<Integer> allColors()
|
private static List<Integer> allColors()
|
||||||
{
|
{
|
||||||
List<Integer> colors = new ArrayList<>();
|
List<Integer> colors = new ArrayList<>();
|
||||||
for(int i = 0; i < ColorUtils.StaticColor.values().length; i++)
|
for(int i = 0; i < ColorUtils.CSV_PALETTE.length; i++)
|
||||||
colors.add(i);
|
colors.add(i);
|
||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ package org.isoron.uhabits.models.memory;
|
|||||||
import android.support.annotation.*;
|
import android.support.annotation.*;
|
||||||
|
|
||||||
import org.isoron.uhabits.models.*;
|
import org.isoron.uhabits.models.*;
|
||||||
import org.isoron.uhabits.utils.ColorUtils;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -156,8 +155,8 @@ public class MemoryHabitList extends HabitList
|
|||||||
(h1, h2) -> h1.getName().compareTo(h2.getName());
|
(h1, h2) -> h1.getName().compareTo(h2.getName());
|
||||||
|
|
||||||
Comparator<Habit> colorComparator = (h1, h2) -> {
|
Comparator<Habit> colorComparator = (h1, h2) -> {
|
||||||
Integer c1 = ColorUtils.StaticColor.getColorByDbIndex(h1.getColor()).xmlIndex;
|
Integer c1 = h1.getColor();
|
||||||
Integer c2 = ColorUtils.StaticColor.getColorByDbIndex(h2.getColor()).xmlIndex;
|
Integer c2 = h2.getColor();
|
||||||
if (c1.equals(c2)) return nameComparator.compare(h1, h2);
|
if (c1.equals(c2)) return nameComparator.compare(h1, h2);
|
||||||
else return c1.compareTo(c2);
|
else return c1.compareTo(c2);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,55 +25,21 @@ import android.util.*;
|
|||||||
|
|
||||||
public abstract class ColorUtils
|
public abstract class ColorUtils
|
||||||
{
|
{
|
||||||
|
public static String CSV_PALETTE[] = {
|
||||||
public enum StaticColor
|
"#D32F2F", // 0 red
|
||||||
{
|
"#E64A19", // 1 orange
|
||||||
RED ( 0, 0),
|
"#F9A825", // 2 yellow
|
||||||
DEEP_ORANGE ( 1, 1),
|
"#AFB42B", // 3 light green
|
||||||
ORANGE ( 2,13),
|
"#388E3C", // 4 dark green
|
||||||
YELLOW ( 3, 2),
|
"#00897B", // 5 teal
|
||||||
LIGHT_GREEN ( 4, 3),
|
"#00ACC1", // 6 cyan
|
||||||
DARK_GREEN ( 5, 4),
|
"#039BE5", // 7 blue
|
||||||
TEAL ( 6, 5),
|
"#5E35B1", // 8 deep purple
|
||||||
CYAN ( 7, 6),
|
"#8E24AA", // 9 purple
|
||||||
BLUE ( 8, 7),
|
"#D81B60", // 10 pink
|
||||||
DEEP_PURPLE ( 9, 8),
|
"#303030", // 11 dark grey
|
||||||
PURPLE (10, 9),
|
"#aaaaaa" // 12 light grey
|
||||||
PINK (11,10),
|
};
|
||||||
BROWN (12,14),
|
|
||||||
DARK_GREY (13,11),
|
|
||||||
GREY (14,15),
|
|
||||||
LIGHT_GREY (15,12);
|
|
||||||
|
|
||||||
public final int xmlIndex;
|
|
||||||
public final int dbIndex;
|
|
||||||
|
|
||||||
StaticColor(int xmlIndex, int dbIndex)
|
|
||||||
{
|
|
||||||
this.xmlIndex = xmlIndex;
|
|
||||||
this.dbIndex = dbIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StaticColor getColorByDbIndex(int dbIndex)
|
|
||||||
{
|
|
||||||
for(StaticColor c : StaticColor.values())
|
|
||||||
if (c.dbIndex == dbIndex) return c;
|
|
||||||
|
|
||||||
Log.w("ColorHelper",
|
|
||||||
String.format("Invalid color db index: %d. Returning default.", dbIndex));
|
|
||||||
return RED;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StaticColor getColorByXmlIndex(int xmlIndex)
|
|
||||||
{
|
|
||||||
for(StaticColor c : StaticColor.values())
|
|
||||||
if (c.xmlIndex == xmlIndex) return c;
|
|
||||||
|
|
||||||
Log.w("ColorHelper",
|
|
||||||
String.format("Invalid color xml index: %d. Returning default.", xmlIndex));
|
|
||||||
return RED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int colorToPaletteIndex(Context context, int color)
|
public static int colorToPaletteIndex(Context context, int color)
|
||||||
{
|
{
|
||||||
@@ -112,8 +78,6 @@ public abstract class ColorUtils
|
|||||||
if (context == null)
|
if (context == null)
|
||||||
throw new IllegalArgumentException("Context is null");
|
throw new IllegalArgumentException("Context is null");
|
||||||
|
|
||||||
paletteColor = ColorUtils.StaticColor.getColorByDbIndex(paletteColor).xmlIndex;
|
|
||||||
|
|
||||||
StyledResources res = new StyledResources(context);
|
StyledResources res = new StyledResources(context);
|
||||||
int palette[] = res.getPalette();
|
int palette[] = res.getPalette();
|
||||||
if (paletteColor < 0 || paletteColor >= palette.length)
|
if (paletteColor < 0 || paletteColor >= palette.length)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
<array name="lightPalette">
|
<array name="lightPalette">
|
||||||
<item>@color/red_700</item>
|
<item>@color/red_700</item>
|
||||||
<item>@color/deep_orange_700</item>
|
<item>@color/deep_orange_700</item>
|
||||||
<item>@color/orange_700</item>
|
|
||||||
<item>@color/yellow_800</item>
|
<item>@color/yellow_800</item>
|
||||||
<item>@color/lime_700</item>
|
<item>@color/lime_700</item>
|
||||||
<item>@color/green_700</item>
|
<item>@color/green_700</item>
|
||||||
@@ -29,16 +28,13 @@
|
|||||||
<item>@color/deep_purple_600</item>
|
<item>@color/deep_purple_600</item>
|
||||||
<item>@color/purple_600</item>
|
<item>@color/purple_600</item>
|
||||||
<item>@color/pink_600</item>
|
<item>@color/pink_600</item>
|
||||||
<item>@color/brown_700</item>
|
|
||||||
<item>@color/grey_800</item>
|
<item>@color/grey_800</item>
|
||||||
<item>@color/grey_600</item>
|
|
||||||
<item>@color/grey_500</item>
|
<item>@color/grey_500</item>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
<array name="darkPalette">
|
<array name="darkPalette">
|
||||||
<item>@color/red_200</item>
|
<item>@color/red_200</item>
|
||||||
<item>@color/deep_orange_200</item>
|
<item>@color/deep_orange_200</item>
|
||||||
<item>@color/orange_200</item>
|
|
||||||
<item>@color/yellow_200</item>
|
<item>@color/yellow_200</item>
|
||||||
<item>@color/lime_200</item>
|
<item>@color/lime_200</item>
|
||||||
<item>@color/green_A200</item>
|
<item>@color/green_A200</item>
|
||||||
@@ -48,16 +44,13 @@
|
|||||||
<item>@color/deep_purple_200</item>
|
<item>@color/deep_purple_200</item>
|
||||||
<item>@color/purple_200</item>
|
<item>@color/purple_200</item>
|
||||||
<item>@color/pink_200</item>
|
<item>@color/pink_200</item>
|
||||||
<item>@color/brown_200</item>
|
|
||||||
<item>@color/grey_100</item>
|
<item>@color/grey_100</item>
|
||||||
<item>@color/grey_300</item>
|
|
||||||
<item>@color/grey_500</item>
|
<item>@color/grey_500</item>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
<array name="transparentWidgetPalette">
|
<array name="transparentWidgetPalette">
|
||||||
<item>@color/red_800</item>
|
<item>@color/red_800</item>
|
||||||
<item>@color/deep_orange_800</item>
|
<item>@color/deep_orange_800</item>
|
||||||
<item>@color/orange_800</item>
|
|
||||||
<item>@color/yellow_800</item>
|
<item>@color/yellow_800</item>
|
||||||
<item>@color/lime_800</item>
|
<item>@color/lime_800</item>
|
||||||
<item>@color/green_700</item>
|
<item>@color/green_700</item>
|
||||||
@@ -67,8 +60,6 @@
|
|||||||
<item>@color/deep_purple_700</item>
|
<item>@color/deep_purple_700</item>
|
||||||
<item>@color/purple_700</item>
|
<item>@color/purple_700</item>
|
||||||
<item>@color/pink_700</item>
|
<item>@color/pink_700</item>
|
||||||
<item>@color/brown_800</item>
|
|
||||||
<item>@color/black_aa</item>
|
|
||||||
<item>@color/black_aa</item>
|
<item>@color/black_aa</item>
|
||||||
<item>@color/black_aa</item>
|
<item>@color/black_aa</item>
|
||||||
</array>
|
</array>
|
||||||
|
|||||||
@@ -172,8 +172,8 @@ public class HabitListTest extends BaseUnitTest
|
|||||||
|
|
||||||
String expectedCSV =
|
String expectedCSV =
|
||||||
"Position,Name,Description,NumRepetitions,Interval,Color\n" +
|
"Position,Name,Description,NumRepetitions,Interval,Color\n" +
|
||||||
"001,Meditate,Did you meditate this morning?,1,1,LIGHT_GREEN\n" +
|
"001,Meditate,Did you meditate this morning?,1,1,#AFB42B\n" +
|
||||||
"002,Wake up early,Did you wake up before 6am?,2,3,TEAL\n";
|
"002,Wake up early,Did you wake up before 6am?,2,3,#00897B\n";
|
||||||
|
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
list.writeCSV(writer);
|
list.writeCSV(writer);
|
||||||
|
|||||||
Reference in New Issue
Block a user