diff --git a/dependencies.list b/dependencies.list index 650cf73151..158b7666eb 100644 --- a/dependencies.list +++ b/dependencies.list @@ -15,13 +15,13 @@ REALM_BAAS_GIT_HASH=7ba774ab4740e892f701870b4afc6a2c9c682202 REALM_BAAS_UI_GIT_HASH=50bd2bb1d78a8a6ab04202aaa2f50350882b0fe2 # Common Android settings across projects -GRADLE_BUILD_TOOLS=7.4.0 +GRADLE_BUILD_TOOLS=8.0.0 ANDROID_BUILD_TOOLS=30.0.3 KOTLIN=1.6.21 KOTLIN_COROUTINES=1.6.0 # Common classpath dependencies -gradle=7.5 +gradle=8.0 ndkVersion=23.1.7779620 BUILD_INFO_EXTRACTOR_GRADLE=4.17.0 GRADLE_NEXUS_PLUGIN=1.0.0 diff --git a/examples/architectureComponentsExample/build.gradle b/examples/architectureComponentsExample/build.gradle index 20b28d2df4..2e6d7d9b84 100644 --- a/examples/architectureComponentsExample/build.gradle +++ b/examples/architectureComponentsExample/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'realm-android' android { + namespace 'io.realm.examples.arch' compileSdkVersion rootProject.sdkVersion buildToolsVersion rootProject.buildTools diff --git a/examples/compatibilityExample/build.gradle b/examples/compatibilityExample/build.gradle index b74adf0233..8f264a24b3 100644 --- a/examples/compatibilityExample/build.gradle +++ b/examples/compatibilityExample/build.gradle @@ -5,6 +5,7 @@ apply plugin: 'kotlin-android-extensions' apply plugin: 'realm-android' android { + namespace 'io.realm.examples.compatibility' compileSdkVersion rootProject.sdkVersion buildToolsVersion rootProject.buildTools diff --git a/examples/coroutinesExample/build.gradle b/examples/coroutinesExample/build.gradle index 4e909277c9..21557286ee 100644 --- a/examples/coroutinesExample/build.gradle +++ b/examples/coroutinesExample/build.gradle @@ -5,6 +5,7 @@ apply plugin: 'kotlin-kapt' apply plugin: 'realm-android' android { + namespace "io.realm.examples.coroutinesexample" // androidx.lifecycle dependencies requires Android APIs 31 or later compileSdkVersion 31 buildToolsVersion rootProject.buildTools diff --git a/examples/coroutinesExample/src/main/java/io/realm/examples/coroutinesexample/MainActivity.kt b/examples/coroutinesExample/src/main/java/io/realm/examples/coroutinesexample/MainActivity.kt index 7c0fceb194..b10bafbd56 100644 --- a/examples/coroutinesExample/src/main/java/io/realm/examples/coroutinesexample/MainActivity.kt +++ b/examples/coroutinesExample/src/main/java/io/realm/examples/coroutinesexample/MainActivity.kt @@ -57,7 +57,7 @@ class MainActivity : AppCompatActivity(), MainFragment.OnItemClicked { val detailsFragment = DetailsFragment.instantiate(DetailsFragment.ArgsBundle(id)) supportFragmentManager.commit { - setCustomAnimations(R.anim.fragment_open_enter, R.anim.fragment_open_exit) +// setCustomAnimations(R.anim.fragment_open_enter, R.anim.fragment_open_exit) add(R.id.container, detailsFragment, DetailsFragment.TAG) hide(requireNotNull(mainFragment)) addToBackStack(null) diff --git a/examples/encryptionExample/build.gradle b/examples/encryptionExample/build.gradle index 10707b22ae..0eb5be3ac7 100644 --- a/examples/encryptionExample/build.gradle +++ b/examples/encryptionExample/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'realm-android' android { + namespace 'io.realm.examples.encryption' compileSdkVersion rootProject.sdkVersion buildToolsVersion rootProject.buildTools diff --git a/examples/gradle.properties b/examples/gradle.properties index d45755e9bc..c9eff8b86a 100644 --- a/examples/gradle.properties +++ b/examples/gradle.properties @@ -1,6 +1,5 @@ org.gradle.jvmargs=-Xmx2048M -XX:MaxMetaspaceSize=1024M org.gradle.caching=true -android.enableD8=true # Gradle sync failed: Due to a limitation of Gradle’s new variant-aware dependency management, loading the Android Gradle plugin in different class loaders leads to a build error. # This can occur when the buildscript classpaths that contain the Android Gradle plugin in sub-projects, or included projects in the case of composite builds, are set differently. @@ -13,3 +12,4 @@ android.enableBuildScriptClasspathCheck=false # See https://developer.android.com/studio/build/optimize-your-build#configuration_on_demand org.gradle.configureondemand=false android.useAndroidX=true +android.defaults.buildfeatures.buildconfig=true diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties index 2ec77e51a9..1f017e4ee9 100644 --- a/examples/gradle/wrapper/gradle-wrapper.properties +++ b/examples/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/gridViewExample/build.gradle b/examples/gridViewExample/build.gradle index 59945d719b..4c644d6cd0 100644 --- a/examples/gridViewExample/build.gradle +++ b/examples/gridViewExample/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'realm-android' android { + namespace 'io.realm.examples.realmgridview' compileSdkVersion rootProject.sdkVersion buildToolsVersion rootProject.buildTools diff --git a/examples/introExample/build.gradle b/examples/introExample/build.gradle index 84188bec37..2503cdfffa 100644 --- a/examples/introExample/build.gradle +++ b/examples/introExample/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'realm-android' android { + namespace 'io.realm.examples.intro' compileSdkVersion rootProject.sdkVersion buildToolsVersion rootProject.buildTools diff --git a/examples/jsonExample/build.gradle b/examples/jsonExample/build.gradle index 5d489e712d..01a7765de2 100644 --- a/examples/jsonExample/build.gradle +++ b/examples/jsonExample/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'realm-android' android { + namespace 'io.realm.examples.json' compileSdkVersion rootProject.sdkVersion buildToolsVersion rootProject.buildTools diff --git a/examples/kotlinExample/build.gradle b/examples/kotlinExample/build.gradle index f4b29cbc0d..8717267693 100644 --- a/examples/kotlinExample/build.gradle +++ b/examples/kotlinExample/build.gradle @@ -4,6 +4,7 @@ apply plugin: 'kotlin-kapt' apply plugin: 'realm-android' android { + namespace 'io.realm.examples.kotlin' //noinspection GroovyAssignabilityCheck compileSdkVersion rootProject.sdkVersion //noinspection GroovyAssignabilityCheck diff --git a/examples/kotlinExample/src/main/kotlin/io/realm/examples/kotlin/model/Person.kt b/examples/kotlinExample/src/main/kotlin/io/realm/examples/kotlin/model/Person.kt index 829fb1b8cd..c8a20bb93d 100644 --- a/examples/kotlinExample/src/main/kotlin/io/realm/examples/kotlin/model/Person.kt +++ b/examples/kotlinExample/src/main/kotlin/io/realm/examples/kotlin/model/Person.kt @@ -31,7 +31,7 @@ open class Person( // If you use non-nullable types, properties must be initialized with non-null values. @PrimaryKey var id: Long = 0, - var name: String = "", + var name: String? = "", var age: Int = 0, diff --git a/examples/migrationExample/build.gradle b/examples/migrationExample/build.gradle index 317d18d44d..628403605a 100644 --- a/examples/migrationExample/build.gradle +++ b/examples/migrationExample/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'realm-android' android { + namespace "examples.realm.io.migration" compileSdkVersion rootProject.sdkVersion buildToolsVersion rootProject.buildTools diff --git a/examples/migrationExample/src/main/AndroidManifest.xml b/examples/migrationExample/src/main/AndroidManifest.xml index 255b3327bc..af37c02382 100644 --- a/examples/migrationExample/src/main/AndroidManifest.xml +++ b/examples/migrationExample/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="examples.realm.io.migration" > dots = realm.where(Dot.class).findAll(); - - for (int i = dots.size() - 1; i >= 0; i--) { - Dot dot = dots.get(i); - if (dot.isValid()) { - int x = dot.getX(); - int y = dot.getY(); - dot.setX(y); - dot.setY(x); - } + if (view.getId() == R.id.translate_button) { + cancelAsyncTransaction(); + // translate all points coordinates using an async transaction + asyncTransaction = realm.executeTransactionAsync(new Realm.Transaction() { + @Override + public void execute(Realm realm) { + // query for all points + RealmResults dots = realm.where(Dot.class).findAll(); + + for (int i = dots.size() - 1; i >= 0; i--) { + Dot dot = dots.get(i); + if (dot.isValid()) { + int x = dot.getX(); + int y = dot.getY(); + dot.setX(y); + dot.setY(x); } } - }, new Realm.Transaction.OnSuccess() { - @Override - public void onSuccess() { - if (isAdded()) { - Toast.makeText(getActivity(), "Translation completed", Toast.LENGTH_SHORT).show(); - } + } + }, new Realm.Transaction.OnSuccess() { + @Override + public void onSuccess() { + if (isAdded()) { + Toast.makeText(getActivity(), "Translation completed", Toast.LENGTH_SHORT).show(); } - }, new Realm.Transaction.OnError() { - - @Override - public void onError(Throwable e) { - if (isAdded()) { - Toast.makeText(getActivity(), "Error while translating dots", Toast.LENGTH_SHORT).show(); - e.printStackTrace(); - } + } + }, new Realm.Transaction.OnError() { + @Override + public void onError(Throwable e) { + if (isAdded()) { + Toast.makeText(getActivity(), "Error while translating dots", Toast.LENGTH_SHORT).show(); + e.printStackTrace(); } - }); - break; - } + } + }); } } diff --git a/examples/threadExample/src/main/java/io/realm/examples/threads/ThreadFragment.java b/examples/threadExample/src/main/java/io/realm/examples/threads/ThreadFragment.java index fc61e0bef6..2e0891e975 100644 --- a/examples/threadExample/src/main/java/io/realm/examples/threads/ThreadFragment.java +++ b/examples/threadExample/src/main/java/io/realm/examples/threads/ThreadFragment.java @@ -32,6 +32,7 @@ import io.realm.RealmChangeListener; import io.realm.examples.threads.model.Dot; import io.realm.examples.threads.widget.DotsView; +import io.realm.examples.threads.R; /** * This fragment demonstrates how Realm can interact with a background thread. @@ -43,6 +44,9 @@ public class ThreadFragment extends Fragment { private Thread backgroundThread; private DotsView dotsView; + private final int actionAdd = R.id.action_add_dot; + private final int actionClear = R.id.action_clear; + // Realm change listener that refreshes the UI when there is changes to Realm. private RealmChangeListener realmListener = new RealmChangeListener() { @Override @@ -72,32 +76,28 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @Override public boolean onOptionsItemSelected(MenuItem item) { - - switch(item.getItemId()) { - case R.id.action_add_dot: - // Add blue dot from the UI thread - realm.executeTransaction(new Realm.Transaction() { - @Override - public void execute(Realm realm) { - Dot dot = realm.createObject(Dot.class); - dot.setX(random.nextInt(100)); - dot.setY(random.nextInt(100)); - dot.setColor(getResources().getColor(R.color.realm_blue)); - } - }); - return true; - - case R.id.action_clear: - realm.executeTransaction(new Realm.Transaction() { - @Override - public void execute(Realm realm) { - realm.delete(Dot.class); - } - }); - return true; - - default: - return super.onOptionsItemSelected(item); + if (item.getItemId() == R.id.action_add_dot) { + // Add blue dot from the UI thread + realm.executeTransaction(new Realm.Transaction() { + @Override + public void execute(Realm realm) { + Dot dot = realm.createObject(Dot.class); + dot.setX(random.nextInt(100)); + dot.setY(random.nextInt(100)); + dot.setColor(getResources().getColor(R.color.realm_blue)); + } + }); + return true; + } else if (item.getItemId() == R.id.action_clear) { + realm.executeTransaction(new Realm.Transaction() { + @Override + public void execute(Realm realm) { + realm.delete(Dot.class); + } + }); + return true; + } else { + return super.onOptionsItemSelected(item); } } diff --git a/examples/unitTestExample/build.gradle b/examples/unitTestExample/build.gradle index f232f87eed..f5844b4a21 100644 --- a/examples/unitTestExample/build.gradle +++ b/examples/unitTestExample/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.application' apply plugin: 'realm-android' android { + namespace 'io.realm.examples.unittesting' compileSdkVersion rootProject.sdkVersion buildToolsVersion rootProject.buildTools