mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-10 04:52:38 +01:00
Add proper external link parsing
This commit is contained in:
parent
125cd16f84
commit
377c96d364
@ -40,8 +40,14 @@
|
||||
android:theme="@style/FrostTheme" />
|
||||
<activity
|
||||
android:name=".WebOverlayActivity"
|
||||
android:autoRemoveFromRecents="true"
|
||||
android:exported="true"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:taskAffinity="com.pitchedapps.frost.single.web"
|
||||
android:theme="@style/FrostTheme.Overlay">
|
||||
<intent-filter>
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
@ -91,6 +97,7 @@
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".LoginActivity"
|
||||
android:theme="@style/FrostTheme" />
|
||||
|
@ -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?) {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
@ -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()}")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
android:fromXDelta="100%p"
|
||||
android:toXDelta="0" />
|
||||
</set>
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
android:fromXDelta="0"
|
||||
android:toXDelta="100%p" />
|
||||
</set>
|
@ -27,10 +27,7 @@
|
||||
|
||||
<style name="FrostTheme.Overlay">
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:activityOpenEnterAnimation">@anim/slide_in_right</item>
|
||||
<item name="android:activityOpenExitAnimation">@anim/slide_out_right</item>
|
||||
<item name="android:activityCloseEnterAnimation">@anim/slide_in_right</item>
|
||||
<item name="android:activityCloseExitAnimation">@anim/slide_out_right</item>
|
||||
<item name="android:windowAnimationStyle">@style/KauSlideInFadeOut</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
@ -20,7 +20,7 @@ VERSION_CODE=1
|
||||
VERSION_NAME=0.1
|
||||
ANDROID_SUPPORT_LIBS=26.0.0-alpha1
|
||||
|
||||
KAU=9ae298d669
|
||||
KAU=9832aed0ea
|
||||
MATERIAL_DRAWER=5.9.2
|
||||
MATERIAL_DRAWER_KT=1.0.2
|
||||
IICON_GOOGLE=3.0.1.0
|
||||
|
Loading…
Reference in New Issue
Block a user