diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
5 files changed, 57 insertions, 11 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt index ab86724e..9b41d454 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -6,6 +6,7 @@ import ca.allanwang.kau.kpref.StringSet import ca.allanwang.kau.kpref.kpref import ca.allanwang.kau.utils.isColorVisibleOn import ca.allanwang.kau.utils.lazyResettable +import com.pitchedapps.frost.facebook.FeedSort import com.pitchedapps.frost.injectors.InjectorContract /** @@ -23,11 +24,11 @@ object Prefs : KPref() { var theme: Int by kpref("theme", 0, postSetter = { _: Int -> loader.invalidate() }) - var customTextColor: Int by kpref("color_text", Color.BLACK) + var customTextColor: Int by kpref("color_text", Color.WHITE) - var customBackgroundColor: Int by kpref("color_bg", 0xfffafafa.toInt()) + var customBackgroundColor: Int by kpref("color_bg", 0xff37474f.toInt()) - var customHeaderColor: Int by kpref("color_header", 0xff3b5998.toInt()) + var customHeaderColor: Int by kpref("color_header", 0xff039be5.toInt()) var customIconColor: Int by kpref("color_icons", Color.WHITE) @@ -69,6 +70,10 @@ object Prefs : KPref() { val frostId: String get() = "${installDate}-${identifier}" + var tintNavBar: Boolean by kpref("tint_nav_bar", true) + + var feedSort: Int by kpref("feed_sort", FeedSort.DEFAULT.ordinal) + var showRoundedIcons: Boolean by kpref("rounded_icons", true) var showSuggestedFriends: Boolean by kpref("suggested_friends_feed", true) @@ -81,4 +86,8 @@ object Prefs : KPref() { //check if this is the first time launching the web overlay; show snackbar if true var firstWebOverlay: Boolean by kpref("first_web_overlay", true) + + var previouslyPro: Boolean by kpref("previously_pro", false) + + var debugPro: Boolean by kpref("debug_pro", false) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt index 7535eaa2..b4162a66 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt @@ -1,6 +1,7 @@ package com.pitchedapps.frost.utils import android.graphics.Color +import android.support.annotation.StringRes import com.pitchedapps.frost.R import com.pitchedapps.frost.injectors.CssAssets import com.pitchedapps.frost.injectors.InjectorContract @@ -9,7 +10,7 @@ import com.pitchedapps.frost.injectors.JsActions /** * Created by Allan Wang on 2017-06-14. */ -enum class Theme(val textRes: Int, val injector: InjectorContract, +enum class Theme(@StringRes val textRes: Int, val injector: InjectorContract, private val textColorGetter: () -> Int, private val backgroundColorGetter: () -> Int, private val headerColorGetter: () -> Int, private val iconColorGetter: () -> Int) { DEFAULT(R.string.kau_default, JsActions.EMPTY, { Color.BLACK }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 9322af3f..3fe33475 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -163,4 +163,8 @@ fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) } show() } +} + +fun Activity.frostNavigationBar() { + navigationBarColor = if (Prefs.tintNavBar) Prefs.headerColor else Color.BLACK }
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt index 007611c5..11fa1c4b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt @@ -7,10 +7,7 @@ import ca.allanwang.kau.utils.startPlayStoreLink import com.crashlytics.android.answers.PurchaseEvent import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.R -import com.pitchedapps.frost.utils.L -import com.pitchedapps.frost.utils.frostAnswers -import com.pitchedapps.frost.utils.frostAnswersCustom -import com.pitchedapps.frost.utils.materialDialogThemed +import com.pitchedapps.frost.utils.* import org.jetbrains.anko.doAsync /** @@ -38,8 +35,10 @@ object IAB { } } -val Context.isFrostPro: Boolean - get() = BuildConfig.DEBUG || isFromGooglePlay +private const val FROST_PRO = "frost_pro" + +val IS_FROST_PRO: Boolean + get() = (BuildConfig.DEBUG && Prefs.debugPro) || (IAB.helper?.queryInventory()?.getSkuDetails(FROST_PRO) != null) private fun Context.checkFromPlay(): Boolean { val isPlay = isFromGooglePlay @@ -53,7 +52,7 @@ private fun Context.checkFromPlay(): Boolean { return isPlay } -fun Activity.openPlayProPurchase(code: Int) = openPlayPurchase("frost_pro", code) +fun Activity.openPlayProPurchase(code: Int) = openPlayPurchase(FROST_PRO, code) fun Activity.openPlayPurchase(key: String, code: Int) { if (!checkFromPlay()) return diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/Key.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/Key.kt new file mode 100644 index 00000000..a21d8670 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/Key.kt @@ -0,0 +1,33 @@ +package com.pitchedapps.frost.utils.iab + +/** + * Created by Allan Wang on 2017-06-23. + * + * NOTE + * + * Since this is an open source project and all other components are essentially public, + * I have decided to add the keys here too; + * they can be reverse engineered relatively easily since they are constants anyways. + * This is the public billing key from the play store + */ +private const val play_key_1 = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgyTZS" +private const val play_key_2 = "K9Bd3ALpr9KJUsVGczP9CcPelWkdnJfNrrzu1EztJyrHRsGQ4" +private const val play_key_3 = "QVWY9NZwc6Nrk9qdJlEdr8AJAxJ+JiwUqsj3/TxxUYm/G7q8Z" +private const val play_key_4 = "7zo8jSkYZyzqwoAl2PDx2kleI4sZLkhCRLyE6dGQEZQmvJ6kk" +private const val play_key_5 = "W12Gz3FagAM5luRGsoWZj40pJItUrGJA9euMWq4rMhVZv4mVk" +private const val play_key_6 = "KFJB9/vhF/XGz7txpYlFxMESzXuKsbEDKmKCHzvySLq8Ki4N9" +private const val play_key_7 = "DzbgUiw+VzA2KpSVp66JH3GEU8egO8i9SvAWeCPikuolooRVh" +private const val play_key_8 = "jwfBV7gDxZztoLuvmQU6kXvCwRnRa+mkfUnBKKLkH1QIDAQAB" + +internal val PUBLIC_BILLING_KEY: String by lazy { + StringBuilder() + .append(play_key_1) + .append(play_key_2) + .append(play_key_3) + .append(play_key_4) + .append(play_key_5) + .append(play_key_6) + .append(play_key_7) + .append(play_key_8) + .toString() +}
\ No newline at end of file |