From 7bf93ea74b00ab7e8ceedac2aac6ad08fdf099ab Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 16 Jul 2017 20:23:42 -0700 Subject: Test against proguard and fix minor details (#67) * Reenable enum in proguard rules * Add missing permission and upload to beta * Use kau permission const --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 2 +- .../com/pitchedapps/frost/activities/ImageActivity.kt | 16 ++++++---------- .../main/kotlin/com/pitchedapps/frost/utils/Prefs.kt | 12 +++--------- .../kotlin/com/pitchedapps/frost/utils/iab/IAB.kt | 19 ++++++++++++------- 5 files changed, 23 insertions(+), 28 deletions(-) (limited to 'app') diff --git a/app/build.gradle b/app/build.gradle index 2bd90315..a354d2e9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ apply plugin: 'com.github.triplet.play' play { jsonFile = file('../files/gplay-keys.json') - track = 'alpha' + track = 'beta' errorOnSizeLimit = true uploadImages = false untrackOld = true diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1ae569ed..4135ab59 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,7 +7,7 @@ - + diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt index 509ac2cb..487f3a9d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -85,7 +85,7 @@ class ImageActivity : AppCompatActivity() { setContentView(if (!text.isNullOrBlank()) R.layout.activity_image else R.layout.activity_image_textless) container.setBackgroundColor(Prefs.bgColor.withMinAlpha(222)) caption?.setTextColor(Prefs.textColor) - caption?.setBackgroundColor(Prefs.bgColor.colorToForeground(0.1f).withAlpha(255)) + caption?.setBackgroundColor(Prefs.bgColor.colorToForeground(0.2f).withAlpha(255)) caption?.text = text progress.tint(Prefs.accentColor) panel?.addPanelSlideListener(object : SlidingUpPanelLayout.SimplePanelSlideListener() { @@ -174,16 +174,13 @@ class ImageActivity : AppCompatActivity() { val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date()) val imageFileName = "Frost_" + timeStamp + "_" val storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES) - return File.createTempFile( - imageFileName, /* prefix */ - ".png", /* suffix */ - storageDir /* directory */ - ) + return File.createTempFile(imageFileName, ".png", storageDir) } internal fun downloadImage() { kauRequestPermissions(PERMISSION_WRITE_EXTERNAL_STORAGE) { granted, _ -> + L.d("Download image callback granted: $granted") if (granted) { doAsync { val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date()) @@ -199,6 +196,7 @@ class ImageActivity : AppCompatActivity() { } catch (e: Exception) { success = false } finally { + L.d("Download image async finished: $success") uiThread { snackbar(if (success) R.string.image_download_success else R.string.image_download_fail) if (success) { @@ -230,7 +228,7 @@ class ImageActivity : AppCompatActivity() { } } -internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.textColor, val backgroundTint: Int = Prefs.accentBackgroundColor.withAlpha(255)) { +internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconColor, val backgroundTint: Int = Prefs.iconBackgroundColor.withAlpha(255)) { ERROR(GoogleMaterial.Icon.gmd_error, Color.WHITE, Color.RED) { override fun onClick(activity: ImageActivity) { //todo add something @@ -240,9 +238,7 @@ internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.textC override fun onClick(activity: ImageActivity) {} }, DOWNLOAD(GoogleMaterial.Icon.gmd_file_download) { - override fun onClick(activity: ImageActivity) { - activity.downloadImage() - } + override fun onClick(activity: ImageActivity) = activity.downloadImage() }, SHARE(GoogleMaterial.Icon.gmd_share) { override fun onClick(activity: ImageActivity) { 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 f8c7af56..63e57554 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -65,16 +65,10 @@ object Prefs : KPref() { get() = if (headerColor.isColorVisibleOn(bgColor, 100)) headerColor else textColor /** - * Ensures that the color is visible against both the foreground and background + * Ensures that the color is visible against the background */ - val accentBackgroundColor: Int - get() { - if (headerColor.isColorVisibleOn(textColor, 100)) { - if (headerColor.isColorVisibleOn(bgColor, 100)) return headerColor - else return headerColor.colorToForeground(0.2f) - } - return bgColor.colorToForeground(0.2f) - } + val iconBackgroundColor: Int + get() = if (headerColor.isColorVisibleOn(bgColor)) headerColor else headerColor.colorToForeground(0.2f) val themeInjector: InjectorContract get() = t.injector 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 964e771c..669b2c9e 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 @@ -158,13 +158,18 @@ private fun SettingsActivity.finishRestore(snackbar: Snackbar, hasPro: Boolean) */ fun Activity.validatePro() { L.d("Play Store Validate pro") - getInventory(Prefs.pro, false, { if (Prefs.pro) playStoreNoLongerPro() }) { - inv, helper -> - val proSku = inv.hasPurchase(FROST_PRO) - L.d("Play Store Validation finished: ${Prefs.pro} should be $proSku") - if (!proSku && Prefs.pro) playStoreNoLongerPro() - else if (proSku && !Prefs.pro) playStoreFoundPro() - helper.disposeWhenFinished() + try { + getInventory(Prefs.pro, false, { if (Prefs.pro) playStoreNoLongerPro() }) { + inv, helper -> + val proSku = inv.hasPurchase(FROST_PRO) + L.d("Play Store Validation finished: ${Prefs.pro} should be $proSku") + if (!proSku && Prefs.pro) playStoreNoLongerPro() + else if (proSku && !Prefs.pro) playStoreFoundPro() + IAB.dispose(helper) + } + } catch (e: Exception) { + L.e(e, "Play store validation exception") + IAB.dispose() } } -- cgit v1.2.3