mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-10 04:52:38 +01:00
Misc 2 (#191)
* Add further checks for iab and remove generic error dialog * Theme all snackbars * Add dynamic media action tile
This commit is contained in:
parent
ede53aff0c
commit
f5394badad
@ -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)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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())
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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}")
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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"/>
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
## Beta Updates
|
||||
* Update secondary background for transparent themes to be more visible.
|
||||
* Pressing enter when searching will launch the full search page
|
||||
* Add different backgrounds for news feed articles.
|
||||
* Add option to get image/video from default camera or gallery app.
|
||||
* Fix some bug reports.
|
||||
* Remove error dialog for IAB. It will now depend solely on the google services dialogs.
|
||||
|
||||
## v1.4.5
|
||||
* Create more robust IM notification fetcher with a timeout
|
||||
|
Loading…
Reference in New Issue
Block a user