aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/activities
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/activities')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt49
1 files changed, 45 insertions, 4 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
index de806779..aa8b87de 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
@@ -21,11 +21,11 @@ import com.pitchedapps.frost.contracts.ActivityWebContract
import com.pitchedapps.frost.contracts.FileChooserContract
import com.pitchedapps.frost.contracts.FileChooserDelegate
import com.pitchedapps.frost.enums.OverlayContext
-import com.pitchedapps.frost.facebook.FbCookie
-import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
-import com.pitchedapps.frost.facebook.formattedFbUrl
+import com.pitchedapps.frost.facebook.*
import com.pitchedapps.frost.utils.*
import com.pitchedapps.frost.web.FrostWebView
+import io.reactivex.disposables.Disposable
+import okhttp3.HttpUrl
/**
@@ -41,7 +41,48 @@ import com.pitchedapps.frost.web.FrostWebView
* Used by notifications. Unlike the other overlays, this runs as a singleInstance
* Going back will bring you back to the previous app
*/
-class FrostWebActivity : WebOverlayActivityBase(false)
+class FrostWebActivity : WebOverlayActivityBase(false) {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ val requiresAction = !parseActionSend()
+ super.onCreate(savedInstanceState)
+ if (requiresAction) {
+ /*
+ * Signifies that we need to let the user know of a bad url
+ * We will subscribe to the load cycle once,
+ * and pop a dialog giving the user the option to copy the shared text
+ */
+ var disposable: Disposable? = null
+ disposable = frostWeb.web.refreshObservable.subscribe {
+ disposable?.dispose()
+ materialDialogThemed {
+ title(R.string.invalid_share_url)
+ content(R.string.invalid_share_url_desc)
+ }
+ }
+ }
+ }
+
+ /**
+ * Attempts to parse the action url
+ * Returns [true] if no action exists or if the action has been consumed, [false] if we need to notify the user of a bad action
+ */
+ private fun parseActionSend(): Boolean {
+ if (intent.action != Intent.ACTION_SEND || intent.type != "text/plain") return true
+ val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: return true
+ val url = HttpUrl.parse(text)?.toString()
+ if (url == null) {
+ L.i("Attempted to share a non-url", text)
+ copyToClipboard(text, "Text to Share", showToast = false)
+ intent.putExtra(ARG_URL, FbItem.FEED.url)
+ return false
+ } else {
+ L.i("Sharing url through overlay", url)
+ intent.putExtra(ARG_URL, "${FB_URL_BASE}/sharer/sharer.php?u=$url")
+ return true
+ }
+ }
+}
/**
* Variant that forces a basic user agent. This is largely internal,