Skip to content

Commit

Permalink
Merge branch 'next-major'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
cmelchior committed Mar 14, 2018
2 parents 69ba73d + 09a7dc2 commit 383208f
Show file tree
Hide file tree
Showing 116 changed files with 5,084 additions and 914 deletions.
30 changes: 29 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
## 4.4.1 (YYY-MM-DD)
## 5.0.0 (YYYY-MM-DD)

This release is compatible with the Realm Object Server 3.0.0-beta.3 or later.

### Known Bugs

* API's marked @ObjectServer are shipped as part of the base binary, they should only be available when enabling synchronized Realms.

### Breaking Changes

* [ObjectServer] Renamed `SyncUser.currentUser()` to `SyncUser.current()`.
* [ObjectServer] Renamed `SyncUser.login(...)` and `SyncUser.loginAsync(...)` to `SyncUser.logIn(...)` and `SyncUser.logInAsync(...)`.
* [ObjectServer] Renamed `SyncUser.logout()` to `SyncUser.logOut()`.
* The `OrderedCollectionChangeSet` parameter in `OrderedRealmCollectionChangeListener.onChange()` is no longer nullable. Use `changeSet.getState()` instead (#5619).
* `realm.subscribeForObjects()` have been removed. Use `RealmQuery.findAllAsync(String subscriptionName)` and `RealmQuery.findAllAsync()` instead.
* Removed previously deprecated `RealmQuery.findAllSorted()`, `RealmQuery.findAllSortedAsync()` `RealmQuery.distinct() and `RealmQuery.distinctAsync()`.
* Renamed `RealmQuery.distinctValues()` to `RealmQuery.distinct()`

### Enhancements

* [ObjectServer] Added support for partial Realms. Read [here](https://realm.io/docs/java/latest/#partial-realms) for more information.
* [ObjectServer] Added support for Object Level Permissions (requires partial synchronized Realms). Read [here](https://realm.io/docs/java/latest/#partial-realms) for more information.
* [ObjectServer] Added `SyncConfiguration.automatic()` and `SyncConfiguration.automatic(SyncUser user)` (#5806).
* Added two new methods to `OrderedCollectionChangeSet`: `getState()` and `getError()` (#5619).

## Bug Fixes

* Better exception message if a non model class is provided to methods only accepting those (#5779).

### Internal

* Upgraded to Realm Sync 3.0.0
* Upgraded to Realm Core 5.3.0


## 4.4.0 (2018-03-13)

Expand Down
8 changes: 5 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ try {
// on PR's for even more throughput.
def ABIs = ""
def instrumentationTestTarget = "connectedAndroidTest"
if (!['master'].contains(env.BRANCH_NAME)) {
if (!['master', 'next-major'].contains(env.BRANCH_NAME)) {
ABIs = "armeabi-v7a"
instrumentationTestTarget = "connectedObjectServerDebugAndroidTest" // Run in debug more for better error reporting
}
Expand Down Expand Up @@ -118,11 +118,13 @@ try {

// TODO: add support for running monkey on the example apps

if (env.BRANCH_NAME == 'master') {
if (['master'].contains(env.BRANCH_NAME)) {
stage('Collect metrics') {
collectAarMetrics()
}
}

if (['master', 'next-major'].contains(env.BRANCH_NAME)) {
stage('Publish to OJO') {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'bintray', passwordVariable: 'BINTRAY_KEY', usernameVariable: 'BINTRAY_USER']]) {
sh "chmod +x gradlew && ./gradlew -PbintrayUser=${env.BINTRAY_USER} -PbintrayKey=${env.BINTRAY_KEY} assemble ojoUpload --stacktrace"
Expand All @@ -145,7 +147,7 @@ try {
buildSuccess = false
throw e
} finally {
if (['master', 'releases'].contains(env.BRANCH_NAME) && !buildSuccess) {
if (['master', 'releases', 'next-major'].contains(env.BRANCH_NAME) && !buildSuccess) {
node {
withCredentials([[$class: 'StringBinding', credentialsId: 'slack-java-url', variable: 'SLACK_URL']]) {
def payload = JsonOutput.toJson([
Expand Down
7 changes: 3 additions & 4 deletions dependencies.list
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Realm Sync Core release used by Realm Java
# https://github.com/realm/realm-sync/releases
REALM_SYNC_VERSION=2.2.9
REALM_SYNC_SHA256=d770d639d2b187c15e6d0bc798b909f5b424d61444f1f83f9e56f5be43e96afc
REALM_SYNC_VERSION=3.0.0
REALM_SYNC_SHA256=9141177ccc92d8f9282625dace61eee5c3d971d2daca7593266e175b610a24cf

# Object Server Release used by Integration tests. Installed using NPM.
# Use `npm view realm-object-server versions` to get a list of available versions.
REALM_OBJECT_SERVER_DE_VERSION=2.6.0

REALM_OBJECT_SERVER_DE_VERSION=3.0.0-rc.1
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void execute(Realm realm) {
}

// Sorting
RealmResults<Person> sortedPersons = realm.where(Person.class).findAllSorted("age", Sort.DESCENDING);
RealmResults<Person> sortedPersons = realm.where(Person.class).sort("age", Sort.DESCENDING).findAll();
status += "\nSorting " + sortedPersons.last().getName() + " == " + realm.where(Person.class).findFirst()
.getName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class KotlinExampleActivity : Activity() {
}

// Sorting
val sortedPersons = realm.where<Person>().findAllSorted(Person::age.name, Sort.DESCENDING)
val sortedPersons = realm.where<Person>().sort(Person::age.name, Sort.DESCENDING).findAll()
status += "\nSorting ${sortedPersons.last()?.name} == ${realm.where<Person>().findAll().first()?.name}"

} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public Flowable<RealmResults<NYTimesStory>> loadNewsFeed(@NonNull String section
// save data in Realm
return realm.where(NYTimesStory.class)
.equalTo(NYTimesStory.API_SECTION, sectionKey)
.findAllSortedAsync(NYTimesStory.PUBLISHED_DATE, Sort.DESCENDING)
.sort(NYTimesStory.PUBLISHED_DATE, Sort.DESCENDING)
.findAllAsync()
.asFlowable();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_logout:
closeRealm();
user.logout();
user.logOut();
user = getLoggedInUser();
return true;

Expand Down Expand Up @@ -198,7 +198,7 @@ public void execute(@Nonnull Realm realm) {
private SyncUser getLoggedInUser() {
SyncUser user = null;

try { user = SyncUser.currentUser(); }
try { user = SyncUser.current(); }
catch (IllegalStateException ignore) { }

if (user == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void onError(@Nonnull ObjectServerError error) {
}
};

SyncUser.loginAsync(creds, REALM_AUTH_URL, callback);
SyncUser.logInAsync(creds, REALM_AUTH_URL, callback);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ protected void onResume() {

// Trigger updates
realm.executeTransaction(r ->
r.where(Person.class).findAllSorted( "name", Sort.ASCENDING).get(0).setAge(new Random().nextInt(100)));
r.where(Person.class).sort( "name", Sort.ASCENDING).findAll().get(0).setAge(new Random().nextInt(100)));
}

/**
* Shows how to be careful with `subscribeOn()`
*/
private void testSubscribeOn() {
Disposable subscribeOnDisposable = realm.asFlowable()
.map(realm -> realm.where(Person.class).findAllSorted("name").get(0))
.map(realm -> realm.where(Person.class).sort("name").findAll().get(0))
// The Realm was created on the UI thread. Accessing it on `Schedulers.io()` will crash.
// Avoid using subscribeOn() and use Realms `findAllAsync*()` methods instead.
.subscribeOn(Schedulers.io()) //
Expand All @@ -90,7 +90,7 @@ private void testSubscribeOn() {
compositeDisposable.add(subscribeOnDisposable);

// Use Realms Async API instead
Disposable asyncSubscribeOnDisposable = realm.where(Person.class).findAllSortedAsync("name").get(0).<Person>asFlowable()
Disposable asyncSubscribeOnDisposable = realm.where(Person.class).sort("name").findAllAsync().get(0).<Person>asFlowable()
.subscribe(
person -> showStatus("subscribeOn/async: " + person.getName() + ":" + person.getAge()),
throwable -> showStatus("subscribeOn/async: " +throwable.toString())
Expand All @@ -103,7 +103,7 @@ private void testSubscribeOn() {
*/
private void testBuffer() {
Flowable<Person> personFlowable =
realm.asFlowable().map(realm -> realm.where(Person.class).findAllSorted("name").get(0));
realm.asFlowable().map(realm -> realm.where(Person.class).sort("name").findAll().get(0));

// buffer() caches objects until the buffer is full. Due to Realms auto-update of all objects it means
// that all objects in the cache will contain the same data.
Expand All @@ -122,7 +122,7 @@ private void testBuffer() {
*/
private void testDistinct() {
Flowable<Person> personFlowable =
realm.asFlowable().map(realm -> realm.where(Person.class).findAllSorted("name").get(0));
realm.asFlowable().map(realm -> realm.where(Person.class).sort("name").findAll().get(0));

// distinct() and distinctUntilChanged() uses standard equals with older objects stored in a HashMap.
// Realm objects auto-update which means the objects stored will also auto-update.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected void onResume() {
super.onResume();

// Load all persons and merge them with their latest stats from GitHub (if they have any)
disposable = realm.where(Person.class).isNotNull("githubUserName").findAllSortedAsync("name").asFlowable()
disposable = realm.where(Person.class).isNotNull("githubUserName").sort("name").findAllAsync().asFlowable()
// We only want the list once it is loaded.
.filter(people -> people.isLoaded())
.switchMap(people -> Flowable.fromIterable(people))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ protected void onResume() {
// Realm currently doesn't support the standard Schedulers.
return realm.where(Person.class)
.beginsWith("name", textChangeEvent.text().toString())
.findAllSortedAsync("name")
.sort("name")
.findAllAsync()
.asFlowable();
})
// Only continue once data is actually loaded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void buildSyncConf() {
final String urlAuth = "http://objectserver.realm.io:9080/auth";
final String url = "realm://objectserver.realm.io/default";

SyncUser.loginAsync(credentials, urlAuth, new SyncUser.Callback<SyncUser>() {
SyncUser.logInAsync(credentials, urlAuth, new SyncUser.Callback<SyncUser>() {
@Override
public void onSuccess(SyncUser user) {
SyncConfiguration secureConfig = new SyncConfiguration.Builder(user, url).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ public void onStart() {
allSortedDots = realm.where(Dot.class)
.between("x", 25, 75)
.between("y", 0, 50)
.findAllSortedAsync(
.sort(
"x", Sort.ASCENDING,
"y", Sort.DESCENDING
);
)
.findAllAsync();
dotAdapter.updateList(allSortedDots);
allSortedDots.addChangeListener(this);
}
Expand Down
15 changes: 15 additions & 0 deletions realm/config/findbugs/findbugs-filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,20 @@
<Match>
<Class name="io.realm.io_realm_permissions_PermissionRealmProxy"/>
</Match>
<Match>
<Class name="io.realm.io_realm_sync_permissions_ClassPermissionsRealmProxy"/>
</Match>
<Match>
<Class name="io.realm.io_realm_sync_permissions_RealmPermissionsRealmProxy"/>
</Match>
<Match>
<Class name="io.realm.io_realm_sync_permissions_PermissionRealmProxy"/>
</Match>
<Match>
<Class name="io.realm.io_realm_sync_permissions_RoleRealmProxy"/>
</Match>
<Match>
<Class name="io.realm.io_realm_sync_permissions_PermissionUserRealmProxy"/>
</Match>

</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,13 @@ public static String getReferencedTypeInternalClassNameStatement(String qualifie
}

// If we cannot find the name in the current processor round, we have to defer resolving the
// name to runtime. The reason being that proxy classes in libraries on the classpath
// might already have been obfuscated, which means we have no easy way of finding them.
//
// name to runtime. The reason being that the annotation processor can only access the
// compile type class path using Elements and Types which do not allow us to read
// field values.
//
// Doing it this way unfortunately means that if the class is not on the apps classpath
// a rather obscure class-not-found exception will be thrown, but since this is probably
// a very niche use case that is acceptable for now.
// a rather obscure class-not-found exception will be thrown when starting the app, but since
// this is probably a very niche use case that is acceptable for now.
//
// TODO: We could probably create an internal annotation like `@InternalName("__Permission")`
// which should make it possible for the annotation processor to read the value from the
Expand Down
12 changes: 10 additions & 2 deletions realm/realm-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ android {
debug {
// FIXME: If enabled, crashes with https://issuetracker.google.com/issues/37116868
testCoverageEnabled = false
// minifyEnabled = true;
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

release {
// minifyEnabled = true;
}
}

Expand Down Expand Up @@ -132,7 +138,8 @@ android {
arguments "-DREALM_FLAVOR=base"
}
}
consumerProguardFiles 'proguard-rules-common.pro', 'proguard-rules-base.pro'
consumerProguardFiles 'proguard-rules-consumer-common.pro', 'proguard-rules-consumer-base.pro'
proguardFiles 'proguard-rules-build-common.pro'
}
objectServer {
dimension 'api'
Expand All @@ -141,7 +148,8 @@ android {
arguments "-DREALM_FLAVOR=objectServer"
}
}
consumerProguardFiles 'proguard-rules-common.pro', 'proguard-rules-objectServer.pro'
consumerProguardFiles 'proguard-rules-consumer-common.pro', 'proguard-rules-consumer-objectServer.pro'
proguardFiles 'proguard-rules-build-common.pro', 'proguard-rules-build-objectServer.pro'
}
}

Expand Down
2 changes: 2 additions & 0 deletions realm/realm-library/proguard-rules-build-common.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Common proguard configuration for building the Base and ObjectServer variants
# Note: This is for _building the Realm library, not for consuming it.
2 changes: 2 additions & 0 deletions realm/realm-library/proguard-rules-build-objectServer.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Proguard configuration specific for building the ObjectServer variant.
# Note: This is for _building the Realm library, not for consuming it.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# It's OK not to exist SyncObjectServerFacade in base library.
-dontnote io.realm.internal.SyncObjectServerFacade

Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void typedQueryWithJavaNames() {
.equalTo("camelCase", "foo") // Java name in model class
.equalTo("parents.PascalCase", 1) // Backlinks also uses java names
.sort("mHungarian") // Sorting uses Java names
.distinctValues("customName") // Distinct uses Java names
.distinct("customName") // Distinct uses Java names
.findAll();
assertTrue(results.isEmpty());
}
Expand All @@ -142,7 +142,7 @@ public void typedQueryWithInternalNamesThrows() {

// Distinct
try {
realm.where(ClassWithPolicy.class).distinctValues(ClassWithPolicy.FIELD_CAMEL_CASE);
realm.where(ClassWithPolicy.class).distinct(ClassWithPolicy.FIELD_CAMEL_CASE);
} catch (IllegalArgumentException ignore) {
}

Expand All @@ -156,7 +156,7 @@ public void dynamicQueryWithInternalNames() {
RealmResults<DynamicRealmObject> results = dynamicRealm.where(ClassWithPolicy.CLASS_NAME)
.equalTo(ClassWithPolicy.FIELD_CAMEL_CASE, "foo") // Normal queries use internal names
.sort(ClassWithPolicy.FIELD_M_HUNGARIAN) // Sorting uses internal names
.distinctValues(ClassWithPolicy.FIELD_CUSTOM_NAME) // Distinct uses internal names
.distinct(ClassWithPolicy.FIELD_CUSTOM_NAME) // Distinct uses internal names
.findAll();
assertTrue(results.isEmpty());
}
Expand All @@ -176,7 +176,7 @@ public void dynamicQueryWithJavaNamesThrows() {

// Distinct
try {
dynamicRealm.where(ClassWithPolicy.CLASS_NAME).distinctValues("camelCase");
dynamicRealm.where(ClassWithPolicy.CLASS_NAME).distinct("camelCase");
} catch (IllegalArgumentException ignore) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ public void query_multipleReferencesWithDistinct() {

assertEquals(2, child.getListParents().size());

RealmResults<AllJavaTypes> distinctParents = child.getListParents().where().distinctValues("fieldId").findAll();
RealmResults<AllJavaTypes> distinctParents = child.getListParents().where().distinct("fieldId").findAll();
assertEquals(1, distinctParents.size());
assertTrue(child.getListParents().contains(parent));
}
Expand Down
Loading

0 comments on commit 383208f

Please sign in to comment.