mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Merge tag 'v1.7.3' into dev
1.7.3
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
### 1.7.3 (May 30, 2017)
|
||||||
|
|
||||||
|
* Improve performance of 'sort by score'
|
||||||
|
* Other minor bug fixes
|
||||||
|
|
||||||
### 1.7.2 (May 27, 2017)
|
### 1.7.2 (May 27, 2017)
|
||||||
|
|
||||||
* Fix crash at startup
|
* Fix crash at startup
|
||||||
|
|||||||
1
gradle/wrapper/gradle-wrapper.properties
vendored
1
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -4,3 +4,4 @@ distributionPath=wrapper/dists
|
|||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-4.0-20170417000025+0000-all.zip
|
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-4.0-20170417000025+0000-all.zip
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.support.test.uiautomator.*;
|
|||||||
|
|
||||||
import com.linkedin.android.testbutler.*;
|
import com.linkedin.android.testbutler.*;
|
||||||
|
|
||||||
|
import org.isoron.androidbase.*;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
import static android.support.test.InstrumentationRegistry.*;
|
import static android.support.test.InstrumentationRegistry.*;
|
||||||
@@ -39,8 +40,14 @@ public class BaseUIAutomatorTest
|
|||||||
public void setUp()
|
public void setUp()
|
||||||
{
|
{
|
||||||
TestButler.setup(getTargetContext());
|
TestButler.setup(getTargetContext());
|
||||||
TestButler.verifyAnimationsDisabled(getTargetContext());
|
|
||||||
device = getInstance(getInstrumentation());
|
device = getInstance(getInstrumentation());
|
||||||
|
|
||||||
|
HabitsComponent component = DaggerHabitsComponent
|
||||||
|
.builder()
|
||||||
|
.appModule(new AppModule(getTargetContext()))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HabitsApplication.setComponent(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|||||||
@@ -34,9 +34,8 @@ import org.junit.runner.*;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static android.support.test.espresso.matcher.ViewMatchers.*;
|
||||||
import static org.hamcrest.MatcherAssert.*;
|
import static org.hamcrest.core.IsEqual.*;
|
||||||
import static org.hamcrest.core.IsNot.not;
|
|
||||||
import static org.isoron.uhabits.core.models.Checkmark.*;
|
import static org.isoron.uhabits.core.models.Checkmark.*;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@@ -66,13 +65,14 @@ public class SQLiteRepetitionListTest extends BaseAndroidTest
|
|||||||
public void testAdd()
|
public void testAdd()
|
||||||
{
|
{
|
||||||
RepetitionRecord record = getByTimestamp(today + day);
|
RepetitionRecord record = getByTimestamp(today + day);
|
||||||
assertThat(record, is(nullValue()));
|
assertNull(record);
|
||||||
|
|
||||||
Repetition rep = new Repetition(today + day, CHECKED_EXPLICITLY);
|
Repetition rep = new Repetition(today + day, CHECKED_EXPLICITLY);
|
||||||
habit.getRepetitions().add(rep);
|
habit.getRepetitions().add(rep);
|
||||||
|
|
||||||
record = getByTimestamp(today + day);
|
record = getByTimestamp(today + day);
|
||||||
assertThat(record, is(not(nullValue())));
|
assertNotNull(record);
|
||||||
|
assertThat(record.value, equalTo(CHECKED_EXPLICITLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -91,18 +91,18 @@ public class SQLiteRepetitionListTest extends BaseAndroidTest
|
|||||||
public void testGetByTimestamp()
|
public void testGetByTimestamp()
|
||||||
{
|
{
|
||||||
Repetition rep = repetitions.getByTimestamp(today);
|
Repetition rep = repetitions.getByTimestamp(today);
|
||||||
assertThat(rep, is(not(nullValue())));
|
assertNotNull(rep);
|
||||||
assertThat(rep.getTimestamp(), equalTo(today));
|
assertThat(rep.getTimestamp(), equalTo(today));
|
||||||
|
|
||||||
rep = repetitions.getByTimestamp(today - 2 * day);
|
rep = repetitions.getByTimestamp(today - 2 * day);
|
||||||
assertThat(rep, is(nullValue()));
|
assertNull(rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetOldest()
|
public void testGetOldest()
|
||||||
{
|
{
|
||||||
Repetition rep = repetitions.getOldest();
|
Repetition rep = repetitions.getOldest();
|
||||||
assertThat(rep, is(not(nullValue())));
|
assertNotNull(rep);
|
||||||
assertThat(rep.getTimestamp(), equalTo(today - 120 * day));
|
assertThat(rep.getTimestamp(), equalTo(today - 120 * day));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,20 +111,20 @@ public class SQLiteRepetitionListTest extends BaseAndroidTest
|
|||||||
{
|
{
|
||||||
Habit empty = fixtures.createEmptyHabit();
|
Habit empty = fixtures.createEmptyHabit();
|
||||||
Repetition rep = empty.getRepetitions().getOldest();
|
Repetition rep = empty.getRepetitions().getOldest();
|
||||||
assertThat(rep, is(nullValue()));
|
assertNull(rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemove()
|
public void testRemove()
|
||||||
{
|
{
|
||||||
RepetitionRecord record = getByTimestamp(today);
|
RepetitionRecord record = getByTimestamp(today);
|
||||||
assertThat(record, is(not(nullValue())));
|
assertNotNull(record);
|
||||||
|
|
||||||
Repetition rep = record.toRepetition();
|
Repetition rep = record.toRepetition();
|
||||||
repetitions.remove(rep);
|
repetitions.remove(rep);
|
||||||
|
|
||||||
record = getByTimestamp(today);
|
record = getByTimestamp(today);
|
||||||
assertThat(record, is(nullValue()));
|
assertNull(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
<manifest
|
<manifest
|
||||||
package="org.isoron.uhabits"
|
package="org.isoron.uhabits"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:versionCode="29"
|
android:versionCode="30"
|
||||||
android:versionName="1.7.2">
|
android:versionName="1.7.3">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
|
|
||||||
|
|||||||
@@ -20,24 +20,27 @@
|
|||||||
package org.isoron.uhabits.activities.common.views;
|
package org.isoron.uhabits.activities.common.views;
|
||||||
|
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
|
import android.support.v4.os.*;
|
||||||
|
|
||||||
public class BundleSavedState extends android.support.v4.view.AbsSavedState
|
public class BundleSavedState extends android.support.v4.view.AbsSavedState
|
||||||
{
|
{
|
||||||
public static final Parcelable.Creator<BundleSavedState> CREATOR =
|
public static final Parcelable.Creator<BundleSavedState> CREATOR =
|
||||||
new Parcelable.Creator<BundleSavedState>()
|
ParcelableCompat.newCreator(
|
||||||
{
|
new ParcelableCompatCreatorCallbacks<BundleSavedState>()
|
||||||
@Override
|
|
||||||
public BundleSavedState createFromParcel(Parcel source)
|
|
||||||
{
|
{
|
||||||
return new BundleSavedState(source, getClass().getClassLoader());
|
@Override
|
||||||
}
|
public BundleSavedState createFromParcel(Parcel source,
|
||||||
|
ClassLoader loader)
|
||||||
|
{
|
||||||
|
return new BundleSavedState(source, loader);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BundleSavedState[] newArray(int size)
|
public BundleSavedState[] newArray(int size)
|
||||||
{
|
{
|
||||||
return new BundleSavedState[size];
|
return new BundleSavedState[size];
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
public final Bundle bundle;
|
public final Bundle bundle;
|
||||||
|
|
||||||
@@ -50,7 +53,7 @@ public class BundleSavedState extends android.support.v4.view.AbsSavedState
|
|||||||
public BundleSavedState(Parcel source, ClassLoader loader)
|
public BundleSavedState(Parcel source, ClassLoader loader)
|
||||||
{
|
{
|
||||||
super(source, loader);
|
super(source, loader);
|
||||||
this.bundle = source.readBundle(getClass().getClassLoader());
|
this.bundle = source.readBundle(loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -107,6 +107,12 @@ public abstract class ScrollableChart extends View
|
|||||||
@Override
|
@Override
|
||||||
public void onRestoreInstanceState(Parcelable state)
|
public void onRestoreInstanceState(Parcelable state)
|
||||||
{
|
{
|
||||||
|
if(!(state instanceof BundleSavedState))
|
||||||
|
{
|
||||||
|
super.onRestoreInstanceState(state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BundleSavedState bss = (BundleSavedState) state;
|
BundleSavedState bss = (BundleSavedState) state;
|
||||||
int x = bss.bundle.getInt("x");
|
int x = bss.bundle.getInt("x");
|
||||||
int y = bss.bundle.getInt("y");
|
int y = bss.bundle.getInt("y");
|
||||||
|
|||||||
@@ -155,6 +155,12 @@ public class HabitCardListView extends RecyclerView
|
|||||||
@Override
|
@Override
|
||||||
protected void onRestoreInstanceState(Parcelable state)
|
protected void onRestoreInstanceState(Parcelable state)
|
||||||
{
|
{
|
||||||
|
if(!(state instanceof BundleSavedState))
|
||||||
|
{
|
||||||
|
super.onRestoreInstanceState(state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BundleSavedState bss = (BundleSavedState) state;
|
BundleSavedState bss = (BundleSavedState) state;
|
||||||
dataOffset = bss.bundle.getInt("dataOffset");
|
dataOffset = bss.bundle.getInt("dataOffset");
|
||||||
super.onRestoreInstanceState(bss.getSuperState());
|
super.onRestoreInstanceState(bss.getSuperState());
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ public class SQLiteCheckmarkList extends CheckmarkList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
protected Checkmark getOldestComputed()
|
protected Checkmark getOldestComputed()
|
||||||
{
|
{
|
||||||
check(habit.getId());
|
check(habit.getId());
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class SQLiteRepetitionList extends RepetitionList
|
public class SQLiteRepetitionList extends RepetitionList
|
||||||
{
|
{
|
||||||
|
|
||||||
private final SQLiteUtils<RepetitionRecord> sqlite;
|
private final SQLiteUtils<RepetitionRecord> sqlite;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -45,14 +46,17 @@ public class SQLiteRepetitionList extends RepetitionList
|
|||||||
|
|
||||||
private SQLiteStatement addStatement;
|
private SQLiteStatement addStatement;
|
||||||
|
|
||||||
|
public static final String ADD_QUERY =
|
||||||
|
"insert into repetitions(habit, timestamp, value) " +
|
||||||
|
"values (?,?,?)";
|
||||||
|
|
||||||
public SQLiteRepetitionList(@NonNull Habit habit)
|
public SQLiteRepetitionList(@NonNull Habit habit)
|
||||||
{
|
{
|
||||||
super(habit);
|
super(habit);
|
||||||
sqlite = new SQLiteUtils<>(RepetitionRecord.class);
|
sqlite = new SQLiteUtils<>(RepetitionRecord.class);
|
||||||
|
|
||||||
SQLiteDatabase db = Cache.openDatabase();
|
SQLiteDatabase db = Cache.openDatabase();
|
||||||
String addQuery = "insert into repetitions(habit, timestamp) values (?,?)";
|
addStatement = db.compileStatement(ADD_QUERY);
|
||||||
addStatement = db.compileStatement(addQuery);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,6 +73,7 @@ public class SQLiteRepetitionList extends RepetitionList
|
|||||||
check(habit.getId());
|
check(habit.getId());
|
||||||
addStatement.bindLong(1, habit.getId());
|
addStatement.bindLong(1, habit.getId());
|
||||||
addStatement.bindLong(2, rep.getTimestamp());
|
addStatement.bindLong(2, rep.getTimestamp());
|
||||||
|
addStatement.bindLong(3, rep.getValue());
|
||||||
addStatement.execute();
|
addStatement.execute();
|
||||||
observable.notifyListeners();
|
observable.notifyListeners();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public abstract class CheckmarkList
|
|||||||
Checkmark newest = getNewestComputed();
|
Checkmark newest = getNewestComputed();
|
||||||
Checkmark oldest = getOldestComputed();
|
Checkmark oldest = getOldestComputed();
|
||||||
|
|
||||||
if (newest == null)
|
if (newest == null || oldest == null)
|
||||||
{
|
{
|
||||||
forceRecompute(from, to);
|
forceRecompute(from, to);
|
||||||
}
|
}
|
||||||
@@ -218,6 +218,7 @@ public abstract class CheckmarkList
|
|||||||
*
|
*
|
||||||
* @return oldest checkmark already computed
|
* @return oldest checkmark already computed
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
protected abstract Checkmark getOldestComputed();
|
protected abstract Checkmark getOldestComputed();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -295,5 +296,6 @@ public abstract class CheckmarkList
|
|||||||
*
|
*
|
||||||
* @return newest checkmark already computed
|
* @return newest checkmark already computed
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
protected abstract Checkmark getNewestComputed();
|
protected abstract Checkmark getNewestComputed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public class MemoryCheckmarkList extends CheckmarkList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
protected Checkmark getOldestComputed()
|
protected Checkmark getOldestComputed()
|
||||||
{
|
{
|
||||||
if(list.isEmpty()) return null;
|
if(list.isEmpty()) return null;
|
||||||
@@ -79,6 +80,7 @@ public class MemoryCheckmarkList extends CheckmarkList
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
protected Checkmark getNewestComputed()
|
protected Checkmark getNewestComputed()
|
||||||
{
|
{
|
||||||
if(list.isEmpty()) return null;
|
if(list.isEmpty()) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user