1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 20:12:39 +01:00

Dev - minor updates (#73)

* Add lint

* Add new libs

* Update libs and add friends tab

* Aggressively hide nonrecent posts

* Update dependencies

* Add php to most recents

* Add full size image downloader

* Fix css cleaner
This commit is contained in:
Allan Wang 2017-07-19 00:28:56 -07:00 committed by GitHub
parent e4679b1663
commit 495b1bd498
22 changed files with 71 additions and 122 deletions

View File

@ -23,7 +23,7 @@ script:
- cd $TRAVIS_BUILD_DIR/ - cd $TRAVIS_BUILD_DIR/
- printf "Starting script\n" - printf "Starting script\n"
- ./gradlew --quiet androidGitVersion - ./gradlew --quiet androidGitVersion
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then ./gradlew publishRelease; else ./gradlew testReleaseUnitTest assembleReleaseTest; fi - if [[ "$TRAVIS_BRANCH" == "master" ]]; then ./gradlew lintRelease publishRelease; else ./gradlew lintReleaseTest testReleaseUnitTest assembleReleaseTest; fi
notifications: notifications:
email: false email: false
slack: slack:

View File

@ -43,6 +43,15 @@ android {
} }
} }
lintOptions {
warningsAsErrors true
disable 'LogNotTimber',
'TrustAllX509TrustManager',
'UnusedResources',
'ContentDescription',
'RtlSymmetry'
}
signingConfigs { signingConfigs {
def releaseProps = new Properties() def releaseProps = new Properties()

View File

@ -1 +1 @@
#threadlist_rows i.img:not(.profpic), i.img.profpic:not(._1_0m), ._42b6._42b6._42b6, ._5i9c.img, img._2cu2, i.img.l, [id*=threadlist] i.img:not(._1_0m) { border-radius: 50%; } #threadlist_rows i.img:not(.profpic), i.img.profpic:not(._1_0m), ._42b6._42b6._42b6, ._5i9c.img, img._2cu2, i.img.l, [id*=threadlist] i.img:not(._1_0m) { border-radius: 50% !important; }

View File

@ -1,3 +1,3 @@
#threadlist_rows i.img:not(.profpic), i.img.profpic:not(._1_0m), ._42b6._42b6._42b6, ._5i9c.img, img._2cu2, i.img.l, [id*=threadlist] i.img:not(._1_0m) { #threadlist_rows i.img:not(.profpic), i.img.profpic:not(._1_0m), ._42b6._42b6._42b6, ._5i9c.img, img._2cu2, i.img.l, [id*=threadlist] i.img:not(._1_0m) {
border-radius: 50%; border-radius: 50% !important;
} }

View File

@ -40,6 +40,8 @@ class AboutActivity : AboutActivityBase(null, {
val include = arrayOf( val include = arrayOf(
"AboutLibraries", "AboutLibraries",
"AndroidIconics", "AndroidIconics",
"androidslidinguppanel",
"Crashlytics",
"dbflow", "dbflow",
"fastadapter", "fastadapter",
"glide", "glide",
@ -47,24 +49,10 @@ class AboutActivity : AboutActivityBase(null, {
"kau", "kau",
"kotterknife", "kotterknife",
"materialdialogs", "materialdialogs",
"materialdrawer" "materialdrawer",
"subsamplingscaleimageview"
) )
/*
* These are great libraries, but either aren't used directly or are too common to be listed
* Give more emphasis on the unique libs!
*/
val exclude = arrayOf(
"GoogleMaterialDesignIcons",
"intellijannotations",
"MaterialDesignIconicIcons",
"MaterialDesignIcons",
"materialize",
"appcompat_v7",
"design",
"recyclerview_v7",
"support_v4"
)
val l = libs.prepareLibraries(this, include, null, false, true) val l = libs.prepareLibraries(this, include, null, false, true)
// l.forEach { KL.d("Lib ${it.definedName}") } // l.forEach { KL.d("Lib ${it.definedName}") }
return l return l

View File

@ -166,11 +166,9 @@ class ImageActivity : AppCompatActivity() {
} }
} }
@Suppress("SIMPLE_DATE_FORMAT")
@Throws(IOException::class) @Throws(IOException::class)
private fun createImageFile(): File { private fun createImageFile(): File {
// Create an image file name // Create an image file name
@SuppressLint("SimpleDateFormat")
val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date()) val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
val imageFileName = "Frost_" + timeStamp + "_" val imageFileName = "Frost_" + timeStamp + "_"
val storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES) val storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES)
@ -264,27 +262,9 @@ internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconC
* If it's in view, give it some animations * If it's in view, give it some animations
*/ */
fun update(fab: FloatingActionButton) { fun update(fab: FloatingActionButton) {
if (!fab.isShown) { fab.transition {
fab.setIcon(iicon, color = iconColor) setIcon(iicon, color = iconColor)
fab.backgroundTintList = ColorStateList.valueOf(backgroundTint) backgroundTintList = ColorStateList.valueOf(backgroundTint)
} else {
var switched = false
ValueAnimator.ofFloat(1.0f, 0.0f, 1.0f).apply {
duration = 500L
addUpdateListener {
val x = it.animatedValue as Float
val scale = x * 0.3f + 0.7f
fab.scaleX = scale
fab.scaleY = scale
fab.imageAlpha = (x * 255).toInt()
if (it.animatedFraction > 0.5f && !switched) {
switched = true
fab.setIcon(iicon, color = iconColor)
fab.backgroundTintList = ColorStateList.valueOf(backgroundTint)
}
}
start()
}
} }
} }

View File

@ -110,7 +110,7 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
if (BuildConfig.VERSION_CODE > Prefs.versionCode) { if (BuildConfig.VERSION_CODE > Prefs.versionCode) {
Prefs.versionCode = BuildConfig.VERSION_CODE Prefs.versionCode = BuildConfig.VERSION_CODE
if (!BuildConfig.DEBUG) { if (!BuildConfig.DEBUG) {
showChangelog(R.xml.changelog, Prefs.textColor) { theme() } showChangelog(R.xml.frost_changelog, Prefs.textColor) { theme() }
frostAnswersCustom("Version") { frostAnswersCustom("Version") {
putCustomAttribute("Version code", BuildConfig.VERSION_CODE) putCustomAttribute("Version code", BuildConfig.VERSION_CODE)
putCustomAttribute("Version name", BuildConfig.VERSION_NAME) putCustomAttribute("Version name", BuildConfig.VERSION_NAME)
@ -288,6 +288,7 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
divider() divider()
primaryFrostItem(FbTab.PHOTOS) primaryFrostItem(FbTab.PHOTOS)
primaryFrostItem(FbTab.GROUPS) primaryFrostItem(FbTab.GROUPS)
primaryFrostItem(FbTab.FRIENDS)
primaryFrostItem(FbTab.PAGES) primaryFrostItem(FbTab.PAGES)
divider() divider()
primaryFrostItem(FbTab.EVENTS) primaryFrostItem(FbTab.EVENTS)

View File

@ -132,7 +132,7 @@ class SettingsActivity : KPrefActivity(), IabBroadcastReceiver.IabBroadcastListe
items(Support.values().map { string(it.title) }) items(Support.values().map { string(it.title) })
itemsCallback { _, _, which, _ -> Support.values()[which].sendEmail(this@SettingsActivity) } itemsCallback { _, _, which, _ -> Support.values()[which].sendEmail(this@SettingsActivity) }
} }
R.id.action_changelog -> showChangelog(R.xml.changelog, Prefs.textColor) { theme() } R.id.action_changelog -> showChangelog(R.xml.frost_changelog, Prefs.textColor) { theme() }
else -> return super.onOptionsItemSelected(item) else -> return super.onOptionsItemSelected(item)
} }
return true return true

View File

@ -11,26 +11,26 @@ import com.pitchedapps.frost.web.FrostWebViewClientMenu
import com.pitchedapps.frost.web.FrostWebViewCore import com.pitchedapps.frost.web.FrostWebViewCore
enum class FbTab(@StringRes val titleId: Int, val icon: IIcon, relativeUrl: String, val webClient: ((webCore: FrostWebViewCore) -> FrostWebViewClient)? = null) { enum class FbTab(@StringRes val titleId: Int, val icon: IIcon, relativeUrl: String, val webClient: ((webCore: FrostWebViewCore) -> FrostWebViewClient)? = null) {
FEED(R.string.feed, CommunityMaterial.Icon.cmd_newspaper, ""),
FEED_MOST_RECENT(R.string.most_recent, GoogleMaterial.Icon.gmd_history, "?sk=h_chr"),
FEED_TOP_STORIES(R.string.top_stories, GoogleMaterial.Icon.gmd_star, "?sk=h_nor"),
PROFILE(R.string.profile, CommunityMaterial.Icon.cmd_account, "me"),
EVENTS(R.string.events, GoogleMaterial.Icon.gmd_event_note, "events/upcoming"),
FRIENDS(R.string.friends, GoogleMaterial.Icon.gmd_people, "friends/center/requests"),
MESSAGES(R.string.messages, MaterialDesignIconic.Icon.gmi_comments, "messages"),
NOTIFICATIONS(R.string.notifications, MaterialDesignIconic.Icon.gmi_globe, "notifications"),
ACTIVITY_LOG(R.string.activity_log, GoogleMaterial.Icon.gmd_list, "me/allactivity"), ACTIVITY_LOG(R.string.activity_log, GoogleMaterial.Icon.gmd_list, "me/allactivity"),
PAGES(R.string.pages, GoogleMaterial.Icon.gmd_flag, "pages"),
GROUPS(R.string.groups, GoogleMaterial.Icon.gmd_group, "groups"),
SAVED(R.string.saved, GoogleMaterial.Icon.gmd_bookmark, "saved"),
BIRTHDAYS(R.string.birthdays, GoogleMaterial.Icon.gmd_cake, "events/birthdays"), BIRTHDAYS(R.string.birthdays, GoogleMaterial.Icon.gmd_cake, "events/birthdays"),
CHAT(R.string.chat, GoogleMaterial.Icon.gmd_chat, "buddylist"), CHAT(R.string.chat, GoogleMaterial.Icon.gmd_chat, "buddylist"),
PHOTOS(R.string.photos, GoogleMaterial.Icon.gmd_photo, "me/photos"), EVENTS(R.string.events, GoogleMaterial.Icon.gmd_event_note, "events/upcoming"),
SETTINGS(R.string.settings, GoogleMaterial.Icon.gmd_settings, "settings"), FEED(R.string.feed, CommunityMaterial.Icon.cmd_newspaper, ""),
FEED_MOST_RECENT(R.string.most_recent, GoogleMaterial.Icon.gmd_history, "home.php?sk=h_chr"),
FEED_TOP_STORIES(R.string.top_stories, GoogleMaterial.Icon.gmd_star, "home.php?sk=h_nor"),
FRIENDS(R.string.friends, GoogleMaterial.Icon.gmd_person_add, "friends/center/requests"),
GROUPS(R.string.groups, GoogleMaterial.Icon.gmd_group, "groups"),
MENU(R.string.menu, GoogleMaterial.Icon.gmd_menu, "settings", { FrostWebViewClientMenu(it) }), MENU(R.string.menu, GoogleMaterial.Icon.gmd_menu, "settings", { FrostWebViewClientMenu(it) }),
MESSAGES(R.string.messages, MaterialDesignIconic.Icon.gmi_comments, "messages"),
NOTES(R.string.notes, CommunityMaterial.Icon.cmd_note, "notes"), NOTES(R.string.notes, CommunityMaterial.Icon.cmd_note, "notes"),
NOTIFICATIONS(R.string.notifications, MaterialDesignIconic.Icon.gmi_globe, "notifications"),
ON_THIS_DAY(R.string.on_this_day, GoogleMaterial.Icon.gmd_today, "onthisday"), ON_THIS_DAY(R.string.on_this_day, GoogleMaterial.Icon.gmd_today, "onthisday"),
SEARCH(R.string.search_menu_title, GoogleMaterial.Icon.gmd_search, "search") PAGES(R.string.pages, GoogleMaterial.Icon.gmd_flag, "pages"),
PHOTOS(R.string.photos, GoogleMaterial.Icon.gmd_photo, "me/photos"),
PROFILE(R.string.profile, CommunityMaterial.Icon.cmd_account, "me"),
SAVED(R.string.saved, GoogleMaterial.Icon.gmd_bookmark, "saved"),
SEARCH(R.string.search_menu_title, GoogleMaterial.Icon.gmd_search, "search"),
SETTINGS(R.string.settings, GoogleMaterial.Icon.gmd_settings, "settings"),
; ;
val url = "$FB_URL_BASE$relativeUrl" val url = "$FB_URL_BASE$relativeUrl"

View File

@ -3,6 +3,7 @@ package com.pitchedapps.frost.injectors
import android.graphics.Color import android.graphics.Color
import android.webkit.WebView import android.webkit.WebView
import ca.allanwang.kau.utils.* import ca.allanwang.kau.utils.*
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.Prefs
/** /**

View File

@ -1,7 +1,6 @@
package com.pitchedapps.frost.injectors package com.pitchedapps.frost.injectors
import android.webkit.WebView import android.webkit.WebView
import com.pitchedapps.frost.utils.L
/** /**
* Created by Allan Wang on 2017-05-31. * Created by Allan Wang on 2017-05-31.
@ -16,7 +15,8 @@ enum class CssHider(vararg val items: String) : InjectorContract {
"article[data-store*=sponsor]" "article[data-store*=sponsor]"
), ),
PEOPLE_YOU_MAY_KNOW("article._d2r"), PEOPLE_YOU_MAY_KNOW("article._d2r"),
MESSENGER("._s15", "[data-testid=info_panel]", "js_i") MESSENGER("._s15", "[data-testid=info_panel]", "js_i"),
NON_RECENT("article:not([data-store*=actor_name])")
; ;
val injector: JsInjector by lazy { JsBuilder().css("${items.joinToString(separator = ",")}{display:none!important}").build() } val injector: JsInjector by lazy { JsBuilder().css("${items.joinToString(separator = ",")}{display:none!important}").build() }

View File

@ -25,7 +25,7 @@ class JsBuilder {
override fun toString(): String { override fun toString(): String {
val builder = StringBuilder().append("!function(){") val builder = StringBuilder().append("!function(){")
if (css.isNotBlank()) { if (css.isNotBlank()) {
val cssMin = css.replace(Regex("\\s+"), "") val cssMin = css.replace(Regex("[\\r\\n\\t\\f\\v]\\s*"), "")
builder.append("var a=document.createElement('style');a.innerHTML='$cssMin';document.head.appendChild(a);") builder.append("var a=document.createElement('style');a.innerHTML='$cssMin';document.head.appendChild(a);")
} }
if (js.isNotBlank()) if (js.isNotBlank())

View File

@ -35,6 +35,8 @@ val Context.frostNotification: NotificationCompat.Builder
color = color(R.color.frost_notification_accent) color = color(R.color.frost_notification_accent)
} }
@Suppress("DEPRECATION")
//The update feature is for Android O and seems to still be in beta
fun Notification.frostConfig() = apply { fun Notification.frostConfig() = apply {
if (Prefs.notificationVibrate) defaults = defaults or Notification.DEFAULT_VIBRATE if (Prefs.notificationVibrate) defaults = defaults or Notification.DEFAULT_VIBRATE
if (Prefs.notificationSound) defaults = defaults or Notification.DEFAULT_SOUND if (Prefs.notificationSound) defaults = defaults or Notification.DEFAULT_SOUND

View File

@ -134,7 +134,7 @@ fun SettingsActivity.restorePurchases() {
finishRestore(restore, false) finishRestore(restore, false)
} }
getInventory(false, true, reset) { getInventory(false, true, reset) {
inv, helper -> inv, _ ->
val proSku = inv.hasPurchase(FROST_PRO) val proSku = inv.hasPurchase(FROST_PRO)
Prefs.pro = proSku Prefs.pro = proSku
L.d("Play Store Restore found: ${Prefs.pro}") L.d("Play Store Restore found: ${Prefs.pro}")

View File

@ -79,6 +79,7 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient
internal fun injectAndFinish() { internal fun injectAndFinish() {
L.d("Page finished reveal") L.d("Page finished reveal")
webCore.jsInject(CssHider.HEADER, webCore.jsInject(CssHider.HEADER,
CssHider.NON_RECENT.maybe(webCore.url.contains("?sk=h_chr")),
Prefs.themeInjector, Prefs.themeInjector,
callback = { callback = {
refreshObservable.onNext(false) refreshObservable.onNext(false)
@ -104,15 +105,25 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient
* returns true to override the url * returns true to override the url
*/ */
private fun launchRequest(request: WebResourceRequest): Boolean { private fun launchRequest(request: WebResourceRequest): Boolean {
L.d("Launching ${request.url}") L.d("Launching Url", request.url.toString())
webCore.context.launchWebOverlay(request.url.toString()) webCore.context.launchWebOverlay(request.url.toString())
return true return true
} }
private fun launchImage(request: WebResourceRequest, text: String? = null): Boolean {
L.d("Launching Image", request.url.toString())
webCore.context.launchImageActivity(request.url.toString(), text)
if (webCore.canGoBack()) webCore.goBack()
return true
}
override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
L.i("Url Loading ${request.url}") L.i("Url Loading ${request.url}")
val path = request.url.path ?: return super.shouldOverrideUrlLoading(view, request) val path = request.url.path ?: return super.shouldOverrideUrlLoading(view, request)
L.v("Url Loading Path $path")
if (path.startsWith("/composer/")) return launchRequest(request) if (path.startsWith("/composer/")) return launchRequest(request)
if (request.url.toString().contains("scontent-sea1-1.xx.fbcdn.net") && (path.endsWith(".jpg") || path.endsWith(".png")))
return launchImage(request)
return super.shouldOverrideUrlLoading(view, request) return super.shouldOverrideUrlLoading(view, request)
} }

View File

@ -21,5 +21,4 @@
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:scaleType="center" /> android:scaleType="center" />
</LinearLayout> </LinearLayout>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/menu_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/kau_shadow_overlay"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
android:padding="@dimen/kau_padding_normal">
<TextView
android:id="@+id/menu_url"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/kau_padding_normal" />
<android.support.v7.widget.RecyclerView
android:id="@+id/menu_recycler"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content"
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
</LinearLayout>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/linear_out_slow_in"
android:transitionOrdering="together">
<fade android:duration="200">
<targets>
<target android:targetId="@id/menu_container" />
</targets>
</fade>
<slide
android:duration="400"
android:slideEdge="bottom"
android:startDelay="1000">
<targets>
<target android:excludeId="@android:id/navigationBarBackground" />
<target android:excludeId="@android:id/statusBarBackground" />
<target android:excludeId="@id/menu_container" />
</targets>
</slide>
</transitionSet>

View File

@ -9,17 +9,18 @@
--> -->
<version title="Beta Updates" /> <version title="Beta Updates" />
<item text="Fix notification duplicates" />
<item text="Fix long pressing album images" /> <item text="Add friend request tab in nav bar" />
<item text="" /> <item text="Aggressively filter nonrecent posts in recents mode" />
<item text="" /> <item text="Add download option for full sized images" />
<item text="" />
<item text="" /> <item text="" />
<version title="v1.4" /> <version title="v1.4" />
<item text="Update IAB helper" /> <item text="Update IAB helper" />
<item text="Create image viewing and downloading; long press any image!" /> <item text="Create image viewing and downloading; long press any image!" />
<item text="Start filtering out unnecessary loads" /> <item text="Start filtering out unnecessary loads" />
<item text="Fix notification duplicates" />
<item text="Fix long pressing album images" />
<version title="v1.3" /> <version title="v1.3" />
<item text="Create toggle for notifications only from primary account" /> <item text="Create toggle for notifications only from primary account" />

View File

@ -19,7 +19,7 @@ task clean(type: Delete) {
} }
task generateChangelogMd() { task generateChangelogMd() {
def parsedProjectXml = (new XmlParser()).parse("$project.rootDir/app/src/main/res/xml/changelog.xml") def parsedProjectXml = (new XmlParser()).parse("$project.rootDir/app/src/main/res/xml/frost_changelog.xml")
def sw = new StringWriter() def sw = new StringWriter()
sw.append("# Changelog\n") sw.append("# Changelog\n")
parsedProjectXml.depthFirst().each { parsedProjectXml.depthFirst().each {

View File

@ -1,9 +1,16 @@
# Changelog # Changelog
## Beta Updates ## Beta Updates
* Add friend request tab in nav bar
* Aggressively filter nonrecent posts in recents mode
* Add download option for full sized images
## v1.4
* Update IAB helper * Update IAB helper
* Create image viewing and downloading; long press any image! * Create image viewing and downloading; long press any image!
* Start filtering out unnecessary loads * Start filtering out unnecessary loads
* Fix notification duplicates
* Fix long pressing album images
## v1.3 ## v1.3
* Create toggle for notifications only from primary account * Create toggle for notifications only from primary account

View File

@ -17,10 +17,10 @@ MIN_SDK=21
TARGET_SDK=26 TARGET_SDK=26
BUILD_TOOLS=26.0.0 BUILD_TOOLS=26.0.0
KAU=eddaded KAU=v2.1
KOTLIN=1.1.3-2 KOTLIN=1.1.3-2
CRASHLYTICS=2.6.8 CRASHLYTICS=2.6.8
DBFLOW=4.0.4 DBFLOW=4.0.5
GLIDE=4.0.0-RC1 GLIDE=4.0.0-RC1
IICON_COMMUNITY=1.9.32.2 IICON_COMMUNITY=1.9.32.2
IICON_MATERIAL=2.2.0.3 IICON_MATERIAL=2.2.0.3