-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
161 additions
and
32 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 |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
.idea | ||
.DS_Store | ||
local.properties | ||
google-services.json | ||
*.iml | ||
build |
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,24 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application> | ||
|
||
<activity | ||
android:name=".GoogleActivity" | ||
android:screenOrientation="fullSensor" | ||
android:exported="true"> | ||
|
||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
<intent-filter> | ||
<action android:name="com.tananaev.passportreader.REQUEST" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
|
||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
60 changes: 60 additions & 0 deletions
60
app/src/google/java/com/tananaev/passportreader/GoogleActivity.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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.tananaev.passportreader | ||
|
||
import android.os.Bundle | ||
import android.preference.PreferenceManager | ||
import android.widget.FrameLayout | ||
import com.google.android.gms.ads.AdRequest | ||
import com.google.android.gms.ads.AdSize | ||
import com.google.android.gms.ads.AdView | ||
import com.google.android.gms.ads.MobileAds | ||
import com.google.android.play.core.review.ReviewManagerFactory | ||
import com.google.firebase.analytics.FirebaseAnalytics | ||
import com.google.firebase.analytics.ktx.analytics | ||
import com.google.firebase.ktx.Firebase | ||
|
||
class GoogleActivity : MainActivity() { | ||
private lateinit var firebaseAnalytics: FirebaseAnalytics | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
firebaseAnalytics = Firebase.analytics | ||
MobileAds.initialize(this) {} | ||
|
||
val adView = AdView(this).apply { | ||
setAdSize(AdSize.BANNER) | ||
adUnitId = "ca-app-pub-9061647223840223/5869276959" | ||
loadAd(AdRequest.Builder().build()) | ||
} | ||
val params = FrameLayout.LayoutParams( | ||
FrameLayout.LayoutParams.MATCH_PARENT, | ||
FrameLayout.LayoutParams.WRAP_CONTENT, | ||
) | ||
val containerView: FrameLayout = findViewById(R.id.bottom_container) | ||
containerView.addView(adView, params) | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
handleRating() | ||
} | ||
|
||
@Suppress("DEPRECATION") | ||
private fun handleRating() { | ||
val preferences = PreferenceManager.getDefaultSharedPreferences(this) | ||
if (!preferences.getBoolean("ratingShown", false)) { | ||
val openTimes = preferences.getInt("openTimes", 0) + 1 | ||
preferences.edit().putInt("openTimes", openTimes).apply() | ||
if (openTimes >= 5) { | ||
val reviewManager = ReviewManagerFactory.create(this) | ||
reviewManager.requestReviewFlow().addOnCompleteListener { infoTask -> | ||
if (infoTask.isSuccessful) { | ||
val flow = reviewManager.launchReviewFlow(this, infoTask.result) | ||
flow.addOnCompleteListener { | ||
preferences.edit().putBoolean("ratingShown", true).apply() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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 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,24 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application> | ||
|
||
<activity | ||
android:name=".RegularActivity" | ||
android:screenOrientation="fullSensor" | ||
android:exported="true"> | ||
|
||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
<intent-filter> | ||
<action android:name="com.tananaev.passportreader.REQUEST" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
|
||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
3 changes: 3 additions & 0 deletions
3
app/src/regular/java/com/tananaev/passportreader/RegularActivity.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.tananaev.passportreader | ||
|
||
class RegularActivity : MainActivity() |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
org.gradle.jvmargs=-Xmx4096m | ||
android.enableJetifier=true | ||
android.useAndroidX=true |