-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/develop'
- Loading branch information
Showing
30 changed files
with
291 additions
and
132 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
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
12 changes: 6 additions & 6 deletions
12
app/src/main/java/com/telex/analytics/FirebaseAnalyticsReporter.kt
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package com.telex.analytics | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import com.google.firebase.analytics.FirebaseAnalytics | ||
import com.google.firebase.analytics.ktx.analytics | ||
import com.google.firebase.ktx.Firebase | ||
import com.telex.base.analytics.AnalyticsReporter | ||
|
||
/** | ||
* @author Sergey Petrov | ||
*/ | ||
class FirebaseAnalyticsReporter( | ||
private val context: Context | ||
) : AnalyticsReporter { | ||
class FirebaseAnalyticsReporter : AnalyticsReporter { | ||
|
||
private val firebaseAnalytics = Firebase.analytics | ||
|
||
override fun logEvent(eventKey: String) { | ||
FirebaseAnalytics.getInstance(context).logEvent(eventKey, Bundle()) | ||
firebaseAnalytics.logEvent(eventKey, Bundle()) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
package com.telex.di | ||
|
||
import android.content.Context | ||
import com.telex.analytics.FirebaseAnalyticsReporter | ||
import com.telex.base.analytics.AnalyticsReporter | ||
import com.telex.base.model.interactors.RemoteConfigInteractor | ||
import com.telex.base.model.source.local.AppData | ||
import com.telex.base.review.AppReviewManager | ||
import com.telex.model.interactors.FirebaseRemoteConfigInteractor | ||
import com.telex.review.InAppReviewManager | ||
import toothpick.config.Module | ||
|
||
class AppToolsModule(context: Context) : Module() { | ||
init { | ||
val appData = AppData(context) | ||
bind(AppData::class.java).toInstance(appData) | ||
|
||
val analyticsReporter = FirebaseAnalyticsReporter() | ||
bind(AnalyticsReporter::class.java).toInstance(analyticsReporter) | ||
bind(RemoteConfigInteractor::class.java).toInstance(FirebaseRemoteConfigInteractor()) | ||
|
||
val appReviewManager = InAppReviewManager(context, appData) | ||
bind(AppReviewManager::class.java).toInstance(appReviewManager) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
package com.telex.review | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import com.google.android.play.core.review.ReviewManagerFactory | ||
import com.telex.base.analytics.AnalyticsHelper | ||
import com.telex.base.model.source.local.AppData | ||
import com.telex.base.review.AppReviewManager | ||
import io.reactivex.Completable | ||
import java.lang.ref.WeakReference | ||
import java.util.concurrent.TimeUnit | ||
import javax.inject.Singleton | ||
|
||
/** | ||
* @author Sergey Petrov | ||
*/ | ||
private val APP_REVIEW_REQUEST_INTERVAL = TimeUnit.DAYS.toMillis(60) // 2 months | ||
|
||
@Singleton | ||
class InAppReviewManager constructor( | ||
private val context: Context, | ||
private val appData: AppData | ||
) : AppReviewManager { | ||
|
||
override fun tryRequestAppReview(activity: Activity): Completable { | ||
val activityReference = WeakReference(activity) | ||
return Completable.create { emitter -> | ||
if (needRequestAppReview()) { | ||
val reviewManager = ReviewManagerFactory.create(context) | ||
val requestReviewFlow = reviewManager.requestReviewFlow() | ||
|
||
AnalyticsHelper.logAppReviewRequested() | ||
appData.putLastAppReviewRequestTime(System.currentTimeMillis()) | ||
|
||
requestReviewFlow.addOnCompleteListener { request -> | ||
when { | ||
request.isSuccessful -> { | ||
activityReference.get()?.apply { | ||
reviewManager.launchReviewFlow(this, request.result) | ||
.addOnCompleteListener { | ||
emitter.onComplete() | ||
}.addOnFailureListener { emitter.tryOnError(it) } | ||
} ?: emitter.onComplete() | ||
} | ||
else -> { | ||
emitter.onComplete() | ||
} | ||
} | ||
}.addOnFailureListener { emitter.tryOnError(it) } | ||
} else emitter.onComplete() | ||
} | ||
} | ||
|
||
override fun trackAuthorizedAppLaunch() { | ||
appData.putAuthorizedAppLaunch(appData.getAuthorizedAppLaunch() + 1) | ||
} | ||
|
||
private fun needRequestAppReview(): Boolean { | ||
return appData.getAuthorizedAppLaunch() % 10 == 0 && | ||
System.currentTimeMillis() - appData.getLastAppReviewRequestTime() > APP_REVIEW_REQUEST_INTERVAL | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
package com.telex.base.di | ||
|
||
import android.content.Context | ||
import com.telex.base.analytics.AnalyticsReporter | ||
import com.telex.base.analytics.DefaultAnalyticsReporter | ||
import com.telex.base.model.interactors.DefaultRemoteConfigInteractor | ||
import com.telex.base.model.interactors.RemoteConfigInteractor | ||
import com.telex.base.model.source.local.AppData | ||
import com.telex.base.review.AppReviewManager | ||
import com.telex.base.review.DefaultAppReviewManager | ||
import toothpick.config.Module | ||
|
||
class AppToolsModule(context: Context) : Module() { | ||
init { | ||
val appData = AppData(context) | ||
bind(AppData::class.java).toInstance(appData) | ||
|
||
bind(AnalyticsReporter::class.java).toInstance(DefaultAnalyticsReporter()) | ||
bind(RemoteConfigInteractor::class.java).toInstance(DefaultRemoteConfigInteractor()) | ||
bind(AppReviewManager::class.java).toInstance(DefaultAppReviewManager()) | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
base/src/main/java/com/telex/base/di/RemoteConfigModule.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.