Skip to content

Commit

Permalink
Candidate for v0.0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobaxter committed May 15, 2020
1 parent 1c1cf9a commit 7908808
Show file tree
Hide file tree
Showing 25 changed files with 262 additions and 294 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Harmony Preferences
[![CircleCI](https://circleci.com/gh/pablobaxter/HarmonyPreferences/tree/master.svg?style=shield)](https://circleci.com/gh/pablobaxter/HarmonyPreferences/tree/master) ![GitHub](https://img.shields.io/github/license/pablobaxter/HarmonyPreferences) [ ![Download](https://api.bintray.com/packages/soaboz/Harmony/com.frybits.harmonyprefs/images/download.svg?version=0.0.1) ](https://bintray.com/soaboz/Harmony/com.frybits.harmonyprefs/0.0.1/link)
[![CircleCI](https://circleci.com/gh/pablobaxter/Harmony/tree/master.svg?style=shield)](https://circleci.com/gh/pablobaxter/Harmony/tree/master)
![GitHub](https://img.shields.io/github/license/pablobaxter/Harmony)
[![Download](https://api.bintray.com/packages/soaboz/Harmony/com.frybits.harmony/images/download.svg?version=0.0.2)](https://bintray.com/soaboz/Harmony/com.frybits.harmony/0.0.2/link)

Working on multiprocess Android apps is a complex undertaking. One of the biggest challenges is managing shared data between the multiple processes. Most solutions rely on one process to be available for another to read the data, which can be quite slow and could potentially lead to ANRs.

Expand All @@ -16,7 +18,7 @@ Harmony is a thread-safe, process-safe, full [`SharedPreferences`](https://devel
## Download
### Gradle
```
implementation 'com.frybits.harmonyprefs:harmony:0.0.1'
implementation 'com.frybits.harmony:harmony:0.0.2'
```

## Usage
Expand All @@ -37,6 +39,14 @@ SharedPreferences prefs = Harmony.getSharedPreferences(context, "PREF_NAME")
Once you have this `SharedPreferences` object, it can be used just like any other `SharedPreferences`. The main difference with `Harmony` is that any changes made to `"PREF_NAME"` using `apply()` or `commit()` is reflected across all processes.

## Change Log
### Version 0.0.2 / 2020-05-15
- Removes `app_name` from the `strings.xml` file
- Restructures library to be under the package `com.frybits.harmony`
instead of `com.frybits.harmonyprefs`
- Renames the `Harmony` class to `HarmonyImpl` and sets class to
private.
- Import of `getHarmonySharedPreferences()` method is now cleaner

### Version 0.0.1 / 2020-05-15
- Initial release!

Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
compileSdkVersion compileSdk_version
buildToolsVersion buildtools_version
defaultConfig {
applicationId "com.frybits.harmonyprefs"
applicationId "com.frybits.harmony.app"
minSdkVersion 16
targetSdkVersion targetSdk_version
versionCode 1
Expand All @@ -33,6 +33,7 @@ android {

dependencies {
implementation project (':library')
// implementation 'com.frybits.harmony:harmony:0.0.2'

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.frybits.harmonyprefs">
package="com.frybits.harmony.app">

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.frybits.harmonyprefs
package com.frybits.harmony.app

/**
* Created by Pablo Baxter (Github: pablobaxter)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.frybits.harmonyprefs
package com.frybits.harmony.app

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import com.frybits.harmonyprefs.test.bulkentry.apply.HarmonyPrefsBulkApplyActivity
import com.frybits.harmonyprefs.test.bulkentry.commit.HarmonyPrefsBulkCommitActivity
import com.frybits.harmonyprefs.test.singleentry.apply.HarmonyPrefsApplyActivity
import com.frybits.harmonyprefs.test.singleentry.commit.HarmonyPrefsCommitActivity
import com.frybits.harmony.app.test.bulkentry.apply.HarmonyPrefsBulkApplyActivity
import com.frybits.harmony.app.test.bulkentry.commit.HarmonyPrefsBulkCommitActivity
import com.frybits.harmony.app.test.singleentry.apply.HarmonyPrefsApplyActivity
import com.frybits.harmony.app.test.singleentry.commit.HarmonyPrefsCommitActivity
import com.tencent.mmkv.MMKV

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.frybits.harmonyprefs.test.bulkentry
package com.frybits.harmony.app.test.bulkentry

import android.app.Service
import android.content.Intent
import android.content.SharedPreferences
import android.os.IBinder
import android.util.Log
import com.frybits.harmonyprefs.ITERATIONS
import com.frybits.harmonyprefs.PREFS_NAME
import com.frybits.harmonyprefs.library.Harmony.Companion.getHarmonySharedPreferences
import com.frybits.harmony.app.ITERATIONS
import com.frybits.harmony.app.PREFS_NAME
import com.frybits.harmony.getHarmonySharedPreferences
import kotlin.system.measureTimeMillis

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.frybits.harmonyprefs.test.bulkentry.apply
package com.frybits.harmony.app.test.bulkentry.apply

import android.content.Intent
import android.content.SharedPreferences
Expand All @@ -9,11 +9,11 @@ import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import androidx.lifecycle.lifecycleScope
import com.frybits.harmonyprefs.ITERATIONS
import com.frybits.harmonyprefs.PREFS_NAME
import com.frybits.harmonyprefs.R
import com.frybits.harmonyprefs.library.Harmony.Companion.getHarmonySharedPreferences
import com.frybits.harmonyprefs.test.bulkentry.HarmonyPrefsBulkReadService
import com.frybits.harmony.app.ITERATIONS
import com.frybits.harmony.app.PREFS_NAME
import com.frybits.harmony.getHarmonySharedPreferences
import com.frybits.harmony.app.R
import com.frybits.harmony.app.test.bulkentry.HarmonyPrefsBulkReadService
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.frybits.harmonyprefs.test.bulkentry.commit
package com.frybits.harmony.app.test.bulkentry.commit

import android.content.Intent
import android.content.SharedPreferences
Expand All @@ -9,11 +9,11 @@ import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import androidx.lifecycle.lifecycleScope
import com.frybits.harmonyprefs.ITERATIONS
import com.frybits.harmonyprefs.PREFS_NAME
import com.frybits.harmonyprefs.R
import com.frybits.harmonyprefs.library.Harmony.Companion.getHarmonySharedPreferences
import com.frybits.harmonyprefs.test.bulkentry.HarmonyPrefsBulkReadService
import com.frybits.harmony.app.ITERATIONS
import com.frybits.harmony.app.PREFS_NAME
import com.frybits.harmony.getHarmonySharedPreferences
import com.frybits.harmony.app.R
import com.frybits.harmony.app.test.bulkentry.HarmonyPrefsBulkReadService
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -80,7 +80,7 @@ class HarmonyPrefsBulkCommitActivity : AppCompatActivity() {
)
}
val measure = measureTimeMillis { editor.commit() }
Log.i("Trial", "${this@HarmonyPrefsBulkCommitActivity::class.java.simpleName}: Time to apply $ITERATIONS items: $measure ms")
Log.i("Trial", "${this@HarmonyPrefsBulkCommitActivity::class.java.simpleName}: Time to bulk commit $ITERATIONS items: $measure ms")
delay(17) // Give it about the time it takes for a single frame render at 60hz
startService(Intent(this@HarmonyPrefsBulkCommitActivity, HarmonyPrefsBulkReadService::class.java).apply { putExtra("START", true) })
startService(Intent(this@HarmonyPrefsBulkCommitActivity, HarmonyPrefsBulkReadService::class.java).apply { putExtra("STOP", true) })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.frybits.harmonyprefs.test.singleentry
package com.frybits.harmony.app.test.singleentry

import android.app.Service
import android.content.Intent
import android.content.SharedPreferences
import android.os.IBinder
import android.os.SystemClock
import android.util.Log
import com.frybits.harmonyprefs.ITERATIONS
import com.frybits.harmonyprefs.PREFS_NAME
import com.frybits.harmonyprefs.library.Harmony.Companion.getHarmonySharedPreferences
import com.frybits.harmony.app.ITERATIONS
import com.frybits.harmony.app.PREFS_NAME
import com.frybits.harmony.getHarmonySharedPreferences
import kotlin.system.measureTimeMillis

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.frybits.harmonyprefs.test.singleentry.apply
package com.frybits.harmony.app.test.singleentry.apply

import android.content.Intent
import android.content.SharedPreferences
Expand All @@ -9,11 +9,11 @@ import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import androidx.lifecycle.lifecycleScope
import com.frybits.harmonyprefs.ITERATIONS
import com.frybits.harmonyprefs.PREFS_NAME
import com.frybits.harmonyprefs.R
import com.frybits.harmonyprefs.library.Harmony.Companion.getHarmonySharedPreferences
import com.frybits.harmonyprefs.test.singleentry.HarmonyPrefsReceiveService
import com.frybits.harmony.app.ITERATIONS
import com.frybits.harmony.app.PREFS_NAME
import com.frybits.harmony.app.R
import com.frybits.harmony.app.test.singleentry.HarmonyPrefsReceiveService
import com.frybits.harmony.getHarmonySharedPreferences
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.frybits.harmonyprefs.test.singleentry.commit
package com.frybits.harmony.app.test.singleentry.commit

import android.content.Intent
import android.content.SharedPreferences
Expand All @@ -9,11 +9,11 @@ import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import androidx.lifecycle.lifecycleScope
import com.frybits.harmonyprefs.ITERATIONS
import com.frybits.harmonyprefs.PREFS_NAME
import com.frybits.harmonyprefs.R
import com.frybits.harmonyprefs.library.Harmony.Companion.getHarmonySharedPreferences
import com.frybits.harmonyprefs.test.singleentry.HarmonyPrefsReceiveService
import com.frybits.harmony.app.ITERATIONS
import com.frybits.harmony.app.PREFS_NAME
import com.frybits.harmony.getHarmonySharedPreferences
import com.frybits.harmony.app.R
import com.frybits.harmony.app.test.singleentry.HarmonyPrefsReceiveService
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
Expand Down
17 changes: 0 additions & 17 deletions app/src/test/java/com/frybits/harmonyprefs/ExampleUnitTest.kt

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ buildscript {
targetSdk_version = 29
buildtools_version = '29.0.2'

version_name = "0.0.1"
version_name = "0.0.2"
}
repositories {
google()
Expand Down
10 changes: 5 additions & 5 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ afterEvaluate {
from components.release

// You can then customize attributes of the publication as shown below.
groupId = 'com.frybits.harmonyprefs'
groupId = 'com.frybits.harmony'
artifactId = 'harmony'
version = version_name

Expand All @@ -100,7 +100,7 @@ afterEvaluate {

pom.withXml { pom ->
def root = asNode()
root.appendNode('name', 'HarmonyPreferences')
root.appendNode('name', 'Harmony')
root.appendNode('description', 'A process-safe SharedPreferences implementation')
def license = root.appendNode('licenses').appendNode('license')
license.appendNode('name', 'MIT License')
Expand Down Expand Up @@ -140,11 +140,11 @@ bintray {

pkg {
repo = 'Harmony' // the name of the repository you created on Bintray
name = 'com.frybits.harmonyprefs' // the name of the package you created inside it
name = 'com.frybits.harmony' // the name of the package you created inside it
desc = 'A process-safe SharedPreferences implementation'
licenses = ['MIT']
vcsUrl = 'https://github.com/pablobaxter/HarmonyPreferences.git'
githubRepo = 'pablobaxter/HarmonyPreferences' //Optional Github repository
vcsUrl = 'https://github.com/pablobaxter/Harmony.git'
githubRepo = 'pablobaxter/Harmony' //Optional Github repository
version {
name = version_name
released = new Date()
Expand Down
4 changes: 2 additions & 2 deletions library/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.frybits.harmonyprefs.library"
<manifest package="com.frybits.harmony"
xmlns:android="http://schemas.android.com/apk/res/android">
<instrumentation
android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.frybits.harmonyprefs.library"
android:targetPackage="com.frybits.harmony"
android:targetProcesses="*">
<meta-data
android:name="remoteMethod"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.frybits.harmonyprefs.library
package com.frybits.harmony

import android.content.SharedPreferences
import androidx.core.content.edit
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.frybits.harmonyprefs.library.Harmony.Companion.getHarmonySharedPreferences
import com.frybits.harmony.Harmony.Companion.getHarmonySharedPreferences
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.runBlocking
import org.junit.Before
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.frybits.harmonyprefs.library
package com.frybits.harmony

import android.util.JsonReader
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.frybits.harmonyprefs.library.core.toMap
import com.frybits.harmony.core.toMap
import org.junit.Test
import org.junit.runner.RunWith
import java.io.StringReader
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.frybits.harmonyprefs.library" />
<manifest package="com.frybits.harmony" />
Loading

0 comments on commit 7908808

Please sign in to comment.