Skip to content

Commit

Permalink
Merge branch 'dev' into llunak/custom_snooze
Browse files Browse the repository at this point in the history
  • Loading branch information
iSoron committed Sep 28, 2017
2 parents e970473 + e052a14 commit 223b8bc
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions uhabits-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
<string name="pure_black_description">Replaces gray backgrounds with pure black in night mode. Reduces battery usage in phones with AMOLED display.</string>
<string name="interface_preferences">Interface</string>
<string name="reverse_days">Reverse order of days</string>
<string name="reverse_days_description">Show days in reverse order on the main screen</string>
<string name="reverse_days_description">Show days in reverse order on the main screen.</string>

<string name="day">Day</string>
<string name="week">Week</string>
Expand All @@ -191,8 +191,8 @@

<string name="sticky_notifications">Make notifications sticky</string>
<string name="sticky_notifications_description">Prevents notifications from being swiped away.</string>
<string name="led_notifications">LED</string>
<string name="led_notifications_description">Notifications blinking light.</string>
<string name="led_notifications">Notification light</string>
<string name="led_notifications_description">Shows a blinking light for reminders. Only available in phones with LED notification lights.</string>
<string name="repair_database">Repair database</string>
<string name="database_repaired">Database repaired.</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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);
}

Expand All @@ -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)
{
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion uhabits-core/src/main/resources/migrations/22.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 223b8bc

Please sign in to comment.