diff options
author | Allan Wang <me@allanwang.ca> | 2017-09-24 16:39:26 -0400 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-09-24 16:39:26 -0400 |
commit | 38d7b144cdf96f7e079a38ace7f9ece25694592d (patch) | |
tree | 0b88644f3bfacc0ae882c2dd1551e09623a0cd18 /app/src/main/kotlin | |
parent | b2967e539e21e3f3e57f7848a397c9f94ef6a54d (diff) | |
parent | 251e697e8e3a17370359273c5fcf7cc2a9f33912 (diff) | |
download | frost-38d7b144cdf96f7e079a38ace7f9ece25694592d.tar.gz frost-38d7b144cdf96f7e079a38ace7f9ece25694592d.tar.bz2 frost-38d7b144cdf96f7e079a38ace7f9ece25694592d.zip |
Merge
Diffstat (limited to 'app/src/main/kotlin')
6 files changed, 26 insertions, 41 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt index 53480f86..14ee3904 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt @@ -117,7 +117,7 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract, if (BuildConfig.VERSION_CODE > Prefs.versionCode) { Prefs.versionCode = BuildConfig.VERSION_CODE if (!BuildConfig.DEBUG) { - showChangelog(R.xml.frost_changelog, Prefs.textColor) { theme() } + frostChangelog() frostAnswersCustom("Version", "Version code" to BuildConfig.VERSION_CODE, "Version name" to BuildConfig.VERSION_NAME, diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt index c51b6fe5..0e0599bf 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt @@ -14,7 +14,6 @@ import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder import ca.allanwang.kau.kpref.activity.items.KPrefItemBase import ca.allanwang.kau.ui.views.RippleCanvas import ca.allanwang.kau.utils.* -import ca.allanwang.kau.xml.showChangelog import com.mikepenz.community_material_typeface_library.CommunityMaterial import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.pitchedapps.frost.BuildConfig @@ -72,7 +71,7 @@ class SettingsActivity : KPrefActivity(), FrostBilling by IABSettings() { accentColor = { Prefs.accentColor } } - override fun onCreateKPrefs(savedInstanceState: android.os.Bundle?): KPrefAdapterBuilder.() -> Unit = { + override fun onCreateKPrefs(savedInstanceState: Bundle?): KPrefAdapterBuilder.() -> Unit = { subItems(R.string.appearance, getAppearancePrefs()) { descRes = R.string.appearance_desc iicon = GoogleMaterial.Icon.gmd_palette @@ -180,7 +179,7 @@ class SettingsActivity : KPrefActivity(), FrostBilling by IABSettings() { items(Support.values().map { string(it.title) }) itemsCallback { _, _, which, _ -> Support.values()[which].sendEmail(this@SettingsActivity) } } - R.id.action_changelog -> showChangelog(R.xml.frost_changelog, Prefs.textColor) { theme() } + R.id.action_changelog -> frostChangelog() else -> return super.onOptionsItemSelected(item) } return true diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt index cf935360..3155b11a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt @@ -39,7 +39,7 @@ enum class CssAssets(val folder: String = "themes") : InjectorContract { .replace("\$BT\$", bt) .replace("\$BBT\$", Prefs.bgColor.withAlpha(51).colorToForeground(0.35f).toRgbaString()) .replace("\$O\$", Prefs.bgColor.withAlpha(255).toRgbaString()) - .replace("\$OO\$", Prefs.bgColor.colorToForeground(0.35f).withAlpha(255).toRgbaString()) + .replace("\$OO\$", Prefs.bgColor.withAlpha(255).colorToForeground(0.35f).toRgbaString()) .replace("\$D\$", Prefs.textColor.adjustAlpha(0.3f).toRgbaString()) } injector = JsBuilder().css(content).build() 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 e5e1a706..aeddd20c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -16,6 +16,7 @@ import android.widget.TextView import ca.allanwang.kau.mediapicker.createMediaFile import ca.allanwang.kau.mediapicker.createPrivateMediaFile import ca.allanwang.kau.utils.* +import ca.allanwang.kau.xml.showChangelog import com.afollestad.materialdialogs.MaterialDialog import com.bumptech.glide.RequestBuilder import com.bumptech.glide.load.resource.bitmap.CircleCrop @@ -197,3 +198,12 @@ fun Context.resolveActivityForUri(uri: Uri): Boolean { inline val String?.isFacebookUrl get() = this != null && this.contains(FACEBOOK_COM) +fun Context.frostChangelog() = showChangelog(R.xml.frost_changelog, Prefs.textColor) { + theme() + if (System.currentTimeMillis() - Prefs.installDate > 2592000000) { //show after 1 month + neutralText(R.string.kau_rate) + onNeutral { _, _ -> startPlayStoreLink(R.string.play_store_package_id) } + } +} + + diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt index e997731b..8ddb46d2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt @@ -78,44 +78,14 @@ fun Activity.playStorePurchaseUnsupported() { } } -fun Activity.playStoreProNotAvailable() { - L.d("Pro query; store not available") - materialDialogThemed { - title(R.string.uh_oh) - content(R.string.play_store_not_found_pro_query) - positiveText(R.string.kau_ok) - neutralText(R.string.kau_play_store) - onNeutral { _, _ -> startPlayStoreLink(R.string.play_store_package_id) } - } -} - -fun Activity.playStoreGenericError(text: String? = "Store generic error") { - if (text != null) playStoreLog("IAB: $text") - materialDialogThemed { - title(R.string.uh_oh) - content(R.string.play_store_billing_error) - positiveText(R.string.kau_ok) - } -} - -fun Activity.playStoreAlreadyPurchased(key: String) { - L.d("Play store already purchased $key") - materialDialogThemed { - title(R.string.play_already_purchased) - content(String.format(string(R.string.play_already_purchased_content), key)) - positiveText(R.string.reload) - dismissListener { - this@playStoreAlreadyPurchased.playRestart() - } - } -} - fun Activity.playStorePurchasedSuccessfully(key: String) { L.d("Play store purchased $key successfully") materialDialogThemed { title(R.string.play_thank_you) content(R.string.play_purchased_pro) positiveText(R.string.kau_ok) + neutralText(R.string.kau_rate) + onNeutral { _, _ -> startPlayStoreLink(R.string.play_store_package_id) } } } @@ -123,7 +93,7 @@ fun Activity.purchaseRestored() { L.d("Purchase restored") materialDialogThemed { title(R.string.play_thank_you) - content(R.string.play_purchased_pro) + content(R.string.purchases_restored_with_pro) positiveText(R.string.kau_ok) } }
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt index c398469c..31aaaa6f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -50,7 +50,6 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient refreshObservable.onNext(true) } - fun launchLogin(c: Context) { if (c is MainActivity && c.cookies().isNotEmpty()) c.launchNewTask(SelectorActivity::class.java, c.cookies()) @@ -58,8 +57,15 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient c.launchNewTask(LoginActivity::class.java) } - private fun injectBackgroundColor() - = webCore.setBackgroundColor(if (isMain) Color.TRANSPARENT else Prefs.bgColor.withAlpha(255)) + private fun injectBackgroundColor() { + webCore.setBackgroundColor( + when { + isMain -> Color.TRANSPARENT + webCore.url.isFacebookUrl -> Prefs.bgColor.withAlpha(255) + else -> Color.WHITE + } + ) + } override fun onPageCommitVisible(view: WebView, url: String?) { |