mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 04:28:35 +00:00
Add initial implementation of calls tab behind a feature flag.
This commit is contained in:
committed by
Greyson Parrelli
parent
d1373d2767
commit
88de0f21e7
@@ -125,6 +125,10 @@ class SelectBuilderPart3(
|
||||
return SelectBuilderPart4b(db, columns, tableName, where, whereArgs, limit)
|
||||
}
|
||||
|
||||
fun limit(limit: Int, offset: Int): SelectBuilderPart4b {
|
||||
return SelectBuilderPart4b(db, columns, tableName, where, whereArgs, "$offset,$limit")
|
||||
}
|
||||
|
||||
fun run(): Cursor {
|
||||
return db.query(
|
||||
SupportSQLiteQueryBuilder
|
||||
@@ -152,6 +156,10 @@ class SelectBuilderPart4a(
|
||||
return SelectBuilderPart5(db, columns, tableName, where, whereArgs, orderBy, limit)
|
||||
}
|
||||
|
||||
fun limit(limit: Int, offset: Int): SelectBuilderPart5 {
|
||||
return SelectBuilderPart5(db, columns, tableName, where, whereArgs, orderBy, "$offset,$limit")
|
||||
}
|
||||
|
||||
fun run(): Cursor {
|
||||
return db.query(
|
||||
SupportSQLiteQueryBuilder
|
||||
|
||||
@@ -394,5 +394,15 @@ object SqlUtil {
|
||||
return Query(query, args.toTypedArray())
|
||||
}
|
||||
|
||||
class Query(val where: String, val whereArgs: Array<String>)
|
||||
class Query(val where: String, val whereArgs: Array<String>) {
|
||||
infix fun and(other: Query): Query {
|
||||
return if (where.isNotEmpty() && other.where.isNotEmpty()) {
|
||||
Query("($where) AND (${other.where})", whereArgs + other.whereArgs)
|
||||
} else if (where.isNotEmpty()) {
|
||||
this
|
||||
} else {
|
||||
other
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,6 +282,16 @@ public final class SqlUtilTest {
|
||||
assertArrayEquals(new String[] { "5", "6" }, output.get(1).getWhereArgs());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aggregateQueries() {
|
||||
SqlUtil.Query q1 = SqlUtil.buildQuery("a = ?", 1);
|
||||
SqlUtil.Query q2 = SqlUtil.buildQuery("b = ?", 2);
|
||||
SqlUtil.Query q3 = q1.and(q2);
|
||||
|
||||
assertEquals("(a = ?) AND (b = ?)", q3.getWhere());
|
||||
assertArrayEquals(new String[]{"1", "2"}, q3.getWhereArgs());
|
||||
}
|
||||
|
||||
private static byte[] hexToBytes(String hex) {
|
||||
try {
|
||||
return Hex.fromStringCondensed(hex);
|
||||
|
||||
Reference in New Issue
Block a user