forked from mozilla-mobile/fenix
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #675: Integrate Adjust SDK (for Greenfield flavor)
- Loading branch information
1 parent
c4fe445
commit b9aee25
Showing
8 changed files
with
181 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.fenix | ||
|
||
import android.content.Context | ||
|
||
object AdjustHelper { | ||
fun setupAdjustIfNeeded(context: Context) { | ||
// DEBUG: No Adjust - This class has different implementations for all build types. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.fenix | ||
|
||
import android.app.Activity | ||
import android.app.Application | ||
import android.os.Bundle | ||
import android.text.TextUtils | ||
|
||
import com.adjust.sdk.Adjust | ||
import com.adjust.sdk.AdjustConfig | ||
import com.adjust.sdk.LogLevel | ||
import mozilla.components.service.glean.Glean | ||
|
||
object AdjustHelper { | ||
fun setupAdjustIfNeeded(application: FenixApplication) { | ||
// RELEASE: Enable Adjust - This class has different implementations for all build types. | ||
|
||
if (TextUtils.isEmpty(BuildConfig.ADJUST_TOKEN)) { | ||
throw IllegalStateException("No adjust token defined for release build") | ||
} | ||
|
||
if (!Glean.getUploadEnabled()) { | ||
return | ||
} | ||
|
||
val config = AdjustConfig( | ||
application, | ||
BuildConfig.ADJUST_TOKEN, | ||
AdjustConfig.ENVIRONMENT_PRODUCTION, | ||
true | ||
) | ||
|
||
config.setLogLevel(LogLevel.SUPRESS) | ||
|
||
Adjust.onCreate(config) | ||
|
||
application.registerActivityLifecycleCallbacks(AdjustLifecycleCallbacks()) | ||
} | ||
|
||
private class AdjustLifecycleCallbacks : Application.ActivityLifecycleCallbacks { | ||
override fun onActivityResumed(activity: Activity) { | ||
Adjust.onResume() | ||
} | ||
|
||
override fun onActivityPaused(activity: Activity) { | ||
Adjust.onPause() | ||
} | ||
|
||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle) {} | ||
|
||
override fun onActivityStarted(activity: Activity) {} | ||
|
||
override fun onActivityStopped(activity: Activity) {} | ||
|
||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} | ||
|
||
override fun onActivityDestroyed(activity: Activity) {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters