diff options
Diffstat (limited to 'app/src/main/kotlin/com')
12 files changed, 52 insertions, 45 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt index f0956ec7..a4d98d8a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt @@ -59,7 +59,7 @@ class AboutActivity : AboutActivityBase(null, { "subsamplingscaleimageview" ) - val l = libs.prepareLibraries(this, include, null, false, true) + val l = libs.prepareLibraries(this, include, null, false, true,true) // l.forEach { KL.d{"Lib ${it.definedName}"} } return l } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt index 54fa0b8c..02f9134c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -426,7 +426,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } override fun collapseAppBar() { - appBar.setExpanded(false) + appBar.post { appBar.setExpanded(false) } } override fun backConsumer(): Boolean { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt index 554eaa00..7b2cfbf2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/TabCustomizerActivity.kt @@ -65,7 +65,7 @@ class TabCustomizerActivity : BaseActivity() { adapter.add(tabs.map(::TabIItem)) bindSwapper(adapter, recycler) - adapter.withOnClickListener { view, _, _, _ -> view.wobble(); true } + adapter.withOnClickListener { view, _, _, _ -> view!!.wobble(); true } setResult(Activity.RESULT_CANCELED) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt index 7dce6c6e..43463752 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt @@ -13,6 +13,9 @@ interface MainActivityContract : ActivityContract, MainFabContract { val fragmentSubject: PublishSubject<Int> fun setTitle(res: Int) fun setTitle(text: CharSequence) + /** + * Available on all threads + */ fun collapseAppBar() fun reloadFragment(fragment: BaseFragment) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt index ab3a40ec..613295e6 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FrostContentContract.kt @@ -55,6 +55,7 @@ interface FrostContentParent : DynamicUiContract { /** * Toggle state for allowing swipes + * Allowed on any thread */ var swipeEnabled: Boolean diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt index 625ecff9..1211b742 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt @@ -34,7 +34,7 @@ interface ClickableIItemContract { adapter.fastAdapter.withSelectable(false) .withOnClickListener { v, _, item, _ -> if (item is ClickableIItemContract) { - item.click(v.context) + item.click(v!!.context) true } else false diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt index d1f9eaf4..e5dcd8a4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt @@ -34,10 +34,10 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : KauI .withOnClickListener { v, _, item, position -> val notif = item.notification if (notif.unread) { - FrostRunnable.markNotificationRead(v.context, notif.id, item.cookie) + FrostRunnable.markNotificationRead(v!!.context, notif.id, item.cookie) adapter.set(position, NotificationIItem(notif.copy(unread = false), item.cookie)) } - v.context.launchWebOverlay(notif.url) + v!!.context.launchWebOverlay(notif.url) true } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt index 286bce4f..08cf321c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -9,7 +9,6 @@ import android.app.job.JobScheduler import android.content.ComponentName import android.content.Context import android.content.Intent -import android.graphics.Bitmap import android.net.Uri import android.os.BaseBundle import android.os.Build @@ -19,8 +18,6 @@ import android.support.v4.app.NotificationManagerCompat import ca.allanwang.kau.utils.color import ca.allanwang.kau.utils.dpToPx import ca.allanwang.kau.utils.string -import com.bumptech.glide.request.target.SimpleTarget -import com.bumptech.glide.request.transition.Transition import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.FrostWebActivity @@ -39,7 +36,6 @@ import com.pitchedapps.frost.utils.ARG_USER_ID import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.frostAnswersCustom -import org.jetbrains.anko.runOnUiThread import java.util.* /** @@ -75,23 +71,7 @@ fun NotificationCompat.Builder.withDefaults(ringtone: String = Prefs.notificatio setDefaults(defaults) } -/** - * Created by Allan Wang on 2017-07-08. - * - * Custom target to set the content view and update a given notification - * 40dp is the size of the right avatar - */ -class FrostNotificationTarget(val context: Context, - val notifId: Int, - val notifTag: String, - val builder: NotificationCompat.Builder -) : SimpleTarget<Bitmap>(40.dpToPx, 40.dpToPx) { - - override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) { - builder.setLargeIcon(resource) - NotificationManagerCompat.from(context).notify(notifTag, notifId, builder.build()) - } -} +private val _40_DP = 40.dpToPx /** * Enum to handle notification creations @@ -170,6 +150,17 @@ enum class NotificationType( summaryNotification(context, userId, notifCount) } + private fun debugNotification(context: Context, data: CookieModel) { + val content = NotificationContent(data, + System.currentTimeMillis(), + "https://github.com/AllanWang/Frost-for-Facebook", + "Debug Notif", + "Test 123", + System.currentTimeMillis() / 1000, + "https://www.iconexperience.com/_img/v_collection_png/256x256/shadow/dog.png") + createNotification(context, content, true) + } + /** * Create and submit a new notification with the given [content] * If [withDefaults] is set, it will also add the appropriate sound, vibration, and light @@ -198,18 +189,22 @@ enum class NotificationType( if (timestamp != -1L) notifBuilder.setWhen(timestamp * 1000) L.v { "Notif load $content" } - NotificationManagerCompat.from(context).notify(group, notifId, notifBuilder.build()) if (profileUrl != null) { - context.runOnUiThread { - //todo verify if context is valid? - GlideApp.with(context) + try { + val profileImg = GlideApp.with(context) .asBitmap() .load(profileUrl) .transform(FrostGlide.circleCrop) - .into(FrostNotificationTarget(context, notifId, group, notifBuilder)) + .submit(_40_DP, _40_DP) + .get() + notifBuilder.setLargeIcon(profileImg) + } catch (e: Exception) { + L.e { "Failed to get image $profileUrl" } } } + + NotificationManagerCompat.from(context).notify(group, notifId, notifBuilder.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 144e65ef..3e102671 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -272,7 +272,7 @@ inline val String?.isIndependent: Boolean val dependentSegments = arrayOf( "photoset_token", "direct_action_execute", "messages/?pageNum", "sharer.php", - "events/permalink", + "events/permalink", "events/feed/watch", /** * Editing images */ diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt index 43653382..4622971b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt @@ -12,7 +12,6 @@ import com.pitchedapps.frost.R import com.pitchedapps.frost.contracts.FrostContentContainer import com.pitchedapps.frost.contracts.FrostContentCore import com.pitchedapps.frost.contracts.FrostContentParent -import com.pitchedapps.frost.contracts.MainActivityContract import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.WEB_LOAD_DELAY import com.pitchedapps.frost.utils.L @@ -59,14 +58,12 @@ abstract class FrostContentView<out T> @JvmOverloads constructor( protected abstract val layoutRes: Int - override var swipeEnabled: Boolean - get() = refresh.isEnabled + override var swipeEnabled = true set(value) { - refresh.isEnabled = value - if (!value) { - // locked onto an input field; ensure content is visible - (context as? MainActivityContract)?.collapseAppBar() - } + if (field == value) + return + field = value + refresh.post { refresh.isEnabled = value } } /** diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 4a3fa2a2..564b0e04 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -2,6 +2,7 @@ package com.pitchedapps.frost.web import android.webkit.JavascriptInterface import com.pitchedapps.frost.activities.MainActivity +import com.pitchedapps.frost.contracts.MainActivityContract import com.pitchedapps.frost.contracts.VideoViewHolder import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.utils.* @@ -63,6 +64,7 @@ class FrostJSI(val web: FrostWebView) { @JavascriptInterface fun longClick(start: Boolean) { activity?.viewPager?.enableSwipe = !start + web.parent.swipeEnabled = !start } /** @@ -70,7 +72,11 @@ class FrostJSI(val web: FrostWebView) { */ @JavascriptInterface fun disableSwipeRefresh(disable: Boolean) { - web.post { web.parent.swipeEnabled = !disable } + web.parent.swipeEnabled = !disable + if (disable) { + // locked onto an input field; ensure content is visible + (context as? MainActivityContract)?.collapseAppBar() + } } @JavascriptInterface diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt index 8df5b065..7e5f1632 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt @@ -72,6 +72,11 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean { */ val messageWhitelist = setOf(FbItem.MESSAGES, FbItem.CHAT, FbItem.FEED_MOST_RECENT, FbItem.FEED_TOP_STORIES).map { it.url }.toSet() -val String.shouldUseBasicAgent - get() = !contains("story.php") //we will use basic agent for anything that isn't a comment section -// get() = (messageWhitelist.any { contains(it) }) || this == FB_URL_BASE
\ No newline at end of file +val String.shouldUseBasicAgent: Boolean + get() { + if (contains("story.php")) // do not use basic for comment section + return false + if (contains("/events/")) // do not use for events (namely the map) + return false + return true // use for everything else + }
\ No newline at end of file |