Skip to content

Commit

Permalink
Release version 2.2.1 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
arun251 authored Mar 12, 2018
1 parent 39a91dd commit b8a1796
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 90 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@

All notable changes to the LaunchDarkly Android SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [2.2.1] - 2018-03-11
### Changed
- The minimum polling interval is now 5 minutes, and the default event publishing interval is 30 seconds.
- HTTP requests are cached in the app's cache directory.
- The SDK now provides a `consumer-proguard-rules.pro` file containing recommended ProGuard rules.
- Due to a Guava dependency update, we recommend a new ProGuard rule which you may need to add if the rules in `consumer-proguard-rules.pro` are not applied automatically:
```
-dontwarn com.google.errorprone.annotations.**
```

### Fixed
- Restored support for Java 1.7.

## [2.2.0] - 2018-01-25
## Added
- Support for specifying [private user attributes](https://docs.launchdarkly.com/docs/private-user-attributes) in order to prevent user attributes from being sent in analytics events back to LaunchDarkly. See the `allAttributesPrivate` and `setPrivateAttributeNames` methods on `LDConfig.Builder` as well as the `privateX` methods on `LDUser.Builder`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Check out the included example app, or follow things here:
1. Declare this dependency:

```
compile 'com.launchdarkly:launchdarkly-android-client:2.2.0'
compile 'com.launchdarkly:launchdarkly-android-client:2.2.1'
```
1. In your application configure and initialize the client:

Expand Down
8 changes: 3 additions & 5 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

dexOptions {
Expand All @@ -43,9 +42,8 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.google.code.gson:gson:2.8.2"
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation project(path: ':launchdarkly-android-client')
implementation 'com.android.support:multidex:1.0.2'
// Comment the previous line and uncomment this one to depend on the published artifact:
// compile 'com.launchdarkly:launchdarkly-android-client:1.0.1'

Expand Down
202 changes: 141 additions & 61 deletions example/src/main/java/com/launchdarkly/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;

import com.google.gson.JsonNull;
import com.launchdarkly.android.FeatureFlagChangeListener;
import com.launchdarkly.android.LDClient;
import com.launchdarkly.android.LDConfig;
import com.launchdarkly.android.LDUser;
Expand Down Expand Up @@ -59,20 +61,31 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onStop() {
super.onStop();
doSafeClientAction(() -> {
try {
ldClient.close();
} catch (IOException e) {
Log.e(TAG, "Exception when closing LaunchDarkly Client", e);
doSafeClientAction(new LDClientFunction() {
@Override
public void call() {
try {
ldClient.close();
} catch (IOException e) {
Log.e(TAG, "Exception when closing LaunchDarkly Client", e);
}
}
});
}

private void setupFlushButton() {
Button flushButton = findViewById(R.id.flush_button);
flushButton.setOnClickListener((View v) -> {
Log.i(TAG, "flush onClick");
doSafeClientAction(() -> ldClient.flush());
flushButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "flush onClick");
MainActivity.this.doSafeClientAction(new LDClientFunction() {
@Override
public void call() {
ldClient.flush();
}
});
}
});
}

Expand Down Expand Up @@ -100,29 +113,58 @@ private <V> V doSafeClientGet(LDClientGetFunction<V> function) {

private void setupTrackButton() {
Button trackButton = findViewById(R.id.track_button);
trackButton.setOnClickListener(v -> {
Log.i(TAG, "track onClick");
doSafeClientAction(() -> ldClient.track("Android event name"));
trackButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "track onClick");
MainActivity.this.doSafeClientAction(new LDClientFunction() {
@Override
public void call() {
ldClient.track("Android event name");
}
});
}
});
}

private void setupIdentifyButton() {
Button identify = findViewById(R.id.identify_button);
identify.setOnClickListener(v -> {
Log.i(TAG, "identify onClick");
String userKey = ((EditText) findViewById(R.id.userKey_editText)).getText().toString();
LDUser updatedUser = new LDUser.Builder(userKey).build();
doSafeClientAction(() -> ldClient.identify(updatedUser));
identify.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "identify onClick");
String userKey = ((EditText) MainActivity.this.findViewById(R.id.userKey_editText)).getText().toString();
final LDUser updatedUser = new LDUser.Builder(userKey).build();
MainActivity.this.doSafeClientAction(new LDClientFunction() {
@Override
public void call() {
ldClient.identify(updatedUser);
}
});
}
});
}

private void setupOfflineSwitch() {
Switch offlineSwitch = findViewById(R.id.offlineSwitch);
offlineSwitch.setOnCheckedChangeListener((compoundButton, isChecked) -> {
if (isChecked) {
doSafeClientAction(() -> ldClient.setOffline());
} else {
doSafeClientAction(() -> ldClient.setOnline());
offlineSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked) {
MainActivity.this.doSafeClientAction(new LDClientFunction() {
@Override
public void call() {
ldClient.setOffline();
}
});
} else {
MainActivity.this.doSafeClientAction(new LDClientFunction() {
@Override
public void call() {
ldClient.setOnline();
}
});
}
}
});
}
Expand All @@ -135,46 +177,84 @@ private void setupEval() {
spinner.setAdapter(adapter);

Button evalButton = findViewById(R.id.eval_button);
evalButton.setOnClickListener((View v) -> {
Log.i(TAG, "eval onClick");
final String flagKey = ((EditText) findViewById(R.id.feature_flag_key)).getText().toString();

String type = spinner.getSelectedItem().toString();
final String result;
String logResult = "no result";
switch (type) {
case "String":
result = doSafeClientGet(() -> ldClient.stringVariation(flagKey, "default"));
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) findViewById(R.id.result_textView)).setText(result);
doSafeClientAction(() -> ldClient.registerFeatureFlagListener(flagKey, flagKey1 -> ((TextView) findViewById(R.id.result_textView))
.setText(ldClient.stringVariation(flagKey1, "default"))));
break;
case "Boolean":
result = doSafeClientGet(() -> ldClient.boolVariation(flagKey, false).toString());
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) findViewById(R.id.result_textView)).setText(result);
break;
case "Integer":
result = doSafeClientGet(() -> ldClient.intVariation(flagKey, 0).toString());
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) findViewById(R.id.result_textView)).setText(result);
break;
case "Float":
result = doSafeClientGet(() -> ldClient.floatVariation(flagKey, 0F).toString());
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) findViewById(R.id.result_textView)).setText(result);
break;
case "Json":
result = doSafeClientGet(() -> ldClient.jsonVariation(flagKey, JsonNull.INSTANCE).toString());
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) findViewById(R.id.result_textView)).setText(result);
break;
evalButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, "eval onClick");
final String flagKey = ((EditText) MainActivity.this.findViewById(R.id.feature_flag_key)).getText().toString();

String type = spinner.getSelectedItem().toString();
final String result;
String logResult;
switch (type) {
case "String":
result = MainActivity.this.doSafeClientGet(new LDClientGetFunction<String>() {
@Override
public String get() {
return ldClient.stringVariation(flagKey, "default");
}
});
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) MainActivity.this.findViewById(R.id.result_textView)).setText(result);
MainActivity.this.doSafeClientAction(new LDClientFunction() {
@Override
public void call() {
ldClient.registerFeatureFlagListener(flagKey, new FeatureFlagChangeListener() {
@Override
public void onFeatureFlagChange(String flagKey1) {
((TextView) MainActivity.this.findViewById(R.id.result_textView))
.setText(ldClient.stringVariation(flagKey1, "default"));
}
});
}
});
break;
case "Boolean":
result = MainActivity.this.doSafeClientGet(new LDClientGetFunction<String>() {
@Override
public String get() {
return ldClient.boolVariation(flagKey, false).toString();
}
});
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) MainActivity.this.findViewById(R.id.result_textView)).setText(result);
break;
case "Integer":
result = MainActivity.this.doSafeClientGet(new LDClientGetFunction<String>() {
@Override
public String get() {
return ldClient.intVariation(flagKey, 0).toString();
}
});
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) MainActivity.this.findViewById(R.id.result_textView)).setText(result);
break;
case "Float":
result = MainActivity.this.doSafeClientGet(new LDClientGetFunction<String>() {
@Override
public String get() {
return ldClient.floatVariation(flagKey, 0F).toString();
}
});
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) MainActivity.this.findViewById(R.id.result_textView)).setText(result);
break;
case "Json":
result = MainActivity.this.doSafeClientGet(new LDClientGetFunction<String>() {
@Override
public String get() {
return ldClient.jsonVariation(flagKey, JsonNull.INSTANCE).toString();
}
});
logResult = result == null ? "no result" : result;
Log.i(TAG, logResult);
((TextView) MainActivity.this.findViewById(R.id.result_textView)).setText(result);
break;
}
}
});
}
Expand Down
14 changes: 7 additions & 7 deletions launchdarkly-android-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ apply plugin: 'io.codearte.nexus-staging'

allprojects {
group = 'com.launchdarkly'
version = '2.2.0'
version = '2.2.1'
sourceCompatibility = 1.7
targetCompatibility = 1.7
}

gradle.projectsEvaluated {
Expand All @@ -27,7 +29,7 @@ android {
versionCode 1
versionName version
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
consumerProguardFiles 'consumer-proguard-rules.pro'
}
lintOptions {
// TODO: fix things and set this to true
Expand All @@ -39,8 +41,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

packagingOptions {
Expand All @@ -65,12 +67,11 @@ ext {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleDependency
implementation 'com.google.guava:guava:20.0'
implementation 'com.google.guava:guava:22.0-android'
implementation 'com.noveogroup.android:android-logger:1.3.5'
implementation "com.google.code.gson:gson:$gsonVersion"
implementation "com.launchdarkly:okhttp-eventsource:$eventsourceVersion"
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation 'com.android.support:multidex:1.0.2'

androidTestImplementation "com.android.support:appcompat-v7:$supportVersion"
androidTestImplementation "com.android.support:support-annotations:$supportVersion"
Expand All @@ -80,7 +81,6 @@ dependencies {
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation 'org.easymock:easymock:3.4'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support:multidex:1.0.2'

javadocDeps "com.google.code.gson:gson:$gsonVersion"
javadocDeps "com.squareup.okhttp3:okhttp:$okhttpVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
-dontwarn java.lang.ClassValue
-dontwarn com.google.j2objc.annotations.Weak
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

-dontwarn com.google.errorprone.annotations.**
Loading

0 comments on commit b8a1796

Please sign in to comment.