-
Notifications
You must be signed in to change notification settings - Fork 24
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
75 changed files
with
2,074 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "966913976495", | ||
"firebase_url": "https://browser-e3b83.firebaseio.com", | ||
"project_id": "browser-e3b83", | ||
"storage_bucket": "browser-e3b83.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:966913976495:android:7f07c0d7905eb43b", | ||
"android_client_info": { | ||
"package_name": "com.mercandalli.android.browser" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "966913976495-sfk9eeao7js481r57ijv0adfp4pcc0ve.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyDy9zFmaVwBHij08mOuoKLBuI8e461EswA" | ||
} | ||
], | ||
"services": { | ||
"analytics_service": { | ||
"status": 1 | ||
}, | ||
"appinvite_service": { | ||
"status": 1, | ||
"other_platform_oauth_client": [] | ||
}, | ||
"ads_service": { | ||
"status": 2 | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
16 changes: 0 additions & 16 deletions
16
app/src/main/java/com/mercandalli/android/browser/ad_blocker/AdBloackerModule.kt
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
23 changes: 15 additions & 8 deletions
23
app/src/main/java/com/mercandalli/android/browser/ad_blocker/AdBlockerManagerImpl.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,35 +1,42 @@ | ||
package com.mercandalli.android.browser.ad_blocker | ||
|
||
import android.content.SharedPreferences | ||
import com.mercandalli.android.browser.product.ProductManager | ||
|
||
class AdBlockerManagerImpl( | ||
private val sharedPreferences: SharedPreferences | ||
private val sharedPreferences: SharedPreferences, | ||
private val productManager: ProductManager | ||
) : AdBlockerManager { | ||
|
||
private var enabled = false | ||
private var enabledLoaded = false | ||
private var loaded = false | ||
|
||
override fun isFeatureAvailable() = productManager.isFullVersionAvailable() | ||
|
||
override fun isEnabled(): Boolean { | ||
if (!isFeatureAvailable()) { | ||
return false | ||
} | ||
load() | ||
return enabled | ||
} | ||
|
||
override fun setEnabled(enabled: Boolean) { | ||
this.enabled = enabled | ||
sharedPreferences.edit().putBoolean(KEY, enabled).apply() | ||
sharedPreferences.edit().putBoolean(KEY_ENABLED, this.enabled).apply() | ||
} | ||
|
||
private fun load() { | ||
if (enabledLoaded) { | ||
if (loaded) { | ||
return | ||
} | ||
enabledLoaded = true | ||
enabled = sharedPreferences.getBoolean(KEY, enabled) | ||
loaded = true | ||
enabled = sharedPreferences.getBoolean(KEY_ENABLED, enabled) | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
val PREFERENCE_NAME = "AdBlockerManager" | ||
private const val KEY = "ad-blocker-enabled" | ||
val PREFERENCE_NAME = "ad-blocker" | ||
private const val KEY_ENABLED = "enabled" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/mercandalli/android/browser/ad_blocker/AdBlockerModule.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,21 @@ | ||
package com.mercandalli.android.browser.ad_blocker | ||
|
||
import android.content.Context | ||
import com.mercandalli.android.browser.main.ApplicationGraph | ||
|
||
class AdBlockerModule( | ||
private val context: Context | ||
) { | ||
|
||
fun createAdBlockerManager(): AdBlockerManager { | ||
val sharedPreferences = context.getSharedPreferences( | ||
AdBlockerManagerImpl.PREFERENCE_NAME, | ||
Context.MODE_PRIVATE | ||
) | ||
val productManager = ApplicationGraph.getProductManager() | ||
return AdBlockerManagerImpl( | ||
sharedPreferences, | ||
productManager | ||
) | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/mercandalli/android/browser/product/ProductManager.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,8 @@ | ||
package com.mercandalli.android.browser.product | ||
|
||
interface ProductManager { | ||
|
||
fun isFullVersionAvailable(): Boolean | ||
|
||
fun isSubscribeToFullVersion(): Boolean | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/mercandalli/android/browser/product/ProductManagerImpl.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,15 @@ | ||
package com.mercandalli.android.browser.product | ||
|
||
import com.mercandalli.android.browser.main.MainApplication | ||
import com.mercandalli.android.browser.remote_config.RemoteConfig | ||
import com.mercandalli.android.libs.monetization.in_app.InAppManager | ||
|
||
class ProductManagerImpl( | ||
private val remoteConfig: RemoteConfig, | ||
private val inAppManager: InAppManager | ||
) : ProductManager { | ||
|
||
override fun isFullVersionAvailable() = remoteConfig.isFullVersionAvailable | ||
|
||
override fun isSubscribeToFullVersion() = inAppManager.isPurchased(MainApplication.SKU_SUBSCRIPTION_FULL_VERSION) | ||
} |
Oops, something went wrong.