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