mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Reorganize file tree according to feature
This commit is contained in:
@@ -24,8 +24,8 @@ import android.os.Build;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.support.test.InstrumentationRegistry;
|
import android.support.test.InstrumentationRegistry;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.tasks.BaseTask;
|
import org.isoron.uhabits.tasks.BaseTask;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
@@ -51,8 +51,8 @@ public class BaseTest
|
|||||||
targetContext = InstrumentationRegistry.getTargetContext();
|
targetContext = InstrumentationRegistry.getTargetContext();
|
||||||
testContext = InstrumentationRegistry.getContext();
|
testContext = InstrumentationRegistry.getContext();
|
||||||
|
|
||||||
UIHelper.setFixedTheme(R.style.AppBaseTheme);
|
InterfaceUtils.setFixedTheme(R.style.AppBaseTheme);
|
||||||
DateHelper.setFixedLocalTime(FIXED_LOCAL_TIME);
|
DateUtils.setFixedLocalTime(FIXED_LOCAL_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForAsyncTasks() throws InterruptedException, TimeoutException
|
protected void waitForAsyncTasks() throws InterruptedException, TimeoutException
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ import android.support.test.espresso.intent.rule.IntentsTestRule;
|
|||||||
import android.support.test.runner.AndroidJUnit4;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.MainActivity;
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
import org.isoron.uhabits.MainActivity;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -300,7 +300,7 @@ public class MainTest
|
|||||||
|
|
||||||
clickMenuItem(R.string.settings);
|
clickMenuItem(R.string.settings);
|
||||||
|
|
||||||
String date = DateHelper.getBackupDateFormat().format(DateHelper.getLocalTime());
|
String date = DateUtils.getBackupDateFormat().format(DateUtils.getLocalTime());
|
||||||
date = date.substring(0, date.length() - 2);
|
date = date.substring(0, date.length() - 2);
|
||||||
|
|
||||||
clickSettingsItem("Export full backup");
|
clickSettingsItem("Export full backup");
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ import android.content.Context;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.tasks.BaseTask;
|
import org.isoron.uhabits.tasks.BaseTask;
|
||||||
import org.isoron.uhabits.tasks.ExportDBTask;
|
import org.isoron.uhabits.tasks.ExportDBTask;
|
||||||
@@ -50,11 +51,11 @@ public class HabitFixtures
|
|||||||
habit.freqDen = 3;
|
habit.freqDen = 3;
|
||||||
habit.save();
|
habit.save();
|
||||||
|
|
||||||
long timestamp = DateHelper.getStartOfToday();
|
long timestamp = DateUtils.getStartOfToday();
|
||||||
for(boolean c : NON_DAILY_HABIT_CHECKS)
|
for(boolean c : NON_DAILY_HABIT_CHECKS)
|
||||||
{
|
{
|
||||||
if(c) habit.repetitions.toggle(timestamp);
|
if(c) habit.repetitions.toggle(timestamp);
|
||||||
timestamp -= DateHelper.millisecondsInOneDay;
|
timestamp -= DateUtils.millisecondsInOneDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
return habit;
|
return habit;
|
||||||
@@ -80,8 +81,8 @@ public class HabitFixtures
|
|||||||
habit.color = 4;
|
habit.color = 4;
|
||||||
habit.save();
|
habit.save();
|
||||||
|
|
||||||
long day = DateHelper.millisecondsInOneDay;
|
long day = DateUtils.millisecondsInOneDay;
|
||||||
long today = DateHelper.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
int marks[] = { 0, 1, 3, 5, 7, 8, 9, 10, 12, 14, 15, 17, 19, 20, 26, 27, 28, 50, 51, 52,
|
int marks[] = { 0, 1, 3, 5, 7, 8, 9, 10, 12, 14, 15, 17, 19, 20, 26, 27, 28, 50, 51, 52,
|
||||||
53, 54, 58, 60, 63, 65, 70, 71, 72, 73, 74, 75, 80, 81, 83, 89, 90, 91, 95,
|
53, 54, 58, 60, 63, 65, 70, 71, 72, 73, 74, 75, 80, 81, 83, 89, 90, 91, 95,
|
||||||
102, 103, 108, 109, 120};
|
102, 103, 108, 109, 120};
|
||||||
@@ -97,7 +98,7 @@ public class HabitFixtures
|
|||||||
final int nHabits = 30;
|
final int nHabits = 30;
|
||||||
final int nYears = 5;
|
final int nYears = 5;
|
||||||
|
|
||||||
DatabaseHelper.executeAsTransaction(new DatabaseHelper.Command()
|
DatabaseUtils.executeAsTransaction(new DatabaseUtils.Command()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
@@ -112,8 +113,8 @@ public class HabitFixtures
|
|||||||
habit.name = String.format("Habit %d", i);
|
habit.name = String.format("Habit %d", i);
|
||||||
habit.save();
|
habit.save();
|
||||||
|
|
||||||
long today = DateHelper.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
long day = DateHelper.millisecondsInOneDay;
|
long day = DateUtils.millisecondsInOneDay;
|
||||||
|
|
||||||
|
|
||||||
for(int j = 0; j < 365 * nYears; j++)
|
for(int j = 0; j < 365 * nYears; j++)
|
||||||
@@ -147,12 +148,12 @@ public class HabitFixtures
|
|||||||
|
|
||||||
public static void loadHugeDataSet(Context testContext) throws Throwable
|
public static void loadHugeDataSet(Context testContext) throws Throwable
|
||||||
{
|
{
|
||||||
File baseDir = DatabaseHelper.getFilesDir("Backups");
|
File baseDir = FileUtils.getFilesDir("Backups");
|
||||||
if(baseDir == null) fail("baseDir should not be null");
|
if(baseDir == null) fail("baseDir should not be null");
|
||||||
|
|
||||||
File dst = new File(String.format("%s/%s", baseDir.getPath(), "loopHuge.db"));
|
File dst = new File(String.format("%s/%s", baseDir.getPath(), "loopHuge.db"));
|
||||||
InputStream in = testContext.getAssets().open("fixtures/loopHuge.db");
|
InputStream in = testContext.getAssets().open("fixtures/loopHuge.db");
|
||||||
DatabaseHelper.copy(in, dst);
|
FileUtils.copy(in, dst);
|
||||||
|
|
||||||
ImportDataTask task = new ImportDataTask(dst, null);
|
ImportDataTask task = new ImportDataTask(dst, null);
|
||||||
task.execute();
|
task.execute();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import android.test.suitebuilder.annotation.SmallTest;
|
|||||||
|
|
||||||
import org.isoron.uhabits.BaseTest;
|
import org.isoron.uhabits.BaseTest;
|
||||||
import org.isoron.uhabits.commands.ToggleRepetitionCommand;
|
import org.isoron.uhabits.commands.ToggleRepetitionCommand;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.unit.HabitFixtures;
|
import org.isoron.uhabits.unit.HabitFixtures;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -50,7 +50,7 @@ public class ToggleRepetitionCommandTest extends BaseTest
|
|||||||
|
|
||||||
habit = HabitFixtures.createShortHabit();
|
habit = HabitFixtures.createShortHabit();
|
||||||
|
|
||||||
today = DateHelper.getStartOfToday();
|
today = DateUtils.getStartOfToday();
|
||||||
command = new ToggleRepetitionCommand(habit, today);
|
command = new ToggleRepetitionCommand(habit, today);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import android.support.test.runner.AndroidJUnit4;
|
|||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.BaseTest;
|
import org.isoron.uhabits.BaseTest;
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
import org.isoron.uhabits.io.HabitsCSVExporter;
|
import org.isoron.uhabits.io.HabitsCSVExporter;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.unit.HabitFixtures;
|
import org.isoron.uhabits.unit.HabitFixtures;
|
||||||
@@ -79,7 +79,7 @@ public class HabitsCSVExporterTest extends BaseTest
|
|||||||
File parent = outputFile.getParentFile();
|
File parent = outputFile.getParentFile();
|
||||||
if(parent != null) parent.mkdirs();
|
if(parent != null) parent.mkdirs();
|
||||||
|
|
||||||
DatabaseHelper.copy(stream, outputFile);
|
FileUtils.copy(stream, outputFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
zip.close();
|
zip.close();
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import android.support.test.runner.AndroidJUnit4;
|
|||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.BaseTest;
|
import org.isoron.uhabits.BaseTest;
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.io.GenericImporter;
|
import org.isoron.uhabits.io.GenericImporter;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.unit.HabitFixtures;
|
import org.isoron.uhabits.unit.HabitFixtures;
|
||||||
@@ -58,18 +58,18 @@ public class ImportTest extends BaseTest
|
|||||||
public void setup()
|
public void setup()
|
||||||
{
|
{
|
||||||
super.setup();
|
super.setup();
|
||||||
DateHelper.setFixedLocalTime(null);
|
DateUtils.setFixedLocalTime(null);
|
||||||
|
|
||||||
HabitFixtures.purgeHabits();
|
HabitFixtures.purgeHabits();
|
||||||
context = InstrumentationRegistry.getInstrumentation().getContext();
|
context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||||
baseDir = DatabaseHelper.getFilesDir("Backups");
|
baseDir = FileUtils.getFilesDir("Backups");
|
||||||
if(baseDir == null) fail("baseDir should not be null");
|
if(baseDir == null) fail("baseDir should not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyAssetToFile(String assetPath, File dst) throws IOException
|
private void copyAssetToFile(String assetPath, File dst) throws IOException
|
||||||
{
|
{
|
||||||
InputStream in = context.getAssets().open(assetPath);
|
InputStream in = context.getAssets().open(assetPath);
|
||||||
DatabaseHelper.copy(in, dst);
|
FileUtils.copy(in, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void importFromFile(String assetFilename) throws IOException
|
private void importFromFile(String assetFilename) throws IOException
|
||||||
@@ -87,7 +87,7 @@ public class ImportTest extends BaseTest
|
|||||||
|
|
||||||
private boolean containsRepetition(Habit h, int year, int month, int day)
|
private boolean containsRepetition(Habit h, int year, int month, int day)
|
||||||
{
|
{
|
||||||
GregorianCalendar date = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar date = DateUtils.getStartOfTodayCalendar();
|
||||||
date.set(year, month - 1, day);
|
date.set(year, month - 1, day);
|
||||||
return h.repetitions.contains(date.getTimeInMillis());
|
return h.repetitions.contains(date.getTimeInMillis());
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ public class ImportTest extends BaseTest
|
|||||||
assertThat(habit.reminderHour, equalTo(8));
|
assertThat(habit.reminderHour, equalTo(8));
|
||||||
assertThat(habit.reminderMin, equalTo(0));
|
assertThat(habit.reminderMin, equalTo(0));
|
||||||
boolean[] reminderDays = {false, true, true, true, true, true, false};
|
boolean[] reminderDays = {false, true, true, true, true, true, false};
|
||||||
assertThat(habit.reminderDays, equalTo(DateHelper.packWeekdayList(reminderDays)));
|
assertThat(habit.reminderDays, equalTo(DateUtils.packWeekdayList(reminderDays)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import android.support.test.runner.AndroidJUnit4;
|
|||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.BaseTest;
|
import org.isoron.uhabits.BaseTest;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.unit.HabitFixtures;
|
import org.isoron.uhabits.unit.HabitFixtures;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -60,7 +60,7 @@ public class CheckmarkListTest extends BaseTest
|
|||||||
@After
|
@After
|
||||||
public void tearDown()
|
public void tearDown()
|
||||||
{
|
{
|
||||||
DateHelper.setFixedLocalTime(null);
|
DateUtils.setFixedLocalTime(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -121,8 +121,8 @@ public class CheckmarkListTest extends BaseTest
|
|||||||
@Test
|
@Test
|
||||||
public void test_getValues_withValidInterval()
|
public void test_getValues_withValidInterval()
|
||||||
{
|
{
|
||||||
long from = DateHelper.getStartOfToday() - 15 * DateHelper.millisecondsInOneDay;
|
long from = DateUtils.getStartOfToday() - 15 * DateUtils.millisecondsInOneDay;
|
||||||
long to = DateHelper.getStartOfToday() - 5 * DateHelper.millisecondsInOneDay;
|
long to = DateUtils.getStartOfToday() - 5 * DateUtils.millisecondsInOneDay;
|
||||||
|
|
||||||
int[] expectedValues = { CHECKED_EXPLICITLY, UNCHECKED, CHECKED_IMPLICITLY,
|
int[] expectedValues = { CHECKED_EXPLICITLY, UNCHECKED, CHECKED_IMPLICITLY,
|
||||||
CHECKED_EXPLICITLY, CHECKED_EXPLICITLY, UNCHECKED, UNCHECKED, UNCHECKED, UNCHECKED,
|
CHECKED_EXPLICITLY, CHECKED_EXPLICITLY, UNCHECKED, UNCHECKED, UNCHECKED, UNCHECKED,
|
||||||
@@ -169,7 +169,7 @@ public class CheckmarkListTest extends BaseTest
|
|||||||
|
|
||||||
private void travelInTime(int days)
|
private void travelInTime(int days)
|
||||||
{
|
{
|
||||||
DateHelper.setFixedLocalTime(FIXED_LOCAL_TIME +
|
DateUtils.setFixedLocalTime(FIXED_LOCAL_TIME +
|
||||||
days * DateHelper.millisecondsInOneDay);
|
days * DateUtils.millisecondsInOneDay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import android.test.suitebuilder.annotation.SmallTest;
|
|||||||
|
|
||||||
import org.hamcrest.MatcherAssert;
|
import org.hamcrest.MatcherAssert;
|
||||||
import org.isoron.uhabits.BaseTest;
|
import org.isoron.uhabits.BaseTest;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.unit.HabitFixtures;
|
import org.isoron.uhabits.unit.HabitFixtures;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -285,7 +285,7 @@ public class HabitTest extends BaseTest
|
|||||||
Habit habit = new Habit();
|
Habit habit = new Habit();
|
||||||
if(i % 2 == 0)
|
if(i % 2 == 0)
|
||||||
{
|
{
|
||||||
habit.reminderDays = DateHelper.ALL_WEEK_DAYS;
|
habit.reminderDays = DateUtils.ALL_WEEK_DAYS;
|
||||||
habit.reminderHour = 8;
|
habit.reminderHour = 8;
|
||||||
habit.reminderMin = 30;
|
habit.reminderMin = 30;
|
||||||
habitsWithReminder.add(habit);
|
habitsWithReminder.add(habit);
|
||||||
@@ -350,7 +350,7 @@ public class HabitTest extends BaseTest
|
|||||||
Habit h = new Habit();
|
Habit h = new Habit();
|
||||||
assertThat(h.hasReminder(), is(false));
|
assertThat(h.hasReminder(), is(false));
|
||||||
|
|
||||||
h.reminderDays = DateHelper.ALL_WEEK_DAYS;
|
h.reminderDays = DateUtils.ALL_WEEK_DAYS;
|
||||||
h.reminderHour = 8;
|
h.reminderHour = 8;
|
||||||
h.reminderMin = 30;
|
h.reminderMin = 30;
|
||||||
assertThat(h.hasReminder(), is(true));
|
assertThat(h.hasReminder(), is(true));
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import android.support.test.runner.AndroidJUnit4;
|
|||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.BaseTest;
|
import org.isoron.uhabits.BaseTest;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.models.Repetition;
|
import org.isoron.uhabits.models.Repetition;
|
||||||
import org.isoron.uhabits.unit.HabitFixtures;
|
import org.isoron.uhabits.unit.HabitFixtures;
|
||||||
@@ -62,31 +62,31 @@ public class RepetitionListTest extends BaseTest
|
|||||||
@After
|
@After
|
||||||
public void tearDown()
|
public void tearDown()
|
||||||
{
|
{
|
||||||
DateHelper.setFixedLocalTime(null);
|
DateUtils.setFixedLocalTime(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_contains()
|
public void test_contains()
|
||||||
{
|
{
|
||||||
long current = DateHelper.getStartOfToday();
|
long current = DateUtils.getStartOfToday();
|
||||||
|
|
||||||
for(boolean b : HabitFixtures.NON_DAILY_HABIT_CHECKS)
|
for(boolean b : HabitFixtures.NON_DAILY_HABIT_CHECKS)
|
||||||
{
|
{
|
||||||
assertThat(habit.repetitions.contains(current), equalTo(b));
|
assertThat(habit.repetitions.contains(current), equalTo(b));
|
||||||
current -= DateHelper.millisecondsInOneDay;
|
current -= DateUtils.millisecondsInOneDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
assertThat(habit.repetitions.contains(current), equalTo(false));
|
assertThat(habit.repetitions.contains(current), equalTo(false));
|
||||||
current -= DateHelper.millisecondsInOneDay;
|
current -= DateUtils.millisecondsInOneDay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_delete()
|
public void test_delete()
|
||||||
{
|
{
|
||||||
long timestamp = DateHelper.getStartOfToday();
|
long timestamp = DateUtils.getStartOfToday();
|
||||||
assertThat(habit.repetitions.contains(timestamp), equalTo(true));
|
assertThat(habit.repetitions.contains(timestamp), equalTo(true));
|
||||||
|
|
||||||
habit.repetitions.delete(timestamp);
|
habit.repetitions.delete(timestamp);
|
||||||
@@ -96,7 +96,7 @@ public class RepetitionListTest extends BaseTest
|
|||||||
@Test
|
@Test
|
||||||
public void test_toggle()
|
public void test_toggle()
|
||||||
{
|
{
|
||||||
long timestamp = DateHelper.getStartOfToday();
|
long timestamp = DateUtils.getStartOfToday();
|
||||||
assertThat(habit.repetitions.contains(timestamp), equalTo(true));
|
assertThat(habit.repetitions.contains(timestamp), equalTo(true));
|
||||||
|
|
||||||
habit.repetitions.toggle(timestamp);
|
habit.repetitions.toggle(timestamp);
|
||||||
@@ -117,11 +117,11 @@ public class RepetitionListTest extends BaseTest
|
|||||||
for(Integer row[] : weekdayCount)
|
for(Integer row[] : weekdayCount)
|
||||||
Arrays.fill(row, 0);
|
Arrays.fill(row, 0);
|
||||||
|
|
||||||
GregorianCalendar day = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar day = DateUtils.getStartOfTodayCalendar();
|
||||||
|
|
||||||
// Sets the current date to the end of November
|
// Sets the current date to the end of November
|
||||||
day.set(2015, 10, 30);
|
day.set(2015, 10, 30);
|
||||||
DateHelper.setFixedLocalTime(day.getTimeInMillis());
|
DateUtils.setFixedLocalTime(day.getTimeInMillis());
|
||||||
|
|
||||||
// Add repetitions randomly from January to December
|
// Add repetitions randomly from January to December
|
||||||
// Leaves the month of March empty, to check that it returns null
|
// Leaves the month of March empty, to check that it returns null
|
||||||
@@ -168,19 +168,19 @@ public class RepetitionListTest extends BaseTest
|
|||||||
@Test
|
@Test
|
||||||
public void test_count()
|
public void test_count()
|
||||||
{
|
{
|
||||||
long to = DateHelper.getStartOfToday();
|
long to = DateUtils.getStartOfToday();
|
||||||
long from = to - 9 * DateHelper.millisecondsInOneDay;
|
long from = to - 9 * DateUtils.millisecondsInOneDay;
|
||||||
assertThat(habit.repetitions.count(from, to), equalTo(6));
|
assertThat(habit.repetitions.count(from, to), equalTo(6));
|
||||||
|
|
||||||
to = DateHelper.getStartOfToday() - DateHelper.millisecondsInOneDay;
|
to = DateUtils.getStartOfToday() - DateUtils.millisecondsInOneDay;
|
||||||
from = to - 5 * DateHelper.millisecondsInOneDay;
|
from = to - 5 * DateUtils.millisecondsInOneDay;
|
||||||
assertThat(habit.repetitions.count(from, to), equalTo(3));
|
assertThat(habit.repetitions.count(from, to), equalTo(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_getOldest()
|
public void test_getOldest()
|
||||||
{
|
{
|
||||||
long expectedOldestTimestamp = DateHelper.getStartOfToday() - 9 * DateHelper.millisecondsInOneDay;
|
long expectedOldestTimestamp = DateUtils.getStartOfToday() - 9 * DateUtils.millisecondsInOneDay;
|
||||||
|
|
||||||
assertThat(habit.repetitions.getOldestTimestamp(), equalTo(expectedOldestTimestamp));
|
assertThat(habit.repetitions.getOldestTimestamp(), equalTo(expectedOldestTimestamp));
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import android.support.test.runner.AndroidJUnit4;
|
|||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.BaseTest;
|
import org.isoron.uhabits.BaseTest;
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.models.Score;
|
import org.isoron.uhabits.models.Score;
|
||||||
import org.isoron.uhabits.unit.HabitFixtures;
|
import org.isoron.uhabits.unit.HabitFixtures;
|
||||||
@@ -57,7 +57,7 @@ public class ScoreListTest extends BaseTest
|
|||||||
@After
|
@After
|
||||||
public void tearDown()
|
public void tearDown()
|
||||||
{
|
{
|
||||||
DateHelper.setFixedLocalTime(null);
|
DateUtils.setFixedLocalTime(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -104,11 +104,11 @@ public class ScoreListTest extends BaseTest
|
|||||||
10129735, 9629735, 9102352, 8546087, 7959357, 7340494, 6687738, 5999234, 5273023,
|
10129735, 9629735, 9102352, 8546087, 7959357, 7340494, 6687738, 5999234, 5273023,
|
||||||
4507040, 3699107, 2846927, 1948077, 1000000 };
|
4507040, 3699107, 2846927, 1948077, 1000000 };
|
||||||
|
|
||||||
long current = DateHelper.getStartOfToday();
|
long current = DateUtils.getStartOfToday();
|
||||||
for(int expectedValue : expectedValues)
|
for(int expectedValue : expectedValues)
|
||||||
{
|
{
|
||||||
assertThat(habit.scores.getValue(current), equalTo(expectedValue));
|
assertThat(habit.scores.getValue(current), equalTo(expectedValue));
|
||||||
current -= DateHelper.millisecondsInOneDay;
|
current -= DateUtils.millisecondsInOneDay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,14 +162,14 @@ public class ScoreListTest extends BaseTest
|
|||||||
|
|
||||||
private void toggleRepetitions(final int from, final int to)
|
private void toggleRepetitions(final int from, final int to)
|
||||||
{
|
{
|
||||||
DatabaseHelper.executeAsTransaction(new DatabaseHelper.Command()
|
DatabaseUtils.executeAsTransaction(new DatabaseUtils.Command()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
{
|
{
|
||||||
long today = DateHelper.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
for (int i = from; i < to; i++)
|
for (int i = from; i < to; i++)
|
||||||
habit.repetitions.toggle(today - i * DateHelper.millisecondsInOneDay);
|
habit.repetitions.toggle(today - i * DateUtils.millisecondsInOneDay);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import android.test.suitebuilder.annotation.SmallTest;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
import org.isoron.uhabits.BaseTest;
|
import org.isoron.uhabits.BaseTest;
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
import org.isoron.uhabits.tasks.ImportDataTask;
|
import org.isoron.uhabits.tasks.ImportDataTask;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -50,14 +50,14 @@ public class ImportDataTaskTest extends BaseTest
|
|||||||
{
|
{
|
||||||
super.setup();
|
super.setup();
|
||||||
|
|
||||||
baseDir = DatabaseHelper.getFilesDir("Backups");
|
baseDir = FileUtils.getFilesDir("Backups");
|
||||||
if(baseDir == null) fail("baseDir should not be null");
|
if(baseDir == null) fail("baseDir should not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyAssetToFile(String assetPath, File dst) throws IOException
|
private void copyAssetToFile(String assetPath, File dst) throws IOException
|
||||||
{
|
{
|
||||||
InputStream in = testContext.getAssets().open(assetPath);
|
InputStream in = testContext.getAssets().open(assetPath);
|
||||||
DatabaseHelper.copy(in, dst);
|
FileUtils.copy(in, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertTaskResult(final int expectedResult, String assetFilename) throws Throwable
|
private void assertTaskResult(final int expectedResult, String assetFilename) throws Throwable
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import android.support.test.runner.AndroidJUnit4;
|
|||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.unit.HabitFixtures;
|
import org.isoron.uhabits.unit.HabitFixtures;
|
||||||
import org.isoron.uhabits.views.CheckmarkWidgetView;
|
import org.isoron.uhabits.views.CheckmarkWidgetView;
|
||||||
@@ -45,7 +45,7 @@ public class CheckmarkWidgetViewTest extends ViewTest
|
|||||||
public void setup()
|
public void setup()
|
||||||
{
|
{
|
||||||
super.setup();
|
super.setup();
|
||||||
UIHelper.setFixedTheme(R.style.TransparentWidgetTheme);
|
InterfaceUtils.setFixedTheme(R.style.TransparentWidgetTheme);
|
||||||
|
|
||||||
habit = HabitFixtures.createShortHabit();
|
habit = HabitFixtures.createShortHabit();
|
||||||
view = new CheckmarkWidgetView(targetContext);
|
view = new CheckmarkWidgetView(targetContext);
|
||||||
@@ -63,7 +63,7 @@ public class CheckmarkWidgetViewTest extends ViewTest
|
|||||||
@Test
|
@Test
|
||||||
public void testRender_unchecked() throws IOException
|
public void testRender_unchecked() throws IOException
|
||||||
{
|
{
|
||||||
habit.repetitions.toggle(DateHelper.getStartOfToday());
|
habit.repetitions.toggle(DateUtils.getStartOfToday());
|
||||||
view.refreshData();
|
view.refreshData();
|
||||||
|
|
||||||
assertRenders(view, "CheckmarkView/unchecked.png");
|
assertRenders(view, "CheckmarkView/unchecked.png");
|
||||||
@@ -72,8 +72,8 @@ public class CheckmarkWidgetViewTest extends ViewTest
|
|||||||
@Test
|
@Test
|
||||||
public void testRender_implicitlyChecked() throws IOException
|
public void testRender_implicitlyChecked() throws IOException
|
||||||
{
|
{
|
||||||
long today = DateHelper.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
long day = DateHelper.millisecondsInOneDay;
|
long day = DateUtils.millisecondsInOneDay;
|
||||||
habit.repetitions.toggle(today);
|
habit.repetitions.toggle(today);
|
||||||
habit.repetitions.toggle(today - day);
|
habit.repetitions.toggle(today - day);
|
||||||
habit.repetitions.toggle(today - 2 * day);
|
habit.repetitions.toggle(today - 2 * day);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package org.isoron.uhabits.unit.views;
|
|||||||
import android.support.test.runner.AndroidJUnit4;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.unit.HabitFixtures;
|
import org.isoron.uhabits.unit.HabitFixtures;
|
||||||
import org.isoron.uhabits.views.HabitHistoryView;
|
import org.isoron.uhabits.views.HabitHistoryView;
|
||||||
@@ -92,7 +92,7 @@ public class HabitHistoryViewTest extends ViewTest
|
|||||||
tap(view, 340, 40); // today's square
|
tap(view, 340, 40); // today's square
|
||||||
waitForAsyncTasks();
|
waitForAsyncTasks();
|
||||||
|
|
||||||
long today = DateHelper.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
assertFalse(habit.repetitions.contains(today));
|
assertFalse(habit.repetitions.contains(today));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ public class HabitHistoryViewTest extends ViewTest
|
|||||||
tap(view, 340, 40); // today's square
|
tap(view, 340, 40); // today's square
|
||||||
waitForAsyncTasks();
|
waitForAsyncTasks();
|
||||||
|
|
||||||
long today = DateHelper.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
assertTrue(habit.repetitions.contains(today));
|
assertTrue(habit.repetitions.contains(today));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import android.support.test.runner.AndroidJUnit4;
|
|||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.views.NumberView;
|
import org.isoron.uhabits.views.NumberView;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -45,7 +45,7 @@ public class NumberViewTest extends ViewTest
|
|||||||
view = new NumberView(targetContext);
|
view = new NumberView(targetContext);
|
||||||
view.setLabel("Hello world");
|
view.setLabel("Hello world");
|
||||||
view.setNumber(31);
|
view.setNumber(31);
|
||||||
view.setColor(ColorHelper.CSV_PALETTE[0]);
|
view.setColor(ColorUtils.CSV_PALETTE[0]);
|
||||||
measureView(dpToPixels(100), dpToPixels(100), view);
|
measureView(dpToPixels(100), dpToPixels(100), view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public class NumberViewTest extends ViewTest
|
|||||||
public void testRender_withDifferentParams() throws IOException
|
public void testRender_withDifferentParams() throws IOException
|
||||||
{
|
{
|
||||||
view.setNumber(500);
|
view.setNumber(500);
|
||||||
view.setColor(ColorHelper.CSV_PALETTE[5]);
|
view.setColor(ColorUtils.CSV_PALETTE[5]);
|
||||||
view.setTextSize(targetContext.getResources().getDimension(R.dimen.tinyTextSize));
|
view.setTextSize(targetContext.getResources().getDimension(R.dimen.tinyTextSize));
|
||||||
|
|
||||||
measureView(dpToPixels(200), dpToPixels(200), view);
|
measureView(dpToPixels(200), dpToPixels(200), view);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import android.graphics.Color;
|
|||||||
import android.support.test.runner.AndroidJUnit4;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.views.RingView;
|
import org.isoron.uhabits.views.RingView;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -45,7 +45,7 @@ public class RingViewTest extends ViewTest
|
|||||||
view = new RingView(targetContext);
|
view = new RingView(targetContext);
|
||||||
view.setPercentage(0.6f);
|
view.setPercentage(0.6f);
|
||||||
view.setText("60%");
|
view.setText("60%");
|
||||||
view.setColor(ColorHelper.CSV_PALETTE[0]);
|
view.setColor(ColorUtils.CSV_PALETTE[0]);
|
||||||
view.setBackgroundColor(Color.WHITE);
|
view.setBackgroundColor(Color.WHITE);
|
||||||
view.setThickness(dpToPixels(3));
|
view.setThickness(dpToPixels(3));
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ public class RingViewTest extends ViewTest
|
|||||||
public void testRender_withDifferentParams() throws IOException
|
public void testRender_withDifferentParams() throws IOException
|
||||||
{
|
{
|
||||||
view.setPercentage(0.25f);
|
view.setPercentage(0.25f);
|
||||||
view.setColor(ColorHelper.CSV_PALETTE[5]);
|
view.setColor(ColorUtils.CSV_PALETTE[5]);
|
||||||
|
|
||||||
measureView(dpToPixels(200), dpToPixels(200), view);
|
measureView(dpToPixels(200), dpToPixels(200), view);
|
||||||
assertRenders(view, "RingView/renderDifferentParams.png");
|
assertRenders(view, "RingView/renderDifferentParams.png");
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import android.view.MotionEvent;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.isoron.uhabits.BaseTest;
|
import org.isoron.uhabits.BaseTest;
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.tasks.BaseTask;
|
import org.isoron.uhabits.tasks.BaseTask;
|
||||||
import org.isoron.uhabits.views.HabitDataView;
|
import org.isoron.uhabits.views.HabitDataView;
|
||||||
|
|
||||||
@@ -124,8 +124,8 @@ public class ViewTest extends BaseTest
|
|||||||
private String saveBitmap(String filename, String suffix, Bitmap bitmap)
|
private String saveBitmap(String filename, String suffix, Bitmap bitmap)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
File dir = DatabaseHelper.getSDCardDir("test-screenshots");
|
File dir = FileUtils.getSDCardDir("test-screenshots");
|
||||||
if(dir == null) dir = DatabaseHelper.getFilesDir("test-screenshots");
|
if(dir == null) dir = FileUtils.getFilesDir("test-screenshots");
|
||||||
if(dir == null) throw new RuntimeException("Could not find suitable dir for screenshots");
|
if(dir == null) throw new RuntimeException("Could not find suitable dir for screenshots");
|
||||||
|
|
||||||
filename = filename.replaceAll("\\.png$", suffix + ".png");
|
filename = filename.replaceAll("\\.png$", suffix + ".png");
|
||||||
@@ -191,7 +191,7 @@ public class ViewTest extends BaseTest
|
|||||||
|
|
||||||
protected int dpToPixels(int dp)
|
protected int dpToPixels(int dp)
|
||||||
{
|
{
|
||||||
return (int) UIHelper.dpToPixels(targetContext, dp);
|
return (int) InterfaceUtils.dpToPixels(targetContext, dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tap(GestureDetector.OnGestureListener view, int x, int y) throws InterruptedException
|
protected void tap(GestureDetector.OnGestureListener view, int x, int y) throws InterruptedException
|
||||||
|
|||||||
@@ -60,23 +60,23 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ShowHabitActivity"
|
android:name=".ui.show.ShowHabitActivity"
|
||||||
android:label="@string/title_activity_show_habit">
|
android:label="@string/title_activity_show_habit">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="org.isoron.uhabits.MainActivity"/>
|
android:value=".MainActivity"/>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".SettingsActivity"
|
android:name=".ui.settings.SettingsActivity"
|
||||||
android:label="@string/settings">
|
android:label="@string/settings">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="org.isoron.uhabits.MainActivity"/>
|
android:value=".MainActivity"/>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".IntroActivity"
|
android:name=".ui.IntroActivity"
|
||||||
android:label=""
|
android:label=""
|
||||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".AboutActivity"
|
android:name=".ui.AboutActivity"
|
||||||
android:label="@string/about">
|
android:label="@string/about">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
|||||||
@@ -36,11 +36,12 @@ import android.support.v4.app.NotificationCompat;
|
|||||||
import android.support.v4.app.TaskStackBuilder;
|
import android.support.v4.app.TaskStackBuilder;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.ReminderHelper;
|
import org.isoron.uhabits.utils.ReminderUtils;
|
||||||
import org.isoron.uhabits.models.Checkmark;
|
import org.isoron.uhabits.models.Checkmark;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.tasks.BaseTask;
|
import org.isoron.uhabits.tasks.BaseTask;
|
||||||
|
import org.isoron.uhabits.ui.show.ShowHabitActivity;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Intent.ACTION_BOOT_COMPLETED:
|
case Intent.ACTION_BOOT_COMPLETED:
|
||||||
ReminderHelper.createReminderAlarms(context);
|
ReminderUtils.createReminderAlarms(context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +87,7 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
ReminderHelper.createReminderAlarms(context);
|
ReminderUtils.createReminderAlarms(context);
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,7 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
long habitId = ContentUris.parseId(data);
|
long habitId = ContentUris.parseId(data);
|
||||||
Habit habit = Habit.get(habitId);
|
Habit habit = Habit.get(habitId);
|
||||||
if(habit != null)
|
if(habit != null)
|
||||||
ReminderHelper.createReminderAlarm(context, habit,
|
ReminderUtils.createReminderAlarm(context, habit,
|
||||||
new Date().getTime() + delayMinutes * 60 * 1000);
|
new Date().getTime() + delayMinutes * 60 * 1000);
|
||||||
dismissNotification(context, habitId);
|
dismissNotification(context, habitId);
|
||||||
}
|
}
|
||||||
@@ -108,7 +109,7 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
private void checkHabit(Context context, Intent intent)
|
private void checkHabit(Context context, Intent intent)
|
||||||
{
|
{
|
||||||
Uri data = intent.getData();
|
Uri data = intent.getData();
|
||||||
Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
|
Long timestamp = intent.getLongExtra("timestamp", DateUtils.getStartOfToday());
|
||||||
|
|
||||||
long habitId = ContentUris.parseId(data);
|
long habitId = ContentUris.parseId(data);
|
||||||
Habit habit = Habit.get(habitId);
|
Habit habit = Habit.get(habitId);
|
||||||
@@ -147,8 +148,8 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
{
|
{
|
||||||
final Uri data = intent.getData();
|
final Uri data = intent.getData();
|
||||||
final Habit habit = Habit.get(ContentUris.parseId(data));
|
final Habit habit = Habit.get(ContentUris.parseId(data));
|
||||||
final Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
|
final Long timestamp = intent.getLongExtra("timestamp", DateUtils.getStartOfToday());
|
||||||
final Long reminderTime = intent.getLongExtra("reminderTime", DateHelper.getStartOfToday());
|
final Long reminderTime = intent.getLongExtra("reminderTime", DateUtils.getStartOfToday());
|
||||||
|
|
||||||
if (habit == null) return;
|
if (habit == null) return;
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
PendingIntent checkIntentPending = buildCheckIntent(context, habit, timestamp);
|
PendingIntent checkIntentPending = buildCheckIntent(context, habit, timestamp);
|
||||||
PendingIntent snoozeIntentPending = buildSnoozeIntent(context, habit);
|
PendingIntent snoozeIntentPending = buildSnoozeIntent(context, habit);
|
||||||
|
|
||||||
Uri ringtoneUri = ReminderHelper.getRingtoneUri(context);
|
Uri ringtoneUri = ReminderUtils.getRingtoneUri(context);
|
||||||
|
|
||||||
NotificationCompat.WearableExtender wearableExtender =
|
NotificationCompat.WearableExtender wearableExtender =
|
||||||
new NotificationCompat.WearableExtender().setBackground(
|
new NotificationCompat.WearableExtender().setBackground(
|
||||||
@@ -254,10 +255,10 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
|
|
||||||
private boolean checkWeekday(Intent intent, Habit habit)
|
private boolean checkWeekday(Intent intent, Habit habit)
|
||||||
{
|
{
|
||||||
Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
|
Long timestamp = intent.getLongExtra("timestamp", DateUtils.getStartOfToday());
|
||||||
|
|
||||||
boolean reminderDays[] = DateHelper.unpackWeekdayList(habit.reminderDays);
|
boolean reminderDays[] = DateUtils.unpackWeekdayList(habit.reminderDays);
|
||||||
int weekday = DateHelper.getWeekday(timestamp);
|
int weekday = DateUtils.getWeekday(timestamp);
|
||||||
|
|
||||||
return reminderDays[weekday];
|
return reminderDays[weekday];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ import android.view.WindowManager;
|
|||||||
|
|
||||||
import com.activeandroid.ActiveAndroid;
|
import com.activeandroid.ActiveAndroid;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -71,11 +72,11 @@ public class HabitsApplication extends Application
|
|||||||
|
|
||||||
if (isTestMode())
|
if (isTestMode())
|
||||||
{
|
{
|
||||||
File db = DatabaseHelper.getDatabaseFile();
|
File db = DatabaseUtils.getDatabaseFile();
|
||||||
if(db.exists()) db.delete();
|
if(db.exists()) db.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseHelper.initializeActiveAndroid();
|
DatabaseUtils.initializeActiveAndroid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -142,10 +143,10 @@ public class HabitsApplication extends Application
|
|||||||
@NonNull
|
@NonNull
|
||||||
public static File dumpBugReportToFile() throws IOException
|
public static File dumpBugReportToFile() throws IOException
|
||||||
{
|
{
|
||||||
String date = DateHelper.getBackupDateFormat().format(DateHelper.getLocalTime());
|
String date = DateUtils.getBackupDateFormat().format(DateUtils.getLocalTime());
|
||||||
|
|
||||||
if(context == null) throw new RuntimeException("application context should not be null");
|
if(context == null) throw new RuntimeException("application context should not be null");
|
||||||
File dir = DatabaseHelper.getFilesDir("Logs");
|
File dir = FileUtils.getFilesDir("Logs");
|
||||||
if (dir == null) throw new IOException("log dir should not be null");
|
if (dir == null) throw new IOException("log dir should not be null");
|
||||||
|
|
||||||
File logFile = new File(String.format("%s/Log %s.txt", dir.getPath(), date));
|
File logFile = new File(String.format("%s/Log %s.txt", dir.getPath(), date));
|
||||||
|
|||||||
@@ -40,13 +40,18 @@ import android.support.v7.app.ActionBar;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import org.isoron.uhabits.fragments.ListHabitsFragment;
|
import org.isoron.uhabits.ui.list.ListHabitsFragment;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.ReminderHelper;
|
import org.isoron.uhabits.utils.ReminderUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Checkmark;
|
import org.isoron.uhabits.models.Checkmark;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.tasks.BaseTask;
|
import org.isoron.uhabits.tasks.BaseTask;
|
||||||
|
import org.isoron.uhabits.ui.AboutActivity;
|
||||||
|
import org.isoron.uhabits.ui.BaseActivity;
|
||||||
|
import org.isoron.uhabits.ui.IntroActivity;
|
||||||
|
import org.isoron.uhabits.ui.settings.SettingsActivity;
|
||||||
|
import org.isoron.uhabits.ui.show.ShowHabitActivity;
|
||||||
import org.isoron.uhabits.widgets.CheckmarkWidgetProvider;
|
import org.isoron.uhabits.widgets.CheckmarkWidgetProvider;
|
||||||
import org.isoron.uhabits.widgets.FrequencyWidgetProvider;
|
import org.isoron.uhabits.widgets.FrequencyWidgetProvider;
|
||||||
import org.isoron.uhabits.widgets.HistoryWidgetProvider;
|
import org.isoron.uhabits.widgets.HistoryWidgetProvider;
|
||||||
@@ -97,7 +102,7 @@ public class MainActivity extends BaseActivity
|
|||||||
{
|
{
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
if(actionBar == null) return;
|
if(actionBar == null) return;
|
||||||
if(UIHelper.isNightMode()) return;
|
if(InterfaceUtils.isNightMode()) return;
|
||||||
|
|
||||||
int color = getResources().getColor(R.color.grey_900);
|
int color = getResources().getColor(R.color.grey_900);
|
||||||
actionBar.setBackgroundDrawable(new ColorDrawable(color));
|
actionBar.setBackgroundDrawable(new ColorDrawable(color));
|
||||||
@@ -106,15 +111,15 @@ public class MainActivity extends BaseActivity
|
|||||||
private void onStartup()
|
private void onStartup()
|
||||||
{
|
{
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
||||||
UIHelper.incrementLaunchCount(this);
|
InterfaceUtils.incrementLaunchCount(this);
|
||||||
UIHelper.updateLastAppVersion(this);
|
InterfaceUtils.updateLastAppVersion(this);
|
||||||
showTutorial();
|
showTutorial();
|
||||||
|
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params)
|
protected Void doInBackground(Void... params)
|
||||||
{
|
{
|
||||||
ReminderHelper.createReminderAlarms(MainActivity.this);
|
ReminderUtils.createReminderAlarms(MainActivity.this);
|
||||||
updateWidgets(MainActivity.this);
|
updateWidgets(MainActivity.this);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -130,7 +135,7 @@ public class MainActivity extends BaseActivity
|
|||||||
{
|
{
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putBoolean("pref_first_run", false);
|
editor.putBoolean("pref_first_run", false);
|
||||||
editor.putLong("last_hint_timestamp", DateHelper.getStartOfToday()).apply();
|
editor.putLong("last_hint_timestamp", DateUtils.getStartOfToday()).apply();
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
||||||
Intent intent = new Intent(this, IntroActivity.class);
|
Intent intent = new Intent(this, IntroActivity.class);
|
||||||
@@ -145,7 +150,7 @@ public class MainActivity extends BaseActivity
|
|||||||
getMenuInflater().inflate(R.menu.list_habits_menu, menu);
|
getMenuInflater().inflate(R.menu.list_habits_menu, menu);
|
||||||
|
|
||||||
MenuItem nightModeItem = menu.findItem(R.id.action_night_mode);
|
MenuItem nightModeItem = menu.findItem(R.id.action_night_mode);
|
||||||
nightModeItem.setChecked(UIHelper.isNightMode());
|
nightModeItem.setChecked(InterfaceUtils.isNightMode());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -157,10 +162,10 @@ public class MainActivity extends BaseActivity
|
|||||||
{
|
{
|
||||||
case R.id.action_night_mode:
|
case R.id.action_night_mode:
|
||||||
{
|
{
|
||||||
if(UIHelper.isNightMode())
|
if(InterfaceUtils.isNightMode())
|
||||||
UIHelper.setCurrentTheme(UIHelper.THEME_LIGHT);
|
InterfaceUtils.setCurrentTheme(InterfaceUtils.THEME_LIGHT);
|
||||||
else
|
else
|
||||||
UIHelper.setCurrentTheme(UIHelper.THEME_DARK);
|
InterfaceUtils.setCurrentTheme(InterfaceUtils.THEME_DARK);
|
||||||
|
|
||||||
refreshTheme();
|
refreshTheme();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -19,10 +19,8 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.commands;
|
package org.isoron.uhabits.commands;
|
||||||
|
|
||||||
import com.activeandroid.ActiveAndroid;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -53,7 +51,7 @@ public class ChangeHabitColorCommand extends Command
|
|||||||
@Override
|
@Override
|
||||||
public void undo()
|
public void undo()
|
||||||
{
|
{
|
||||||
DatabaseHelper.executeAsTransaction(new DatabaseHelper.Command()
|
DatabaseUtils.executeAsTransaction(new DatabaseUtils.Command()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import android.support.annotation.NonNull;
|
|||||||
import com.activeandroid.ActiveAndroid;
|
import com.activeandroid.ActiveAndroid;
|
||||||
import com.opencsv.CSVReader;
|
import com.opencsv.CSVReader;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -76,7 +76,7 @@ public class HabitBullCSVImporter extends AbstractImporter
|
|||||||
int month = Integer.parseInt(dateString[1]);
|
int month = Integer.parseInt(dateString[1]);
|
||||||
int day = Integer.parseInt(dateString[2]);
|
int day = Integer.parseInt(dateString[2]);
|
||||||
|
|
||||||
Calendar date = DateHelper.getStartOfTodayCalendar();
|
Calendar date = DateUtils.getStartOfTodayCalendar();
|
||||||
date.set(year, month - 1, day);
|
date.set(year, month - 1, day);
|
||||||
|
|
||||||
long timestamp = date.getTimeInMillis();
|
long timestamp = date.getTimeInMillis();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.io;
|
package org.isoron.uhabits.io;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.CheckmarkList;
|
import org.isoron.uhabits.models.CheckmarkList;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.models.ScoreList;
|
import org.isoron.uhabits.models.ScoreList;
|
||||||
@@ -93,8 +93,8 @@ public class HabitsCSVExporter
|
|||||||
|
|
||||||
private String writeZipFile() throws IOException
|
private String writeZipFile() throws IOException
|
||||||
{
|
{
|
||||||
SimpleDateFormat dateFormat = DateHelper.getCSVDateFormat();
|
SimpleDateFormat dateFormat = DateUtils.getCSVDateFormat();
|
||||||
String date = dateFormat.format(DateHelper.getStartOfToday());
|
String date = dateFormat.format(DateUtils.getStartOfToday());
|
||||||
String zipFilename = String.format("%s/Loop Habits CSV %s.zip", exportDirName, date);
|
String zipFilename = String.format("%s/Loop Habits CSV %s.zip", exportDirName, date);
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream(zipFilename);
|
FileOutputStream fos = new FileOutputStream(zipFilename);
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ import android.support.annotation.NonNull;
|
|||||||
|
|
||||||
import com.activeandroid.ActiveAndroid;
|
import com.activeandroid.ActiveAndroid;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -54,8 +55,8 @@ public class LoopDBImporter extends AbstractImporter
|
|||||||
public void importHabitsFromFile(@NonNull File file) throws IOException
|
public void importHabitsFromFile(@NonNull File file) throws IOException
|
||||||
{
|
{
|
||||||
ActiveAndroid.dispose();
|
ActiveAndroid.dispose();
|
||||||
File originalDB = DatabaseHelper.getDatabaseFile();
|
File originalDB = DatabaseUtils.getDatabaseFile();
|
||||||
DatabaseHelper.copy(file, originalDB);
|
FileUtils.copy(file, originalDB);
|
||||||
DatabaseHelper.initializeActiveAndroid();
|
DatabaseUtils.initializeActiveAndroid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import android.database.Cursor;
|
|||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -57,7 +57,7 @@ public class RewireDBImporter extends AbstractImporter
|
|||||||
final SQLiteDatabase db = SQLiteDatabase.openDatabase(file.getPath(), null,
|
final SQLiteDatabase db = SQLiteDatabase.openDatabase(file.getPath(), null,
|
||||||
SQLiteDatabase.OPEN_READONLY);
|
SQLiteDatabase.OPEN_READONLY);
|
||||||
|
|
||||||
DatabaseHelper.executeAsTransaction(new DatabaseHelper.Command()
|
DatabaseUtils.executeAsTransaction(new DatabaseUtils.Command()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
@@ -150,7 +150,7 @@ public class RewireDBImporter extends AbstractImporter
|
|||||||
reminderDays[idx] = true;
|
reminderDays[idx] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
habit.reminderDays = DateHelper.packWeekdayList(reminderDays);
|
habit.reminderDays = DateUtils.packWeekdayList(reminderDays);
|
||||||
habit.reminderHour = rewireReminder / 60;
|
habit.reminderHour = rewireReminder / 60;
|
||||||
habit.reminderMin = rewireReminder % 60;
|
habit.reminderMin = rewireReminder % 60;
|
||||||
habit.save();
|
habit.save();
|
||||||
@@ -178,7 +178,7 @@ public class RewireDBImporter extends AbstractImporter
|
|||||||
int month = Integer.parseInt(date.substring(4, 6));
|
int month = Integer.parseInt(date.substring(4, 6));
|
||||||
int day = Integer.parseInt(date.substring(6, 8));
|
int day = Integer.parseInt(date.substring(6, 8));
|
||||||
|
|
||||||
GregorianCalendar cal = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar cal = DateUtils.getStartOfTodayCalendar();
|
||||||
cal.set(year, month - 1, day);
|
cal.set(year, month - 1, day);
|
||||||
|
|
||||||
habit.repetitions.toggle(cal.getTimeInMillis());
|
habit.repetitions.toggle(cal.getTimeInMillis());
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import android.database.Cursor;
|
|||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -57,7 +57,7 @@ public class TickmateDBImporter extends AbstractImporter
|
|||||||
final SQLiteDatabase db = SQLiteDatabase.openDatabase(file.getPath(), null,
|
final SQLiteDatabase db = SQLiteDatabase.openDatabase(file.getPath(), null,
|
||||||
SQLiteDatabase.OPEN_READONLY);
|
SQLiteDatabase.OPEN_READONLY);
|
||||||
|
|
||||||
DatabaseHelper.executeAsTransaction(new DatabaseHelper.Command()
|
DatabaseUtils.executeAsTransaction(new DatabaseUtils.Command()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void execute()
|
public void execute()
|
||||||
@@ -118,7 +118,7 @@ public class TickmateDBImporter extends AbstractImporter
|
|||||||
int month = c.getInt(1);
|
int month = c.getInt(1);
|
||||||
int day = c.getInt(2);
|
int day = c.getInt(2);
|
||||||
|
|
||||||
GregorianCalendar cal = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar cal = DateUtils.getStartOfTodayCalendar();
|
||||||
cal.set(year, month, day);
|
cal.set(year, month, day);
|
||||||
|
|
||||||
habit.repetitions.toggle(cal.getTimeInMillis());
|
habit.repetitions.toggle(cal.getTimeInMillis());
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import com.activeandroid.Cache;
|
|||||||
import com.activeandroid.query.Delete;
|
import com.activeandroid.query.Delete;
|
||||||
import com.activeandroid.query.Select;
|
import com.activeandroid.query.Select;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
@@ -88,7 +88,7 @@ public class CheckmarkList
|
|||||||
Long.toString(toTimestamp) };
|
Long.toString(toTimestamp) };
|
||||||
Cursor cursor = db.rawQuery(query, args);
|
Cursor cursor = db.rawQuery(query, args);
|
||||||
|
|
||||||
long day = DateHelper.millisecondsInOneDay;
|
long day = DateUtils.millisecondsInOneDay;
|
||||||
int nDays = (int) ((toTimestamp - fromTimestamp) / day) + 1;
|
int nDays = (int) ((toTimestamp - fromTimestamp) / day) + 1;
|
||||||
int[] checks = new int[nDays];
|
int[] checks = new int[nDays];
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ public class CheckmarkList
|
|||||||
if(oldestRep == null) return new int[0];
|
if(oldestRep == null) return new int[0];
|
||||||
|
|
||||||
Long fromTimestamp = oldestRep.timestamp;
|
Long fromTimestamp = oldestRep.timestamp;
|
||||||
Long toTimestamp = DateHelper.getStartOfToday();
|
Long toTimestamp = DateUtils.getStartOfToday();
|
||||||
|
|
||||||
return getValues(fromTimestamp, toTimestamp);
|
return getValues(fromTimestamp, toTimestamp);
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ public class CheckmarkList
|
|||||||
long fromTimestamp = habit.repetitions.getOldestTimestamp();
|
long fromTimestamp = habit.repetitions.getOldestTimestamp();
|
||||||
if(fromTimestamp == 0) return;
|
if(fromTimestamp == 0) return;
|
||||||
|
|
||||||
Long toTimestamp = DateHelper.getStartOfToday();
|
Long toTimestamp = DateUtils.getStartOfToday();
|
||||||
|
|
||||||
compute(fromTimestamp, toTimestamp);
|
compute(fromTimestamp, toTimestamp);
|
||||||
}
|
}
|
||||||
@@ -152,9 +152,9 @@ public class CheckmarkList
|
|||||||
*/
|
*/
|
||||||
protected void compute(long from, final long to)
|
protected void compute(long from, final long to)
|
||||||
{
|
{
|
||||||
UIHelper.throwIfMainThread();
|
InterfaceUtils.throwIfMainThread();
|
||||||
|
|
||||||
final long day = DateHelper.millisecondsInOneDay;
|
final long day = DateUtils.millisecondsInOneDay;
|
||||||
|
|
||||||
Checkmark newestCheckmark = findNewest();
|
Checkmark newestCheckmark = findNewest();
|
||||||
if(newestCheckmark != null)
|
if(newestCheckmark != null)
|
||||||
@@ -235,7 +235,7 @@ public class CheckmarkList
|
|||||||
{
|
{
|
||||||
return new Select().from(Checkmark.class)
|
return new Select().from(Checkmark.class)
|
||||||
.where("habit = ?", habit.getId())
|
.where("habit = ?", habit.getId())
|
||||||
.and("timestamp <= ?", DateHelper.getStartOfToday())
|
.and("timestamp <= ?", DateUtils.getStartOfToday())
|
||||||
.orderBy("timestamp desc")
|
.orderBy("timestamp desc")
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.executeSingle();
|
.executeSingle();
|
||||||
@@ -249,7 +249,7 @@ public class CheckmarkList
|
|||||||
@Nullable
|
@Nullable
|
||||||
public Checkmark getToday()
|
public Checkmark getToday()
|
||||||
{
|
{
|
||||||
long today = DateHelper.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
compute(today, today);
|
compute(today, today);
|
||||||
return findNewest();
|
return findNewest();
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ public class CheckmarkList
|
|||||||
{
|
{
|
||||||
computeAll();
|
computeAll();
|
||||||
|
|
||||||
SimpleDateFormat dateFormat = DateHelper.getCSVDateFormat();
|
SimpleDateFormat dateFormat = DateUtils.getCSVDateFormat();
|
||||||
|
|
||||||
String query = "select timestamp, value from checkmarks where habit = ? order by timestamp";
|
String query = "select timestamp, value from checkmarks where habit = ? order by timestamp";
|
||||||
String params[] = { habit.getId().toString() };
|
String params[] = { habit.getId().toString() };
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import com.activeandroid.query.Update;
|
|||||||
import com.activeandroid.util.SQLiteUtils;
|
import com.activeandroid.util.SQLiteUtils;
|
||||||
import com.opencsv.CSVWriter;
|
import com.opencsv.CSVWriter;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
@@ -154,7 +154,7 @@ public class Habit extends Model
|
|||||||
*/
|
*/
|
||||||
public Habit(Habit model)
|
public Habit(Habit model)
|
||||||
{
|
{
|
||||||
reminderDays = DateHelper.ALL_WEEK_DAYS;
|
reminderDays = DateUtils.ALL_WEEK_DAYS;
|
||||||
|
|
||||||
copyAttributes(model);
|
copyAttributes(model);
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ public class Habit extends Model
|
|||||||
this.archived = 0;
|
this.archived = 0;
|
||||||
this.freqDen = 7;
|
this.freqDen = 7;
|
||||||
this.freqNum = 3;
|
this.freqNum = 3;
|
||||||
this.reminderDays = DateHelper.ALL_WEEK_DAYS;
|
this.reminderDays = DateUtils.ALL_WEEK_DAYS;
|
||||||
|
|
||||||
checkmarks = new CheckmarkList(this);
|
checkmarks = new CheckmarkList(this);
|
||||||
streaks = new StreakList(this);
|
streaks = new StreakList(this);
|
||||||
@@ -475,7 +475,7 @@ public class Habit extends Model
|
|||||||
{
|
{
|
||||||
reminderHour = null;
|
reminderHour = null;
|
||||||
reminderMin = null;
|
reminderMin = null;
|
||||||
reminderDays = DateHelper.ALL_WEEK_DAYS;
|
reminderDays = DateUtils.ALL_WEEK_DAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -502,7 +502,7 @@ public class Habit extends Model
|
|||||||
habit.description,
|
habit.description,
|
||||||
Integer.toString(habit.freqNum),
|
Integer.toString(habit.freqNum),
|
||||||
Integer.toString(habit.freqDen),
|
Integer.toString(habit.freqDen),
|
||||||
ColorHelper.toHTML(ColorHelper.CSV_PALETTE[habit.color])
|
ColorUtils.toHTML(ColorUtils.CSV_PALETTE[habit.color])
|
||||||
};
|
};
|
||||||
|
|
||||||
csv.writeNext(cols, false);
|
csv.writeNext(cols, false);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ import com.activeandroid.query.From;
|
|||||||
import com.activeandroid.query.Select;
|
import com.activeandroid.query.Select;
|
||||||
import com.activeandroid.util.SQLiteUtils;
|
import com.activeandroid.util.SQLiteUtils;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
@@ -52,7 +52,7 @@ public class RepetitionList
|
|||||||
{
|
{
|
||||||
return new Select().from(Repetition.class)
|
return new Select().from(Repetition.class)
|
||||||
.where("habit = ?", habit.getId())
|
.where("habit = ?", habit.getId())
|
||||||
.and("timestamp <= ?", DateHelper.getStartOfToday())
|
.and("timestamp <= ?", DateUtils.getStartOfToday())
|
||||||
.orderBy("timestamp");
|
.orderBy("timestamp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ public class RepetitionList
|
|||||||
*/
|
*/
|
||||||
public void toggle(long timestamp)
|
public void toggle(long timestamp)
|
||||||
{
|
{
|
||||||
timestamp = DateHelper.getStartOfDay(timestamp);
|
timestamp = DateUtils.getStartOfDay(timestamp);
|
||||||
|
|
||||||
if (contains(timestamp))
|
if (contains(timestamp))
|
||||||
delete(timestamp);
|
delete(timestamp);
|
||||||
@@ -133,11 +133,11 @@ public class RepetitionList
|
|||||||
*/
|
*/
|
||||||
public long getOldestTimestamp()
|
public long getOldestTimestamp()
|
||||||
{
|
{
|
||||||
String[] args = { habit.getId().toString(), Long.toString(DateHelper.getStartOfToday()) };
|
String[] args = { habit.getId().toString(), Long.toString(DateUtils.getStartOfToday()) };
|
||||||
String query = "select timestamp from Repetitions where habit = ? and timestamp <= ? " +
|
String query = "select timestamp from Repetitions where habit = ? and timestamp <= ? " +
|
||||||
"order by timestamp limit 1";
|
"order by timestamp limit 1";
|
||||||
|
|
||||||
return DatabaseHelper.longQuery(query, args);
|
return DatabaseUtils.longQuery(query, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +164,7 @@ public class RepetitionList
|
|||||||
"group by year, month, weekday";
|
"group by year, month, weekday";
|
||||||
|
|
||||||
String[] params = { habit.getId().toString(),
|
String[] params = { habit.getId().toString(),
|
||||||
Long.toString(DateHelper.getStartOfToday()) };
|
Long.toString(DateUtils.getStartOfToday()) };
|
||||||
|
|
||||||
SQLiteDatabase db = Cache.openDatabase();
|
SQLiteDatabase db = Cache.openDatabase();
|
||||||
Cursor cursor = db.rawQuery(query, params);
|
Cursor cursor = db.rawQuery(query, params);
|
||||||
@@ -172,7 +172,7 @@ public class RepetitionList
|
|||||||
if(!cursor.moveToFirst()) return new HashMap<>();
|
if(!cursor.moveToFirst()) return new HashMap<>();
|
||||||
|
|
||||||
HashMap <Long, Integer[]> map = new HashMap<>();
|
HashMap <Long, Integer[]> map = new HashMap<>();
|
||||||
GregorianCalendar date = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar date = DateUtils.getStartOfTodayCalendar();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ import com.activeandroid.query.From;
|
|||||||
import com.activeandroid.query.Select;
|
import com.activeandroid.query.Select;
|
||||||
import com.activeandroid.util.SQLiteUtils;
|
import com.activeandroid.util.SQLiteUtils;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
@@ -85,7 +85,7 @@ public class ScoreList
|
|||||||
long fromTimestamp = habit.repetitions.getOldestTimestamp();
|
long fromTimestamp = habit.repetitions.getOldestTimestamp();
|
||||||
if(fromTimestamp == 0) return;
|
if(fromTimestamp == 0) return;
|
||||||
|
|
||||||
long toTimestamp = DateHelper.getStartOfToday();
|
long toTimestamp = DateUtils.getStartOfToday();
|
||||||
compute(fromTimestamp, toTimestamp);
|
compute(fromTimestamp, toTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,9 +103,9 @@ public class ScoreList
|
|||||||
*/
|
*/
|
||||||
protected void compute(long from, long to)
|
protected void compute(long from, long to)
|
||||||
{
|
{
|
||||||
UIHelper.throwIfMainThread();
|
InterfaceUtils.throwIfMainThread();
|
||||||
|
|
||||||
final long day = DateHelper.millisecondsInOneDay;
|
final long day = DateUtils.millisecondsInOneDay;
|
||||||
final double freq = ((double) habit.freqNum) / habit.freqDen;
|
final double freq = ((double) habit.freqNum) / habit.freqDen;
|
||||||
|
|
||||||
int newestScoreValue = findNewestValue();
|
int newestScoreValue = findNewestValue();
|
||||||
@@ -151,7 +151,7 @@ public class ScoreList
|
|||||||
{
|
{
|
||||||
String args[] = { habit.getId().toString() };
|
String args[] = { habit.getId().toString() };
|
||||||
String query = "select timestamp from Score where habit = ? order by timestamp desc limit 1";
|
String query = "select timestamp from Score where habit = ? order by timestamp desc limit 1";
|
||||||
return DatabaseHelper.longQuery(query, args);
|
return DatabaseUtils.longQuery(query, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insert(long timestamps[], long values[])
|
private void insert(long timestamps[], long values[])
|
||||||
@@ -238,7 +238,7 @@ public class ScoreList
|
|||||||
if(oldestRep == null) return new int[0];
|
if(oldestRep == null) return new int[0];
|
||||||
|
|
||||||
long fromTimestamp = oldestRep.timestamp;
|
long fromTimestamp = oldestRep.timestamp;
|
||||||
long toTimestamp = DateHelper.getStartOfToday();
|
long toTimestamp = DateUtils.getStartOfToday();
|
||||||
return getValues(fromTimestamp, toTimestamp, divisor);
|
return getValues(fromTimestamp, toTimestamp, divisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ public class ScoreList
|
|||||||
{
|
{
|
||||||
compute(from, to);
|
compute(from, to);
|
||||||
|
|
||||||
divisor *= DateHelper.millisecondsInOneDay;
|
divisor *= DateUtils.millisecondsInOneDay;
|
||||||
Long offset = to + divisor;
|
Long offset = to + divisor;
|
||||||
|
|
||||||
String query = "select ((timestamp - ?) / ?) as time, avg(score) from Score " +
|
String query = "select ((timestamp - ?) / ?) as time, avg(score) from Score " +
|
||||||
@@ -291,7 +291,7 @@ public class ScoreList
|
|||||||
@Nullable
|
@Nullable
|
||||||
protected Score getToday()
|
protected Score getToday()
|
||||||
{
|
{
|
||||||
return get(DateHelper.getStartOfToday());
|
return get(DateUtils.getStartOfToday());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -301,7 +301,7 @@ public class ScoreList
|
|||||||
*/
|
*/
|
||||||
public int getTodayValue()
|
public int getTodayValue()
|
||||||
{
|
{
|
||||||
return getValue(DateHelper.getStartOfToday());
|
return getValue(DateUtils.getStartOfToday());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -321,7 +321,7 @@ public class ScoreList
|
|||||||
{
|
{
|
||||||
computeAll();
|
computeAll();
|
||||||
|
|
||||||
SimpleDateFormat dateFormat = DateHelper.getCSVDateFormat();
|
SimpleDateFormat dateFormat = DateUtils.getCSVDateFormat();
|
||||||
|
|
||||||
String query = "select timestamp, score from score where habit = ? order by timestamp";
|
String query = "select timestamp, score from score where habit = ? order by timestamp";
|
||||||
String params[] = { habit.getId().toString() };
|
String params[] = { habit.getId().toString() };
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import com.activeandroid.Cache;
|
|||||||
import com.activeandroid.query.Delete;
|
import com.activeandroid.query.Delete;
|
||||||
import com.activeandroid.query.Select;
|
import com.activeandroid.query.Select;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -50,7 +50,7 @@ public class StreakList
|
|||||||
String query = "select * from (select * from streak where habit=? " +
|
String query = "select * from (select * from streak where habit=? " +
|
||||||
"order by end <> ?, length desc, end desc limit ?) order by end desc";
|
"order by end <> ?, length desc, end desc limit ?) order by end desc";
|
||||||
|
|
||||||
String params[] = {habit.getId().toString(), Long.toString(DateHelper.getStartOfToday()),
|
String params[] = {habit.getId().toString(), Long.toString(DateUtils.getStartOfToday()),
|
||||||
Integer.toString(limit)};
|
Integer.toString(limit)};
|
||||||
|
|
||||||
SQLiteDatabase db = Cache.openDatabase();
|
SQLiteDatabase db = Cache.openDatabase();
|
||||||
@@ -87,11 +87,11 @@ public class StreakList
|
|||||||
|
|
||||||
public void rebuild()
|
public void rebuild()
|
||||||
{
|
{
|
||||||
UIHelper.throwIfMainThread();
|
InterfaceUtils.throwIfMainThread();
|
||||||
|
|
||||||
long beginning;
|
long beginning;
|
||||||
long today = DateHelper.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
long day = DateHelper.millisecondsInOneDay;
|
long day = DateUtils.millisecondsInOneDay;
|
||||||
|
|
||||||
Streak newestStreak = getNewest();
|
Streak newestStreak = getNewest();
|
||||||
if (newestStreak != null)
|
if (newestStreak != null)
|
||||||
@@ -154,7 +154,7 @@ public class StreakList
|
|||||||
{
|
{
|
||||||
new Delete().from(Streak.class)
|
new Delete().from(Streak.class)
|
||||||
.where("habit = ?", habit.getId())
|
.where("habit = ?", habit.getId())
|
||||||
.and("end >= ?", timestamp - DateHelper.millisecondsInOneDay)
|
.and("end >= ?", timestamp - DateUtils.millisecondsInOneDay)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import android.support.annotation.Nullable;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
import org.isoron.uhabits.io.HabitsCSVExporter;
|
import org.isoron.uhabits.io.HabitsCSVExporter;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ public class ExportCSVTask extends BaseTask
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File dir = DatabaseHelper.getFilesDir("CSV");
|
File dir = FileUtils.getFilesDir("CSV");
|
||||||
if(dir == null) return;
|
if(dir == null) return;
|
||||||
|
|
||||||
HabitsCSVExporter exporter = new HabitsCSVExporter(selectedHabits, dir);
|
HabitsCSVExporter exporter = new HabitsCSVExporter(selectedHabits, dir);
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ import android.support.annotation.Nullable;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.DatabaseUtils;
|
||||||
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -80,10 +81,10 @@ public class ExportDBTask extends BaseTask
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File dir = DatabaseHelper.getFilesDir("Backups");
|
File dir = FileUtils.getFilesDir("Backups");
|
||||||
if(dir == null) return;
|
if(dir == null) return;
|
||||||
|
|
||||||
filename = DatabaseHelper.saveDatabaseCopy(dir);
|
filename = DatabaseUtils.saveDatabaseCopy(dir);
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits;
|
package org.isoron.uhabits.ui;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -25,7 +25,9 @@ import android.os.Bundle;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.BuildConfig;
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
public class AboutActivity extends BaseActivity implements View.OnClickListener
|
public class AboutActivity extends BaseActivity implements View.OnClickListener
|
||||||
{
|
{
|
||||||
@@ -38,7 +40,7 @@ public class AboutActivity extends BaseActivity implements View.OnClickListener
|
|||||||
setContentView(R.layout.about);
|
setContentView(R.layout.about);
|
||||||
setupSupportActionBar(true);
|
setupSupportActionBar(true);
|
||||||
|
|
||||||
int color = UIHelper.getStyledColor(this, R.attr.aboutScreenColor);
|
int color = InterfaceUtils.getStyledColor(this, R.attr.aboutScreenColor);
|
||||||
setupActionBarColor(color);
|
setupActionBarColor(color);
|
||||||
|
|
||||||
TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
|
TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits;
|
package org.isoron.uhabits.ui;
|
||||||
|
|
||||||
import android.app.backup.BackupManager;
|
import android.app.backup.BackupManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@@ -31,9 +31,11 @@ import android.support.v7.widget.Toolbar;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.isoron.uhabits.HabitsApplication;
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.commands.Command;
|
import org.isoron.uhabits.commands.Command;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
|
|||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
UIHelper.applyCurrentTheme(this);
|
InterfaceUtils.applyCurrentTheme(this);
|
||||||
|
|
||||||
androidExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
androidExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
Thread.setDefaultUncaughtExceptionHandler(this);
|
Thread.setDefaultUncaughtExceptionHandler(this);
|
||||||
@@ -133,7 +135,7 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
|
|||||||
if(toolbar == null) return;
|
if(toolbar == null) return;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
toolbar.setElevation(UIHelper.dpToPixels(this, 2));
|
toolbar.setElevation(InterfaceUtils.dpToPixels(this, 2));
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
@@ -172,14 +174,14 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
|
|||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
if(actionBar == null) return;
|
if(actionBar == null) return;
|
||||||
|
|
||||||
if (!UIHelper.getStyledBoolean(this, R.attr.useHabitColorAsPrimary)) return;
|
if (!InterfaceUtils.getStyledBoolean(this, R.attr.useHabitColorAsPrimary)) return;
|
||||||
|
|
||||||
ColorDrawable drawable = new ColorDrawable(color);
|
ColorDrawable drawable = new ColorDrawable(color);
|
||||||
actionBar.setBackgroundDrawable(drawable);
|
actionBar.setBackgroundDrawable(drawable);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
{
|
{
|
||||||
int darkerColor = ColorHelper.mixColors(color, Color.BLACK, 0.75f);
|
int darkerColor = ColorUtils.mixColors(color, Color.BLACK, 0.75f);
|
||||||
getWindow().setStatusBarColor(darkerColor);
|
getWindow().setStatusBarColor(darkerColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.helpers;
|
package org.isoron.uhabits.ui;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
@@ -28,6 +28,7 @@ import android.view.View;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
|
|
||||||
public class HintManager
|
public class HintManager
|
||||||
{
|
{
|
||||||
@@ -59,7 +60,7 @@ public class HintManager
|
|||||||
Integer lastHintNumber = prefs.getInt("last_hint_number", -1);
|
Integer lastHintNumber = prefs.getInt("last_hint_number", -1);
|
||||||
Long lastHintTimestamp = prefs.getLong("last_hint_timestamp", -1);
|
Long lastHintTimestamp = prefs.getLong("last_hint_timestamp", -1);
|
||||||
|
|
||||||
if (DateHelper.getStartOfToday() > lastHintTimestamp) showHint(lastHintNumber + 1);
|
if (DateUtils.getStartOfToday() > lastHintTimestamp) showHint(lastHintNumber + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showHint(int hintNumber)
|
private void showHint(int hintNumber)
|
||||||
@@ -68,7 +69,7 @@ public class HintManager
|
|||||||
if (hintNumber >= hints.length) return;
|
if (hintNumber >= hints.length) return;
|
||||||
|
|
||||||
prefs.edit().putInt("last_hint_number", hintNumber).apply();
|
prefs.edit().putInt("last_hint_number", hintNumber).apply();
|
||||||
prefs.edit().putLong("last_hint_timestamp", DateHelper.getStartOfToday()).apply();
|
prefs.edit().putLong("last_hint_timestamp", DateUtils.getStartOfToday()).apply();
|
||||||
|
|
||||||
TextView tvContent = (TextView) hintView.findViewById(R.id.hintContent);
|
TextView tvContent = (TextView) hintView.findViewById(R.id.hintContent);
|
||||||
tvContent.setText(hints[hintNumber]);
|
tvContent.setText(hints[hintNumber]);
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits;
|
package org.isoron.uhabits.ui;
|
||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -25,6 +25,8 @@ import android.os.Bundle;
|
|||||||
import com.github.paolorotolo.appintro.AppIntro2;
|
import com.github.paolorotolo.appintro.AppIntro2;
|
||||||
import com.github.paolorotolo.appintro.AppIntroFragment;
|
import com.github.paolorotolo.appintro.AppIntroFragment;
|
||||||
|
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
|
||||||
public class IntroActivity extends AppIntro2
|
public class IntroActivity extends AppIntro2
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.dialogs;
|
package org.isoron.uhabits.ui.edit;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@@ -44,10 +44,10 @@ import org.isoron.uhabits.R;
|
|||||||
import org.isoron.uhabits.commands.Command;
|
import org.isoron.uhabits.commands.Command;
|
||||||
import org.isoron.uhabits.commands.CreateHabitCommand;
|
import org.isoron.uhabits.commands.CreateHabitCommand;
|
||||||
import org.isoron.uhabits.commands.EditHabitCommand;
|
import org.isoron.uhabits.commands.EditHabitCommand;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
|
||||||
import org.isoron.uhabits.helpers.UIHelper.OnSavedListener;
|
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public class EditHabitDialogFragment extends AppCompatDialogFragment
|
|||||||
static final int EDIT_MODE = 0;
|
static final int EDIT_MODE = 0;
|
||||||
static final int CREATE_MODE = 1;
|
static final int CREATE_MODE = 1;
|
||||||
|
|
||||||
private OnSavedListener onSavedListener;
|
private InterfaceUtils.OnSavedListener onSavedListener;
|
||||||
|
|
||||||
private Habit originalHabit;
|
private Habit originalHabit;
|
||||||
private Habit modifiedHabit;
|
private Habit modifiedHabit;
|
||||||
@@ -176,7 +176,7 @@ public class EditHabitDialogFragment extends AppCompatDialogFragment
|
|||||||
private void changeColor(int paletteColor)
|
private void changeColor(int paletteColor)
|
||||||
{
|
{
|
||||||
modifiedHabit.color = paletteColor;
|
modifiedHabit.color = paletteColor;
|
||||||
tvName.setTextColor(ColorHelper.getColor(getActivity(), paletteColor));
|
tvName.setTextColor(ColorUtils.getColor(getActivity(), paletteColor));
|
||||||
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putInt("pref_default_habit_palette_color", paletteColor);
|
editor.putInt("pref_default_habit_palette_color", paletteColor);
|
||||||
@@ -188,12 +188,12 @@ public class EditHabitDialogFragment extends AppCompatDialogFragment
|
|||||||
{
|
{
|
||||||
if (modifiedHabit.hasReminder())
|
if (modifiedHabit.hasReminder())
|
||||||
{
|
{
|
||||||
tvReminderTime.setText(DateHelper.formatTime(getActivity(), modifiedHabit.reminderHour,
|
tvReminderTime.setText(DateUtils.formatTime(getActivity(), modifiedHabit.reminderHour,
|
||||||
modifiedHabit.reminderMin));
|
modifiedHabit.reminderMin));
|
||||||
llReminderDays.setVisibility(View.VISIBLE);
|
llReminderDays.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
boolean weekdays[] = DateHelper.unpackWeekdayList(modifiedHabit.reminderDays);
|
boolean weekdays[] = DateUtils.unpackWeekdayList(modifiedHabit.reminderDays);
|
||||||
tvReminderDays.setText(DateHelper.formatWeekdayList(getActivity(), weekdays));
|
tvReminderDays.setText(DateUtils.formatWeekdayList(getActivity(), weekdays));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -202,7 +202,7 @@ public class EditHabitDialogFragment extends AppCompatDialogFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnSavedListener(OnSavedListener onSavedListener)
|
public void setOnSavedListener(InterfaceUtils.OnSavedListener onSavedListener)
|
||||||
{
|
{
|
||||||
this.onSavedListener = onSavedListener;
|
this.onSavedListener = onSavedListener;
|
||||||
}
|
}
|
||||||
@@ -236,17 +236,17 @@ public class EditHabitDialogFragment extends AppCompatDialogFragment
|
|||||||
|
|
||||||
private void onColorButtonClick()
|
private void onColorButtonClick()
|
||||||
{
|
{
|
||||||
int originalAndroidColor = ColorHelper.getColor(getActivity(), modifiedHabit.color);
|
int originalAndroidColor = ColorUtils.getColor(getActivity(), modifiedHabit.color);
|
||||||
|
|
||||||
ColorPickerDialog picker = ColorPickerDialog.newInstance(
|
ColorPickerDialog picker = ColorPickerDialog.newInstance(
|
||||||
R.string.color_picker_default_title, ColorHelper.getPalette(getActivity()),
|
R.string.color_picker_default_title, ColorUtils.getPalette(getActivity()),
|
||||||
originalAndroidColor, 4, ColorPickerDialog.SIZE_SMALL);
|
originalAndroidColor, 4, ColorPickerDialog.SIZE_SMALL);
|
||||||
|
|
||||||
picker.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener()
|
picker.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener()
|
||||||
{
|
{
|
||||||
public void onColorSelected(int androidColor)
|
public void onColorSelected(int androidColor)
|
||||||
{
|
{
|
||||||
int paletteColor = ColorHelper.colorToPaletteIndex(getActivity(), androidColor);
|
int paletteColor = ColorUtils.colorToPaletteIndex(getActivity(), androidColor);
|
||||||
changeColor(paletteColor);
|
changeColor(paletteColor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -331,7 +331,7 @@ public class EditHabitDialogFragment extends AppCompatDialogFragment
|
|||||||
|
|
||||||
WeekdayPickerDialog dialog = new WeekdayPickerDialog();
|
WeekdayPickerDialog dialog = new WeekdayPickerDialog();
|
||||||
dialog.setListener(this);
|
dialog.setListener(this);
|
||||||
dialog.setSelectedDays(DateHelper.unpackWeekdayList(modifiedHabit.reminderDays));
|
dialog.setSelectedDays(DateUtils.unpackWeekdayList(modifiedHabit.reminderDays));
|
||||||
dialog.show(getFragmentManager(), "weekdayPicker");
|
dialog.show(getFragmentManager(), "weekdayPicker");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ public class EditHabitDialogFragment extends AppCompatDialogFragment
|
|||||||
{
|
{
|
||||||
modifiedHabit.reminderHour = hour;
|
modifiedHabit.reminderHour = hour;
|
||||||
modifiedHabit.reminderMin = minute;
|
modifiedHabit.reminderMin = minute;
|
||||||
modifiedHabit.reminderDays = DateHelper.ALL_WEEK_DAYS;
|
modifiedHabit.reminderDays = DateUtils.ALL_WEEK_DAYS;
|
||||||
updateReminder();
|
updateReminder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +360,7 @@ public class EditHabitDialogFragment extends AppCompatDialogFragment
|
|||||||
|
|
||||||
if(count == 0) Arrays.fill(selectedDays, true);
|
if(count == 0) Arrays.fill(selectedDays, true);
|
||||||
|
|
||||||
modifiedHabit.reminderDays = DateHelper.packWeekdayList(selectedDays);
|
modifiedHabit.reminderDays = DateUtils.packWeekdayList(selectedDays);
|
||||||
updateReminder();
|
updateReminder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.dialogs;
|
package org.isoron.uhabits.ui.edit;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.dialogs;
|
package org.isoron.uhabits.ui.edit;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@@ -26,7 +26,7 @@ import android.support.v7.app.AlertDialog;
|
|||||||
import android.support.v7.app.AppCompatDialogFragment;
|
import android.support.v7.app.AppCompatDialogFragment;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
|
|
||||||
public class WeekdayPickerDialog extends AppCompatDialogFragment
|
public class WeekdayPickerDialog extends AppCompatDialogFragment
|
||||||
implements DialogInterface.OnMultiChoiceClickListener, DialogInterface.OnClickListener
|
implements DialogInterface.OnMultiChoiceClickListener, DialogInterface.OnClickListener
|
||||||
@@ -55,7 +55,7 @@ public class WeekdayPickerDialog extends AppCompatDialogFragment
|
|||||||
{
|
{
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setTitle(R.string.select_weekdays)
|
builder.setTitle(R.string.select_weekdays)
|
||||||
.setMultiChoiceItems(DateHelper.getLongDayNames(), selectedDays, this)
|
.setMultiChoiceItems(DateUtils.getLongDayNames(), selectedDays, this)
|
||||||
.setPositiveButton(android.R.string.yes, this)
|
.setPositiveButton(android.R.string.yes, this)
|
||||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener()
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener()
|
||||||
{
|
{
|
||||||
@@ -17,48 +17,45 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.fragments;
|
package org.isoron.uhabits.ui.list;
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.view.ActionMode;
|
import android.support.v7.view.ActionMode;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
|
|
||||||
import com.android.colorpicker.ColorPickerDialog;
|
import com.android.colorpicker.ColorPickerDialog;
|
||||||
import com.android.colorpicker.ColorPickerSwatch;
|
import com.android.colorpicker.ColorPickerSwatch;
|
||||||
|
|
||||||
import org.isoron.uhabits.BaseActivity;
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.commands.ArchiveHabitsCommand;
|
import org.isoron.uhabits.commands.ArchiveHabitsCommand;
|
||||||
import org.isoron.uhabits.commands.ChangeHabitColorCommand;
|
import org.isoron.uhabits.commands.ChangeHabitColorCommand;
|
||||||
import org.isoron.uhabits.commands.DeleteHabitsCommand;
|
import org.isoron.uhabits.commands.DeleteHabitsCommand;
|
||||||
import org.isoron.uhabits.commands.UnarchiveHabitsCommand;
|
import org.isoron.uhabits.commands.UnarchiveHabitsCommand;
|
||||||
import org.isoron.uhabits.dialogs.EditHabitDialogFragment;
|
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
|
||||||
import org.isoron.uhabits.loaders.HabitListLoader;
|
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
import org.isoron.uhabits.ui.BaseActivity;
|
||||||
|
import org.isoron.uhabits.ui.edit.EditHabitDialogFragment;
|
||||||
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HabitSelectionCallback implements ActionMode.Callback
|
public class HabitSelectionCallback implements ActionMode.Callback
|
||||||
{
|
{
|
||||||
private HabitListLoader loader;
|
private ListHabitsLoader loader;
|
||||||
private List<Integer> selectedPositions;
|
private List<Integer> selectedPositions;
|
||||||
private BaseActivity activity;
|
private BaseActivity activity;
|
||||||
private Listener listener;
|
private Listener listener;
|
||||||
private UIHelper.OnSavedListener onSavedListener;
|
private InterfaceUtils.OnSavedListener onSavedListener;
|
||||||
private ProgressBar progressBar;
|
|
||||||
|
|
||||||
public interface Listener
|
public interface Listener
|
||||||
{
|
{
|
||||||
void onActionModeDestroyed(ActionMode mode);
|
void onActionModeDestroyed(ActionMode mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HabitSelectionCallback(BaseActivity activity, HabitListLoader loader)
|
public HabitSelectionCallback(BaseActivity activity, ListHabitsLoader loader)
|
||||||
{
|
{
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
@@ -70,12 +67,7 @@ public class HabitSelectionCallback implements ActionMode.Callback
|
|||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgressBar(ProgressBar progressBar)
|
public void setOnSavedListener(InterfaceUtils.OnSavedListener onSavedListener)
|
||||||
{
|
|
||||||
this.progressBar = progressBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnSavedListener(UIHelper.OnSavedListener onSavedListener)
|
|
||||||
{
|
{
|
||||||
this.onSavedListener = onSavedListener;
|
this.onSavedListener = onSavedListener;
|
||||||
}
|
}
|
||||||
@@ -110,10 +102,7 @@ public class HabitSelectionCallback implements ActionMode.Callback
|
|||||||
for (int i : selectedPositions)
|
for (int i : selectedPositions)
|
||||||
{
|
{
|
||||||
Habit h = loader.habitsList.get(i);
|
Habit h = loader.habitsList.get(i);
|
||||||
if (h.isArchived())
|
if (h.isArchived()) showArchive = false;
|
||||||
{
|
|
||||||
showArchive = false;
|
|
||||||
}
|
|
||||||
else showUnarchive = false;
|
else showUnarchive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,17 +154,17 @@ public class HabitSelectionCallback implements ActionMode.Callback
|
|||||||
|
|
||||||
case R.id.action_color:
|
case R.id.action_color:
|
||||||
{
|
{
|
||||||
int originalAndroidColor = ColorHelper.getColor(activity, firstHabit.color);
|
int originalAndroidColor = ColorUtils.getColor(activity, firstHabit.color);
|
||||||
|
|
||||||
ColorPickerDialog picker = ColorPickerDialog.newInstance(
|
ColorPickerDialog picker = ColorPickerDialog.newInstance(
|
||||||
R.string.color_picker_default_title, ColorHelper.getPalette(activity),
|
R.string.color_picker_default_title, ColorUtils.getPalette(activity),
|
||||||
originalAndroidColor, 4, ColorPickerDialog.SIZE_SMALL);
|
originalAndroidColor, 4, ColorPickerDialog.SIZE_SMALL);
|
||||||
|
|
||||||
picker.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener()
|
picker.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener()
|
||||||
{
|
{
|
||||||
public void onColorSelected(int androidColor)
|
public void onColorSelected(int androidColor)
|
||||||
{
|
{
|
||||||
int paletteColor = ColorHelper.colorToPaletteIndex(activity,
|
int paletteColor = ColorUtils.colorToPaletteIndex(activity,
|
||||||
androidColor);
|
androidColor);
|
||||||
activity.executeCommand(new ChangeHabitColorCommand(selectedHabits,
|
activity.executeCommand(new ChangeHabitColorCommand(selectedHabits,
|
||||||
paletteColor), null);
|
paletteColor), null);
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.fragments;
|
package org.isoron.uhabits.ui.list;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -26,23 +26,21 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.ListHabitsHelper;
|
|
||||||
import org.isoron.uhabits.loaders.HabitListLoader;
|
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class HabitListAdapter extends BaseAdapter
|
class ListHabitsAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private LayoutInflater inflater;
|
private LayoutInflater inflater;
|
||||||
private HabitListLoader loader;
|
private ListHabitsLoader loader;
|
||||||
private ListHabitsHelper helper;
|
private ListHabitsHelper helper;
|
||||||
private List selectedPositions;
|
private List selectedPositions;
|
||||||
private View.OnLongClickListener onCheckmarkLongClickListener;
|
private View.OnLongClickListener onCheckmarkLongClickListener;
|
||||||
private View.OnClickListener onCheckmarkClickListener;
|
private View.OnClickListener onCheckmarkClickListener;
|
||||||
|
|
||||||
public HabitListAdapter(Context context, HabitListLoader loader)
|
public ListHabitsAdapter(Context context, ListHabitsLoader loader)
|
||||||
{
|
{
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
|
|
||||||
@@ -74,7 +72,7 @@ class HabitListAdapter extends BaseAdapter
|
|||||||
final Habit habit = loader.habitsList.get(position);
|
final Habit habit = loader.habitsList.get(position);
|
||||||
boolean selected = selectedPositions.contains(position);
|
boolean selected = selectedPositions.contains(position);
|
||||||
|
|
||||||
if (view == null || (Long) view.getTag(R.id.timestamp_key) != DateHelper.getStartOfToday())
|
if (view == null || (Long) view.getTag(R.id.timestamp_key) != DateUtils.getStartOfToday())
|
||||||
{
|
{
|
||||||
view = helper.inflateHabitCard(inflater, onCheckmarkLongClickListener,
|
view = helper.inflateHabitCard(inflater, onCheckmarkLongClickListener,
|
||||||
onCheckmarkClickListener);
|
onCheckmarkClickListener);
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.fragments;
|
package org.isoron.uhabits.ui.list;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -50,20 +50,18 @@ import com.mobeta.android.dslv.DragSortController;
|
|||||||
import com.mobeta.android.dslv.DragSortListView;
|
import com.mobeta.android.dslv.DragSortListView;
|
||||||
import com.mobeta.android.dslv.DragSortListView.DropListener;
|
import com.mobeta.android.dslv.DragSortListView.DropListener;
|
||||||
|
|
||||||
import org.isoron.uhabits.BaseActivity;
|
import org.isoron.uhabits.ui.BaseActivity;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.commands.Command;
|
import org.isoron.uhabits.commands.Command;
|
||||||
import org.isoron.uhabits.commands.ToggleRepetitionCommand;
|
import org.isoron.uhabits.commands.ToggleRepetitionCommand;
|
||||||
import org.isoron.uhabits.dialogs.EditHabitDialogFragment;
|
import org.isoron.uhabits.ui.edit.EditHabitDialogFragment;
|
||||||
import org.isoron.uhabits.dialogs.FilePickerDialog;
|
import org.isoron.uhabits.ui.settings.FilePickerDialog;
|
||||||
import org.isoron.uhabits.helpers.DatabaseHelper;
|
import org.isoron.uhabits.utils.FileUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.HintManager;
|
import org.isoron.uhabits.ui.HintManager;
|
||||||
import org.isoron.uhabits.helpers.ListHabitsHelper;
|
import org.isoron.uhabits.utils.ReminderUtils;
|
||||||
import org.isoron.uhabits.helpers.ReminderHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils.OnSavedListener;
|
||||||
import org.isoron.uhabits.helpers.UIHelper.OnSavedListener;
|
|
||||||
import org.isoron.uhabits.loaders.HabitListLoader;
|
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.tasks.ExportCSVTask;
|
import org.isoron.uhabits.tasks.ExportCSVTask;
|
||||||
import org.isoron.uhabits.tasks.ExportDBTask;
|
import org.isoron.uhabits.tasks.ExportDBTask;
|
||||||
@@ -76,7 +74,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ListHabitsFragment extends Fragment
|
public class ListHabitsFragment extends Fragment
|
||||||
implements OnSavedListener, OnItemClickListener, OnLongClickListener, DropListener,
|
implements OnSavedListener, OnItemClickListener, OnLongClickListener, DropListener,
|
||||||
OnClickListener, HabitListLoader.Listener, AdapterView.OnItemLongClickListener,
|
OnClickListener, ListHabitsLoader.Listener, AdapterView.OnItemLongClickListener,
|
||||||
HabitSelectionCallback.Listener, ImportDataTask.Listener, ExportCSVTask.Listener,
|
HabitSelectionCallback.Listener, ImportDataTask.Listener, ExportCSVTask.Listener,
|
||||||
ExportDBTask.Listener
|
ExportDBTask.Listener
|
||||||
{
|
{
|
||||||
@@ -85,8 +83,8 @@ public class ListHabitsFragment extends Fragment
|
|||||||
private boolean showArchived;
|
private boolean showArchived;
|
||||||
|
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
private HabitListAdapter adapter;
|
private ListHabitsAdapter adapter;
|
||||||
private HabitListLoader loader;
|
private ListHabitsLoader loader;
|
||||||
private HintManager hintManager;
|
private HintManager hintManager;
|
||||||
private ListHabitsHelper helper;
|
private ListHabitsHelper helper;
|
||||||
private List<Integer> selectedPositions;
|
private List<Integer> selectedPositions;
|
||||||
@@ -114,7 +112,7 @@ public class ListHabitsFragment extends Fragment
|
|||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
selectedPositions = new LinkedList<>();
|
selectedPositions = new LinkedList<>();
|
||||||
loader = new HabitListLoader();
|
loader = new ListHabitsLoader();
|
||||||
helper = new ListHabitsHelper(activity, loader);
|
helper = new ListHabitsHelper(activity, loader);
|
||||||
hintManager = new HintManager(activity, llHint);
|
hintManager = new HintManager(activity, llHint);
|
||||||
|
|
||||||
@@ -122,9 +120,9 @@ public class ListHabitsFragment extends Fragment
|
|||||||
loader.setCheckmarkCount(helper.getButtonCount());
|
loader.setCheckmarkCount(helper.getButtonCount());
|
||||||
|
|
||||||
llHint.setOnClickListener(this);
|
llHint.setOnClickListener(this);
|
||||||
tvStarEmpty.setTypeface(UIHelper.getFontAwesome(activity));
|
tvStarEmpty.setTypeface(InterfaceUtils.getFontAwesome(activity));
|
||||||
|
|
||||||
adapter = new HabitListAdapter(getActivity(), loader);
|
adapter = new ListHabitsAdapter(getActivity(), loader);
|
||||||
adapter.setSelectedPositions(selectedPositions);
|
adapter.setSelectedPositions(selectedPositions);
|
||||||
adapter.setOnCheckmarkClickListener(this);
|
adapter.setOnCheckmarkClickListener(this);
|
||||||
adapter.setOnCheckmarkLongClickListener(this);
|
adapter.setOnCheckmarkLongClickListener(this);
|
||||||
@@ -171,7 +169,7 @@ public class ListHabitsFragment extends Fragment
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
Long timestamp = loader.getLastLoadTimestamp();
|
Long timestamp = loader.getLastLoadTimestamp();
|
||||||
|
|
||||||
if (timestamp != null && timestamp != DateHelper.getStartOfToday())
|
if (timestamp != null && timestamp != DateUtils.getStartOfToday())
|
||||||
loader.updateAllHabits(true);
|
loader.updateAllHabits(true);
|
||||||
|
|
||||||
helper.updateEmptyMessage(llEmpty);
|
helper.updateEmptyMessage(llEmpty);
|
||||||
@@ -282,7 +280,6 @@ public class ListHabitsFragment extends Fragment
|
|||||||
{
|
{
|
||||||
HabitSelectionCallback callback = new HabitSelectionCallback(activity, loader);
|
HabitSelectionCallback callback = new HabitSelectionCallback(activity, loader);
|
||||||
callback.setSelectedPositions(selectedPositions);
|
callback.setSelectedPositions(selectedPositions);
|
||||||
callback.setProgressBar(progressBar);
|
|
||||||
callback.setOnSavedListener(this);
|
callback.setOnSavedListener(this);
|
||||||
callback.setListener(this);
|
callback.setListener(this);
|
||||||
|
|
||||||
@@ -301,7 +298,7 @@ public class ListHabitsFragment extends Fragment
|
|||||||
else activity.executeCommand(command, h.getId());
|
else activity.executeCommand(command, h.getId());
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
ReminderHelper.createReminderAlarms(activity);
|
ReminderUtils.createReminderAlarms(activity);
|
||||||
|
|
||||||
if(actionMode != null) actionMode.finish();
|
if(actionMode != null) actionMode.finish();
|
||||||
}
|
}
|
||||||
@@ -433,7 +430,7 @@ public class ListHabitsFragment extends Fragment
|
|||||||
|
|
||||||
public void showImportDialog()
|
public void showImportDialog()
|
||||||
{
|
{
|
||||||
File dir = DatabaseHelper.getFilesDir(null);
|
File dir = FileUtils.getFilesDir(null);
|
||||||
if(dir == null)
|
if(dir == null)
|
||||||
{
|
{
|
||||||
activity.showToast(R.string.could_not_import);
|
activity.showToast(R.string.could_not_import);
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.helpers;
|
package org.isoron.uhabits.ui.list;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@@ -32,7 +32,9 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.loaders.HabitListLoader;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.models.Score;
|
import org.isoron.uhabits.models.Score;
|
||||||
import org.isoron.uhabits.views.RingView;
|
import org.isoron.uhabits.views.RingView;
|
||||||
@@ -48,20 +50,20 @@ public class ListHabitsHelper
|
|||||||
private final int mediumContrastColor;
|
private final int mediumContrastColor;
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final HabitListLoader loader;
|
private final ListHabitsLoader loader;
|
||||||
|
|
||||||
public ListHabitsHelper(Context context, HabitListLoader loader)
|
public ListHabitsHelper(Context context, ListHabitsLoader loader)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
|
|
||||||
lowContrastColor = UIHelper.getStyledColor(context, R.attr.lowContrastTextColor);
|
lowContrastColor = InterfaceUtils.getStyledColor(context, R.attr.lowContrastTextColor);
|
||||||
mediumContrastColor = UIHelper.getStyledColor(context, R.attr.mediumContrastTextColor);
|
mediumContrastColor = InterfaceUtils.getStyledColor(context, R.attr.mediumContrastTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getButtonCount()
|
public int getButtonCount()
|
||||||
{
|
{
|
||||||
float screenWidth = UIHelper.getScreenWidth(context);
|
float screenWidth = InterfaceUtils.getScreenWidth(context);
|
||||||
float labelWidth = context.getResources().getDimension(R.dimen.habitNameWidth);
|
float labelWidth = context.getResources().getDimension(R.dimen.habitNameWidth);
|
||||||
float buttonWidth = context.getResources().getDimension(R.dimen.checkmarkWidth);
|
float buttonWidth = context.getResources().getDimension(R.dimen.checkmarkWidth);
|
||||||
return Math.max(0, (int) ((screenWidth - labelWidth) / buttonWidth));
|
return Math.max(0, (int) ((screenWidth - labelWidth) / buttonWidth));
|
||||||
@@ -69,9 +71,9 @@ public class ListHabitsHelper
|
|||||||
|
|
||||||
public int getHabitNameWidth()
|
public int getHabitNameWidth()
|
||||||
{
|
{
|
||||||
float screenWidth = UIHelper.getScreenWidth(context);
|
float screenWidth = InterfaceUtils.getScreenWidth(context);
|
||||||
float buttonWidth = context.getResources().getDimension(R.dimen.checkmarkWidth);
|
float buttonWidth = context.getResources().getDimension(R.dimen.checkmarkWidth);
|
||||||
float padding = UIHelper.dpToPixels(context, 15);
|
float padding = InterfaceUtils.dpToPixels(context, 15);
|
||||||
return (int) (screenWidth - padding - getButtonCount() * buttonWidth);
|
return (int) (screenWidth - padding - getButtonCount() * buttonWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +102,7 @@ public class ListHabitsHelper
|
|||||||
|
|
||||||
public int getActiveColor(Habit habit)
|
public int getActiveColor(Habit habit)
|
||||||
{
|
{
|
||||||
int activeColor = ColorHelper.getColor(context, habit.color);
|
int activeColor = ColorUtils.getColor(context, habit.color);
|
||||||
if(habit.isArchived()) activeColor = mediumContrastColor;
|
if(habit.isArchived()) activeColor = mediumContrastColor;
|
||||||
|
|
||||||
return activeColor;
|
return activeColor;
|
||||||
@@ -193,9 +195,9 @@ public class ListHabitsHelper
|
|||||||
Drawable background;
|
Drawable background;
|
||||||
|
|
||||||
if (isSelected)
|
if (isSelected)
|
||||||
background = UIHelper.getStyledDrawable(context, R.attr.selectedBackground);
|
background = InterfaceUtils.getStyledDrawable(context, R.attr.selectedBackground);
|
||||||
else
|
else
|
||||||
background = UIHelper.getStyledDrawable(context, R.attr.cardBackground);
|
background = InterfaceUtils.getStyledDrawable(context, R.attr.cardBackground);
|
||||||
|
|
||||||
view.setBackgroundDrawable(background);
|
view.setBackgroundDrawable(background);
|
||||||
}
|
}
|
||||||
@@ -208,20 +210,20 @@ public class ListHabitsHelper
|
|||||||
{
|
{
|
||||||
View check = inflater.inflate(R.layout.list_habits_item_check, null);
|
View check = inflater.inflate(R.layout.list_habits_item_check, null);
|
||||||
TextView btCheck = (TextView) check.findViewById(R.id.tvCheck);
|
TextView btCheck = (TextView) check.findViewById(R.id.tvCheck);
|
||||||
btCheck.setTypeface(UIHelper.getFontAwesome(context));
|
btCheck.setTypeface(InterfaceUtils.getFontAwesome(context));
|
||||||
btCheck.setOnLongClickListener(onLongClickListener);
|
btCheck.setOnLongClickListener(onLongClickListener);
|
||||||
btCheck.setOnClickListener(onClickListener);
|
btCheck.setOnClickListener(onClickListener);
|
||||||
btCheck.setHapticFeedbackEnabled(false);
|
btCheck.setHapticFeedbackEnabled(false);
|
||||||
((LinearLayout) view.findViewById(R.id.llButtons)).addView(check);
|
((LinearLayout) view.findViewById(R.id.llButtons)).addView(check);
|
||||||
}
|
}
|
||||||
|
|
||||||
view.setTag(R.id.timestamp_key, DateHelper.getStartOfToday());
|
view.setTag(R.id.timestamp_key, DateUtils.getStartOfToday());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHeader(ViewGroup header)
|
public void updateHeader(ViewGroup header)
|
||||||
{
|
{
|
||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
GregorianCalendar day = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar day = DateUtils.getStartOfTodayCalendar();
|
||||||
header.removeAllViews();
|
header.removeAllViews();
|
||||||
|
|
||||||
for (int i = 0; i < getButtonCount(); i++)
|
for (int i = 0; i < getButtonCount(); i++)
|
||||||
@@ -233,7 +235,7 @@ public class ListHabitsHelper
|
|||||||
|
|
||||||
View tvDay = inflater.inflate(R.layout.list_habits_header_check, null);
|
View tvDay = inflater.inflate(R.layout.list_habits_header_check, null);
|
||||||
TextView btCheck = (TextView) tvDay.findViewById(R.id.tvCheck);
|
TextView btCheck = (TextView) tvDay.findViewById(R.id.tvCheck);
|
||||||
btCheck.setText(DateHelper.formatHeaderDate(day));
|
btCheck.setText(DateUtils.formatHeaderDate(day));
|
||||||
header.addView(tvDay, position);
|
header.addView(tvDay, position);
|
||||||
day.add(GregorianCalendar.DAY_OF_MONTH, -1);
|
day.add(GregorianCalendar.DAY_OF_MONTH, -1);
|
||||||
}
|
}
|
||||||
@@ -247,7 +249,7 @@ public class ListHabitsHelper
|
|||||||
|
|
||||||
public void toggleCheckmarkView(View v, Habit habit)
|
public void toggleCheckmarkView(View v, Habit habit)
|
||||||
{
|
{
|
||||||
int androidColor = ColorHelper.getColor(context, habit.color);
|
int androidColor = ColorUtils.getColor(context, habit.color);
|
||||||
|
|
||||||
if (v.getTag(R.string.toggle_key).equals(2))
|
if (v.getTag(R.string.toggle_key).equals(2))
|
||||||
updateCheckmark(androidColor, (TextView) v, 0);
|
updateCheckmark(androidColor, (TextView) v, 0);
|
||||||
@@ -263,8 +265,8 @@ public class ListHabitsHelper
|
|||||||
public long getTimestampFromCheckmarkView(View v)
|
public long getTimestampFromCheckmarkView(View v)
|
||||||
{
|
{
|
||||||
Integer offset = (Integer) v.getTag(R.string.offset_key);
|
Integer offset = (Integer) v.getTag(R.string.offset_key);
|
||||||
return DateHelper.getStartOfDay(DateHelper.getLocalTime() -
|
return DateUtils.getStartOfDay(DateUtils.getLocalTime() -
|
||||||
offset * DateHelper.millisecondsInOneDay);
|
offset * DateUtils.millisecondsInOneDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void triggerRipple(View v, final float x, final float y)
|
public void triggerRipple(View v, final float x, final float y)
|
||||||
@@ -17,16 +17,16 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.loaders;
|
package org.isoron.uhabits.ui.list;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.tasks.BaseTask;
|
import org.isoron.uhabits.tasks.BaseTask;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HabitListLoader
|
public class ListHabitsLoader
|
||||||
{
|
{
|
||||||
public interface Listener
|
public interface Listener
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ public class HabitListLoader
|
|||||||
return lastLoadTimestamp;
|
return lastLoadTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HabitListLoader()
|
public ListHabitsLoader()
|
||||||
{
|
{
|
||||||
habits = new HashMap<>();
|
habits = new HashMap<>();
|
||||||
checkmarks = new HashMap<>();
|
checkmarks = new HashMap<>();
|
||||||
@@ -103,8 +103,8 @@ public class HabitListLoader
|
|||||||
newScores = new HashMap<>();
|
newScores = new HashMap<>();
|
||||||
newHabitList = Habit.getAll(includeArchived);
|
newHabitList = Habit.getAll(includeArchived);
|
||||||
|
|
||||||
long dateTo = DateHelper.getStartOfDay(DateHelper.getLocalTime());
|
long dateTo = DateUtils.getStartOfDay(DateUtils.getLocalTime());
|
||||||
long dateFrom = dateTo - (checkmarkCount - 1) * DateHelper.millisecondsInOneDay;
|
long dateFrom = dateTo - (checkmarkCount - 1) * DateUtils.millisecondsInOneDay;
|
||||||
int[] empty = new int[checkmarkCount];
|
int[] empty = new int[checkmarkCount];
|
||||||
|
|
||||||
for(Habit h : newHabitList)
|
for(Habit h : newHabitList)
|
||||||
@@ -160,7 +160,7 @@ public class HabitListLoader
|
|||||||
{
|
{
|
||||||
if (isCancelled()) return;
|
if (isCancelled()) return;
|
||||||
|
|
||||||
lastLoadTimestamp = DateHelper.getStartOfToday();
|
lastLoadTimestamp = DateUtils.getStartOfToday();
|
||||||
currentFetchTask = null;
|
currentFetchTask = null;
|
||||||
|
|
||||||
if(listener != null) listener.onLoadFinished();
|
if(listener != null) listener.onLoadFinished();
|
||||||
@@ -180,8 +180,8 @@ public class HabitListLoader
|
|||||||
@Override
|
@Override
|
||||||
protected void doInBackground()
|
protected void doInBackground()
|
||||||
{
|
{
|
||||||
long dateTo = DateHelper.getStartOfDay(DateHelper.getLocalTime());
|
long dateTo = DateUtils.getStartOfDay(DateUtils.getLocalTime());
|
||||||
long dateFrom = dateTo - (checkmarkCount - 1) * DateHelper.millisecondsInOneDay;
|
long dateFrom = dateTo - (checkmarkCount - 1) * DateUtils.millisecondsInOneDay;
|
||||||
|
|
||||||
Habit h = Habit.get(id);
|
Habit h = Habit.get(id);
|
||||||
if(h == null) return;
|
if(h == null) return;
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.dialogs;
|
package org.isoron.uhabits.ui.settings;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@@ -17,11 +17,13 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits;
|
package org.isoron.uhabits.ui.settings;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
import org.isoron.uhabits.ui.BaseActivity;
|
||||||
|
|
||||||
public class SettingsActivity extends BaseActivity
|
public class SettingsActivity extends BaseActivity
|
||||||
{
|
{
|
||||||
@@ -32,7 +34,7 @@ public class SettingsActivity extends BaseActivity
|
|||||||
setContentView(R.layout.settings_activity);
|
setContentView(R.layout.settings_activity);
|
||||||
setupSupportActionBar(true);
|
setupSupportActionBar(true);
|
||||||
|
|
||||||
int color = UIHelper.getStyledColor(this, R.attr.aboutScreenColor);
|
int color = InterfaceUtils.getStyledColor(this, R.attr.aboutScreenColor);
|
||||||
setupActionBarColor(color);
|
setupActionBarColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.fragments;
|
package org.isoron.uhabits.ui.settings;
|
||||||
|
|
||||||
import android.app.backup.BackupManager;
|
import android.app.backup.BackupManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -29,8 +29,8 @@ import android.support.v7.preference.PreferenceFragmentCompat;
|
|||||||
|
|
||||||
import org.isoron.uhabits.MainActivity;
|
import org.isoron.uhabits.MainActivity;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ReminderHelper;
|
import org.isoron.uhabits.utils.ReminderUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
public class SettingsFragment extends PreferenceFragmentCompat
|
public class SettingsFragment extends PreferenceFragmentCompat
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener
|
implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
@@ -50,7 +50,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
|
|
||||||
updateRingtoneDescription();
|
updateRingtoneDescription();
|
||||||
|
|
||||||
if(UIHelper.isLocaleFullyTranslated())
|
if(InterfaceUtils.isLocaleFullyTranslated())
|
||||||
removePreference("translate", "linksCategory");
|
removePreference("translate", "linksCategory");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
|
|
||||||
if (preference.getKey().equals("reminderSound"))
|
if (preference.getKey().equals("reminderSound"))
|
||||||
{
|
{
|
||||||
ReminderHelper.startRingtonePickerActivity(this, RINGTONE_REQUEST_CODE);
|
ReminderUtils.startRingtonePickerActivity(this, RINGTONE_REQUEST_CODE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
{
|
{
|
||||||
if(requestCode == RINGTONE_REQUEST_CODE)
|
if(requestCode == RINGTONE_REQUEST_CODE)
|
||||||
{
|
{
|
||||||
ReminderHelper.parseRingtoneData(getContext(), data);
|
ReminderUtils.parseRingtoneData(getContext(), data);
|
||||||
updateRingtoneDescription();
|
updateRingtoneDescription();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
|
|
||||||
private void updateRingtoneDescription()
|
private void updateRingtoneDescription()
|
||||||
{
|
{
|
||||||
String ringtoneName = ReminderHelper.getRingtoneName(getContext());
|
String ringtoneName = ReminderUtils.getRingtoneName(getContext());
|
||||||
Preference ringtonePreference = findPreference("reminderSound");
|
Preference ringtonePreference = findPreference("reminderSound");
|
||||||
ringtonePreference.setSummary(ringtoneName);
|
ringtonePreference.setSummary(ringtoneName);
|
||||||
}
|
}
|
||||||
@@ -17,15 +17,17 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits;
|
package org.isoron.uhabits.ui.show;
|
||||||
|
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
|
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
import org.isoron.uhabits.ui.BaseActivity;
|
||||||
|
|
||||||
public class ShowHabitActivity extends BaseActivity
|
public class ShowHabitActivity extends BaseActivity
|
||||||
{
|
{
|
||||||
@@ -54,7 +56,7 @@ public class ShowHabitActivity extends BaseActivity
|
|||||||
|
|
||||||
actionBar.setTitle(habit.name);
|
actionBar.setTitle(habit.name);
|
||||||
|
|
||||||
setupActionBarColor(ColorHelper.getColor(this, habit.color));
|
setupActionBarColor(ColorUtils.getColor(this, habit.color));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Habit getHabit()
|
public Habit getHabit()
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.fragments;
|
package org.isoron.uhabits.ui.show;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
@@ -35,14 +35,13 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.isoron.uhabits.HabitBroadcastReceiver;
|
import org.isoron.uhabits.HabitBroadcastReceiver;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.ShowHabitActivity;
|
|
||||||
import org.isoron.uhabits.commands.Command;
|
import org.isoron.uhabits.commands.Command;
|
||||||
import org.isoron.uhabits.dialogs.EditHabitDialogFragment;
|
import org.isoron.uhabits.ui.edit.EditHabitDialogFragment;
|
||||||
import org.isoron.uhabits.dialogs.HistoryEditorDialog;
|
import org.isoron.uhabits.ui.edit.HistoryEditorDialog;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.ReminderHelper;
|
import org.isoron.uhabits.utils.ReminderUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.models.Score;
|
import org.isoron.uhabits.models.Score;
|
||||||
import org.isoron.uhabits.tasks.BaseTask;
|
import org.isoron.uhabits.tasks.BaseTask;
|
||||||
@@ -57,7 +56,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ShowHabitFragment extends Fragment
|
public class ShowHabitFragment extends Fragment
|
||||||
implements UIHelper.OnSavedListener, HistoryEditorDialog.Listener,
|
implements InterfaceUtils.OnSavedListener, HistoryEditorDialog.Listener,
|
||||||
Spinner.OnItemSelectedListener
|
Spinner.OnItemSelectedListener
|
||||||
{
|
{
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -95,8 +94,8 @@ public class ShowHabitFragment extends Fragment
|
|||||||
activity = (ShowHabitActivity) getActivity();
|
activity = (ShowHabitActivity) getActivity();
|
||||||
|
|
||||||
habit = activity.getHabit();
|
habit = activity.getHabit();
|
||||||
activeColor = ColorHelper.getColor(getContext(), habit.color);
|
activeColor = ColorUtils.getColor(getContext(), habit.color);
|
||||||
inactiveColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
inactiveColor = InterfaceUtils.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
||||||
|
|
||||||
updateHeader(view);
|
updateHeader(view);
|
||||||
|
|
||||||
@@ -107,7 +106,7 @@ public class ShowHabitFragment extends Fragment
|
|||||||
|
|
||||||
scoreView = (HabitScoreView) view.findViewById(R.id.scoreView);
|
scoreView = (HabitScoreView) view.findViewById(R.id.scoreView);
|
||||||
|
|
||||||
int defaultScoreInterval = UIHelper.getDefaultScoreInterval(getContext());
|
int defaultScoreInterval = InterfaceUtils.getDefaultScoreInterval(getContext());
|
||||||
previousScoreInterval = defaultScoreInterval;
|
previousScoreInterval = defaultScoreInterval;
|
||||||
setScoreBucketSize(defaultScoreInterval);
|
setScoreBucketSize(defaultScoreInterval);
|
||||||
|
|
||||||
@@ -162,7 +161,7 @@ public class ShowHabitFragment extends Fragment
|
|||||||
|
|
||||||
TextView reminderLabel = (TextView) view.findViewById(R.id.reminderLabel);
|
TextView reminderLabel = (TextView) view.findViewById(R.id.reminderLabel);
|
||||||
if(habit.hasReminder())
|
if(habit.hasReminder())
|
||||||
reminderLabel.setText(DateHelper.formatTime(getActivity(), habit.reminderHour,
|
reminderLabel.setText(DateUtils.formatTime(getActivity(), habit.reminderHour,
|
||||||
habit.reminderMin));
|
habit.reminderMin));
|
||||||
else
|
else
|
||||||
reminderLabel.setText(getResources().getString(R.string.reminder_off));
|
reminderLabel.setText(getResources().getString(R.string.reminder_off));
|
||||||
@@ -219,7 +218,7 @@ public class ShowHabitFragment extends Fragment
|
|||||||
float yearDiff = todayPercentage - (lastYearScore / Score.MAX_VALUE);
|
float yearDiff = todayPercentage - (lastYearScore / Score.MAX_VALUE);
|
||||||
|
|
||||||
RingView scoreRing = (RingView) view.findViewById(R.id.scoreRing);
|
RingView scoreRing = (RingView) view.findViewById(R.id.scoreRing);
|
||||||
int androidColor = ColorHelper.getColor(getActivity(), habit.color);
|
int androidColor = ColorUtils.getColor(getActivity(), habit.color);
|
||||||
scoreRing.setColor(androidColor);
|
scoreRing.setColor(androidColor);
|
||||||
scoreRing.setPercentage(todayPercentage);
|
scoreRing.setPercentage(todayPercentage);
|
||||||
|
|
||||||
@@ -254,7 +253,7 @@ public class ShowHabitFragment extends Fragment
|
|||||||
if(habit == null || activity == null) return;
|
if(habit == null || activity == null) return;
|
||||||
|
|
||||||
TextView textView = (TextView) view.findViewById(viewId);
|
TextView textView = (TextView) view.findViewById(viewId);
|
||||||
int androidColor = ColorHelper.getColor(activity, habit.color);
|
int androidColor = ColorUtils.getColor(activity, habit.color);
|
||||||
textView.setTextColor(androidColor);
|
textView.setTextColor(androidColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +292,7 @@ public class ShowHabitFragment extends Fragment
|
|||||||
if (h == null) activity.executeCommand(command, null);
|
if (h == null) activity.executeCommand(command, null);
|
||||||
else activity.executeCommand(command, h.getId());
|
else activity.executeCommand(command, h.getId());
|
||||||
|
|
||||||
ReminderHelper.createReminderAlarms(activity);
|
ReminderUtils.createReminderAlarms(activity);
|
||||||
HabitBroadcastReceiver.sendRefreshBroadcast(getActivity());
|
HabitBroadcastReceiver.sendRefreshBroadcast(getActivity());
|
||||||
|
|
||||||
activity.recreate();
|
activity.recreate();
|
||||||
@@ -316,9 +315,9 @@ public class ShowHabitFragment extends Fragment
|
|||||||
if(habit == null) return;
|
if(habit == null) return;
|
||||||
if(dataViews == null) return;
|
if(dataViews == null) return;
|
||||||
|
|
||||||
long today = DateHelper.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
long lastMonth = today - 30 * DateHelper.millisecondsInOneDay;
|
long lastMonth = today - 30 * DateUtils.millisecondsInOneDay;
|
||||||
long lastYear = today - 365 * DateHelper.millisecondsInOneDay;
|
long lastYear = today - 365 * DateUtils.millisecondsInOneDay;
|
||||||
|
|
||||||
todayScore = (float) habit.scores.getTodayValue();
|
todayScore = (float) habit.scores.getTodayValue();
|
||||||
lastMonthScore = (float) habit.scores.getValue(lastMonth);
|
lastMonthScore = (float) habit.scores.getValue(lastMonth);
|
||||||
@@ -362,7 +361,7 @@ public class ShowHabitFragment extends Fragment
|
|||||||
HabitBroadcastReceiver.sendRefreshBroadcast(getActivity());
|
HabitBroadcastReceiver.sendRefreshBroadcast(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
UIHelper.setDefaultScoreInterval(getContext(), position);
|
InterfaceUtils.setDefaultScoreInterval(getContext(), position);
|
||||||
previousScoreInterval = position;
|
previousScoreInterval = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.helpers;
|
package org.isoron.uhabits.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@@ -25,7 +25,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
|
|
||||||
public class ColorHelper
|
public abstract class ColorUtils
|
||||||
{
|
{
|
||||||
public static int CSV_PALETTE[] =
|
public static int CSV_PALETTE[] =
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ public class ColorHelper
|
|||||||
|
|
||||||
public static int[] getPalette(Context context)
|
public static int[] getPalette(Context context)
|
||||||
{
|
{
|
||||||
int resourceId = UIHelper.getStyleResource(context, R.attr.palette);
|
int resourceId = InterfaceUtils.getStyleResource(context, R.attr.palette);
|
||||||
if(resourceId < 0) return CSV_PALETTE;
|
if(resourceId < 0) return CSV_PALETTE;
|
||||||
|
|
||||||
return context.getResources().getIntArray(resourceId);
|
return context.getResources().getIntArray(resourceId);
|
||||||
@@ -17,15 +17,11 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.helpers;
|
package org.isoron.uhabits.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Environment;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.activeandroid.ActiveAndroid;
|
import com.activeandroid.ActiveAndroid;
|
||||||
import com.activeandroid.Cache;
|
import com.activeandroid.Cache;
|
||||||
@@ -40,37 +36,11 @@ import org.isoron.uhabits.models.Score;
|
|||||||
import org.isoron.uhabits.models.Streak;
|
import org.isoron.uhabits.models.Streak;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
public class DatabaseHelper
|
public abstract class DatabaseUtils
|
||||||
{
|
{
|
||||||
public static void copy(File src, File dst) throws IOException
|
|
||||||
{
|
|
||||||
FileInputStream inStream = new FileInputStream(src);
|
|
||||||
FileOutputStream outStream = new FileOutputStream(dst);
|
|
||||||
copy(inStream, outStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copy(InputStream inStream, File dst) throws IOException
|
|
||||||
{
|
|
||||||
FileOutputStream outStream = new FileOutputStream(dst);
|
|
||||||
copy(inStream, outStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copy(InputStream in, OutputStream out) throws IOException
|
|
||||||
{
|
|
||||||
int numBytes;
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
|
|
||||||
while ((numBytes = in.read(buffer)) != -1)
|
|
||||||
out.write(buffer, 0, numBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Command
|
public interface Command
|
||||||
{
|
{
|
||||||
void execute();
|
void execute();
|
||||||
@@ -95,11 +65,11 @@ public class DatabaseHelper
|
|||||||
{
|
{
|
||||||
File db = getDatabaseFile();
|
File db = getDatabaseFile();
|
||||||
|
|
||||||
SimpleDateFormat dateFormat = DateHelper.getBackupDateFormat();
|
SimpleDateFormat dateFormat = DateUtils.getBackupDateFormat();
|
||||||
String date = dateFormat.format(DateHelper.getLocalTime());
|
String date = dateFormat.format(DateUtils.getLocalTime());
|
||||||
File dbCopy = new File(String.format("%s/Loop Habits Backup %s.db", dir.getAbsolutePath(), date));
|
File dbCopy = new File(String.format("%s/Loop Habits Backup %s.db", dir.getAbsolutePath(), date));
|
||||||
|
|
||||||
copy(db, dbCopy);
|
FileUtils.copy(db, dbCopy);
|
||||||
|
|
||||||
return dbCopy.getAbsolutePath();
|
return dbCopy.getAbsolutePath();
|
||||||
}
|
}
|
||||||
@@ -127,63 +97,6 @@ public class DatabaseHelper
|
|||||||
return databaseFilename;
|
return databaseFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static File getSDCardDir(@Nullable String relativePath)
|
|
||||||
{
|
|
||||||
File parents[] = new File[]{ Environment.getExternalStorageDirectory() };
|
|
||||||
return getDir(parents, relativePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static File getFilesDir(@Nullable String relativePath)
|
|
||||||
{
|
|
||||||
Context context = HabitsApplication.getContext();
|
|
||||||
if(context == null)
|
|
||||||
{
|
|
||||||
Log.e("DatabaseHelper", "getFilesDir: no application context available");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
File externalFilesDirs[] = ContextCompat.getExternalFilesDirs(context, null);
|
|
||||||
|
|
||||||
if(externalFilesDirs == null)
|
|
||||||
{
|
|
||||||
Log.e("DatabaseHelper", "getFilesDir: getExternalFilesDirs returned null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getDir(externalFilesDirs, relativePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private static File getDir(@NonNull File potentialParentDirs[], @Nullable String relativePath)
|
|
||||||
{
|
|
||||||
if(relativePath == null) relativePath = "";
|
|
||||||
|
|
||||||
File chosenDir = null;
|
|
||||||
for(File dir : potentialParentDirs)
|
|
||||||
{
|
|
||||||
if (dir == null || !dir.canWrite()) continue;
|
|
||||||
chosenDir = dir;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(chosenDir == null)
|
|
||||||
{
|
|
||||||
Log.e("DatabaseHelper", "getDir: all potential parents are null or non-writable");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
File dir = new File(String.format("%s/%s/", chosenDir.getAbsolutePath(), relativePath));
|
|
||||||
if (!dir.exists() && !dir.mkdirs())
|
|
||||||
{
|
|
||||||
Log.e("DatabaseHelper", "getDir: chosen dir does not exist and cannot be created");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void initializeActiveAndroid()
|
public static void initializeActiveAndroid()
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.helpers;
|
package org.isoron.uhabits.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
@@ -31,7 +31,7 @@ import java.util.GregorianCalendar;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class DateHelper
|
public abstract class DateUtils
|
||||||
{
|
{
|
||||||
public static long millisecondsInOneDay = 24 * 60 * 60 * 1000;
|
public static long millisecondsInOneDay = 24 * 60 * 60 * 1000;
|
||||||
public static int ALL_WEEK_DAYS = 127;
|
public static int ALL_WEEK_DAYS = 127;
|
||||||
@@ -84,7 +84,7 @@ public class DateHelper
|
|||||||
|
|
||||||
public static long getStartOfToday()
|
public static long getStartOfToday()
|
||||||
{
|
{
|
||||||
return getStartOfDay(DateHelper.getLocalTime());
|
return getStartOfDay(DateUtils.getLocalTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatTime(Context context, int hours, int minutes)
|
public static String formatTime(Context context, int hours, int minutes)
|
||||||
119
app/src/main/java/org/isoron/uhabits/utils/FileUtils.java
Normal file
119
app/src/main/java/org/isoron/uhabits/utils/FileUtils.java
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Á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.Context;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.isoron.uhabits.HabitsApplication;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
public abstract class FileUtils
|
||||||
|
{
|
||||||
|
public static void copy(File src, File dst) throws IOException
|
||||||
|
{
|
||||||
|
FileInputStream inStream = new FileInputStream(src);
|
||||||
|
FileOutputStream outStream = new FileOutputStream(dst);
|
||||||
|
copy(inStream, outStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copy(InputStream inStream, File dst) throws IOException
|
||||||
|
{
|
||||||
|
FileOutputStream outStream = new FileOutputStream(dst);
|
||||||
|
copy(inStream, outStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copy(InputStream in, OutputStream out) throws IOException
|
||||||
|
{
|
||||||
|
int numBytes;
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
|
||||||
|
while ((numBytes = in.read(buffer)) != -1)
|
||||||
|
out.write(buffer, 0, numBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static File getSDCardDir(@Nullable String relativePath)
|
||||||
|
{
|
||||||
|
File parents[] = new File[]{ Environment.getExternalStorageDirectory() };
|
||||||
|
return getDir(parents, relativePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static File getFilesDir(@Nullable String relativePath)
|
||||||
|
{
|
||||||
|
Context context = HabitsApplication.getContext();
|
||||||
|
if(context == null)
|
||||||
|
{
|
||||||
|
Log.e("DatabaseHelper", "getFilesDir: no application context available");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
File externalFilesDirs[] = ContextCompat.getExternalFilesDirs(context, null);
|
||||||
|
|
||||||
|
if(externalFilesDirs == null)
|
||||||
|
{
|
||||||
|
Log.e("DatabaseHelper", "getFilesDir: getExternalFilesDirs returned null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getDir(externalFilesDirs, relativePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static File getDir(@NonNull File potentialParentDirs[], @Nullable String relativePath)
|
||||||
|
{
|
||||||
|
if(relativePath == null) relativePath = "";
|
||||||
|
|
||||||
|
File chosenDir = null;
|
||||||
|
for(File dir : potentialParentDirs)
|
||||||
|
{
|
||||||
|
if (dir == null || !dir.canWrite()) continue;
|
||||||
|
chosenDir = dir;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(chosenDir == null)
|
||||||
|
{
|
||||||
|
Log.e("DatabaseHelper", "getDir: all potential parents are null or non-writable");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
File dir = new File(String.format("%s/%s/", chosenDir.getAbsolutePath(), relativePath));
|
||||||
|
if (!dir.exists() && !dir.mkdirs())
|
||||||
|
{
|
||||||
|
Log.e("DatabaseHelper", "getDir: chosen dir does not exist and cannot be created");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.helpers;
|
package org.isoron.uhabits.utils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -43,7 +43,7 @@ import org.isoron.uhabits.commands.Command;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public abstract class UIHelper
|
public abstract class InterfaceUtils
|
||||||
{
|
{
|
||||||
public static final String ISORON_NAMESPACE = "http://isoron.org/android";
|
public static final String ISORON_NAMESPACE = "http://isoron.org/android";
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public abstract class UIHelper
|
|||||||
|
|
||||||
public static void setFixedTheme(Integer fixedTheme)
|
public static void setFixedTheme(Integer fixedTheme)
|
||||||
{
|
{
|
||||||
UIHelper.fixedTheme = fixedTheme;
|
InterfaceUtils.fixedTheme = fixedTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnSavedListener
|
public interface OnSavedListener
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.isoron.uhabits.helpers;
|
package org.isoron.uhabits.utils;
|
||||||
|
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
@@ -42,7 +42,7 @@ import java.text.DateFormat;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class ReminderHelper
|
public abstract class ReminderUtils
|
||||||
{
|
{
|
||||||
public static void createReminderAlarms(Context context)
|
public static void createReminderAlarms(Context context)
|
||||||
{
|
{
|
||||||
@@ -70,7 +70,7 @@ public class ReminderHelper
|
|||||||
reminderTime += AlarmManager.INTERVAL_DAY;
|
reminderTime += AlarmManager.INTERVAL_DAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
long timestamp = DateHelper.getStartOfDay(DateHelper.toLocalTime(reminderTime));
|
long timestamp = DateUtils.getStartOfDay(DateUtils.toLocalTime(reminderTime));
|
||||||
|
|
||||||
Uri uri = habit.getUri();
|
Uri uri = habit.getUri();
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ public class ReminderHelper
|
|||||||
|
|
||||||
public static void startRingtonePickerActivity(Fragment fragment, int requestCode)
|
public static void startRingtonePickerActivity(Fragment fragment, int requestCode)
|
||||||
{
|
{
|
||||||
Uri existingRingtoneUri = ReminderHelper.getRingtoneUri(fragment.getContext());
|
Uri existingRingtoneUri = ReminderUtils.getRingtoneUri(fragment.getContext());
|
||||||
Uri defaultRingtoneUri = Settings.System.DEFAULT_NOTIFICATION_URI;
|
Uri defaultRingtoneUri = Settings.System.DEFAULT_NOTIFICATION_URI;
|
||||||
|
|
||||||
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
||||||
@@ -27,8 +27,8 @@ import android.util.TypedValue;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Checkmark;
|
import org.isoron.uhabits.models.Checkmark;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.models.Score;
|
import org.isoron.uhabits.models.Score;
|
||||||
@@ -68,7 +68,7 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|||||||
{
|
{
|
||||||
percentage = 0.75f;
|
percentage = 0.75f;
|
||||||
name = "Wake up early";
|
name = "Wake up early";
|
||||||
activeColor = ColorHelper.CSV_PALETTE[6];
|
activeColor = ColorUtils.CSV_PALETTE[6];
|
||||||
checkmarkValue = Checkmark.CHECKED_EXPLICITLY;
|
checkmarkValue = Checkmark.CHECKED_EXPLICITLY;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|||||||
{
|
{
|
||||||
super.setHabit(habit);
|
super.setHabit(habit);
|
||||||
this.name = habit.name;
|
this.name = habit.name;
|
||||||
this.activeColor = ColorHelper.getColor(getContext(), habit.color);
|
this.activeColor = ColorUtils.getColor(getContext(), habit.color);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|||||||
text = getResources().getString(R.string.fa_check);
|
text = getResources().getString(R.string.fa_check);
|
||||||
backgroundColor = activeColor;
|
backgroundColor = activeColor;
|
||||||
foregroundColor =
|
foregroundColor =
|
||||||
UIHelper.getStyledColor(context, R.attr.highContrastReverseTextColor);
|
InterfaceUtils.getStyledColor(context, R.attr.highContrastReverseTextColor);
|
||||||
|
|
||||||
setShadowAlpha(0x4f);
|
setShadowAlpha(0x4f);
|
||||||
rebuildBackground();
|
rebuildBackground();
|
||||||
@@ -110,15 +110,15 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|||||||
|
|
||||||
case Checkmark.CHECKED_IMPLICITLY:
|
case Checkmark.CHECKED_IMPLICITLY:
|
||||||
text = getResources().getString(R.string.fa_check);
|
text = getResources().getString(R.string.fa_check);
|
||||||
backgroundColor = UIHelper.getStyledColor(context, R.attr.cardBackgroundColor);
|
backgroundColor = InterfaceUtils.getStyledColor(context, R.attr.cardBackgroundColor);
|
||||||
foregroundColor = UIHelper.getStyledColor(context, R.attr.mediumContrastTextColor);
|
foregroundColor = InterfaceUtils.getStyledColor(context, R.attr.mediumContrastTextColor);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Checkmark.UNCHECKED:
|
case Checkmark.UNCHECKED:
|
||||||
default:
|
default:
|
||||||
text = getResources().getString(R.string.fa_times);
|
text = getResources().getString(R.string.fa_times);
|
||||||
backgroundColor = UIHelper.getStyledColor(context, R.attr.cardBackgroundColor);
|
backgroundColor = InterfaceUtils.getStyledColor(context, R.attr.cardBackgroundColor);
|
||||||
foregroundColor = UIHelper.getStyledColor(context, R.attr.mediumContrastTextColor);
|
foregroundColor = InterfaceUtils.getStyledColor(context, R.attr.mediumContrastTextColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ import android.graphics.RectF;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -73,7 +73,7 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
|
|||||||
public HabitFrequencyView(Context context, AttributeSet attrs)
|
public HabitFrequencyView(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
this.primaryColor = ColorHelper.getColor(getContext(), 7);
|
this.primaryColor = ColorUtils.getColor(getContext(), 7);
|
||||||
this.frequency = new HashMap<>();
|
this.frequency = new HashMap<>();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -89,8 +89,8 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
|
|||||||
createPaints();
|
createPaints();
|
||||||
createColors();
|
createColors();
|
||||||
|
|
||||||
dfMonth = DateHelper.getDateFormat("MMM");
|
dfMonth = DateUtils.getDateFormat("MMM");
|
||||||
dfYear = DateHelper.getDateFormat("yyyy");
|
dfYear = DateUtils.getDateFormat("yyyy");
|
||||||
|
|
||||||
rect = new RectF();
|
rect = new RectF();
|
||||||
prevRect = new RectF();
|
prevRect = new RectF();
|
||||||
@@ -100,17 +100,17 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
|
|||||||
{
|
{
|
||||||
if(habit != null)
|
if(habit != null)
|
||||||
{
|
{
|
||||||
this.primaryColor = ColorHelper.getColor(getContext(), habit.color);
|
this.primaryColor = ColorUtils.getColor(getContext(), habit.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
textColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
textColor = InterfaceUtils.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
||||||
gridColor = UIHelper.getStyledColor(getContext(), R.attr.lowContrastTextColor);
|
gridColor = InterfaceUtils.getStyledColor(getContext(), R.attr.lowContrastTextColor);
|
||||||
|
|
||||||
colors = new int[4];
|
colors = new int[4];
|
||||||
colors[0] = gridColor;
|
colors[0] = gridColor;
|
||||||
colors[3] = primaryColor;
|
colors[3] = primaryColor;
|
||||||
colors[1] = ColorHelper.mixColors(colors[0], colors[3], 0.66f);
|
colors[1] = ColorUtils.mixColors(colors[0], colors[3], 0.66f);
|
||||||
colors[2] = ColorHelper.mixColors(colors[0], colors[3], 0.33f);
|
colors[2] = ColorUtils.mixColors(colors[0], colors[3], 0.33f);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createPaints()
|
protected void createPaints()
|
||||||
@@ -159,7 +159,7 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
|
|||||||
private float getMaxMonthWidth()
|
private float getMaxMonthWidth()
|
||||||
{
|
{
|
||||||
float maxMonthWidth = 0;
|
float maxMonthWidth = 0;
|
||||||
GregorianCalendar day = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar day = DateUtils.getStartOfTodayCalendar();
|
||||||
|
|
||||||
for(int i = 0; i < 12; i++)
|
for(int i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
@@ -183,7 +183,7 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
|
|||||||
|
|
||||||
private void generateRandomData()
|
private void generateRandomData()
|
||||||
{
|
{
|
||||||
GregorianCalendar date = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar date = DateUtils.getStartOfTodayCalendar();
|
||||||
date.set(Calendar.DAY_OF_MONTH, 1);
|
date.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
frequency.clear();
|
frequency.clear();
|
||||||
@@ -214,7 +214,7 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
|
|||||||
pGraph.setColor(primaryColor);
|
pGraph.setColor(primaryColor);
|
||||||
prevRect.setEmpty();
|
prevRect.setEmpty();
|
||||||
|
|
||||||
GregorianCalendar currentDate = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar currentDate = DateUtils.getStartOfTodayCalendar();
|
||||||
|
|
||||||
currentDate.set(Calendar.DAY_OF_MONTH, 1);
|
currentDate.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
currentDate.add(Calendar.MONTH, -nColumns + 2 - getDataOffset());
|
currentDate.add(Calendar.MONTH, -nColumns + 2 - getDataOffset());
|
||||||
@@ -235,13 +235,13 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
|
|||||||
float rowHeight = rect.height() / 8.0f;
|
float rowHeight = rect.height() / 8.0f;
|
||||||
prevRect.set(rect);
|
prevRect.set(rect);
|
||||||
|
|
||||||
Integer[] localeWeekdayList = DateHelper.getLocaleWeekdayList();
|
Integer[] localeWeekdayList = DateUtils.getLocaleWeekdayList();
|
||||||
for (int j = 0; j < localeWeekdayList.length; j++)
|
for (int j = 0; j < localeWeekdayList.length; j++)
|
||||||
{
|
{
|
||||||
rect.set(0, 0, baseSize, baseSize);
|
rect.set(0, 0, baseSize, baseSize);
|
||||||
rect.offset(prevRect.left, prevRect.top + baseSize * j);
|
rect.offset(prevRect.left, prevRect.top + baseSize * j);
|
||||||
|
|
||||||
int i = DateHelper.javaWeekdayToLoopWeekday(localeWeekdayList[j]);
|
int i = DateUtils.javaWeekdayToLoopWeekday(localeWeekdayList[j]);
|
||||||
if(values != null)
|
if(values != null)
|
||||||
drawMarker(canvas, rect, values[i]);
|
drawMarker(canvas, rect, values[i]);
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ public class HabitFrequencyView extends ScrollableDataView implements HabitDataV
|
|||||||
pText.setColor(textColor);
|
pText.setColor(textColor);
|
||||||
pGrid.setColor(gridColor);
|
pGrid.setColor(gridColor);
|
||||||
|
|
||||||
for (String day : DateHelper.getLocaleDayNames(Calendar.SHORT)) {
|
for (String day : DateUtils.getLocaleDayNames(Calendar.SHORT)) {
|
||||||
canvas.drawText(day, rGrid.right - columnWidth,
|
canvas.drawText(day, rGrid.right - columnWidth,
|
||||||
rGrid.top + rowHeight / 2 + 0.25f * em, pText);
|
rGrid.top + rowHeight / 2 + 0.25f * em, pText);
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ import android.view.HapticFeedbackConstants;
|
|||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.tasks.BaseTask;
|
import org.isoron.uhabits.tasks.BaseTask;
|
||||||
import org.isoron.uhabits.tasks.ToggleRepetitionTask;
|
import org.isoron.uhabits.tasks.ToggleRepetitionTask;
|
||||||
@@ -98,20 +98,20 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
|
|||||||
|
|
||||||
isEditable = false;
|
isEditable = false;
|
||||||
checkmarks = new int[0];
|
checkmarks = new int[0];
|
||||||
primaryColor = ColorHelper.getColor(getContext(), 7);
|
primaryColor = ColorUtils.getColor(getContext(), 7);
|
||||||
dfMonth = DateHelper.getDateFormat("MMM");
|
dfMonth = DateUtils.getDateFormat("MMM");
|
||||||
dfYear = DateHelper.getDateFormat("yyyy");
|
dfYear = DateUtils.getDateFormat("yyyy");
|
||||||
|
|
||||||
baseLocation = new RectF();
|
baseLocation = new RectF();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDate()
|
private void updateDate()
|
||||||
{
|
{
|
||||||
baseDate = DateHelper.getStartOfTodayCalendar();
|
baseDate = DateUtils.getStartOfTodayCalendar();
|
||||||
baseDate.add(Calendar.DAY_OF_YEAR, -(getDataOffset() - 1) * 7);
|
baseDate.add(Calendar.DAY_OF_YEAR, -(getDataOffset() - 1) * 7);
|
||||||
|
|
||||||
nDays = (nColumns - 1) * 7;
|
nDays = (nColumns - 1) * 7;
|
||||||
int realWeekday = DateHelper.getStartOfTodayCalendar().get(Calendar.DAY_OF_WEEK);
|
int realWeekday = DateUtils.getStartOfTodayCalendar().get(Calendar.DAY_OF_WEEK);
|
||||||
todayPositionInColumn = (7 + realWeekday - baseDate.getFirstDayOfWeek()) % 7;
|
todayPositionInColumn = (7 + realWeekday - baseDate.getFirstDayOfWeek()) % 7;
|
||||||
|
|
||||||
baseDate.add(Calendar.DAY_OF_YEAR, -nDays);
|
baseDate.add(Calendar.DAY_OF_YEAR, -nDays);
|
||||||
@@ -133,7 +133,7 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
|
|||||||
float baseSize = height / 8.0f;
|
float baseSize = height / 8.0f;
|
||||||
setScrollerBucketSize((int) baseSize);
|
setScrollerBucketSize((int) baseSize);
|
||||||
|
|
||||||
squareSpacing = UIHelper.dpToPixels(getContext(), 1.0f);
|
squareSpacing = InterfaceUtils.dpToPixels(getContext(), 1.0f);
|
||||||
float maxTextSize = getResources().getDimension(R.dimen.regularTextSize);
|
float maxTextSize = getResources().getDimension(R.dimen.regularTextSize);
|
||||||
float textSize = height * 0.06f;
|
float textSize = height * 0.06f;
|
||||||
textSize = Math.min(textSize, maxTextSize);
|
textSize = Math.min(textSize, maxTextSize);
|
||||||
@@ -157,7 +157,7 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
|
|||||||
{
|
{
|
||||||
float width = 0;
|
float width = 0;
|
||||||
|
|
||||||
for(String w : DateHelper.getLocaleDayNames(Calendar.SHORT))
|
for(String w : DateUtils.getLocaleDayNames(Calendar.SHORT))
|
||||||
width = Math.max(width, pSquareFg.measureText(w));
|
width = Math.max(width, pSquareFg.measureText(w));
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
@@ -166,10 +166,10 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
|
|||||||
private void createColors()
|
private void createColors()
|
||||||
{
|
{
|
||||||
if(habit != null)
|
if(habit != null)
|
||||||
this.primaryColor = ColorHelper.getColor(getContext(), habit.color);
|
this.primaryColor = ColorUtils.getColor(getContext(), habit.color);
|
||||||
|
|
||||||
if(isBackgroundTransparent)
|
if(isBackgroundTransparent)
|
||||||
primaryColor = ColorHelper.setMinValue(primaryColor, 0.75f);
|
primaryColor = ColorUtils.setMinValue(primaryColor, 0.75f);
|
||||||
|
|
||||||
int red = Color.red(primaryColor);
|
int red = Color.red(primaryColor);
|
||||||
int green = Color.green(primaryColor);
|
int green = Color.green(primaryColor);
|
||||||
@@ -187,11 +187,11 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
colors = new int[3];
|
colors = new int[3];
|
||||||
colors[0] = UIHelper.getStyledColor(getContext(), R.attr.lowContrastTextColor);
|
colors[0] = InterfaceUtils.getStyledColor(getContext(), R.attr.lowContrastTextColor);
|
||||||
colors[1] = Color.argb(127, red, green, blue);
|
colors[1] = Color.argb(127, red, green, blue);
|
||||||
colors[2] = primaryColor;
|
colors[2] = primaryColor;
|
||||||
textColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
textColor = InterfaceUtils.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
||||||
reverseTextColor = UIHelper.getStyledColor(getContext(), R.attr.highContrastReverseTextColor);
|
reverseTextColor = InterfaceUtils.getStyledColor(getContext(), R.attr.highContrastReverseTextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
|
|||||||
{
|
{
|
||||||
float verticalOffset = pTextHeader.getFontSpacing() * 0.4f;
|
float verticalOffset = pTextHeader.getFontSpacing() * 0.4f;
|
||||||
|
|
||||||
for (String day : DateHelper.getLocaleDayNames(Calendar.SHORT))
|
for (String day : DateUtils.getLocaleDayNames(Calendar.SHORT))
|
||||||
{
|
{
|
||||||
location.offset(0, columnWidth);
|
location.offset(0, columnWidth);
|
||||||
canvas.drawText(day, location.left + headerTextOffset,
|
canvas.drawText(day, location.left + headerTextOffset,
|
||||||
@@ -379,7 +379,7 @@ public class HabitHistoryView extends ScrollableDataView implements HabitDataVie
|
|||||||
Calendar date = (Calendar) baseDate.clone();
|
Calendar date = (Calendar) baseDate.clone();
|
||||||
date.add(Calendar.DAY_OF_YEAR, offset);
|
date.add(Calendar.DAY_OF_YEAR, offset);
|
||||||
|
|
||||||
if(DateHelper.getStartOfDay(date.getTimeInMillis()) > DateHelper.getStartOfToday())
|
if(DateUtils.getStartOfDay(date.getTimeInMillis()) > DateUtils.getStartOfToday())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return date.getTimeInMillis();
|
return date.getTimeInMillis();
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ import android.support.annotation.Nullable;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.models.Score;
|
import org.isoron.uhabits.models.Score;
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
|||||||
public HabitScoreView(Context context, AttributeSet attrs)
|
public HabitScoreView(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
this.primaryColor = ColorHelper.getColor(getContext(), 7);
|
this.primaryColor = ColorUtils.getColor(getContext(), 7);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,9 +107,9 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
|||||||
createPaints();
|
createPaints();
|
||||||
createColors();
|
createColors();
|
||||||
|
|
||||||
dfYear = DateHelper.getDateFormat("yyyy");
|
dfYear = DateUtils.getDateFormat("yyyy");
|
||||||
dfMonth = DateHelper.getDateFormat("MMM");
|
dfMonth = DateUtils.getDateFormat("MMM");
|
||||||
dfDay = DateHelper.getDateFormat("d");
|
dfDay = DateUtils.getDateFormat("d");
|
||||||
|
|
||||||
rect = new RectF();
|
rect = new RectF();
|
||||||
prevRect = new RectF();
|
prevRect = new RectF();
|
||||||
@@ -118,11 +118,11 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
|||||||
private void createColors()
|
private void createColors()
|
||||||
{
|
{
|
||||||
if(habit != null)
|
if(habit != null)
|
||||||
this.primaryColor = ColorHelper.getColor(getContext(), habit.color);
|
this.primaryColor = ColorUtils.getColor(getContext(), habit.color);
|
||||||
|
|
||||||
textColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
textColor = InterfaceUtils.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
||||||
gridColor = UIHelper.getStyledColor(getContext(), R.attr.lowContrastTextColor);
|
gridColor = InterfaceUtils.getStyledColor(getContext(), R.attr.lowContrastTextColor);
|
||||||
backgroundColor = UIHelper.getStyledColor(getContext(), R.attr.cardBackgroundColor);
|
backgroundColor = InterfaceUtils.getStyledColor(getContext(), R.attr.cardBackgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createPaints()
|
protected void createPaints()
|
||||||
@@ -171,7 +171,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
|||||||
|
|
||||||
columnHeight = 8 * baseSize;
|
columnHeight = 8 * baseSize;
|
||||||
|
|
||||||
float minStrokeWidth = UIHelper.dpToPixels(getContext(), 1);
|
float minStrokeWidth = InterfaceUtils.dpToPixels(getContext(), 1);
|
||||||
pGraph.setTextSize(baseSize * 0.5f);
|
pGraph.setTextSize(baseSize * 0.5f);
|
||||||
pGraph.setStrokeWidth(baseSize * 0.1f);
|
pGraph.setStrokeWidth(baseSize * 0.1f);
|
||||||
pGrid.setStrokeWidth(Math.min(minStrokeWidth, baseSize * 0.05f));
|
pGrid.setStrokeWidth(Math.min(minStrokeWidth, baseSize * 0.05f));
|
||||||
@@ -252,10 +252,10 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
|||||||
previousYearText = "";
|
previousYearText = "";
|
||||||
skipYear = 0;
|
skipYear = 0;
|
||||||
|
|
||||||
long currentDate = DateHelper.getStartOfToday();
|
long currentDate = DateUtils.getStartOfToday();
|
||||||
|
|
||||||
for(int k = 0; k < nColumns + getDataOffset() - 1; k++)
|
for(int k = 0; k < nColumns + getDataOffset() - 1; k++)
|
||||||
currentDate -= bucketSize * DateHelper.millisecondsInOneDay;
|
currentDate -= bucketSize * DateUtils.millisecondsInOneDay;
|
||||||
|
|
||||||
for (int k = 0; k < nColumns; k++)
|
for (int k = 0; k < nColumns; k++)
|
||||||
{
|
{
|
||||||
@@ -284,7 +284,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
|||||||
|
|
||||||
drawFooter(activeCanvas, rect, currentDate);
|
drawFooter(activeCanvas, rect, currentDate);
|
||||||
|
|
||||||
currentDate += bucketSize * DateHelper.millisecondsInOneDay;
|
currentDate += bucketSize * DateUtils.millisecondsInOneDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(activeCanvas != canvas)
|
if(activeCanvas != canvas)
|
||||||
@@ -301,7 +301,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
|||||||
String monthText = dfMonth.format(currentDate);
|
String monthText = dfMonth.format(currentDate);
|
||||||
String dayText = dfDay.format(currentDate);
|
String dayText = dfDay.format(currentDate);
|
||||||
|
|
||||||
GregorianCalendar calendar = DateHelper.getCalendar(currentDate);
|
GregorianCalendar calendar = DateUtils.getCalendar(currentDate);
|
||||||
|
|
||||||
String text;
|
String text;
|
||||||
int year = calendar.get(Calendar.YEAR);
|
int year = calendar.get(Calendar.YEAR);
|
||||||
@@ -408,7 +408,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
|||||||
private float getMaxMonthWidth()
|
private float getMaxMonthWidth()
|
||||||
{
|
{
|
||||||
float maxMonthWidth = 0;
|
float maxMonthWidth = 0;
|
||||||
GregorianCalendar day = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar day = DateUtils.getStartOfTodayCalendar();
|
||||||
|
|
||||||
for(int i = 0; i < 12; i++)
|
for(int i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
@@ -423,7 +423,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
|||||||
private float getMaxDayWidth()
|
private float getMaxDayWidth()
|
||||||
{
|
{
|
||||||
float maxDayWidth = 0;
|
float maxDayWidth = 0;
|
||||||
GregorianCalendar day = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar day = DateUtils.getStartOfTodayCalendar();
|
||||||
|
|
||||||
for(int i = 0; i < 28; i++)
|
for(int i = 0; i < 28; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ import android.util.AttributeSet;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.models.Streak;
|
import org.isoron.uhabits.models.Streak;
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class HabitStreakView extends View implements HabitDataView
|
|||||||
public HabitStreakView(Context context, AttributeSet attrs)
|
public HabitStreakView(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
this.primaryColor = ColorHelper.getColor(getContext(), 7);
|
this.primaryColor = ColorUtils.getColor(getContext(), 7);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ public class HabitStreakView extends View implements HabitDataView
|
|||||||
private void createColors()
|
private void createColors()
|
||||||
{
|
{
|
||||||
if(habit != null)
|
if(habit != null)
|
||||||
this.primaryColor = ColorHelper.getColor(getContext(), habit.color);
|
this.primaryColor = ColorUtils.getColor(getContext(), habit.color);
|
||||||
|
|
||||||
int red = Color.red(primaryColor);
|
int red = Color.red(primaryColor);
|
||||||
int green = Color.green(primaryColor);
|
int green = Color.green(primaryColor);
|
||||||
@@ -135,9 +135,9 @@ public class HabitStreakView extends View implements HabitDataView
|
|||||||
colors[3] = primaryColor;
|
colors[3] = primaryColor;
|
||||||
colors[2] = Color.argb(192, red, green, blue);
|
colors[2] = Color.argb(192, red, green, blue);
|
||||||
colors[1] = Color.argb(96, red, green, blue);
|
colors[1] = Color.argb(96, red, green, blue);
|
||||||
colors[0] = UIHelper.getStyledColor(getContext(), R.attr.lowContrastTextColor);
|
colors[0] = InterfaceUtils.getStyledColor(getContext(), R.attr.lowContrastTextColor);
|
||||||
textColor = UIHelper.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
textColor = InterfaceUtils.getStyledColor(getContext(), R.attr.mediumContrastTextColor);
|
||||||
reverseTextColor = UIHelper.getStyledColor(getContext(), R.attr.highContrastReverseTextColor);
|
reverseTextColor = InterfaceUtils.getStyledColor(getContext(), R.attr.highContrastReverseTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createPaints()
|
protected void createPaints()
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -71,7 +71,7 @@ public abstract class HabitWidgetView extends FrameLayout implements HabitDataV
|
|||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
inflate(getContext(), getInnerLayoutId(), this);
|
inflate(getContext(), getInnerLayoutId(), this);
|
||||||
shadowAlpha = (int) (255 * UIHelper.getStyledFloat(getContext(), R.attr.widgetShadowAlpha));
|
shadowAlpha = (int) (255 * InterfaceUtils.getStyledFloat(getContext(), R.attr.widgetShadowAlpha));
|
||||||
rebuildBackground();
|
rebuildBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,13 +82,13 @@ public abstract class HabitWidgetView extends FrameLayout implements HabitDataV
|
|||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
|
|
||||||
int backgroundAlpha =
|
int backgroundAlpha =
|
||||||
(int) (255 * UIHelper.getStyledFloat(context, R.attr.widgetBackgroundAlpha));
|
(int) (255 * InterfaceUtils.getStyledFloat(context, R.attr.widgetBackgroundAlpha));
|
||||||
|
|
||||||
int shadowRadius = (int) UIHelper.dpToPixels(context, 2);
|
int shadowRadius = (int) InterfaceUtils.dpToPixels(context, 2);
|
||||||
int shadowOffset = (int) UIHelper.dpToPixels(context, 1);
|
int shadowOffset = (int) InterfaceUtils.dpToPixels(context, 1);
|
||||||
int shadowColor = Color.argb(shadowAlpha, 0, 0, 0);
|
int shadowColor = Color.argb(shadowAlpha, 0, 0, 0);
|
||||||
|
|
||||||
float cornerRadius = UIHelper.dpToPixels(context, 5);
|
float cornerRadius = InterfaceUtils.dpToPixels(context, 5);
|
||||||
float[] radii = new float[8];
|
float[] radii = new float[8];
|
||||||
Arrays.fill(radii, cornerRadius);
|
Arrays.fill(radii, cornerRadius);
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ public abstract class HabitWidgetView extends FrameLayout implements HabitDataV
|
|||||||
insetRightBottom);
|
insetRightBottom);
|
||||||
backgroundPaint = innerDrawable.getPaint();
|
backgroundPaint = innerDrawable.getPaint();
|
||||||
backgroundPaint.setShadowLayer(shadowRadius, shadowOffset, shadowOffset, shadowColor);
|
backgroundPaint.setShadowLayer(shadowRadius, shadowOffset, shadowOffset, shadowColor);
|
||||||
backgroundPaint.setColor(UIHelper.getStyledColor(context, R.attr.cardBackgroundColor));
|
backgroundPaint.setColor(InterfaceUtils.getStyledColor(context, R.attr.cardBackgroundColor));
|
||||||
backgroundPaint.setAlpha(backgroundAlpha);
|
backgroundPaint.setAlpha(backgroundAlpha);
|
||||||
|
|
||||||
frame = (ViewGroup) findViewById(R.id.frame);
|
frame = (ViewGroup) findViewById(R.id.frame);
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ import android.util.AttributeSet;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
public class NumberView extends View
|
public class NumberView extends View
|
||||||
{
|
{
|
||||||
@@ -66,12 +66,12 @@ public class NumberView extends View
|
|||||||
|
|
||||||
this.textSize = getResources().getDimension(R.dimen.regularTextSize);
|
this.textSize = getResources().getDimension(R.dimen.regularTextSize);
|
||||||
|
|
||||||
this.label = UIHelper.getAttribute(context, attrs, "label", "Number");
|
this.label = InterfaceUtils.getAttribute(context, attrs, "label", "Number");
|
||||||
this.number = UIHelper.getIntAttribute(context, attrs, "number", 0);
|
this.number = InterfaceUtils.getIntAttribute(context, attrs, "number", 0);
|
||||||
this.textSize = UIHelper.getFloatAttribute(context, attrs, "textSize",
|
this.textSize = InterfaceUtils.getFloatAttribute(context, attrs, "textSize",
|
||||||
getResources().getDimension(R.dimen.regularTextSize));
|
getResources().getDimension(R.dimen.regularTextSize));
|
||||||
|
|
||||||
this.color = ColorHelper.getColor(getContext(), 7);
|
this.color = ColorUtils.getColor(getContext(), 7);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ import android.content.Context;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.DateHelper;
|
import org.isoron.uhabits.utils.DateUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@@ -39,9 +39,9 @@ public class RepetitionCountView extends NumberView implements HabitDataView
|
|||||||
public RepetitionCountView(Context context, AttributeSet attrs)
|
public RepetitionCountView(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
this.interval = UIHelper.getIntAttribute(context, attrs, "interval", 7);
|
this.interval = InterfaceUtils.getIntAttribute(context, attrs, "interval", 7);
|
||||||
int labelValue = UIHelper.getIntAttribute(context, attrs, "labelValue", 7);
|
int labelValue = InterfaceUtils.getIntAttribute(context, attrs, "labelValue", 7);
|
||||||
String labelFormat = UIHelper.getAttribute(context, attrs, "labelFormat",
|
String labelFormat = InterfaceUtils.getAttribute(context, attrs, "labelFormat",
|
||||||
getResources().getString(R.string.last_x_days));
|
getResources().getString(R.string.last_x_days));
|
||||||
|
|
||||||
setLabel(String.format(labelFormat, labelValue));
|
setLabel(String.format(labelFormat, labelValue));
|
||||||
@@ -56,7 +56,7 @@ public class RepetitionCountView extends NumberView implements HabitDataView
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long to = DateHelper.getStartOfToday();
|
long to = DateUtils.getStartOfToday();
|
||||||
long from;
|
long from;
|
||||||
|
|
||||||
if(interval == 0)
|
if(interval == 0)
|
||||||
@@ -65,7 +65,7 @@ public class RepetitionCountView extends NumberView implements HabitDataView
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GregorianCalendar fromCalendar = DateHelper.getStartOfTodayCalendar();
|
GregorianCalendar fromCalendar = DateUtils.getStartOfTodayCalendar();
|
||||||
fromCalendar.add(Calendar.DAY_OF_YEAR, -interval + 1);
|
fromCalendar.add(Calendar.DAY_OF_YEAR, -interval + 1);
|
||||||
from = fromCalendar.getTimeInMillis();
|
from = fromCalendar.getTimeInMillis();
|
||||||
}
|
}
|
||||||
@@ -80,6 +80,6 @@ public class RepetitionCountView extends NumberView implements HabitDataView
|
|||||||
public void setHabit(Habit habit)
|
public void setHabit(Habit habit)
|
||||||
{
|
{
|
||||||
this.habit = habit;
|
this.habit = habit;
|
||||||
setColor(ColorHelper.getColor(getContext(), habit.color));
|
setColor(ColorUtils.getColor(getContext(), habit.color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ import android.util.AttributeSet;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.ColorHelper;
|
import org.isoron.uhabits.utils.ColorUtils;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
|
|
||||||
public class RingView extends View
|
public class RingView extends View
|
||||||
{
|
{
|
||||||
@@ -70,8 +70,8 @@ public class RingView extends View
|
|||||||
|
|
||||||
percentage = 0.0f;
|
percentage = 0.0f;
|
||||||
precision = 0.01f;
|
precision = 0.01f;
|
||||||
color = ColorHelper.CSV_PALETTE[0];
|
color = ColorUtils.CSV_PALETTE[0];
|
||||||
thickness = UIHelper.dpToPixels(getContext(), 2);
|
thickness = InterfaceUtils.dpToPixels(getContext(), 2);
|
||||||
text = "";
|
text = "";
|
||||||
textSize = context.getResources().getDimension(R.dimen.smallTextSize);
|
textSize = context.getResources().getDimension(R.dimen.smallTextSize);
|
||||||
|
|
||||||
@@ -82,23 +82,23 @@ public class RingView extends View
|
|||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
percentage = UIHelper.getFloatAttribute(context, attrs, "percentage", 0);
|
percentage = InterfaceUtils.getFloatAttribute(context, attrs, "percentage", 0);
|
||||||
precision = UIHelper.getFloatAttribute(context, attrs, "precision", 0.01f);
|
precision = InterfaceUtils.getFloatAttribute(context, attrs, "precision", 0.01f);
|
||||||
|
|
||||||
color = UIHelper.getColorAttribute(context, attrs, "color", 0);
|
color = InterfaceUtils.getColorAttribute(context, attrs, "color", 0);
|
||||||
backgroundColor = UIHelper.getColorAttribute(context, attrs, "backgroundColor", null);
|
backgroundColor = InterfaceUtils.getColorAttribute(context, attrs, "backgroundColor", null);
|
||||||
inactiveColor = UIHelper.getColorAttribute(context, attrs, "inactiveColor", null);
|
inactiveColor = InterfaceUtils.getColorAttribute(context, attrs, "inactiveColor", null);
|
||||||
|
|
||||||
thickness = UIHelper.getFloatAttribute(context, attrs, "thickness", 0);
|
thickness = InterfaceUtils.getFloatAttribute(context, attrs, "thickness", 0);
|
||||||
thickness = UIHelper.dpToPixels(context, thickness);
|
thickness = InterfaceUtils.dpToPixels(context, thickness);
|
||||||
|
|
||||||
float defaultTextSize = context.getResources().getDimension(R.dimen.smallTextSize);
|
float defaultTextSize = context.getResources().getDimension(R.dimen.smallTextSize);
|
||||||
textSize = UIHelper.getFloatAttribute(context, attrs, "textSize", defaultTextSize);
|
textSize = InterfaceUtils.getFloatAttribute(context, attrs, "textSize", defaultTextSize);
|
||||||
textSize = UIHelper.spToPixels(context, textSize);
|
textSize = InterfaceUtils.spToPixels(context, textSize);
|
||||||
|
|
||||||
text = UIHelper.getAttribute(context, attrs, "text", "");
|
text = InterfaceUtils.getAttribute(context, attrs, "text", "");
|
||||||
|
|
||||||
enableFontAwesome = UIHelper.getBooleanAttribute(context, attrs, "enableFontAwesome", false);
|
enableFontAwesome = InterfaceUtils.getBooleanAttribute(context, attrs, "enableFontAwesome", false);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -153,12 +153,12 @@ public class RingView extends View
|
|||||||
pRing.setTextAlign(Paint.Align.CENTER);
|
pRing.setTextAlign(Paint.Align.CENTER);
|
||||||
|
|
||||||
if(backgroundColor == null)
|
if(backgroundColor == null)
|
||||||
backgroundColor = UIHelper.getStyledColor(getContext(), R.attr.cardBackgroundColor);
|
backgroundColor = InterfaceUtils.getStyledColor(getContext(), R.attr.cardBackgroundColor);
|
||||||
|
|
||||||
if(inactiveColor == null)
|
if(inactiveColor == null)
|
||||||
inactiveColor = UIHelper.getStyledColor(getContext(), R.attr.highContrastTextColor);
|
inactiveColor = InterfaceUtils.getStyledColor(getContext(), R.attr.highContrastTextColor);
|
||||||
|
|
||||||
inactiveColor = ColorHelper.setAlpha(inactiveColor, 0.1f);
|
inactiveColor = ColorUtils.setAlpha(inactiveColor, 0.1f);
|
||||||
|
|
||||||
rect = new RectF();
|
rect = new RectF();
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ public class RingView extends View
|
|||||||
|
|
||||||
pRing.setColor(color);
|
pRing.setColor(color);
|
||||||
pRing.setTextSize(textSize);
|
pRing.setTextSize(textSize);
|
||||||
if(enableFontAwesome) pRing.setTypeface(UIHelper.getFontAwesome(getContext()));
|
if(enableFontAwesome) pRing.setTypeface(InterfaceUtils.getFontAwesome(getContext()));
|
||||||
activeCanvas.drawText(text, rect.centerX(), rect.centerY() + 0.4f * em, pRing);
|
activeCanvas.drawText(text, rect.centerX(), rect.centerY() + 0.4f * em, pRing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import android.widget.RemoteViews;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.tasks.BaseTask;
|
import org.isoron.uhabits.tasks.BaseTask;
|
||||||
|
|
||||||
@@ -170,13 +170,13 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
|
|||||||
|
|
||||||
if (options != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
|
if (options != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
|
||||||
{
|
{
|
||||||
maxWidth = (int) UIHelper.dpToPixels(context,
|
maxWidth = (int) InterfaceUtils.dpToPixels(context,
|
||||||
options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH));
|
options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH));
|
||||||
maxHeight = (int) UIHelper.dpToPixels(context,
|
maxHeight = (int) InterfaceUtils.dpToPixels(context,
|
||||||
options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT));
|
options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT));
|
||||||
minWidth = (int) UIHelper.dpToPixels(context,
|
minWidth = (int) InterfaceUtils.dpToPixels(context,
|
||||||
options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH));
|
options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH));
|
||||||
minHeight = (int) UIHelper.dpToPixels(context,
|
minHeight = (int) InterfaceUtils.dpToPixels(context,
|
||||||
options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT));
|
options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import android.widget.ListView;
|
|||||||
import org.isoron.uhabits.MainActivity;
|
import org.isoron.uhabits.MainActivity;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.widgets.BaseWidgetProvider;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import android.view.View;
|
|||||||
|
|
||||||
import org.isoron.uhabits.HabitBroadcastReceiver;
|
import org.isoron.uhabits.HabitBroadcastReceiver;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.helpers.UIHelper;
|
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.Habit;
|
||||||
import org.isoron.uhabits.views.GraphWidgetView;
|
import org.isoron.uhabits.views.GraphWidgetView;
|
||||||
import org.isoron.uhabits.views.HabitDataView;
|
import org.isoron.uhabits.views.HabitDataView;
|
||||||
@@ -35,7 +35,7 @@ public class ScoreWidgetProvider extends BaseWidgetProvider
|
|||||||
@Override
|
@Override
|
||||||
protected View buildCustomView(Context context, Habit habit)
|
protected View buildCustomView(Context context, Habit habit)
|
||||||
{
|
{
|
||||||
int defaultScoreInterval = UIHelper.getDefaultScoreInterval(context);
|
int defaultScoreInterval = InterfaceUtils.getDefaultScoreInterval(context);
|
||||||
int size = HabitScoreView.DEFAULT_BUCKET_SIZES[defaultScoreInterval];
|
int size = HabitScoreView.DEFAULT_BUCKET_SIZES[defaultScoreInterval];
|
||||||
|
|
||||||
HabitScoreView dataView = new HabitScoreView(context);
|
HabitScoreView dataView = new HabitScoreView(context);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
style="@style/dialogForm"
|
style="@style/dialogForm"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context=".dialogs.EditHabitDialogFragment"
|
tools:context=".ui.edit.EditHabitDialogFragment"
|
||||||
tools:ignore="MergeRootFrame">
|
tools:ignore="MergeRootFrame">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="org.isoron.uhabits.MainActivity"
|
tools:context=".MainActivity"
|
||||||
tools:ignore="MergeRootFrame">
|
tools:ignore="MergeRootFrame">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/fragment1"
|
android:id="@+id/fragment1"
|
||||||
android:name="org.isoron.uhabits.fragments.ListHabitsFragment"
|
android:name="org.isoron.uhabits.ui.list.ListHabitsFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@id/toolbar"
|
android:layout_below="@id/toolbar"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="org.isoron.uhabits.SettingsActivity"
|
tools:context=".ui.settings.SettingsActivity"
|
||||||
tools:ignore="MergeRootFrame">
|
tools:ignore="MergeRootFrame">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/fragment"
|
android:id="@+id/fragment"
|
||||||
android:name="org.isoron.uhabits.fragments.SettingsFragment"
|
android:name="org.isoron.uhabits.ui.settings.SettingsFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
style="@style/CardList"
|
style="@style/CardList"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
tools:context="org.isoron.uhabits.ShowHabitActivity">
|
tools:context=".ui.show.ShowHabitActivity">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/subtitle"
|
android:id="@+id/subtitle"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="org.isoron.uhabits.ShowHabitActivity"
|
tools:context=".ui.show.ShowHabitActivity"
|
||||||
tools:ignore="MergeRootFrame"
|
tools:ignore="MergeRootFrame"
|
||||||
tools:menu="show_habit_activity_menu,show_habit_fragment_menu">
|
tools:menu="show_habit_activity_menu,show_habit_fragment_menu">
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/fragment2"
|
android:id="@+id/fragment2"
|
||||||
android:name="org.isoron.uhabits.fragments.ShowHabitFragment"
|
android:name="org.isoron.uhabits.ui.show.ShowHabitFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@id/toolbar"
|
android:layout_below="@id/toolbar"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="org.isoron.uhabits.MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_add"
|
android:id="@+id/action_add"
|
||||||
|
|||||||
@@ -20,6 +20,6 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
tools:context="org.isoron.uhabits.MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
Reference in New Issue
Block a user