Skip to content

Commit 5a644f0

Browse files
committed
Merge branch 'hotfix/patches'
2 parents d1c3103 + a9320cd commit 5a644f0

File tree

27 files changed

+1197
-509
lines changed

27 files changed

+1197
-509
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
Change Log
22
===============================================================================
3+
Version 2.1.4 *(2017-01-30)*
4+
----------------------------
5+
* Fixed: Bugs in execution of some scheduled actions (#604, #609)
6+
* Fixed: Multi-currency transactions not exported when format is QIF (#571)
7+
* Fixed: Incorrect date of last export shown in book manager (#615, #617)
8+
* Fixed: Large exports may be reported as successful even if they didn't complete yet (#616)
9+
* Fixed: Custom date range (in reports) does not select correct ending date (#611)
10+
* Fixed: Account color reset when editing an account (#620)
11+
* Fixed: Export to OwnCloud fails if folder already exists
12+
* Fixed: User not notified if export to external target fails
13+
* Improved translations
14+
15+
316
Version 2.1.3 *(2016-10-20)*
417
----------------------------
518
* Fixed: Scheduled exports execute too often or not at all in some cases

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ The following (incomplete list of) people (in no particular order) contributed (
3636
* Felipe Morato <[email protected]>
3737
* Alceu Rodrigues Neto <[email protected]>
3838
* Salama AB <[email protected]>
39+
* Juan Villa <[email protected]>
3940

4041
Please visit https://crowdin.com/project/gnucash-android for a more complete list of translation contributions

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ apply plugin: 'io.fabric'
77

88
def versionMajor = 2
99
def versionMinor = 1
10-
def versionPatch = 3
11-
def versionBuild = 1
10+
def versionPatch = 4
11+
def versionBuild = 2
1212

1313
def buildTime() {
1414
def df = new SimpleDateFormat("yyyyMMdd HH:mm 'UTC'")

app/src/main/java/org/gnucash/android/db/adapter/RecurrenceDbAdapter.java

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@
2020
import android.database.sqlite.SQLiteDatabase;
2121
import android.database.sqlite.SQLiteStatement;
2222
import android.support.annotation.NonNull;
23+
import android.support.annotation.Nullable;
2324

2425
import org.gnucash.android.app.GnuCashApplication;
2526
import org.gnucash.android.model.PeriodType;
2627
import org.gnucash.android.model.Recurrence;
2728

2829
import java.sql.Timestamp;
30+
import java.util.ArrayList;
31+
import java.util.Calendar;
32+
import java.util.Collections;
33+
import java.util.List;
2934

3035
import static org.gnucash.android.db.DatabaseSchema.RecurrenceEntry;
3136

@@ -58,7 +63,7 @@ public Recurrence buildModelInstance(@NonNull Cursor cursor) {
5863
long multiplier = cursor.getLong(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_MULTIPLIER));
5964
String periodStart = cursor.getString(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_PERIOD_START));
6065
String periodEnd = cursor.getString(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_PERIOD_END));
61-
String byDay = cursor.getString(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_BYDAY));
66+
String byDays = cursor.getString(cursor.getColumnIndexOrThrow(RecurrenceEntry.COLUMN_BYDAY));
6267

6368
PeriodType periodType = PeriodType.valueOf(type);
6469
periodType.setMultiplier((int) multiplier);
@@ -67,7 +72,7 @@ public Recurrence buildModelInstance(@NonNull Cursor cursor) {
6772
recurrence.setPeriodStart(Timestamp.valueOf(periodStart));
6873
if (periodEnd != null)
6974
recurrence.setPeriodEnd(Timestamp.valueOf(periodEnd));
70-
recurrence.setByDay(byDay);
75+
recurrence.setByDays(stringToByDays(byDays));
7176

7277
populateBaseModelAttributes(cursor, recurrence);
7378

@@ -79,8 +84,8 @@ public Recurrence buildModelInstance(@NonNull Cursor cursor) {
7984
stmt.clearBindings();
8085
stmt.bindLong(1, recurrence.getPeriodType().getMultiplier());
8186
stmt.bindString(2, recurrence.getPeriodType().name());
82-
if (recurrence.getByDay() != null)
83-
stmt.bindString(3, recurrence.getByDay());
87+
if (!recurrence.getByDays().isEmpty())
88+
stmt.bindString(3, byDaysToString(recurrence.getByDays()));
8489
//recurrence should always have a start date
8590
stmt.bindString(4, recurrence.getPeriodStart().toString());
8691

@@ -90,4 +95,87 @@ public Recurrence buildModelInstance(@NonNull Cursor cursor) {
9095

9196
return stmt;
9297
}
98+
99+
/**
100+
* Converts a list of days of week as Calendar constants to an String for
101+
* storing in the database.
102+
*
103+
* @param byDays list of days of week constants from Calendar
104+
* @return String of days of the week or null if {@code byDays} was empty
105+
*/
106+
private static @NonNull String byDaysToString(@NonNull List<Integer> byDays) {
107+
StringBuilder builder = new StringBuilder();
108+
for (int day : byDays) {
109+
switch (day) {
110+
case Calendar.MONDAY:
111+
builder.append("MO");
112+
break;
113+
case Calendar.TUESDAY:
114+
builder.append("TU");
115+
break;
116+
case Calendar.WEDNESDAY:
117+
builder.append("WE");
118+
break;
119+
case Calendar.THURSDAY:
120+
builder.append("TH");
121+
break;
122+
case Calendar.FRIDAY:
123+
builder.append("FR");
124+
break;
125+
case Calendar.SATURDAY:
126+
builder.append("SA");
127+
break;
128+
case Calendar.SUNDAY:
129+
builder.append("SU");
130+
break;
131+
default:
132+
throw new RuntimeException("bad day of week: " + day);
133+
}
134+
builder.append(",");
135+
}
136+
builder.deleteCharAt(builder.length()-1);
137+
return builder.toString();
138+
}
139+
140+
/**
141+
* Converts a String with the comma-separated days of the week into a
142+
* list of Calendar constants.
143+
*
144+
* @param byDaysString String with comma-separated days fo the week
145+
* @return list of days of the week as Calendar constants.
146+
*/
147+
private static @NonNull List<Integer> stringToByDays(@Nullable String byDaysString) {
148+
if (byDaysString == null)
149+
return Collections.emptyList();
150+
151+
List<Integer> byDaysList = new ArrayList<>();
152+
for (String day : byDaysString.split(",")) {
153+
switch (day) {
154+
case "MO":
155+
byDaysList.add(Calendar.MONDAY);
156+
break;
157+
case "TU":
158+
byDaysList.add(Calendar.TUESDAY);
159+
break;
160+
case "WE":
161+
byDaysList.add(Calendar.WEDNESDAY);
162+
break;
163+
case "TH":
164+
byDaysList.add(Calendar.THURSDAY);
165+
break;
166+
case "FR":
167+
byDaysList.add(Calendar.FRIDAY);
168+
break;
169+
case "SA":
170+
byDaysList.add(Calendar.SATURDAY);
171+
break;
172+
case "SU":
173+
byDaysList.add(Calendar.SUNDAY);
174+
break;
175+
default:
176+
throw new RuntimeException("bad day of week: " + day);
177+
}
178+
}
179+
return byDaysList;
180+
}
93181
}

0 commit comments

Comments
 (0)