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