mirror of https://github.com/iSoron/uhabits.git
parent
d23b59ced2
commit
51ca4aa98e
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.isoron.uhabits.utils;
|
||||
|
||||
import android.support.annotation.*;
|
||||
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
import static android.text.format.DateFormat.getBestDateTimePattern;
|
||||
|
||||
public class AndroidDateFormats
|
||||
{
|
||||
@NonNull
|
||||
public static SimpleDateFormat fromSkeleton(@NonNull String skeleton)
|
||||
{
|
||||
Locale locale = Locale.getDefault();
|
||||
skeleton = getBestDateTimePattern(locale, skeleton);
|
||||
return DateFormats.fromSkeleton(skeleton, locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Álinson Santos Xavier <isoron@gmail.com>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.utils;
|
||||
|
||||
import android.content.*;
|
||||
import android.text.format.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AndroidDateUtils
|
||||
{
|
||||
public static String formatTime(Context context, int hours, int minutes)
|
||||
{
|
||||
int reminderMilliseconds = (hours * 60 + minutes) * 60 * 1000;
|
||||
|
||||
Date date = new Date(reminderMilliseconds);
|
||||
java.text.DateFormat df = DateFormat.getTimeFormat(context);
|
||||
df.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
|
||||
return df.format(date);
|
||||
}
|
||||
|
||||
public static String formatWeekdayList(Context context, boolean weekday[])
|
||||
{
|
||||
String shortDayNames[] = DateUtils.getShortDayNames();
|
||||
String longDayNames[] = DateUtils.getLongDayNames();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
int count = 0;
|
||||
int first = 0;
|
||||
boolean isFirst = true;
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
if (weekday[i])
|
||||
{
|
||||
if (isFirst) first = i;
|
||||
else buffer.append(", ");
|
||||
|
||||
buffer.append(shortDayNames[i]);
|
||||
isFirst = false;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 1) return longDayNames[first];
|
||||
if (count == 2 && weekday[0] && weekday[1])
|
||||
return context.getString(R.string.weekends);
|
||||
if (count == 5 && !weekday[0] && !weekday[1])
|
||||
return context.getString(R.string.any_weekday);
|
||||
if (count == 7) return context.getString(R.string.any_day);
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.isoron.uhabits.utils;
|
||||
|
||||
public class ColorConstants
|
||||
{
|
||||
public static String[] CSV_PALETTE = {
|
||||
"#D32F2F", // 0 red
|
||||
"#E64A19", // 1 orange
|
||||
"#F9A825", // 2 yellow
|
||||
"#AFB42B", // 3 light green
|
||||
"#388E3C", // 4 dark green
|
||||
"#00897B", // 5 teal
|
||||
"#00ACC1", // 6 cyan
|
||||
"#039BE5", // 7 blue
|
||||
"#5E35B1", // 8 deep purple
|
||||
"#8E24AA", // 9 purple
|
||||
"#D81B60", // 10 pink
|
||||
"#303030", // 11 dark grey
|
||||
"#aaaaaa" // 12 light grey
|
||||
};
|
||||
}
|
Loading…
Reference in new issue