Skip to content

Commit

Permalink
Updating permissions for modules so that the interface is accessible …
Browse files Browse the repository at this point in the history
…from kotlin. Adding kotlin sample file.
  • Loading branch information
ArtursKadikis committed May 13, 2020
1 parent 83c884c commit 0ff064d
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 27 deletions.
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

repositories {
maven {
url "http://dl.bintray.com/countly/maven"
}
mavenCentral()
}

android {
Expand Down Expand Up @@ -46,6 +49,8 @@ dependencies {
androidTestImplementation 'androidx.test:core:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//implementation 'ly.count.android:sdk:19.02.3'
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@
android:host="sample_b" />
</intent-filter>
</activity>
<activity android:name=".ActivityExampleKotlin" />

<service android:name="org.openudid.OpenUDID_service" android:exported="false">
<service android:name="org.openudid.OpenUDID_service" android:exported="false">
<intent-filter>
<action android:name="org.OpenUDID.GETUDID" />
</intent-filter>
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/java/ly/count/android/demo/ActivityExampleKotlin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ly.count.android.demo

import android.app.Activity
import android.content.res.Configuration
import ly.count.android.sdk.Countly
import ly.count.android.sdk.ModuleAPM

class ActivityExampleKotlin : Activity() {
override fun onStart() {
super.onStart()
Countly.sharedInstance().onStart(this);

Countly.sharedInstance().apm().startTrace("fff");
Countly.sharedInstance().consent().checkAllConsent();
Countly.sharedInstance().crashes().addCrashBreadcrumb("ddd");
Countly.sharedInstance().events().recordEvent("ddd");
val count : Int = Countly.sharedInstance().ratings().getAutomaticStarRatingSessionLimit();
Countly.sharedInstance().remoteConfig().allValues;
Countly.sharedInstance().sessions().beginSession()
Countly.sharedInstance().views().isAutomaticViewTrackingEnabled;

}

override fun onStop() {
Countly.sharedInstance().onStop();
super.onStop()
}

override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig)
Countly.sharedInstance().onConfigurationChanged(newConfig);
}
}
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
ext.kotlin_version = '1.3.72'
repositories {
maven {
url 'https://dl.bintray.com/countly/maven'
}
Expand All @@ -13,8 +14,9 @@ buildscript {
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.google.gms:google-services:4.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/main/java/ly/count/android/sdk/Countly.java
Original file line number Diff line number Diff line change
Expand Up @@ -2479,7 +2479,7 @@ protected boolean anyConsentGiven() {
*
* @param widgetId ID that identifies this dialog
* @return
* @deprecated use 'Countly.sharedInstance().remoteConfig().showFeedbackPopup'
* @deprecated use 'Countly.sharedInstance().ratings().showFeedbackPopup'
*/
public synchronized Countly showFeedbackPopup(final String widgetId, final String closeButtonText, final Activity activity, final CountlyStarRating.FeedbackRatingCallback feedbackCallback) {
if (!isInitialized()) {
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/main/java/ly/count/android/sdk/ModuleAPM.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void calculateAppRunningTimes(int previousCount, int newCount) {
}

@Override
public void halt() {
void halt() {
codeTraces = null;
networkTraces = null;
}
Expand All @@ -348,7 +348,7 @@ public void halt() {
* @param activity
*/
@Override
public void callbackOnActivityResumed(Activity activity) {
void callbackOnActivityResumed(Activity activity) {
if (_cly.isLoggingEnabled()) {
Log.d(Countly.TAG, "[Apm] Calling 'callbackOnActivityResumed', [" + activitiesOpen + "] -> [" + (activitiesOpen + 1) + "]");
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/main/java/ly/count/android/sdk/ModuleConsent.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ModuleConsent extends ModuleBase {
}

@Override
public void halt() {
void halt() {
consentInterface = null;
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/src/main/java/ly/count/android/sdk/ModuleCrash.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class ModuleCrash extends ModuleBase {
public class ModuleCrash extends ModuleBase {
//native crash
private static final String countlyFolderName = "Countly";
private static final String countlyNativeCrashFolderName = "CrashDumps";
Expand Down Expand Up @@ -47,7 +47,7 @@ class ModuleCrash extends ModuleBase {
*
* @param context android context
*/
protected synchronized void checkForNativeCrashDumps(Context context) {
synchronized void checkForNativeCrashDumps(Context context) {
if (_cly.isLoggingEnabled()) {
Log.d(Countly.TAG, "[ModuleCrash] Checking for native crash dumps");
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/main/java/ly/count/android/sdk/ModuleDeviceId.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void changeDeviceIdWithMerge(String deviceId) {
}

@Override
public void halt() {
void halt() {

}
}
4 changes: 2 additions & 2 deletions sdk/src/main/java/ly/count/android/sdk/ModuleEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import java.util.HashMap;
import java.util.Map;

class ModuleEvents extends ModuleBase {
public class ModuleEvents extends ModuleBase {
static final Map<String, Event> timedEvents = new HashMap<>();
static final String[] reservedSegmentationKeys = new String[] { "aaaaaaaaaaaaaaaaaaaaCountly" };//just a test key that no one should realistically use

//interface for SDK users
final Events eventsInterface;

public ModuleEvents(Countly cly, CountlyConfig config) {
ModuleEvents(Countly cly, CountlyConfig config) {
super(cly);

if (_cly.isLoggingEnabled()) {
Expand Down
8 changes: 4 additions & 4 deletions sdk/src/main/java/ly/count/android/sdk/ModuleRatings.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.HashMap;
import java.util.Map;

class ModuleRatings extends ModuleBase {
public class ModuleRatings extends ModuleBase {
static final String STAR_RATING_EVENT_KEY = "[CLY]_star_rating";

//star rating
Expand Down Expand Up @@ -344,7 +344,7 @@ static StarRatingPreferences fromJSON(final JSONObject json) {
* @param context android context
* @param callback
*/
protected void showStarRatingInternal(final Context context, final CountlyStore cs, final StarRatingCallback callback) {
void showStarRatingInternal(final Context context, final CountlyStore cs, final StarRatingCallback callback) {
StarRatingPreferences srp = loadStarRatingPreferences(cs);
showStarRatingCustom(context, srp.dialogTextTitle, srp.dialogTextMessage, srp.dialogTextDismiss, srp.isDialogCancellable, callback);
}
Expand Down Expand Up @@ -383,7 +383,7 @@ static StarRatingPreferences loadStarRatingPreferences(final CountlyStore cs) {
* @param isCancellable
* @param callback
*/
public void showStarRatingCustom(
void showStarRatingCustom(
final Context context,
final String title,
final String message,
Expand Down Expand Up @@ -453,7 +453,7 @@ public void onRatingChanged(RatingBar ratingBar, float v, boolean b) {

/// Countly webDialog user rating

protected static synchronized void showFeedbackPopupInternal(final String widgetId, final String closeButtonText, final Activity activity, final Countly countly, final ConnectionQueue connectionQueue_,
static synchronized void showFeedbackPopupInternal(final String widgetId, final String closeButtonText, final Activity activity, final Countly countly, final ConnectionQueue connectionQueue_,
final FeedbackRatingCallback devCallback) {
if (Countly.sharedInstance().isLoggingEnabled()) {
Log.d(Countly.TAG, "Showing Feedback popup for widget id: [" + widgetId + "]");
Expand Down
16 changes: 8 additions & 8 deletions sdk/src/main/java/ly/count/android/sdk/ModuleRemoteConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.Iterator;
import java.util.Map;

class ModuleRemoteConfig extends ModuleBase {
public class ModuleRemoteConfig extends ModuleBase {
boolean updateRemoteConfigAfterIdChange = false;

RemoteConfig remoteConfigInterface = null;
Expand All @@ -36,7 +36,7 @@ class ModuleRemoteConfig extends ModuleBase {
* @param requestShouldBeDelayed this is set to true in case of update after a deviceId change
* @param callback called after the update is done
*/
protected void updateRemoteConfigValues(final String[] keysOnly, final String[] keysExcept, final ConnectionQueue connectionQueue_, final boolean requestShouldBeDelayed, final RemoteConfigCallback callback) {
void updateRemoteConfigValues(final String[] keysOnly, final String[] keysExcept, final ConnectionQueue connectionQueue_, final boolean requestShouldBeDelayed, final RemoteConfigCallback callback) {
if (Countly.sharedInstance().isLoggingEnabled()) {
Log.d(Countly.TAG, "[ModuleRemoteConfig] Updating remote config values, requestShouldBeDelayed:[" + requestShouldBeDelayed + "]");
}
Expand Down Expand Up @@ -145,35 +145,35 @@ public void callback(JSONObject checkResponse) {
});
}

protected Object getValue(String key) {
Object getValue(String key) {
RemoteConfigValueStore rcvs = loadConfig();
return rcvs.getValue(key);
}

protected void saveConfig(RemoteConfigValueStore rcvs) {
void saveConfig(RemoteConfigValueStore rcvs) {
CountlyStore cs = new CountlyStore(_cly.context_);
cs.setRemoteConfigValues(rcvs.dataToString());
}

protected RemoteConfigValueStore loadConfig() {
RemoteConfigValueStore loadConfig() {
CountlyStore cs = new CountlyStore(_cly.context_);
String rcvsString = cs.getRemoteConfigValues();
//noinspection UnnecessaryLocalVariable
RemoteConfigValueStore rcvs = RemoteConfigValueStore.dataFromString(rcvsString);
return rcvs;
}

protected void clearValueStore() {
void clearValueStore() {
CountlyStore cs = new CountlyStore(_cly.context_);
cs.setRemoteConfigValues("");
}

protected Map<String, Object> getAllRemoteConfigValuesInternal() {
Map<String, Object> getAllRemoteConfigValuesInternal() {
RemoteConfigValueStore rcvs = loadConfig();
return rcvs.getAllValues();
}

protected static class RemoteConfigValueStore {
static class RemoteConfigValueStore {
public JSONObject values = new JSONObject();

//add new values to the current storage
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/main/java/ly/count/android/sdk/ModuleViews.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import java.util.HashMap;
import java.util.Map;

class ModuleViews extends ModuleBase {
public class ModuleViews extends ModuleBase {
private String lastView = null;
private int lastViewStart = 0;
private boolean firstView = true;
final static String VIEW_EVENT_KEY = "[CLY]_view";

Class[] autoTrackingActivityExceptions = null;//excluded activities from automatic view tracking

protected Map<String, Object> automaticViewSegmentation = new HashMap<>();//automatic view segmentation
Map<String, Object> automaticViewSegmentation = new HashMap<>();//automatic view segmentation

//track orientation changes
boolean trackOrientationChanges = false;
Expand All @@ -26,7 +26,7 @@ class ModuleViews extends ModuleBase {
//interface for SDK users
final Views viewsInterface;

public ModuleViews(Countly cly, CountlyConfig config) {
ModuleViews(Countly cly, CountlyConfig config) {
super(cly);

if (_cly.isLoggingEnabled()) {
Expand Down

0 comments on commit 0ff064d

Please sign in to comment.