diff --git a/build.gradle b/build.gradle
index a186732fc..b21b92ae7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.0-alpha8'
+ classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.4'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index b5e196df5..52ff6ae93 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Thu Jul 13 10:27:19 CDT 2017
+#Sun Sep 24 06:01:27 CDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
diff --git a/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseUserInterfaceTest.java b/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseUserInterfaceTest.java
index 75516133a..e2dfb6b1f 100644
--- a/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseUserInterfaceTest.java
+++ b/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseUserInterfaceTest.java
@@ -60,9 +60,9 @@ public static void startActivity(Class cls)
@Before
public void setUp() throws Exception
{
+ device = getInstance(getInstrumentation());
TestButler.setup(getTargetContext());
TestButler.verifyAnimationsDisabled(getTargetContext());
- device = getInstance(getInstrumentation());
HabitsApplication app =
(HabitsApplication) getTargetContext().getApplicationContext();
diff --git a/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/HabitsTest.java b/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/HabitsTest.java
index e76bae1c2..035e0c150 100644
--- a/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/HabitsTest.java
+++ b/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/HabitsTest.java
@@ -31,7 +31,6 @@
import static org.isoron.uhabits.acceptance.steps.EditHabitSteps.*;
import static org.isoron.uhabits.acceptance.steps.ListHabitsSteps.MenuItem.*;
import static org.isoron.uhabits.acceptance.steps.ListHabitsSteps.*;
-import static org.isoron.uhabits.acceptance.steps.ListHabitsSteps.MenuItem.EDIT;
@RunWith(AndroidJUnit4.class)
@LargeTest
@@ -94,7 +93,7 @@ public void shouldEditHabit() throws Exception
clickSave();
verifyShowsScreen(LIST_HABITS);
- verifyDisplaysText("Take a walk");
+ verifyDisplaysTextInSequence("Wake up early", "Take a walk", "Meditate");
verifyDoesNotDisplayText("Track time");
}
diff --git a/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/CommonSteps.java b/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/CommonSteps.java
index fbbafe672..14b16144b 100644
--- a/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/CommonSteps.java
+++ b/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/CommonSteps.java
@@ -31,6 +31,7 @@
import static android.support.test.espresso.Espresso.*;
import static android.support.test.espresso.action.ViewActions.*;
+import static android.support.test.espresso.assertion.PositionAssertions.*;
import static android.support.test.espresso.assertion.ViewAssertions.*;
import static android.support.test.espresso.matcher.ViewMatchers.*;
import static junit.framework.Assert.*;
@@ -114,6 +115,15 @@ public static void verifyDisplaysText(String text)
onView(withText(text)).check(matches(isEnabled()));
}
+ public static void verifyDisplaysTextInSequence(String... text)
+ {
+ verifyDisplaysText(text[0]);
+ for(int i = 1; i < text.length; i++) {
+ verifyDisplaysText(text[i]);
+ onView(withText(text[i])).check(isBelow(withText(text[i-1])));
+ }
+ }
+
private static void verifyDisplaysView(String className)
{
onView(withClassName(endsWith(className))).check(matches(isEnabled()));
diff --git a/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitDialog.java b/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitDialog.java
index 55ea8e691..6ff2bfa6b 100644
--- a/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitDialog.java
+++ b/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitDialog.java
@@ -171,6 +171,8 @@ void onSaveButtonClick()
if (type == Habit.NUMBER_HABIT && !targetPanel.validate()) return;
Habit habit = modelFactory.buildHabit();
+ if( originalHabit != null )
+ habit.copyFrom(originalHabit);
habit.setName(namePanel.getName());
habit.setDescription(namePanel.getDescription());
habit.setColor(namePanel.getColor());
diff --git a/uhabits-android/src/main/java/org/isoron/uhabits/notifications/AndroidNotificationTray.kt b/uhabits-android/src/main/java/org/isoron/uhabits/notifications/AndroidNotificationTray.kt
index d06d0e320..6a25300d0 100644
--- a/uhabits-android/src/main/java/org/isoron/uhabits/notifications/AndroidNotificationTray.kt
+++ b/uhabits-android/src/main/java/org/isoron/uhabits/notifications/AndroidNotificationTray.kt
@@ -21,8 +21,8 @@ package org.isoron.uhabits.notifications
import android.app.*
import android.content.*
+import android.graphics.*
import android.graphics.BitmapFactory.*
-import android.graphics.Color
import android.support.v4.app.*
import android.support.v4.app.NotificationCompat.*
import org.isoron.androidbase.*
@@ -85,13 +85,13 @@ class AndroidNotificationTray
.setWhen(reminderTime)
.setShowWhen(true)
.setOngoing(preferences.shouldMakeNotificationsSticky())
+
if (preferences.shouldMakeNotificationsLed())
- builder.setLights(Color.RED, 1000, 1000)
- val notification = builder.build()
+ builder.setLights(Color.RED, 1000, 1000)
val notificationManager = context.getSystemService(
Activity.NOTIFICATION_SERVICE) as NotificationManager
- notificationManager.notify(notificationId, notification)
+ notificationManager.notify(notificationId, builder.build())
}
}
diff --git a/uhabits-android/src/main/java/org/isoron/uhabits/utils/DatabaseUtils.java b/uhabits-android/src/main/java/org/isoron/uhabits/utils/DatabaseUtils.java
index e0bc5d42e..8f99eb42d 100644
--- a/uhabits-android/src/main/java/org/isoron/uhabits/utils/DatabaseUtils.java
+++ b/uhabits-android/src/main/java/org/isoron/uhabits/utils/DatabaseUtils.java
@@ -92,7 +92,7 @@ public static String saveDatabaseCopy(Context context, File dir)
throws IOException
{
SimpleDateFormat dateFormat = DateFormats.getBackupDateFormat();
- String date = dateFormat.format(DateUtils.getStartOfToday());
+ String date = dateFormat.format(DateUtils.getLocalTime());
String format = "%s/Loop Habits Backup %s.db";
String filename = String.format(format, dir.getAbsolutePath(), date);
diff --git a/uhabits-android/src/main/res/values/strings.xml b/uhabits-android/src/main/res/values/strings.xml
index 814a53d32..a78c873cb 100644
--- a/uhabits-android/src/main/res/values/strings.xml
+++ b/uhabits-android/src/main/res/values/strings.xml
@@ -166,7 +166,7 @@
Replaces gray backgrounds with pure black in night mode. Reduces battery usage in phones with AMOLED display.
Interface
Reverse order of days
- Show days in reverse order on the main screen
+ Show days in reverse order on the main screen.
Day
Week
@@ -191,8 +191,8 @@
Make notifications sticky
Prevents notifications from being swiped away.
- LED
- Notifications blinking light.
+ Notification light
+ Shows a blinking light for reminders. Only available in phones with LED notification lights.
Repair database
Database repaired.
diff --git a/uhabits-core/src/main/java/org/isoron/uhabits/core/models/ScoreList.java b/uhabits-core/src/main/java/org/isoron/uhabits/core/models/ScoreList.java
index 43959c11c..b3ba68370 100644
--- a/uhabits-core/src/main/java/org/isoron/uhabits/core/models/ScoreList.java
+++ b/uhabits-core/src/main/java/org/isoron/uhabits/core/models/ScoreList.java
@@ -172,7 +172,7 @@ public void writeCSV(Writer out) throws IOException
for (Score s : this)
{
String timestamp = dateFormat.format(s.getTimestamp().getUnixTime());
- String score = String.format("%.4f", s.getValue());
+ String score = String.format((Locale)null, "%.4f", s.getValue());
out.write(String.format("%s,%s\n", timestamp, score));
}
}
diff --git a/uhabits-core/src/main/java/org/isoron/uhabits/core/utils/DateUtils.java b/uhabits-core/src/main/java/org/isoron/uhabits/core/utils/DateUtils.java
index 9d2a3f476..2771f3500 100644
--- a/uhabits-core/src/main/java/org/isoron/uhabits/core/utils/DateUtils.java
+++ b/uhabits-core/src/main/java/org/isoron/uhabits/core/utils/DateUtils.java
@@ -34,6 +34,8 @@ public abstract class DateUtils
private static TimeZone fixedTimeZone = null;
+ private static Locale fixedLocale = null;
+
/**
* Time of the day when the new day starts.
*/
@@ -58,7 +60,7 @@ public static long applyTimezone(long localTimestamp)
public static String formatHeaderDate(GregorianCalendar day)
{
- Locale locale = Locale.getDefault();
+ Locale locale = getLocale();
String dayOfMonth = Integer.toString(day.get(DAY_OF_MONTH));
String dayOfWeek = day.getDisplayName(DAY_OF_WEEK, SHORT, locale);
return dayOfWeek + "\n" + dayOfMonth;
@@ -67,7 +69,7 @@ public static String formatHeaderDate(GregorianCalendar day)
private static GregorianCalendar getCalendar(long timestamp)
{
GregorianCalendar day =
- new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+ new GregorianCalendar(TimeZone.getTimeZone("GMT"), getLocale());
day.setTimeInMillis(timestamp);
return day;
}
@@ -82,7 +84,7 @@ private static String[] getDayNames(int format)
for (int i = 0; i < wdays.length; i++)
{
wdays[i] =
- day.getDisplayName(DAY_OF_WEEK, format, Locale.getDefault());
+ day.getDisplayName(DAY_OF_WEEK, format, getLocale());
day.add(DAY_OF_MONTH, 1);
}
@@ -100,7 +102,7 @@ public static long getLocalTime()
/**
* @return array with weekday names starting according to locale settings,
- * e.g. [Mo,Di,Mi,Do,Fr,Sa,So] in Europe
+ * e.g. [Mo,Di,Mi,Do,Fr,Sa,So] in Germany
*/
public static String[] getLocaleDayNames(int format)
{
@@ -111,7 +113,7 @@ public static String[] getLocaleDayNames(int format)
for (int i = 0; i < days.length; i++)
{
days[i] = calendar.getDisplayName(DAY_OF_WEEK, format,
- Locale.getDefault());
+ getLocale());
calendar.add(DAY_OF_MONTH, 1);
}
@@ -195,6 +197,17 @@ public static void setFixedLocalTime(Long timestamp)
fixedLocalTime = timestamp;
}
+ public static void setFixedLocale(Locale locale)
+ {
+ fixedLocale = locale;
+ }
+
+ private static Locale getLocale()
+ {
+ if(fixedLocale != null) return fixedLocale;
+ return Locale.getDefault();
+ }
+
public static Long truncate(TruncateField field, long timestamp)
{
GregorianCalendar cal = DateUtils.getCalendar(timestamp);
diff --git a/uhabits-core/src/main/resources/migrations/22.sql b/uhabits-core/src/main/resources/migrations/22.sql
index 0417119f9..1d1ffcf9a 100644
--- a/uhabits-core/src/main/resources/migrations/22.sql
+++ b/uhabits-core/src/main/resources/migrations/22.sql
@@ -13,7 +13,7 @@ begin transaction;
habit integer not null references habits(id),
timestamp integer not null,
value integer not null);
- drop index idx_repetitions_habit_timestamp;
+ drop index if exists idx_repetitions_habit_timestamp;
create unique index idx_repetitions_habit_timestamp on Repetitions(
habit, timestamp);
insert into Repetitions select * from RepetitionsBak;
diff --git a/uhabits-core/src/test/java/org/isoron/uhabits/core/utils/DateUtilsTest.java b/uhabits-core/src/test/java/org/isoron/uhabits/core/utils/DateUtilsTest.java
index 57358649a..ca6a3e73a 100644
--- a/uhabits-core/src/test/java/org/isoron/uhabits/core/utils/DateUtilsTest.java
+++ b/uhabits-core/src/test/java/org/isoron/uhabits/core/utils/DateUtilsTest.java
@@ -31,6 +31,14 @@
public class DateUtilsTest extends BaseUnitTest
{
+ @Before
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ DateUtils.setFixedLocale(Locale.US);
+ }
+
@Test
public void testFormatHeaderDate()
{