aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-17 15:32:57 -0700
committerAllan Wang <me@allanwang.ca>2017-06-17 15:32:57 -0700
commit377c96d36418fa1a5709df5ebf4ef87c9cef46c5 (patch)
treec96e9cad924e3fa9c803ba960e4f63ae7ba02d8b /app/src/main/kotlin/com/pitchedapps
parent125cd16f844a27722c947de8be04c4a885c8b6d4 (diff)
downloadfrost-377c96d36418fa1a5709df5ebf4ef87c9cef46c5.tar.gz
frost-377c96d36418fa1a5709df5ebf4ef87c9cef46c5.tar.bz2
frost-377c96d36418fa1a5709df5ebf4ef87c9cef46c5.zip
Add proper external link parsing
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/WebExternalActivity.kt51
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt14
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt14
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt2
6 files changed, 69 insertions, 20 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
index 6f72d8c7..cdded244 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
@@ -97,7 +97,7 @@ class MainActivity : BaseActivity() {
currentFragment.web.scrollOrRefresh()
}
})
- adapter.pages.forEach { tabs.addTab(tabs.newTab().setIcon(it.icon.toDrawable(this, color = Prefs.iconColor))) }
+ adapter.pages.forEach { tabs.addTab(tabs.newTab().setIcon(it.icon.toDrawable(this, sizeDp = 20, color = Prefs.iconColor))) }
}
fun setupDrawer(savedInstanceState: Bundle?) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/WebExternalActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/WebExternalActivity.kt
new file mode 100644
index 00000000..0f429252
--- /dev/null
+++ b/app/src/main/kotlin/com/pitchedapps/frost/WebExternalActivity.kt
@@ -0,0 +1,51 @@
+package com.pitchedapps.frost
+
+import android.content.Intent
+import android.os.Bundle
+import android.os.PersistableBundle
+import android.support.v7.app.AppCompatActivity
+import ca.allanwang.kau.utils.toast
+import com.jude.swipbackhelper.SwipeBackHelper
+import com.pitchedapps.frost.utils.L
+
+/**
+ * Created by Allan Wang on 2017-06-17.
+ */
+class WebExternalActivity : AppCompatActivity() {
+
+ val url: String?
+ get() = intent?.dataString
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ L.d("Create wea")
+ L.d("URL $url")
+ toast(url!!)
+ SwipeBackHelper.onCreate(this)
+ SwipeBackHelper.getCurrentPage(this)
+ .setSwipeBackEnable(true)
+ .setSwipeSensitivity(0.5f)
+ .setSwipeRelateEnable(true)
+ .setSwipeRelateOffset(300)
+ }
+
+ override fun onNewIntent(intent: Intent?) {
+ super.onNewIntent(intent)
+ L.d("Intent wea")
+ }
+
+ override fun onStart() {
+ super.onStart()
+ L.d("Start")
+ }
+
+ override fun onPostCreate(savedInstanceState: Bundle?) {
+ super.onPostCreate(savedInstanceState)
+ SwipeBackHelper.onPostCreate(this)
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ SwipeBackHelper.onDestroy(this)
+ }
+} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
index 28b01486..260db298 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
@@ -6,9 +6,11 @@ import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import ca.allanwang.kau.utils.*
import com.jude.swipbackhelper.SwipeBackHelper
+import com.pitchedapps.frost.facebook.FbTab
+import com.pitchedapps.frost.utils.ARG_URL
import com.pitchedapps.frost.utils.Prefs
+import com.pitchedapps.frost.utils.formattedFbUrl
import com.pitchedapps.frost.utils.setFrostColors
-import com.pitchedapps.frost.utils.url
import com.pitchedapps.frost.web.FrostWebView
@@ -21,6 +23,9 @@ class WebOverlayActivity : AppCompatActivity() {
val frostWeb: FrostWebView by bindView(R.id.overlay_frost_webview)
val coordinator: CoordinatorLayout by bindView(R.id.overlay_main_content)
+ val url: String
+ get() = (intent.extras?.getString(ARG_URL) ?: intent.dataString)?.formattedFbUrl ?: FbTab.FEED.url
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_web_overlay)
@@ -28,7 +33,7 @@ class WebOverlayActivity : AppCompatActivity() {
supportActionBar?.setDisplayShowHomeEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
toolbar.setNavigationOnClickListener { onBackPressed() }
- frostWeb.web.setupWebview(url())
+ frostWeb.web.setupWebview(url)
frostWeb.web.loadBaseUrl()
SwipeBackHelper.onCreate(this)
SwipeBackHelper.getCurrentPage(this)
@@ -65,6 +70,9 @@ class WebOverlayActivity : AppCompatActivity() {
}
override fun onBackPressed() {
- if (!frostWeb.onBackPressed()) super.onBackPressed()
+ if (!frostWeb.onBackPressed()) {
+ finish()
+ overridePendingTransition(R.anim.kau_fade_in, R.anim.kau_slide_out_right_top)
+ }
}
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
index 28aadf21..85765541 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -36,12 +36,12 @@ class NotificationService : IntentService(NotificationService::class.java.simple
L.i("Handling notifications for $id")
if (id == -1L) return
val data = loadFbCookie(id) ?: return
- L.i("Using data $data")
+ L.v("Using data $data")
val doc = Jsoup.connect(FbTab.NOTIFICATIONS.url).cookie(FACEBOOK_COM, data.cookie).get()
val unreadNotifications = doc.getElementById("notifications_list").getElementsByClass("aclb")
var notifCount = 0
var latestEpoch = lastNotificationTime(data.id)
- L.i("Latest Epoch $latestEpoch")
+ L.v("Latest Epoch $latestEpoch")
unreadNotifications.forEach {
elem ->
val notif = parseNotification(data, elem)
@@ -110,14 +110,4 @@ class NotificationService : IntentService(NotificationService::class.java.simple
NotificationManagerCompat.from(this).notify("frost_$userId", userId.toInt(), notifBuilder.build())
}
- private fun log(element: Element) {
- with(element) {
- L.i("\n\nElement ${text()}")
- attributes().forEach {
- L.i("attr ${it.html()}")
- }
- L.i("Content ${html()}")
- }
- }
-
} \ No newline at end of file
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 7000253d..abbd8366 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -50,10 +50,10 @@ fun Context.launchWebOverlay(url: String) {
val argUrl = url.formattedFbUrl
L.i("Launch web overlay: $argUrl")
val intent = Intent(this, WebOverlayActivity::class.java)
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
+// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
intent.putExtra(ARG_URL, argUrl)
- val bundle = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.slide_in_right, R.anim.slide_out_right).toBundle()
- ContextCompat.startActivity(this, intent, bundle)
+// val bundle = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.slide_in_right, R.anim.slide_out_right).toBundle()
+ ContextCompat.startActivity(this, intent, null)
}
fun WebOverlayActivity.url(): String {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
index a600489d..694550d0 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
@@ -26,7 +26,7 @@ class FrostWebView @JvmOverloads constructor(context: Context, attrs: AttributeS
init {
inflate(getContext(), R.layout.swipe_webview, this)
- progress.tint(Prefs.iconColor.withAlpha(180))
+ progress.tint(Prefs.textColor.withAlpha(180))
refresh.setColorSchemeColors(Prefs.iconColor)
refresh.setProgressBackgroundColorSchemeColor(Prefs.headerColor.withAlpha(255))
web.progressObservable.observeOn(AndroidSchedulers.mainThread()).subscribe {