diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-18 20:25:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-18 20:25:41 -0700 |
commit | f5394badad02671dc0de181ab63b9a9bfbe9fd59 (patch) | |
tree | 0d5af7a805e407a4a7daffa610d3e1d5deea91bd /app | |
parent | ede53aff0ca989881247afead959341818f705b4 (diff) | |
download | frost-f5394badad02671dc0de181ab63b9a9bfbe9fd59.tar.gz frost-f5394badad02671dc0de181ab63b9a9bfbe9fd59.tar.bz2 frost-f5394badad02671dc0de181ab63b9a9bfbe9fd59.zip |
Misc 2 (#191)v1.4.6
* Add further checks for iab and remove generic error dialog
* Theme all snackbars
* Add dynamic media action tile
Diffstat (limited to 'app')
9 files changed, 45 insertions, 26 deletions
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 61554312..9a5f3c6e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -184,7 +184,7 @@ class ImageActivity : KauBaseActivity() { L.d("Download image async finished: $success") uiThread { val text = if (success) R.string.image_download_success else R.string.image_download_fail - snackbar(text) + frostSnackbar(text) if (success) fabAction = FabStates.SHARE } } @@ -246,7 +246,7 @@ internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconC } catch (e: Exception) { activity.errorRef = e e.logFrostAnswers("Image share failed") - activity.snackbar(R.string.image_share_failed) + activity.frostSnackbar(R.string.image_share_failed) } } }; diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MediaPickerActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MediaPickerActivity.kt index 9b73f9b7..d42b5d9f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MediaPickerActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MediaPickerActivity.kt @@ -1,9 +1,12 @@ package com.pitchedapps.frost.activities import android.content.Context +import android.graphics.Color import android.net.Uri import android.support.v4.content.FileProvider import ca.allanwang.kau.mediapicker.* +import ca.allanwang.kau.utils.colorToBackground +import ca.allanwang.kau.utils.isColorVisibleOn import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.utils.Prefs import java.io.File @@ -11,15 +14,20 @@ import java.io.File /** * Created by Allan Wang on 2017-07-23. */ -private fun actions() = listOf(object : MediaActionCamera(Prefs.accentColor) { +private fun actions(): List<MediaAction> { + var color = Prefs.iconBackgroundColor + if (!color.isColorVisibleOn(Color.WHITE, 50)) + color = 0xff3b5998.toInt() + return listOf(object : MediaActionCamera(color) { - override fun createFile(context: Context): File - = createMediaFile("Frost", ".jpg") + override fun createFile(context: Context): File + = createMediaFile("Frost", ".jpg") - override fun createUri(context: Context, file: File): Uri - = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file) + override fun createUri(context: Context, file: File): Uri + = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file) -}, MediaActionGallery(color = Prefs.accentColor)) + }, MediaActionGallery(color = color.colorToBackground(0.1f))) +} class ImagePickerActivity : MediaPickerActivityOverlayBase(MediaType.IMAGE, actions()) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt index 45d4c8ae..7dff5b16 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt @@ -55,7 +55,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { fun KPrefColorPicker.KPrefColorContract.dependsOnCustom() { enabler = { Prefs.isCustomTheme } - onDisabledClick = { itemView, _, _ -> itemView.frostSnackbar(R.string.requires_custom_theme); true } + onDisabledClick = { itemView, _, _ -> frostSnackbar(R.string.requires_custom_theme); true } allowCustom = true } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt index b1e5015f..8fcb3594 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -2,12 +2,12 @@ package com.pitchedapps.frost.settings import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder import ca.allanwang.kau.utils.minuteToText -import ca.allanwang.kau.utils.snackbar import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.SettingsActivity import com.pitchedapps.frost.services.fetchNotifications import com.pitchedapps.frost.services.scheduleNotifications import com.pitchedapps.frost.utils.Prefs +import com.pitchedapps.frost.utils.frostSnackbar import com.pitchedapps.frost.utils.materialDialogThemed import com.pitchedapps.frost.views.Keywords @@ -70,7 +70,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { onClick = { _, _, _ -> val text = if (fetchNotifications()) R.string.notification_fetch_success else R.string.notification_fetch_fail - snackbar(text) + frostSnackbar(text) true } } 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 74e800df..469a3951 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -148,17 +148,20 @@ fun Throwable?.logFrostAnswers(text: String) { frostAnswersCustom("Errors", "text" to text, "message" to (this?.message ?: "NA")) } -fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) { - Snackbar.make(this, text, Snackbar.LENGTH_LONG).apply { - builder() - //hacky workaround, but it has proper checks and shouldn't crash - ((view as? FrameLayout)?.getChildAt(0) as? SnackbarContentLayout)?.apply { - messageView.setTextColor(Prefs.textColor) - actionView.setTextColor(Prefs.accentColor) - //only set if previous text colors are set - view.setBackgroundColor(Prefs.bgColor.withAlpha(255).colorToForeground(0.1f)) - } - show() +fun Activity.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) + = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder)) + +fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) + = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder)) + +private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snackbar.() -> Unit = { + builder() + //hacky workaround, but it has proper checks and shouldn't crash + ((view as? FrameLayout)?.getChildAt(0) as? SnackbarContentLayout)?.apply { + messageView.setTextColor(Prefs.textColor) + actionView.setTextColor(Prefs.accentColor) + //only set if previous text colors are set + view.setBackgroundColor(Prefs.bgColor.withAlpha(255).colorToForeground(0.1f)) } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABBinder.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABBinder.kt index 7f6e8a6d..8aa3bcde 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABBinder.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABBinder.kt @@ -110,7 +110,7 @@ abstract class IABBinder : FrostBilling { } val a = activity ?: return - if (!BillingProcessor.isIabServiceAvailable(a) || !bp.isOneTimePurchaseSupported) + if (!BillingProcessor.isIabServiceAvailable(a) || !bp.isInitialized || !bp.isOneTimePurchaseSupported) a.playStorePurchaseUnsupported() else bp.purchase(a, FROST_PRO) @@ -127,7 +127,7 @@ class IABSettings : IABBinder() { override fun onBillingError(errorCode: Int, error: Throwable?) { super.onBillingError(errorCode, error) - activity?.playStoreGenericError(null) + L.e("Billing error $errorCode ${error?.message}") } /** diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt index 61711092..386c5339 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt @@ -4,9 +4,10 @@ import android.net.Uri import android.webkit.* import ca.allanwang.kau.permissions.PERMISSION_ACCESS_FINE_LOCATION import ca.allanwang.kau.permissions.kauRequestPermissions -import ca.allanwang.kau.utils.snackbar +import com.pitchedapps.frost.R import com.pitchedapps.frost.contracts.ActivityWebContract import com.pitchedapps.frost.utils.L +import com.pitchedapps.frost.utils.frostSnackbar import io.reactivex.subjects.BehaviorSubject import io.reactivex.subjects.Subject @@ -52,7 +53,7 @@ class FrostChromeClient(webCore: FrostWebViewCore) : WebChromeClient() { } override fun onShowFileChooser(webView: WebView, filePathCallback: ValueCallback<Array<Uri>>, fileChooserParams: FileChooserParams): Boolean { - activityContract?.openFileChooser(filePathCallback, fileChooserParams) ?: webView.snackbar("File chooser not found") + activityContract?.openFileChooser(filePathCallback, fileChooserParams) ?: webView.frostSnackbar(R.string.file_chooser_not_found) return activityContract != null } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 85826588..eff04778 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -63,4 +63,5 @@ <string name="html_extraction_error">An error occurred in the html extraction.</string> <string name="html_extraction_cancelled">The request has been cancelled.</string> <string name="html_extraction_timeout">The request has timed out.</string> + <string name="file_chooser_not_found">File chooser not found</string> </resources> diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml index 6bfcadab..43efb8c5 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -12,6 +12,12 @@ <version title="Beta Updates"/> <item text="Update secondary background for transparent themes to be more visible." /> + <item text="Pressing enter when searching will launch the full search page" /> + <item text="Add different backgrounds for news feed articles." /> + <item text="Add option to get image/video from default camera or gallery app." /> + <item text="Fix some bug reports." /> + <item text="Remove error dialog for IAB. It will now depend solely on the google services dialogs." /> + <item text="" /> <item text="" /> <version title="v1.4.5"/> |