mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-08 12:02:33 +01:00
Enhancement/ktlint (#1259)
* Add spotless * Reformat code * Apply license header * Add remaining license headers
This commit is contained in:
parent
c45b30e28f
commit
697d01882b
@ -6,6 +6,8 @@ apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'com.getkeepsafe.dexcount'
|
||||
apply plugin: 'com.gladed.androidgitversion'
|
||||
|
||||
apply from: '../spotless.gradle'
|
||||
|
||||
android {
|
||||
compileSdkVersion kau.targetSdk
|
||||
buildToolsVersion kau.buildTools
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost
|
||||
|
||||
import android.app.Activity
|
||||
@ -21,7 +37,11 @@ import com.pitchedapps.frost.facebook.FbCookie
|
||||
import com.pitchedapps.frost.glide.GlideApp
|
||||
import com.pitchedapps.frost.services.scheduleNotifications
|
||||
import com.pitchedapps.frost.services.setupNotificationChannels
|
||||
import com.pitchedapps.frost.utils.*
|
||||
import com.pitchedapps.frost.utils.BuildUtils
|
||||
import com.pitchedapps.frost.utils.FrostPglAdBlock
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.Showcase
|
||||
import com.raizlabs.android.dbflow.config.DatabaseConfig
|
||||
import com.raizlabs.android.dbflow.config.FlowConfig
|
||||
import com.raizlabs.android.dbflow.config.FlowManager
|
||||
@ -30,10 +50,9 @@ import io.reactivex.exceptions.UndeliverableException
|
||||
import io.reactivex.plugins.RxJavaPlugins
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.UnknownHostException
|
||||
import java.util.*
|
||||
import java.util.Random
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-05-28.
|
||||
*/
|
||||
@ -46,10 +65,12 @@ class FrostApp : Application() {
|
||||
// lateinit var refWatcher: RefWatcher
|
||||
|
||||
private fun FlowConfig.Builder.withDatabase(name: String, klass: KClass<*>) =
|
||||
addDatabaseConfig(DatabaseConfig.builder(klass.java)
|
||||
addDatabaseConfig(
|
||||
DatabaseConfig.builder(klass.java)
|
||||
.databaseName(name)
|
||||
.modelNotifier(ContentResolverNotifier("${BuildConfig.APPLICATION_ID}.dbflow.provider"))
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
|
||||
override fun onCreate() {
|
||||
if (!buildIsLollipopAndUp) { // not supported
|
||||
@ -57,11 +78,13 @@ class FrostApp : Application() {
|
||||
return
|
||||
}
|
||||
|
||||
FlowManager.init(FlowConfig.Builder(this)
|
||||
FlowManager.init(
|
||||
FlowConfig.Builder(this)
|
||||
.withDatabase(CookiesDb.NAME, CookiesDb::class)
|
||||
.withDatabase(FbTabsDb.NAME, FbTabsDb::class)
|
||||
.withDatabase(NotificationDb.NAME, NotificationDb::class)
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
Showcase.initialize(this, "${BuildConfig.APPLICATION_ID}.showcase")
|
||||
Prefs.initialize(this, "${BuildConfig.APPLICATION_ID}.prefs")
|
||||
// if (LeakCanary.isInAnalyzerProcess(this)) return
|
||||
@ -95,8 +118,10 @@ class FrostApp : Application() {
|
||||
val c = imageView.context
|
||||
val request = GlideApp.with(c)
|
||||
val old = request.load(uri).apply(RequestOptions().placeholder(placeholder))
|
||||
request.load(uri).apply(RequestOptions()
|
||||
.signature(ApplicationVersionSignature.obtain(c)))
|
||||
request.load(uri).apply(
|
||||
RequestOptions()
|
||||
.signature(ApplicationVersionSignature.obtain(c))
|
||||
)
|
||||
.thumbnail(old).into(imageView)
|
||||
}
|
||||
})
|
||||
@ -127,7 +152,6 @@ class FrostApp : Application() {
|
||||
L.e(it) { "RxJava error" }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initBugsnag() {
|
||||
@ -157,5 +181,4 @@ class FrostApp : Application() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost
|
||||
|
||||
import android.content.Intent
|
||||
@ -21,7 +37,8 @@ import com.pitchedapps.frost.utils.EXTRA_COOKIES
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.launchNewTask
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
import java.util.IllegalFormatException
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-05-28.
|
||||
@ -46,7 +63,8 @@ class StartActivity : KauBaseActivity() {
|
||||
if (Prefs.userId != -1L)
|
||||
startActivity<MainActivity>(intentBuilder = {
|
||||
putParcelableArrayListExtra(EXTRA_COOKIES, cookies)
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
||||
Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
})
|
||||
else
|
||||
launchNewTask<SelectorActivity>(cookies)
|
||||
@ -57,7 +75,6 @@ class StartActivity : KauBaseActivity() {
|
||||
} catch (e: Exception) {
|
||||
showInvalidWebView()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun showInvalidWebView() =
|
||||
|
@ -1,17 +1,40 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ca.allanwang.kau.about.AboutActivityBase
|
||||
import ca.allanwang.kau.about.LibraryIItem
|
||||
import ca.allanwang.kau.adapters.FastItemThemedAdapter
|
||||
import ca.allanwang.kau.adapters.ThemableIItem
|
||||
import ca.allanwang.kau.adapters.ThemableIItemDelegate
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.dimenPixelSize
|
||||
import ca.allanwang.kau.utils.resolveDrawable
|
||||
import ca.allanwang.kau.utils.startLink
|
||||
import ca.allanwang.kau.utils.string
|
||||
import ca.allanwang.kau.utils.toDrawable
|
||||
import ca.allanwang.kau.utils.toast
|
||||
import ca.allanwang.kau.utils.withMinAlpha
|
||||
import com.mikepenz.aboutlibraries.Libs
|
||||
import com.mikepenz.aboutlibraries.entity.Library
|
||||
import com.mikepenz.aboutlibraries.entity.License
|
||||
@ -25,7 +48,6 @@ import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-06-26.
|
||||
*/
|
||||
@ -154,8 +176,14 @@ class AboutActivity : AboutActivityBase(null, {
|
||||
}
|
||||
val set = ConstraintSet()
|
||||
set.clone(container)
|
||||
set.createHorizontalChain(ConstraintSet.PARENT_ID, ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT,
|
||||
images.map { it.id }.toIntArray(), null, ConstraintSet.CHAIN_SPREAD_INSIDE)
|
||||
set.createHorizontalChain(ConstraintSet.PARENT_ID,
|
||||
ConstraintSet.LEFT,
|
||||
ConstraintSet.PARENT_ID,
|
||||
ConstraintSet.RIGHT,
|
||||
images.map { it.id }.toIntArray(),
|
||||
null,
|
||||
ConstraintSet.CHAIN_SPREAD_INSIDE
|
||||
)
|
||||
set.applyTo(container)
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.content.res.Configuration
|
||||
@ -80,7 +96,6 @@ abstract class BaseActivity : KauBaseActivity() {
|
||||
//// disposeNetworkConnectivity()
|
||||
// }
|
||||
|
||||
|
||||
override fun onStop() {
|
||||
if (this is VideoViewHolder) videoOnStop()
|
||||
super.onStop()
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
@ -8,25 +24,31 @@ import android.graphics.PointF
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.StringRes
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentPagerAdapter
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.webkit.ValueCallback
|
||||
import android.webkit.WebChromeClient
|
||||
import android.webkit.WebView
|
||||
import android.widget.FrameLayout
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentPagerAdapter
|
||||
import ca.allanwang.kau.searchview.SearchItem
|
||||
import ca.allanwang.kau.searchview.SearchView
|
||||
import ca.allanwang.kau.searchview.SearchViewHolder
|
||||
import ca.allanwang.kau.searchview.bindSearchView
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.fadeScaleTransition
|
||||
import ca.allanwang.kau.utils.restart
|
||||
import ca.allanwang.kau.utils.setIcon
|
||||
import ca.allanwang.kau.utils.setMenuIcons
|
||||
import ca.allanwang.kau.utils.showIf
|
||||
import ca.allanwang.kau.utils.string
|
||||
import ca.allanwang.kau.utils.tint
|
||||
import ca.allanwang.kau.utils.toast
|
||||
import ca.allanwang.kau.utils.withMinAlpha
|
||||
import co.zsmb.materialdrawerkt.builders.Builder
|
||||
import co.zsmb.materialdrawerkt.builders.accountHeader
|
||||
import co.zsmb.materialdrawerkt.builders.drawer
|
||||
@ -35,6 +57,9 @@ import co.zsmb.materialdrawerkt.draweritems.badgeable.secondaryItem
|
||||
import co.zsmb.materialdrawerkt.draweritems.divider
|
||||
import co.zsmb.materialdrawerkt.draweritems.profile.profile
|
||||
import co.zsmb.materialdrawerkt.draweritems.profile.profileSetting
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
import com.mikepenz.iconics.IconicsDrawable
|
||||
import com.mikepenz.iconics.typeface.IIcon
|
||||
@ -57,7 +82,26 @@ import com.pitchedapps.frost.facebook.parsers.SearchParser
|
||||
import com.pitchedapps.frost.facebook.profilePictureUrl
|
||||
import com.pitchedapps.frost.fragments.BaseFragment
|
||||
import com.pitchedapps.frost.fragments.WebFragment
|
||||
import com.pitchedapps.frost.utils.*
|
||||
import com.pitchedapps.frost.utils.ACTIVITY_SETTINGS
|
||||
import com.pitchedapps.frost.utils.EXTRA_COOKIES
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.MAIN_TIMEOUT_DURATION
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.REQUEST_NAV
|
||||
import com.pitchedapps.frost.utils.REQUEST_REFRESH
|
||||
import com.pitchedapps.frost.utils.REQUEST_RESTART
|
||||
import com.pitchedapps.frost.utils.REQUEST_RESTART_APPLICATION
|
||||
import com.pitchedapps.frost.utils.REQUEST_SEARCH
|
||||
import com.pitchedapps.frost.utils.REQUEST_TEXT_ZOOM
|
||||
import com.pitchedapps.frost.utils.cookies
|
||||
import com.pitchedapps.frost.utils.frostChangelog
|
||||
import com.pitchedapps.frost.utils.frostEvent
|
||||
import com.pitchedapps.frost.utils.frostNavigationBar
|
||||
import com.pitchedapps.frost.utils.launchLogin
|
||||
import com.pitchedapps.frost.utils.launchNewTask
|
||||
import com.pitchedapps.frost.utils.launchWebOverlay
|
||||
import com.pitchedapps.frost.utils.materialDialogThemed
|
||||
import com.pitchedapps.frost.utils.setFrostColors
|
||||
import com.pitchedapps.frost.views.BadgedIcon
|
||||
import com.pitchedapps.frost.views.FrostVideoViewer
|
||||
import com.pitchedapps.frost.views.FrostViewPager
|
||||
@ -111,12 +155,14 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
Prefs.versionCode = BuildConfig.VERSION_CODE
|
||||
if (!BuildConfig.DEBUG) {
|
||||
frostChangelog()
|
||||
frostEvent("Version",
|
||||
frostEvent(
|
||||
"Version",
|
||||
"Version code" to BuildConfig.VERSION_CODE,
|
||||
"Prev version code" to Prefs.prevVersionCode,
|
||||
"Version name" to BuildConfig.VERSION_NAME,
|
||||
"Build type" to BuildConfig.BUILD_TYPE,
|
||||
"Frost id" to Prefs.frostId)
|
||||
"Frost id" to Prefs.frostId
|
||||
)
|
||||
}
|
||||
}
|
||||
setupDrawer(savedInstanceState)
|
||||
@ -204,7 +250,9 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
identifier = -2L
|
||||
}
|
||||
profileSetting(nameRes = R.string.kau_add_account) {
|
||||
iconDrawable = IconicsDrawable(this@BaseMainActivity, GoogleMaterial.Icon.gmd_add).actionBar().paddingDp(5).color(Prefs.textColor)
|
||||
iconDrawable =
|
||||
IconicsDrawable(this@BaseMainActivity, GoogleMaterial.Icon.gmd_add).actionBar().paddingDp(5)
|
||||
.color(Prefs.textColor)
|
||||
textColor = Prefs.textColor.toLong()
|
||||
identifier = -3L
|
||||
}
|
||||
@ -225,8 +273,12 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
} else {
|
||||
materialDialogThemed {
|
||||
title(R.string.kau_logout)
|
||||
content(String.format(string(R.string.kau_logout_confirm_as_x), currentCookie.name
|
||||
?: Prefs.userId.toString()))
|
||||
content(
|
||||
String.format(
|
||||
string(R.string.kau_logout_confirm_as_x), currentCookie.name
|
||||
?: Prefs.userId.toString()
|
||||
)
|
||||
)
|
||||
positiveText(R.string.kau_yes)
|
||||
negativeText(R.string.kau_no)
|
||||
onPositive { _, _ -> FbCookie.logout(this@BaseMainActivity) }
|
||||
@ -295,9 +347,11 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_main, menu)
|
||||
toolbar.tint(Prefs.iconColor)
|
||||
setMenuIcons(menu, Prefs.iconColor,
|
||||
setMenuIcons(
|
||||
menu, Prefs.iconColor,
|
||||
R.id.action_settings to GoogleMaterial.Icon.gmd_settings,
|
||||
R.id.action_search to GoogleMaterial.Icon.gmd_search)
|
||||
R.id.action_search to GoogleMaterial.Icon.gmd_search
|
||||
)
|
||||
searchViewBindIfNull {
|
||||
bindSearchView(menu, R.id.action_search, Prefs.iconColor) {
|
||||
textCallback = { query, searchView ->
|
||||
@ -309,7 +363,13 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
if (data != null) {
|
||||
val items = data.mapTo(mutableListOf(), FrostSearch::toSearchItem)
|
||||
if (items.isNotEmpty())
|
||||
items.add(SearchItem("${FbItem._SEARCH.url}?q=$query", string(R.string.show_all_results), iicon = null))
|
||||
items.add(
|
||||
SearchItem(
|
||||
"${FbItem._SEARCH.url}?q=$query",
|
||||
string(R.string.show_all_results),
|
||||
iicon = null
|
||||
)
|
||||
)
|
||||
searchViewCache[query] = items
|
||||
searchView.results = items
|
||||
}
|
||||
@ -332,7 +392,8 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
R.id.action_settings -> {
|
||||
val intent = Intent(this, SettingsActivity::class.java)
|
||||
intent.putParcelableArrayListExtra(EXTRA_COOKIES, cookies())
|
||||
val bundle = ActivityOptions.makeCustomAnimation(this, R.anim.kau_slide_in_right, R.anim.kau_fade_out).toBundle()
|
||||
val bundle =
|
||||
ActivityOptions.makeCustomAnimation(this, R.anim.kau_slide_in_right, R.anim.kau_fade_out).toBundle()
|
||||
startActivityForResult(intent, ACTIVITY_SETTINGS, bundle)
|
||||
}
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
@ -340,7 +401,10 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
return true
|
||||
}
|
||||
|
||||
override fun openFileChooser(filePathCallback: ValueCallback<Array<Uri>?>, fileChooserParams: WebChromeClient.FileChooserParams) {
|
||||
override fun openFileChooser(
|
||||
filePathCallback: ValueCallback<Array<Uri>?>,
|
||||
fileChooserParams: WebChromeClient.FileChooserParams
|
||||
) {
|
||||
openMediaPicker(filePathCallback, fileChooserParams)
|
||||
}
|
||||
|
||||
@ -377,8 +441,10 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
adapter.forcedFallbacks.clear()
|
||||
adapter.forcedFallbacks.addAll(savedInstanceState.getStringArrayList(STATE_FORCE_FALLBACK)
|
||||
?: emptyList())
|
||||
adapter.forcedFallbacks.addAll(
|
||||
savedInstanceState.getStringArrayList(STATE_FORCE_FALLBACK)
|
||||
?: emptyList()
|
||||
)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@ -444,10 +510,12 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
val item = pages[position]
|
||||
return BaseFragment(item.fragmentCreator,
|
||||
return BaseFragment(
|
||||
item.fragmentCreator,
|
||||
forcedFallbacks.contains(item.name),
|
||||
item,
|
||||
position)
|
||||
position
|
||||
)
|
||||
}
|
||||
|
||||
override fun getCount() = pages.size
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.app.Activity
|
||||
@ -9,9 +25,9 @@ import ca.allanwang.kau.internal.KauBaseActivity
|
||||
import ca.allanwang.kau.utils.setIcon
|
||||
import ca.allanwang.kau.utils.visible
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.facebook.FbItem
|
||||
import com.pitchedapps.frost.injectors.JsActions
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.createFreshDir
|
||||
@ -89,7 +105,6 @@ class DebugActivity : KauBaseActivity() {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.content.Intent
|
||||
@ -5,16 +21,25 @@ import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import android.view.View
|
||||
import ca.allanwang.kau.internal.KauBaseActivity
|
||||
import ca.allanwang.kau.logging.KauLoggerExtension
|
||||
import ca.allanwang.kau.mediapicker.scanMedia
|
||||
import ca.allanwang.kau.permissions.PERMISSION_WRITE_EXTERNAL_STORAGE
|
||||
import ca.allanwang.kau.permissions.kauRequestPermissions
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.colorToForeground
|
||||
import ca.allanwang.kau.utils.fadeOut
|
||||
import ca.allanwang.kau.utils.fadeScaleTransition
|
||||
import ca.allanwang.kau.utils.isHidden
|
||||
import ca.allanwang.kau.utils.scaleXY
|
||||
import ca.allanwang.kau.utils.setIcon
|
||||
import ca.allanwang.kau.utils.tint
|
||||
import ca.allanwang.kau.utils.use
|
||||
import ca.allanwang.kau.utils.withAlpha
|
||||
import ca.allanwang.kau.utils.withMinAlpha
|
||||
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
import com.mikepenz.iconics.typeface.IIcon
|
||||
import com.pitchedapps.frost.R
|
||||
@ -23,7 +48,19 @@ import com.pitchedapps.frost.facebook.get
|
||||
import com.pitchedapps.frost.facebook.requests.call
|
||||
import com.pitchedapps.frost.facebook.requests.getFullSizedImageUrl
|
||||
import com.pitchedapps.frost.facebook.requests.requestBuilder
|
||||
import com.pitchedapps.frost.utils.*
|
||||
import com.pitchedapps.frost.utils.ARG_COOKIE
|
||||
import com.pitchedapps.frost.utils.ARG_IMAGE_URL
|
||||
import com.pitchedapps.frost.utils.ARG_TEXT
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.createFreshFile
|
||||
import com.pitchedapps.frost.utils.frostSnackbar
|
||||
import com.pitchedapps.frost.utils.frostUriFromFile
|
||||
import com.pitchedapps.frost.utils.isIndirectImageUrl
|
||||
import com.pitchedapps.frost.utils.logFrostEvent
|
||||
import com.pitchedapps.frost.utils.materialDialogThemed
|
||||
import com.pitchedapps.frost.utils.sendFrostEmail
|
||||
import com.pitchedapps.frost.utils.setFrostColors
|
||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout
|
||||
import kotlinx.android.synthetic.main.activity_image.*
|
||||
import okhttp3.Response
|
||||
@ -34,7 +71,8 @@ import java.io.File
|
||||
import java.io.FileFilter
|
||||
import java.io.IOException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-07-15.
|
||||
@ -94,8 +132,10 @@ class ImageActivity : KauBaseActivity() {
|
||||
|
||||
// a unique image identifier based on the id (if it exists), and its hash
|
||||
private val imageHash: String by lazy {
|
||||
"${Math.abs(FB_IMAGE_ID_MATCHER.find(imageUrl)[1]?.hashCode()
|
||||
?: 0)}_${Math.abs(imageUrl.hashCode())}"
|
||||
"${Math.abs(
|
||||
FB_IMAGE_ID_MATCHER.find(imageUrl)[1]?.hashCode()
|
||||
?: 0
|
||||
)}_${Math.abs(imageUrl.hashCode())}"
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -105,11 +145,15 @@ class ImageActivity : KauBaseActivity() {
|
||||
L.v { "Displaying image $imageUrl" }
|
||||
val layout = if (!imageText.isNullOrBlank()) R.layout.activity_image else R.layout.activity_image_textless
|
||||
setContentView(layout)
|
||||
image_container.setBackgroundColor(if (Prefs.blackMediaBg) Color.BLACK
|
||||
else Prefs.bgColor.withMinAlpha(222))
|
||||
image_container.setBackgroundColor(
|
||||
if (Prefs.blackMediaBg) Color.BLACK
|
||||
else Prefs.bgColor.withMinAlpha(222)
|
||||
)
|
||||
image_text?.setTextColor(if (Prefs.blackMediaBg) Color.WHITE else Prefs.textColor)
|
||||
image_text?.setBackgroundColor((if (Prefs.blackMediaBg) Color.BLACK else Prefs.bgColor)
|
||||
.colorToForeground(0.2f).withAlpha(255))
|
||||
image_text?.setBackgroundColor(
|
||||
(if (Prefs.blackMediaBg) Color.BLACK else Prefs.bgColor)
|
||||
.colorToForeground(0.2f).withAlpha(255)
|
||||
)
|
||||
image_text?.text = imageText
|
||||
image_progress.tint(if (Prefs.blackMediaBg) Color.WHITE else Prefs.accentColor)
|
||||
image_panel?.addPanelSlideListener(object : SlidingUpPanelLayout.SimplePanelSlideListener() {
|
||||
@ -213,7 +257,6 @@ class ImageActivity : KauBaseActivity() {
|
||||
.call()
|
||||
.execute()
|
||||
|
||||
|
||||
@Throws(IOException::class)
|
||||
private fun downloadImageTo(file: File) {
|
||||
val body = getImageResponse().body()
|
||||
@ -272,7 +315,11 @@ class ImageActivity : KauBaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconColor, val backgroundTint: Int = Int.MAX_VALUE) {
|
||||
internal enum class FabStates(
|
||||
val iicon: IIcon,
|
||||
val iconColor: Int = Prefs.iconColor,
|
||||
val backgroundTint: Int = Int.MAX_VALUE
|
||||
) {
|
||||
ERROR(GoogleMaterial.Icon.gmd_error, Color.WHITE, Color.RED) {
|
||||
override fun onClick(activity: ImageActivity) {
|
||||
activity.materialDialogThemed {
|
||||
@ -334,5 +381,4 @@ internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconC
|
||||
}
|
||||
|
||||
abstract fun onClick(activity: ImageActivity)
|
||||
|
||||
}
|
@ -1,31 +1,60 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentPagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.Button
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ImageView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentPagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import ca.allanwang.kau.internal.KauBaseActivity
|
||||
import ca.allanwang.kau.ui.views.RippleCanvas
|
||||
import ca.allanwang.kau.ui.widgets.InkPageIndicator
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.blendWith
|
||||
import ca.allanwang.kau.utils.color
|
||||
import ca.allanwang.kau.utils.fadeScaleTransition
|
||||
import ca.allanwang.kau.utils.navigationBarColor
|
||||
import ca.allanwang.kau.utils.postDelayed
|
||||
import ca.allanwang.kau.utils.scaleXY
|
||||
import ca.allanwang.kau.utils.setIcon
|
||||
import ca.allanwang.kau.utils.statusBarColor
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.intro.*
|
||||
import com.pitchedapps.frost.intro.BaseIntroFragment
|
||||
import com.pitchedapps.frost.intro.IntroAccountFragment
|
||||
import com.pitchedapps.frost.intro.IntroFragmentEnd
|
||||
import com.pitchedapps.frost.intro.IntroFragmentTheme
|
||||
import com.pitchedapps.frost.intro.IntroFragmentWelcome
|
||||
import com.pitchedapps.frost.intro.IntroTabContextFragment
|
||||
import com.pitchedapps.frost.intro.IntroTabTouchFragment
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.cookies
|
||||
import com.pitchedapps.frost.utils.launchNewTask
|
||||
import org.jetbrains.anko.find
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-07-25.
|
||||
*
|
||||
@ -97,7 +126,6 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On
|
||||
page.alpha = 1f
|
||||
page.translationX = 0f
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun finish(x: Float, y: Float) {
|
||||
@ -107,9 +135,11 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On
|
||||
postDelayed(1000) { finish() }
|
||||
}
|
||||
val lastView: View? = fragments.last().view
|
||||
arrayOf<View?>(skip, indicator, next,
|
||||
arrayOf<View?>(
|
||||
skip, indicator, next,
|
||||
lastView?.find(R.id.intro_title),
|
||||
lastView?.find(R.id.intro_desc)).forEach {
|
||||
lastView?.find(R.id.intro_desc)
|
||||
).forEach {
|
||||
it?.animate()?.alpha(0f)?.setDuration(600)?.start()
|
||||
}
|
||||
if (Prefs.textColor != Color.WHITE) {
|
||||
@ -147,7 +177,6 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
@ -162,16 +191,19 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On
|
||||
if (barHasNext == hasNext) return
|
||||
barHasNext = hasNext
|
||||
next.fadeScaleTransition {
|
||||
setIcon(if (barHasNext) GoogleMaterial.Icon.gmd_navigate_next else GoogleMaterial.Icon.gmd_done, color = Prefs.textColor)
|
||||
setIcon(
|
||||
if (barHasNext) GoogleMaterial.Icon.gmd_navigate_next else GoogleMaterial.Icon.gmd_done,
|
||||
color = Prefs.textColor
|
||||
)
|
||||
}
|
||||
skip.animate().scaleXY(if (barHasNext) 1f else 0f)
|
||||
}
|
||||
|
||||
class IntroPageAdapter(fm: FragmentManager, private val fragments: List<BaseIntroFragment>) : FragmentPagerAdapter(fm) {
|
||||
class IntroPageAdapter(fm: FragmentManager, private val fragments: List<BaseIntroFragment>) :
|
||||
FragmentPagerAdapter(fm) {
|
||||
|
||||
override fun getItem(position: Int): Fragment = fragments[position]
|
||||
|
||||
override fun getCount(): Int = fragments.size
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,28 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import android.widget.ImageView
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.fadeIn
|
||||
import ca.allanwang.kau.utils.fadeOut
|
||||
@ -24,14 +40,18 @@ import com.pitchedapps.frost.facebook.profilePictureUrl
|
||||
import com.pitchedapps.frost.glide.FrostGlide
|
||||
import com.pitchedapps.frost.glide.GlideApp
|
||||
import com.pitchedapps.frost.glide.transform
|
||||
import com.pitchedapps.frost.utils.*
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Showcase
|
||||
import com.pitchedapps.frost.utils.frostEvent
|
||||
import com.pitchedapps.frost.utils.launchNewTask
|
||||
import com.pitchedapps.frost.utils.logFrostEvent
|
||||
import com.pitchedapps.frost.utils.setFrostColors
|
||||
import com.pitchedapps.frost.web.LoginWebView
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.functions.BiFunction
|
||||
import io.reactivex.subjects.SingleSubject
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-06-01.
|
||||
*/
|
||||
@ -80,7 +100,8 @@ class LoginActivity : BaseActivity() {
|
||||
Single.zip<Boolean, String, Pair<Boolean, String>>(
|
||||
profileSubject,
|
||||
usernameSubject,
|
||||
BiFunction(::Pair))
|
||||
BiFunction(::Pair)
|
||||
)
|
||||
.observeOn(AndroidSchedulers.mainThread()).subscribe { (foundImage, name) ->
|
||||
refresh = false
|
||||
if (!foundImage) {
|
||||
@ -108,16 +129,26 @@ class LoginActivity : BaseActivity() {
|
||||
loadUsername(cookie)
|
||||
}
|
||||
|
||||
|
||||
private fun loadProfile(id: Long) {
|
||||
profileLoader.load(profilePictureUrl(id))
|
||||
.transform(FrostGlide.roundCorner).listener(object : RequestListener<Drawable> {
|
||||
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
|
||||
override fun onResourceReady(
|
||||
resource: Drawable?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
dataSource: DataSource?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
profileSubject.onSuccess(true)
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
||||
override fun onLoadFailed(
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
e.logFrostEvent("Profile loading exception")
|
||||
profileSubject.onSuccess(false)
|
||||
return false
|
||||
@ -146,5 +177,4 @@ class LoginActivity : BaseActivity() {
|
||||
web.pauseTimers()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,24 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.pitchedapps.frost.facebook.FbItem
|
||||
import com.pitchedapps.frost.views.BadgedIcon
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@ -36,19 +52,19 @@ class MainActivity : BaseMainActivity() {
|
||||
super.onPageScrolled(position, positionOffset, positionOffsetPixels)
|
||||
val delta = positionOffset * (255 - 128).toFloat()
|
||||
tabsForEachView { tabPosition, view ->
|
||||
view.setAllAlpha(when (tabPosition) {
|
||||
view.setAllAlpha(
|
||||
when (tabPosition) {
|
||||
position -> 255.0f - delta
|
||||
position + 1 -> 128.0f + delta
|
||||
else -> 128f
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
viewPager.post { fragmentSubject.onNext(0); lastPosition = 0 } //trigger hook so title is set
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun setupTabs() {
|
||||
viewPager.addOnPageChangeListener(TabLayout.TabLayoutOnPageChangeListener(tabs))
|
||||
tabs.addOnTabSelectedListener(object : TabLayout.ViewPagerOnTabSelectedListener(viewPager) {
|
||||
@ -86,8 +102,8 @@ class MainActivity : BaseMainActivity() {
|
||||
}.disposeOnDestroy()
|
||||
adapter.pages.forEach {
|
||||
tabs.addTab(tabs.newTab()
|
||||
.setCustomView(BadgedIcon(this).apply { iicon = it.icon }))
|
||||
.setCustomView(BadgedIcon(this).apply { iicon = it.icon })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,27 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.view.View
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import com.mikepenz.fastadapter.FastAdapter
|
||||
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
@ -12,14 +28,33 @@ import ca.allanwang.kau.kpref.activity.CoreAttributeContract
|
||||
import ca.allanwang.kau.kpref.activity.KPrefActivity
|
||||
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
|
||||
import ca.allanwang.kau.ui.views.RippleCanvas
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.finishSlideOut
|
||||
import ca.allanwang.kau.utils.setMenuIcons
|
||||
import ca.allanwang.kau.utils.startActivityForResult
|
||||
import ca.allanwang.kau.utils.startLink
|
||||
import ca.allanwang.kau.utils.string
|
||||
import ca.allanwang.kau.utils.tint
|
||||
import ca.allanwang.kau.utils.withSceneTransitionAnimation
|
||||
import com.mikepenz.community_material_typeface_library.CommunityMaterial
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.enums.Support
|
||||
import com.pitchedapps.frost.settings.*
|
||||
import com.pitchedapps.frost.utils.*
|
||||
|
||||
import com.pitchedapps.frost.settings.getAppearancePrefs
|
||||
import com.pitchedapps.frost.settings.getBehaviourPrefs
|
||||
import com.pitchedapps.frost.settings.getDebugPrefs
|
||||
import com.pitchedapps.frost.settings.getExperimentalPrefs
|
||||
import com.pitchedapps.frost.settings.getFeedPrefs
|
||||
import com.pitchedapps.frost.settings.getNotificationPrefs
|
||||
import com.pitchedapps.frost.settings.sendDebug
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.REQUEST_RESTART
|
||||
import com.pitchedapps.frost.utils.cookies
|
||||
import com.pitchedapps.frost.utils.frostChangelog
|
||||
import com.pitchedapps.frost.utils.frostNavigationBar
|
||||
import com.pitchedapps.frost.utils.launchNewTask
|
||||
import com.pitchedapps.frost.utils.materialDialogThemed
|
||||
import com.pitchedapps.frost.utils.setFrostTheme
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-06-06.
|
||||
@ -146,7 +181,6 @@ class SettingsActivity : KPrefActivity() {
|
||||
iicon = CommunityMaterial.Icon.cmd_android_debug_bridge
|
||||
visible = { Prefs.debugSettings }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun shouldRestartMain() {
|
||||
@ -179,9 +213,11 @@ class SettingsActivity : KPrefActivity() {
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_settings, menu)
|
||||
toolbar.tint(Prefs.iconColor)
|
||||
setMenuIcons(menu, Prefs.iconColor,
|
||||
setMenuIcons(
|
||||
menu, Prefs.iconColor,
|
||||
R.id.action_email to GoogleMaterial.Icon.gmd_email,
|
||||
R.id.action_changelog to GoogleMaterial.Icon.gmd_info)
|
||||
R.id.action_changelog to GoogleMaterial.Icon.gmd_info
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.app.Activity
|
||||
@ -5,21 +21,18 @@ import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ca.allanwang.kau.kotlin.lazyContext
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.scaleXY
|
||||
import ca.allanwang.kau.utils.setIcon
|
||||
import com.pitchedapps.frost.R
|
||||
import ca.allanwang.kau.utils.withAlpha
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
|
||||
import com.mikepenz.fastadapter_extensions.drag.ItemTouchCallback
|
||||
import com.mikepenz.fastadapter_extensions.drag.SimpleDragCallback
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.dbflow.TAB_COUNT
|
||||
import com.pitchedapps.frost.dbflow.loadFbTabs
|
||||
import com.pitchedapps.frost.dbflow.save
|
||||
@ -28,7 +41,7 @@ import com.pitchedapps.frost.iitems.TabIItem
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.setFrostColors
|
||||
import kotlinx.android.synthetic.main.activity_tab_customizer.*
|
||||
import java.util.*
|
||||
import java.util.Collections
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 26/11/17.
|
||||
@ -96,9 +109,9 @@ class TabCustomizerActivity : BaseActivity() {
|
||||
override fun itemTouchDropped(oldPosition: Int, newPosition: Int) = Unit
|
||||
}
|
||||
|
||||
|
||||
private class TabDragCallback(
|
||||
directions: Int, itemTouchCallback: ItemTouchCallback
|
||||
directions: Int,
|
||||
itemTouchCallback: ItemTouchCallback
|
||||
) : SimpleDragCallback(directions, itemTouchCallback) {
|
||||
|
||||
private var draggingView: TabIItem.ViewHolder? = null
|
||||
@ -122,7 +135,5 @@ class TabCustomizerActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.activities
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
@ -5,25 +21,52 @@ import android.content.Intent
|
||||
import android.graphics.PointF
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.webkit.ValueCallback
|
||||
import android.webkit.WebChromeClient
|
||||
import android.widget.FrameLayout
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import ca.allanwang.kau.swipe.kauSwipeOnCreate
|
||||
import ca.allanwang.kau.swipe.kauSwipeOnDestroy
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.copyToClipboard
|
||||
import ca.allanwang.kau.utils.darken
|
||||
import ca.allanwang.kau.utils.dpToPx
|
||||
import ca.allanwang.kau.utils.finishSlideOut
|
||||
import ca.allanwang.kau.utils.navigationBarColor
|
||||
import ca.allanwang.kau.utils.setMenuIcons
|
||||
import ca.allanwang.kau.utils.shareText
|
||||
import ca.allanwang.kau.utils.statusBarColor
|
||||
import ca.allanwang.kau.utils.tint
|
||||
import ca.allanwang.kau.utils.toDrawable
|
||||
import ca.allanwang.kau.utils.toast
|
||||
import ca.allanwang.kau.utils.withAlpha
|
||||
import com.google.android.material.snackbar.BaseTransientBottomBar
|
||||
import com.mikepenz.community_material_typeface_library.CommunityMaterial
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.contracts.*
|
||||
import com.pitchedapps.frost.contracts.ActivityContract
|
||||
import com.pitchedapps.frost.contracts.FileChooserContract
|
||||
import com.pitchedapps.frost.contracts.FileChooserDelegate
|
||||
import com.pitchedapps.frost.contracts.FrostContentContainer
|
||||
import com.pitchedapps.frost.contracts.VideoViewHolder
|
||||
import com.pitchedapps.frost.enums.OverlayContext
|
||||
import com.pitchedapps.frost.facebook.*
|
||||
import com.pitchedapps.frost.facebook.FB_URL_BASE
|
||||
import com.pitchedapps.frost.facebook.FbCookie
|
||||
import com.pitchedapps.frost.facebook.FbItem
|
||||
import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
|
||||
import com.pitchedapps.frost.facebook.formattedFbUrl
|
||||
import com.pitchedapps.frost.services.FrostRunnable
|
||||
import com.pitchedapps.frost.utils.*
|
||||
import com.pitchedapps.frost.utils.ARG_URL
|
||||
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.Showcase
|
||||
import com.pitchedapps.frost.utils.frostSnackbar
|
||||
import com.pitchedapps.frost.utils.materialDialogThemed
|
||||
import com.pitchedapps.frost.utils.setFrostColors
|
||||
import com.pitchedapps.frost.views.FrostContentWeb
|
||||
import com.pitchedapps.frost.views.FrostVideoViewer
|
||||
import com.pitchedapps.frost.views.FrostWebView
|
||||
@ -31,7 +74,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import okhttp3.HttpUrl
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-06-01.
|
||||
*
|
||||
@ -235,7 +277,10 @@ open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseAc
|
||||
kauSwipeOnDestroy()
|
||||
}
|
||||
|
||||
override fun openFileChooser(filePathCallback: ValueCallback<Array<Uri>?>, fileChooserParams: WebChromeClient.FileChooserParams) {
|
||||
override fun openFileChooser(
|
||||
filePathCallback: ValueCallback<Array<Uri>?>,
|
||||
fileChooserParams: WebChromeClient.FileChooserParams
|
||||
) {
|
||||
openMediaPicker(filePathCallback, fileChooserParams)
|
||||
}
|
||||
|
||||
@ -247,9 +292,11 @@ open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseAc
|
||||
menuInflater.inflate(R.menu.menu_web, menu)
|
||||
overlayContext?.onMenuCreate(this, menu)
|
||||
toolbar.tint(Prefs.iconColor)
|
||||
setMenuIcons(menu, Prefs.iconColor,
|
||||
setMenuIcons(
|
||||
menu, Prefs.iconColor,
|
||||
R.id.action_share to CommunityMaterial.Icon2.cmd_share,
|
||||
R.id.action_copy_link to GoogleMaterial.Icon.gmd_content_copy)
|
||||
R.id.action_copy_link to GoogleMaterial.Icon.gmd_content_copy
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
@ -270,5 +317,4 @@ open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseAc
|
||||
*/
|
||||
override var videoViewer: FrostVideoViewer? = null
|
||||
override val lowerVideoPadding: PointF = PointF(0f, 0f)
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.contracts
|
||||
|
||||
import com.mikepenz.iconics.typeface.IIcon
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.contracts
|
||||
|
||||
/**
|
||||
@ -21,10 +37,8 @@ interface DynamicUiContract {
|
||||
*/
|
||||
fun reloadTextSize()
|
||||
|
||||
|
||||
/**
|
||||
* Change text size without propagation
|
||||
*/
|
||||
fun reloadTextSizeSelf()
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.contracts
|
||||
|
||||
import android.app.Activity
|
||||
@ -17,12 +33,19 @@ import com.pitchedapps.frost.utils.L
|
||||
const val MEDIA_CHOOSER_RESULT = 67
|
||||
|
||||
interface FileChooserActivityContract {
|
||||
fun openFileChooser(filePathCallback: ValueCallback<Array<Uri>?>, fileChooserParams: WebChromeClient.FileChooserParams)
|
||||
fun openFileChooser(
|
||||
filePathCallback: ValueCallback<Array<Uri>?>,
|
||||
fileChooserParams: WebChromeClient.FileChooserParams
|
||||
)
|
||||
}
|
||||
|
||||
interface FileChooserContract {
|
||||
var filePathCallback: ValueCallback<Array<Uri>?>?
|
||||
fun Activity.openMediaPicker(filePathCallback: ValueCallback<Array<Uri>?>, fileChooserParams: WebChromeClient.FileChooserParams)
|
||||
fun Activity.openMediaPicker(
|
||||
filePathCallback: ValueCallback<Array<Uri>?>,
|
||||
fileChooserParams: WebChromeClient.FileChooserParams
|
||||
)
|
||||
|
||||
fun Activity.onActivityResultWeb(requestCode: Int, resultCode: Int, intent: Intent?): Boolean
|
||||
}
|
||||
|
||||
@ -30,7 +53,10 @@ class FileChooserDelegate : FileChooserContract {
|
||||
|
||||
override var filePathCallback: ValueCallback<Array<Uri>?>? = null
|
||||
|
||||
override fun Activity.openMediaPicker(filePathCallback: ValueCallback<Array<Uri>?>, fileChooserParams: WebChromeClient.FileChooserParams) {
|
||||
override fun Activity.openMediaPicker(
|
||||
filePathCallback: ValueCallback<Array<Uri>?>,
|
||||
fileChooserParams: WebChromeClient.FileChooserParams
|
||||
) {
|
||||
kauRequestPermissions(PERMISSION_WRITE_EXTERNAL_STORAGE) { granted, _ ->
|
||||
if (!granted) {
|
||||
filePathCallback.onReceiveValue(null)
|
||||
@ -52,5 +78,4 @@ class FileChooserDelegate : FileChooserContract {
|
||||
filePathCallback = null
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.contracts
|
||||
|
||||
import android.view.View
|
||||
@ -23,7 +39,6 @@ interface FrostContentContainer {
|
||||
* Update toolbar title
|
||||
*/
|
||||
fun setTitle(title: String)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +99,6 @@ interface FrostContentParent : DynamicUiContract {
|
||||
* For those cases, we will return false to stop it
|
||||
*/
|
||||
fun registerTransition(urlChanged: Boolean, animate: Boolean): Boolean
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,5 +161,4 @@ interface FrostContentCore : DynamicUiContract {
|
||||
* Signal destruction to release some content manually
|
||||
*/
|
||||
fun destroy()
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.contracts
|
||||
|
||||
import io.reactivex.subjects.BehaviorSubject
|
||||
@ -27,5 +43,4 @@ interface FrostObservables {
|
||||
other.progressObservable = progressObservable
|
||||
other.titleObservable = titleObservable
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.contracts
|
||||
|
||||
import android.view.View
|
||||
@ -25,5 +41,4 @@ interface FrostThemable {
|
||||
|
||||
fun <T : View> themeViews(color: Int, vararg views: T?, action: T.(Int) -> Unit) =
|
||||
views.filterNotNull().forEach { it.action(color) }
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.contracts
|
||||
|
||||
import android.app.Activity
|
||||
@ -49,5 +65,4 @@ interface FrameWrapper {
|
||||
setContentView(R.layout.activity_frame_wrapper)
|
||||
frameWrapper.inflate(layoutRes, true)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.dbflow
|
||||
|
||||
import android.os.Parcel
|
||||
@ -11,7 +27,13 @@ import com.raizlabs.android.dbflow.annotation.ConflictAction
|
||||
import com.raizlabs.android.dbflow.annotation.Database
|
||||
import com.raizlabs.android.dbflow.annotation.PrimaryKey
|
||||
import com.raizlabs.android.dbflow.annotation.Table
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.*
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.async
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.delete
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.eq
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.from
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.save
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.select
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.where
|
||||
import com.raizlabs.android.dbflow.structure.BaseModel
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@ -30,7 +52,8 @@ object CookiesDb {
|
||||
|
||||
@PaperParcel
|
||||
@Table(database = CookiesDb::class, allFields = true, primaryKeyConflict = ConflictAction.REPLACE)
|
||||
data class CookieModel(@PrimaryKey var id: Long = -1L, var name: String? = null, var cookie: String? = null) : BaseModel(), Parcelable {
|
||||
data class CookieModel(@PrimaryKey var id: Long = -1L, var name: String? = null, var cookie: String? = null) :
|
||||
BaseModel(), Parcelable {
|
||||
companion object {
|
||||
@JvmField
|
||||
val CREATOR = PaperParcelCookieModel.CREATOR
|
||||
@ -40,18 +63,22 @@ data class CookieModel(@PrimaryKey var id: Long = -1L, var name: String? = null,
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) = PaperParcelCookieModel.writeToParcel(this, dest, flags)
|
||||
}
|
||||
|
||||
fun loadFbCookie(id: Long): CookieModel? = (select from CookieModel::class where (CookieModel_Table.id eq id)).querySingle()
|
||||
fun loadFbCookie(name: String): CookieModel? = (select from CookieModel::class where (CookieModel_Table.name eq name)).querySingle()
|
||||
fun loadFbCookie(id: Long): CookieModel? =
|
||||
(select from CookieModel::class where (CookieModel_Table.id eq id)).querySingle()
|
||||
|
||||
fun loadFbCookie(name: String): CookieModel? =
|
||||
(select from CookieModel::class where (CookieModel_Table.name eq name)).querySingle()
|
||||
|
||||
/**
|
||||
* Loads cookies sorted by name
|
||||
*/
|
||||
fun loadFbCookiesAsync(callback: (cookies: List<CookieModel>) -> Unit) {
|
||||
(select from CookieModel::class).orderBy(CookieModel_Table.name, true).async().queryListResultCallback { _, tResult -> callback(tResult) }.execute()
|
||||
(select from CookieModel::class).orderBy(CookieModel_Table.name, true).async()
|
||||
.queryListResultCallback { _, tResult -> callback(tResult) }.execute()
|
||||
}
|
||||
|
||||
fun loadFbCookiesSync(): List<CookieModel> = (select from CookieModel::class).orderBy(CookieModel_Table.name, true).queryList()
|
||||
|
||||
fun loadFbCookiesSync(): List<CookieModel> =
|
||||
(select from CookieModel::class).orderBy(CookieModel_Table.name, true).queryList()
|
||||
|
||||
inline fun saveFbCookie(cookie: CookieModel, crossinline callback: (() -> Unit) = {}) {
|
||||
cookie.async save {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.dbflow
|
||||
|
||||
import android.content.Context
|
||||
@ -14,7 +30,6 @@ object DbUtils {
|
||||
fun db(name: String) = FlowManager.getDatabase(name)
|
||||
fun dbName(name: String) = "$name.db"
|
||||
fun deleteDatabase(c: Context, name: String) = c.deleteDatabase(dbName(name))
|
||||
|
||||
}
|
||||
|
||||
inline fun <reified T : Any> List<T>.replace(dbName: String) {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.dbflow
|
||||
|
||||
import com.pitchedapps.frost.facebook.FbItem
|
||||
|
@ -1,8 +1,33 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.dbflow
|
||||
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.raizlabs.android.dbflow.annotation.*
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.*
|
||||
import com.raizlabs.android.dbflow.annotation.ConflictAction
|
||||
import com.raizlabs.android.dbflow.annotation.Database
|
||||
import com.raizlabs.android.dbflow.annotation.Migration
|
||||
import com.raizlabs.android.dbflow.annotation.PrimaryKey
|
||||
import com.raizlabs.android.dbflow.annotation.Table
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.async
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.eq
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.from
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.save
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.select
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.where
|
||||
import com.raizlabs.android.dbflow.sql.SQLiteType
|
||||
import com.raizlabs.android.dbflow.sql.migration.AlterTableMigration
|
||||
import com.raizlabs.android.dbflow.structure.BaseModel
|
||||
@ -18,7 +43,8 @@ object NotificationDb {
|
||||
}
|
||||
|
||||
@Migration(version = 2, database = NotificationDb::class)
|
||||
class NotificationMigration2(modelClass: Class<NotificationModel>) : AlterTableMigration<NotificationModel>(modelClass) {
|
||||
class NotificationMigration2(modelClass: Class<NotificationModel>) :
|
||||
AlterTableMigration<NotificationModel>(modelClass) {
|
||||
override fun onPreMigrate() {
|
||||
super.onPreMigrate()
|
||||
addColumn(SQLiteType.INTEGER, "epochIm")
|
||||
@ -27,11 +53,14 @@ class NotificationMigration2(modelClass: Class<NotificationModel>) : AlterTableM
|
||||
}
|
||||
|
||||
@Table(database = NotificationDb::class, allFields = true, primaryKeyConflict = ConflictAction.REPLACE)
|
||||
data class NotificationModel(@PrimaryKey var id: Long = -1L,
|
||||
data class NotificationModel(
|
||||
@PrimaryKey var id: Long = -1L,
|
||||
var epoch: Long = -1L,
|
||||
var epochIm: Long = -1L) : BaseModel()
|
||||
var epochIm: Long = -1L
|
||||
) : BaseModel()
|
||||
|
||||
fun lastNotificationTime(id: Long): NotificationModel = (select from NotificationModel::class where (NotificationModel_Table.id eq id)).querySingle()
|
||||
fun lastNotificationTime(id: Long): NotificationModel =
|
||||
(select from NotificationModel::class where (NotificationModel_Table.id eq id)).querySingle()
|
||||
?: NotificationModel(id = id)
|
||||
|
||||
fun saveNotificationTime(notificationModel: NotificationModel, callback: (() -> Unit)? = null) {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.debugger
|
||||
|
||||
import ca.allanwang.kau.logging.KauLoggerExtension
|
||||
@ -32,7 +48,8 @@ import java.util.zip.ZipOutputStream
|
||||
*
|
||||
* Inspired by <a href="https://github.com/JonasCz/save-for-offline">Save for Offline</a>
|
||||
*/
|
||||
class OfflineWebsite(private val url: String,
|
||||
class OfflineWebsite(
|
||||
private val url: String,
|
||||
private val cookie: String = "",
|
||||
baseUrl: String? = null,
|
||||
private val html: String? = null,
|
||||
@ -40,7 +57,8 @@ class OfflineWebsite(private val url: String,
|
||||
* Directory that holds all the files
|
||||
*/
|
||||
val baseDir: File,
|
||||
private val userAgent: String = USER_AGENT_BASIC) {
|
||||
private val userAgent: String = USER_AGENT_BASIC
|
||||
) {
|
||||
|
||||
/**
|
||||
* Supplied url without the queries
|
||||
@ -94,7 +112,6 @@ class OfflineWebsite(private val url: String,
|
||||
return callback(false)
|
||||
}
|
||||
|
||||
|
||||
if (!assetDir.createFreshDir()) {
|
||||
L.e { "Could not create ${assetDir.absolutePath}" }
|
||||
return callback(false)
|
||||
@ -245,8 +262,10 @@ class OfflineWebsite(private val url: String,
|
||||
}
|
||||
})
|
||||
|
||||
private inline fun <T> String.downloadUrl(fallback: () -> T,
|
||||
action: (file: File, body: ResponseBody) -> T): T {
|
||||
private inline fun <T> String.downloadUrl(
|
||||
fallback: () -> T,
|
||||
action: (file: File, body: ResponseBody) -> T
|
||||
): T {
|
||||
|
||||
val file = File(assetDir, fileName())
|
||||
if (!file.createNewFile()) {
|
||||
@ -293,7 +312,6 @@ class OfflineWebsite(private val url: String,
|
||||
|
||||
val index = atomicInt.getAndIncrement()
|
||||
|
||||
|
||||
var newUrl = "a${index}_$candidate"
|
||||
|
||||
/**
|
||||
@ -326,5 +344,4 @@ class OfflineWebsite(private val url: String,
|
||||
compositeDisposable.dispose()
|
||||
L.v { "Request cancelled" }
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.enums
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.enums
|
||||
|
||||
import com.pitchedapps.frost.R
|
||||
@ -10,7 +26,8 @@ enum class MainActivityLayout(
|
||||
val titleRes: Int,
|
||||
val layoutRes: Int,
|
||||
val backgroundColor: () -> Int,
|
||||
val iconColor: () -> Int) {
|
||||
val iconColor: () -> Int
|
||||
) {
|
||||
|
||||
TOP_BAR(R.string.top_bar,
|
||||
R.layout.activity_main,
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.enums
|
||||
|
||||
import android.content.Context
|
||||
@ -54,7 +70,8 @@ enum class OverlayContext(private val menuItem: FrostMenuItem?) : EnumBundle<Ove
|
||||
class FrostMenuItem(
|
||||
val id: Int,
|
||||
val fbItem: FbItem,
|
||||
val showAsAction: Int = MenuItem.SHOW_AS_ACTION_IF_ROOM) {
|
||||
val showAsAction: Int = MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||
) {
|
||||
fun addToMenu(context: Context, menu: Menu, index: Int) {
|
||||
val item = menu.add(Menu.NONE, id, index, fbItem.titleId)
|
||||
item.icon = fbItem.icon.toDrawable(context, 18)
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.enums
|
||||
|
||||
import android.content.Context
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.enums
|
||||
|
||||
import android.graphics.Color
|
||||
@ -14,13 +30,15 @@ import com.pitchedapps.frost.utils.Prefs
|
||||
const val FACEBOOK_BLUE = 0xff3b5998.toInt()
|
||||
const val BLUE_LIGHT = 0xff5d86dd.toInt()
|
||||
|
||||
enum class Theme(@StringRes val textRes: Int,
|
||||
enum class Theme(
|
||||
@StringRes val textRes: Int,
|
||||
val injector: InjectorContract,
|
||||
private val textColorGetter: () -> Int,
|
||||
private val accentColorGetter: () -> Int,
|
||||
private val backgroundColorGetter: () -> Int,
|
||||
private val headerColorGetter: () -> Int,
|
||||
private val iconColorGetter: () -> Int) {
|
||||
private val iconColorGetter: () -> Int
|
||||
) {
|
||||
|
||||
DEFAULT(R.string.kau_default,
|
||||
JsActions.EMPTY,
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook
|
||||
|
||||
/**
|
||||
@ -12,9 +28,12 @@ fun profilePictureUrl(id: Long) = "https://graph.facebook.com/$id/picture?type=l
|
||||
const val FB_LOGIN_URL = "${FB_URL_BASE}login"
|
||||
const val FB_HOME_URL = "${FB_URL_BASE}home.php"
|
||||
|
||||
const val USER_AGENT_FULL = "Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-G900T Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36"
|
||||
const val USER_AGENT_BASIC_OLD = "Mozilla/5.0 (Linux; Android 6.0) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.1.0.4633 Mobile Safari/537.10+"
|
||||
const val USER_AGENT_MESSENGER = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
|
||||
const val USER_AGENT_FULL =
|
||||
"Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-G900T Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36"
|
||||
const val USER_AGENT_BASIC_OLD =
|
||||
"Mozilla/5.0 (Linux; Android 6.0) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.1.0.4633 Mobile Safari/537.10+"
|
||||
const val USER_AGENT_MESSENGER =
|
||||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
|
||||
const val USER_AGENT_BASIC = USER_AGENT_MESSENGER
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook
|
||||
|
||||
import android.app.Activity
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook
|
||||
|
||||
/**
|
||||
@ -29,4 +45,3 @@ val FB_IMAGE_ID_MATCHER: Regex = Regex("fbcdn.*?/[0-9]+_([0-9]+)_")
|
||||
val FB_REDIRECT_URL_MATCHER: Regex = Regex("url=(.*?fbcdn.*?)\"")
|
||||
|
||||
operator fun MatchResult?.get(groupIndex: Int) = this?.groupValues?.get(groupIndex)
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook
|
||||
|
||||
import com.pitchedapps.frost.utils.L
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook.parsers
|
||||
|
||||
import com.pitchedapps.frost.dbflow.CookieModel
|
||||
@ -54,7 +70,6 @@ interface FrostParser<out T : Any> {
|
||||
* Call parsing with given data
|
||||
*/
|
||||
fun parseFromData(cookie: String?, text: String): ParseResponse<T>?
|
||||
|
||||
}
|
||||
|
||||
const val FALLBACK_TIME_MOD = 1000000
|
||||
|
@ -1,7 +1,27 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook.parsers
|
||||
|
||||
import com.pitchedapps.frost.dbflow.CookieModel
|
||||
import com.pitchedapps.frost.facebook.*
|
||||
import com.pitchedapps.frost.facebook.FB_EPOCH_MATCHER
|
||||
import com.pitchedapps.frost.facebook.FB_MESSAGE_NOTIF_ID_MATCHER
|
||||
import com.pitchedapps.frost.facebook.FbItem
|
||||
import com.pitchedapps.frost.facebook.formattedFbUrl
|
||||
import com.pitchedapps.frost.facebook.get
|
||||
import com.pitchedapps.frost.services.NotificationContent
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import org.apache.commons.text.StringEscapeUtils
|
||||
@ -19,10 +39,10 @@ import org.jsoup.nodes.Element
|
||||
object MessageParser : FrostParser<FrostMessages> by MessageParserImpl() {
|
||||
|
||||
fun queryUser(cookie: String?, name: String) = parseFromUrl(cookie, "${FbItem.MESSAGES.url}/?q=$name")
|
||||
|
||||
}
|
||||
|
||||
data class FrostMessages(val threads: List<FrostThread>,
|
||||
data class FrostMessages(
|
||||
val threads: List<FrostThread>,
|
||||
val seeMore: FrostLink?,
|
||||
val extraLinks: List<FrostLink>
|
||||
) : ParseNotification {
|
||||
@ -58,14 +78,16 @@ data class FrostMessages(val threads: List<FrostThread>,
|
||||
* [unread] true if image is unread, false otherwise
|
||||
* [content] optional string for thread
|
||||
*/
|
||||
data class FrostThread(val id: Long,
|
||||
data class FrostThread(
|
||||
val id: Long,
|
||||
val img: String?,
|
||||
val title: String,
|
||||
val time: Long,
|
||||
val url: String,
|
||||
val unread: Boolean,
|
||||
val content: String?,
|
||||
val contentImgUrl: String?)
|
||||
val contentImgUrl: String?
|
||||
)
|
||||
|
||||
private class MessageParserImpl : FrostParserBase<FrostMessages>(true) {
|
||||
|
||||
@ -92,7 +114,8 @@ private class MessageParserImpl : FrostParserBase<FrostMessages>(true) {
|
||||
|
||||
override fun parseImpl(doc: Document): FrostMessages? {
|
||||
val threadList = doc.getElementById("threadlist_rows") ?: return null
|
||||
val threads: List<FrostThread> = threadList.getElementsByAttributeValueMatching("id", ".*${FB_MESSAGE_NOTIF_ID_MATCHER.pattern}.*")
|
||||
val threads: List<FrostThread> =
|
||||
threadList.getElementsByAttributeValueMatching("id", ".*${FB_MESSAGE_NOTIF_ID_MATCHER.pattern}.*")
|
||||
.mapNotNull(this::parseMessage)
|
||||
val seeMore = parseLink(doc.getElementById("see_older_threads"))
|
||||
val extraLinks = threadList.nextElementSibling().select("a")
|
||||
@ -122,5 +145,4 @@ private class MessageParserImpl : FrostParserBase<FrostMessages>(true) {
|
||||
contentImgUrl = contentImg
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,27 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook.parsers
|
||||
|
||||
import com.pitchedapps.frost.dbflow.CookieModel
|
||||
import com.pitchedapps.frost.facebook.*
|
||||
import com.pitchedapps.frost.facebook.FB_EPOCH_MATCHER
|
||||
import com.pitchedapps.frost.facebook.FB_NOTIF_ID_MATCHER
|
||||
import com.pitchedapps.frost.facebook.FbItem
|
||||
import com.pitchedapps.frost.facebook.formattedFbUrl
|
||||
import com.pitchedapps.frost.facebook.get
|
||||
import com.pitchedapps.frost.services.NotificationContent
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
@ -49,14 +69,16 @@ data class FrostNotifs(
|
||||
* [timeString] text version of time from Facebook
|
||||
* [thumbnailUrl] optional thumbnail url if existent
|
||||
*/
|
||||
data class FrostNotif(val id: Long,
|
||||
data class FrostNotif(
|
||||
val id: Long,
|
||||
val img: String?,
|
||||
val time: Long,
|
||||
val url: String,
|
||||
val unread: Boolean,
|
||||
val content: String,
|
||||
val timeString: String,
|
||||
val thumbnailUrl: String?)
|
||||
val thumbnailUrl: String?
|
||||
)
|
||||
|
||||
private class NotifParserImpl : FrostParserBase<FrostNotifs>(false) {
|
||||
|
||||
@ -95,6 +117,4 @@ private class NotifParserImpl : FrostParserBase<FrostNotifs>(false) {
|
||||
thumbnailUrl = if (thumbnail?.isNotEmpty() == true) thumbnail else null
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook.parsers
|
||||
|
||||
import ca.allanwang.kau.searchview.SearchItem
|
||||
@ -68,10 +84,11 @@ private class SearchParserImpl : FrostParserBase<FrostSearches>(false) {
|
||||
* Removed [data-store*=result_id]
|
||||
*/
|
||||
return FrostSearches(container.select("a.touchable[href]").filter(Element::hasText).map {
|
||||
FrostSearch.create(it.attr("href").formattedFbUrl,
|
||||
FrostSearch.create(
|
||||
it.attr("href").formattedFbUrl,
|
||||
it.select("._uoi").first()?.text() ?: "",
|
||||
it.select("._1tcc").first()?.text())
|
||||
it.select("._1tcc").first()?.text()
|
||||
)
|
||||
}.filter { it.title.isNotBlank() })
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,29 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook.requests
|
||||
|
||||
import com.pitchedapps.frost.BuildConfig
|
||||
import com.pitchedapps.frost.facebook.*
|
||||
import com.pitchedapps.frost.facebook.FB_DTSG_MATCHER
|
||||
import com.pitchedapps.frost.facebook.FB_JSON_URL_MATCHER
|
||||
import com.pitchedapps.frost.facebook.FB_REV_MATCHER
|
||||
import com.pitchedapps.frost.facebook.FB_URL_BASE
|
||||
import com.pitchedapps.frost.facebook.FB_USER_MATCHER
|
||||
import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
|
||||
import com.pitchedapps.frost.facebook.get
|
||||
import com.pitchedapps.frost.rx.RxFlyweight
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import io.reactivex.Single
|
||||
@ -24,7 +46,6 @@ private class RxAuth : RxFlyweight<String, Long, RequestAuth>() {
|
||||
System.currentTimeMillis() - cond < 3600000 // valid for an hour
|
||||
|
||||
override fun cache(input: String) = System.currentTimeMillis()
|
||||
|
||||
}
|
||||
|
||||
private val auth = RxAuth()
|
||||
@ -48,10 +69,12 @@ fun String?.fbRequest(fail: () -> Unit = {}, action: RequestAuth.() -> Unit) {
|
||||
/**
|
||||
* Underlying container for all fb requests
|
||||
*/
|
||||
data class RequestAuth(val userId: Long = -1,
|
||||
data class RequestAuth(
|
||||
val userId: Long = -1,
|
||||
val cookie: String = "",
|
||||
val fb_dtsg: String = "",
|
||||
val rev: String = "") {
|
||||
val rev: String = ""
|
||||
) {
|
||||
val isComplete
|
||||
get() = userId > 0 && cookie.isNotEmpty() && fb_dtsg.isNotEmpty() && rev.isNotEmpty()
|
||||
}
|
||||
@ -75,8 +98,10 @@ internal inline fun <T : Any?> RequestAuth.frostRequest(
|
||||
val httpClient: OkHttpClient by lazy {
|
||||
val builder = OkHttpClient.Builder()
|
||||
if (BuildConfig.DEBUG)
|
||||
builder.addInterceptor(HttpLoggingInterceptor()
|
||||
.setLevel(HttpLoggingInterceptor.Level.BASIC))
|
||||
builder.addInterceptor(
|
||||
HttpLoggingInterceptor()
|
||||
.setLevel(HttpLoggingInterceptor.Level.BASIC)
|
||||
)
|
||||
builder.build()
|
||||
}
|
||||
|
||||
@ -135,8 +160,10 @@ fun String.getAuth(): RequestAuth {
|
||||
return auth
|
||||
}
|
||||
|
||||
inline fun <T, reified R : Any, O> Array<T>.zip(crossinline mapper: (List<R>) -> O,
|
||||
crossinline caller: (T) -> R): Single<O> {
|
||||
inline fun <T, reified R : Any, O> Array<T>.zip(
|
||||
crossinline mapper: (List<R>) -> O,
|
||||
crossinline caller: (T) -> R
|
||||
): Single<O> {
|
||||
if (isEmpty())
|
||||
return Single.just(mapper(emptyList()))
|
||||
val singles = map { Single.fromCallable { caller(it) }.subscribeOn(Schedulers.io()) }
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook.requests
|
||||
|
||||
import com.bumptech.glide.Priority
|
||||
@ -11,7 +27,11 @@ import com.bumptech.glide.load.model.MultiModelLoaderFactory
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.bumptech.glide.signature.ObjectKey
|
||||
import com.pitchedapps.frost.facebook.*
|
||||
import com.pitchedapps.frost.facebook.FB_IMAGE_ID_MATCHER
|
||||
import com.pitchedapps.frost.facebook.FB_REDIRECT_URL_MATCHER
|
||||
import com.pitchedapps.frost.facebook.FB_URL_BASE
|
||||
import com.pitchedapps.frost.facebook.formattedFbUrl
|
||||
import com.pitchedapps.frost.facebook.get
|
||||
import io.reactivex.Maybe
|
||||
import okhttp3.Call
|
||||
import okhttp3.Request
|
||||
@ -51,7 +71,6 @@ data class HdImageMaybe(val url: String, val cookie: String) {
|
||||
val isValid: Boolean by lazy {
|
||||
id != -1L && cookie.isNotBlank()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -75,10 +94,12 @@ fun <T> RequestBuilder<T>.loadWithPotentialHd(model: HdImageMaybe) =
|
||||
|
||||
class HdImageLoading : ModelLoader<HdImageMaybe, InputStream> {
|
||||
|
||||
override fun buildLoadData(model: HdImageMaybe,
|
||||
override fun buildLoadData(
|
||||
model: HdImageMaybe,
|
||||
width: Int,
|
||||
height: Int,
|
||||
options: Options): ModelLoader.LoadData<InputStream>? =
|
||||
options: Options
|
||||
): ModelLoader.LoadData<InputStream>? =
|
||||
if (!model.isValid) null
|
||||
else ModelLoader.LoadData(ObjectKey(model), HdImageFetcher(model))
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook.requests
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator
|
||||
@ -27,7 +43,6 @@ fun RequestAuth.getMenuData(): FrostRequest<MenuData?> {
|
||||
url("${FB_URL_BASE}bookmarks/flyout/body/?id=u_0_2")
|
||||
post(body.toForm())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun parseMenu(call: Call): MenuData? {
|
||||
@ -51,8 +66,11 @@ fun parseMenu(call: Call): MenuData? {
|
||||
.substringAfter("{", "")
|
||||
.substringBefore("}", "")
|
||||
|
||||
val doc = Jsoup.parseBodyFragment(StringEscapeUtils.unescapeEcmaScript(
|
||||
StringEscapeUtils.unescapeEcmaScript(footer)))
|
||||
val doc = Jsoup.parseBodyFragment(
|
||||
StringEscapeUtils.unescapeEcmaScript(
|
||||
StringEscapeUtils.unescapeEcmaScript(footer)
|
||||
)
|
||||
)
|
||||
val footerData = mutableListOf<MenuFooterItem>()
|
||||
val footerSmallData = mutableListOf<MenuFooterItem>()
|
||||
|
||||
@ -76,10 +94,13 @@ fun parseMenu(call: Call): MenuData? {
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class MenuData(val data: List<MenuHeader> = emptyList(),
|
||||
val footer: MenuFooter = MenuFooter()) {
|
||||
data class MenuData(
|
||||
val data: List<MenuHeader> = emptyList(),
|
||||
val footer: MenuFooter = MenuFooter()
|
||||
) {
|
||||
|
||||
@JsonCreator constructor(
|
||||
@JsonCreator
|
||||
constructor(
|
||||
@JsonProperty("data") data: List<MenuHeader>?
|
||||
) : this(data ?: emptyList(), MenuFooter())
|
||||
|
||||
@ -95,7 +116,6 @@ data class MenuData(val data: List<MenuHeader> = emptyList(),
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface MenuItemData {
|
||||
@ -103,12 +123,15 @@ interface MenuItemData {
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class MenuHeader(val id: String? = null,
|
||||
data class MenuHeader(
|
||||
val id: String? = null,
|
||||
val header: String? = null,
|
||||
val visible: List<MenuItem> = emptyList(),
|
||||
val all: List<MenuItem> = emptyList()) : MenuItemData {
|
||||
val all: List<MenuItem> = emptyList()
|
||||
) : MenuItemData {
|
||||
|
||||
@JsonCreator constructor(
|
||||
@JsonCreator
|
||||
constructor(
|
||||
@JsonProperty("id") id: String?,
|
||||
@JsonProperty("header") header: String?,
|
||||
@JsonProperty("visible") visible: List<MenuItem>?,
|
||||
@ -121,14 +144,17 @@ data class MenuHeader(val id: String? = null,
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class MenuItem(val id: String? = null,
|
||||
data class MenuItem(
|
||||
val id: String? = null,
|
||||
val name: String? = null,
|
||||
val pic: String? = null,
|
||||
val url: String? = null,
|
||||
val badge: String? = null,
|
||||
val countDetails: String? = null) : MenuItemData {
|
||||
val countDetails: String? = null
|
||||
) : MenuItemData {
|
||||
|
||||
@JsonCreator constructor(
|
||||
@JsonCreator
|
||||
constructor(
|
||||
@JsonProperty("id") id: String?,
|
||||
@JsonProperty("name") name: String?,
|
||||
@JsonProperty("pic") pic: String?,
|
||||
@ -136,26 +162,31 @@ data class MenuItem(val id: String? = null,
|
||||
@JsonProperty("count") badge: String?,
|
||||
@JsonProperty("count_details") countDetails: String?,
|
||||
@JsonProperty("fake") fake: Boolean?
|
||||
) : this(id, name, pic?.formattedFbUrl,
|
||||
) : this(
|
||||
id, name, pic?.formattedFbUrl,
|
||||
url?.formattedFbUrl,
|
||||
if (badge == "0") null else badge,
|
||||
countDetails)
|
||||
countDetails
|
||||
)
|
||||
|
||||
override val isValid: Boolean
|
||||
get() = !name.isNullOrBlank() && !url.isNullOrBlank()
|
||||
}
|
||||
|
||||
data class MenuFooter(val data: List<MenuFooterItem> = emptyList(),
|
||||
val smallData: List<MenuFooterItem> = emptyList()) {
|
||||
data class MenuFooter(
|
||||
val data: List<MenuFooterItem> = emptyList(),
|
||||
val smallData: List<MenuFooterItem> = emptyList()
|
||||
) {
|
||||
|
||||
val hasContent
|
||||
get() = data.isNotEmpty() || smallData.isNotEmpty()
|
||||
|
||||
}
|
||||
|
||||
data class MenuFooterItem(val name: String? = null,
|
||||
data class MenuFooterItem(
|
||||
val name: String? = null,
|
||||
val url: String? = null,
|
||||
val isSmall: Boolean = false) : MenuItemData {
|
||||
val isSmall: Boolean = false
|
||||
) : MenuItemData {
|
||||
override val isValid: Boolean
|
||||
get() = name != null && url != null
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook.requests
|
||||
|
||||
import com.pitchedapps.frost.facebook.FB_URL_BASE
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.facebook.requests
|
||||
|
||||
import com.pitchedapps.frost.facebook.FB_URL_BASE
|
||||
|
@ -1,15 +1,31 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import ca.allanwang.kau.utils.fadeScaleTransition
|
||||
import ca.allanwang.kau.utils.setIcon
|
||||
import ca.allanwang.kau.utils.withArguments
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.mikepenz.iconics.typeface.IIcon
|
||||
import com.pitchedapps.frost.contracts.DynamicUiContract
|
||||
import com.pitchedapps.frost.contracts.FrostContentParent
|
||||
@ -17,7 +33,12 @@ import com.pitchedapps.frost.contracts.MainActivityContract
|
||||
import com.pitchedapps.frost.contracts.MainFabContract
|
||||
import com.pitchedapps.frost.enums.FeedSort
|
||||
import com.pitchedapps.frost.facebook.FbItem
|
||||
import com.pitchedapps.frost.utils.*
|
||||
import com.pitchedapps.frost.utils.ARG_URL
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.REQUEST_REFRESH
|
||||
import com.pitchedapps.frost.utils.REQUEST_TEXT_ZOOM
|
||||
import com.pitchedapps.frost.utils.frostEvent
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
@ -33,7 +54,12 @@ abstract class BaseFragment : Fragment(), FragmentContract, DynamicUiContract {
|
||||
private const val ARG_POSITION = "arg_position"
|
||||
private const val ARG_VALID = "arg_valid"
|
||||
|
||||
internal operator fun invoke(base: () -> BaseFragment, useFallback: Boolean, data: FbItem, position: Int): BaseFragment {
|
||||
internal operator fun invoke(
|
||||
base: () -> BaseFragment,
|
||||
useFallback: Boolean,
|
||||
data: FbItem,
|
||||
position: Int
|
||||
): BaseFragment {
|
||||
val fragment = if (!useFallback) base() else WebFragment()
|
||||
val d = if (data == FbItem.FEED) FeedSort(Prefs.feedSort).item else data
|
||||
fragment.withArguments(
|
||||
@ -55,8 +81,10 @@ abstract class BaseFragment : Fragment(), FragmentContract, DynamicUiContract {
|
||||
if (value || this is WebFragment) return
|
||||
arguments!!.putBoolean(ARG_VALID, value)
|
||||
L.e { "Invalidating position $position" }
|
||||
frostEvent("Native Fallback",
|
||||
"Item" to baseEnum.name)
|
||||
frostEvent(
|
||||
"Native Fallback",
|
||||
"Item" to baseEnum.name
|
||||
)
|
||||
(context as MainActivityContract).reloadFragment(this)
|
||||
}
|
||||
|
||||
@ -75,7 +103,11 @@ abstract class BaseFragment : Fragment(), FragmentContract, DynamicUiContract {
|
||||
throw IllegalArgumentException("${this::class.java.simpleName} is not attached to a context implementing MainActivityContract")
|
||||
}
|
||||
|
||||
final override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
final override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val view = inflater.inflate(layoutRes, container, false)
|
||||
val content = view as? FrostContentParent
|
||||
?: throw IllegalArgumentException("layoutRes for fragment must return view implementing FrostContentParent")
|
||||
@ -197,4 +229,3 @@ abstract class BaseFragment : Fragment(), FragmentContract, DynamicUiContract {
|
||||
|
||||
override fun onTabClick(): Unit = content?.core?.onTabClicked() ?: Unit
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,26 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.fragments
|
||||
|
||||
import com.pitchedapps.frost.contracts.*
|
||||
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.contracts.MainFabContract
|
||||
import com.pitchedapps.frost.views.FrostRecyclerView
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
@ -74,8 +94,6 @@ interface FragmentContract : FrostContentContainer {
|
||||
fun onBackPressed(): Boolean
|
||||
|
||||
fun onTabClick()
|
||||
|
||||
|
||||
}
|
||||
|
||||
interface RecyclerContentContract {
|
||||
@ -88,5 +106,4 @@ interface RecyclerContentContract {
|
||||
* Callback returns [true] for success, [false] otherwise
|
||||
*/
|
||||
fun reload(progress: (Int) -> Unit, callback: (Boolean) -> Unit)
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.fragments
|
||||
|
||||
import ca.allanwang.kau.adapters.fastAdapter
|
||||
@ -65,7 +81,6 @@ abstract class GenericRecyclerFragment<T, Item : IItem<*, *>> : RecyclerFragment
|
||||
* Create the fast adapter to bind to the recyclerview
|
||||
*/
|
||||
open fun getAdapter(): FastAdapter<IItem<*, *>> = fastAdapter(this.adapter)
|
||||
|
||||
}
|
||||
|
||||
abstract class FrostParserFragment<T : Any, Item : IItem<*, *>> : RecyclerFragment() {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.fragments
|
||||
|
||||
import com.mikepenz.fastadapter.IItem
|
||||
@ -6,8 +22,18 @@ import com.pitchedapps.frost.facebook.FbItem
|
||||
import com.pitchedapps.frost.facebook.parsers.FrostNotifs
|
||||
import com.pitchedapps.frost.facebook.parsers.NotifParser
|
||||
import com.pitchedapps.frost.facebook.parsers.ParseResponse
|
||||
import com.pitchedapps.frost.facebook.requests.*
|
||||
import com.pitchedapps.frost.iitems.*
|
||||
import com.pitchedapps.frost.facebook.requests.MenuFooterItem
|
||||
import com.pitchedapps.frost.facebook.requests.MenuHeader
|
||||
import com.pitchedapps.frost.facebook.requests.MenuItem
|
||||
import com.pitchedapps.frost.facebook.requests.MenuItemData
|
||||
import com.pitchedapps.frost.facebook.requests.fbRequest
|
||||
import com.pitchedapps.frost.facebook.requests.getMenuData
|
||||
import com.pitchedapps.frost.iitems.ClickableIItemContract
|
||||
import com.pitchedapps.frost.iitems.MenuContentIItem
|
||||
import com.pitchedapps.frost.iitems.MenuFooterIItem
|
||||
import com.pitchedapps.frost.iitems.MenuFooterSmallIItem
|
||||
import com.pitchedapps.frost.iitems.MenuHeaderIItem
|
||||
import com.pitchedapps.frost.iitems.NotificationIItem
|
||||
import com.pitchedapps.frost.utils.frostJsoup
|
||||
import com.pitchedapps.frost.views.FrostRecyclerView
|
||||
import org.jetbrains.anko.doAsync
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.fragments
|
||||
|
||||
import android.webkit.WebView
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.glide
|
||||
|
||||
import android.content.Context
|
||||
|
@ -1,12 +1,32 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.glide
|
||||
|
||||
import android.graphics.*
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapShader
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Paint
|
||||
import android.graphics.RectF
|
||||
import android.graphics.Shader
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import java.security.MessageDigest
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 27/12/17.
|
||||
*/
|
||||
@ -31,11 +51,11 @@ class RoundCornerTransformation : BitmapTransformation() {
|
||||
val paint = Paint()
|
||||
paint.isAntiAlias = true
|
||||
paint.shader = BitmapShader(toTransform, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)
|
||||
canvas.drawRoundRect(RectF(0f, 0f, width.toFloat(), height.toFloat()),
|
||||
radius, radius, paint)
|
||||
canvas.drawRoundRect(
|
||||
RectF(0f, 0f, width.toFloat(), height.toFloat()),
|
||||
radius, radius, paint
|
||||
)
|
||||
|
||||
return bitmap
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.iitems
|
||||
|
||||
import android.content.Context
|
||||
@ -41,16 +57,16 @@ interface ClickableIItemContract {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic header item
|
||||
* Not clickable with an accent color
|
||||
*/
|
||||
open class HeaderIItem(val text: String?,
|
||||
itemId: Int = R.layout.iitem_header)
|
||||
: KauIItem<HeaderIItem, HeaderIItem.ViewHolder>(R.layout.iitem_header, ::ViewHolder, itemId) {
|
||||
open class HeaderIItem(
|
||||
val text: String?,
|
||||
itemId: Int = R.layout.iitem_header
|
||||
) : KauIItem<HeaderIItem, HeaderIItem.ViewHolder>(R.layout.iitem_header, ::ViewHolder, itemId) {
|
||||
|
||||
class ViewHolder(itemView: View) : FastAdapter.ViewHolder<HeaderIItem>(itemView) {
|
||||
|
||||
@ -66,17 +82,17 @@ open class HeaderIItem(val text: String?,
|
||||
text.text = null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic text item
|
||||
* Clickable with text color
|
||||
*/
|
||||
open class TextIItem(val text: String?,
|
||||
open class TextIItem(
|
||||
val text: String?,
|
||||
override val url: String?,
|
||||
itemId: Int = R.layout.iitem_text)
|
||||
: KauIItem<TextIItem, TextIItem.ViewHolder>(R.layout.iitem_text, ::ViewHolder, itemId),
|
||||
itemId: Int = R.layout.iitem_text
|
||||
) : KauIItem<TextIItem, TextIItem.ViewHolder>(R.layout.iitem_text, ::ViewHolder, itemId),
|
||||
ClickableIItemContract {
|
||||
|
||||
class ViewHolder(itemView: View) : FastAdapter.ViewHolder<TextIItem>(itemView) {
|
||||
@ -93,5 +109,4 @@ open class TextIItem(val text: String?,
|
||||
text.text = null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.iitems
|
||||
|
||||
import android.view.View
|
||||
@ -21,8 +37,8 @@ import com.pitchedapps.frost.utils.Prefs
|
||||
/**
|
||||
* Created by Allan Wang on 30/12/17.
|
||||
*/
|
||||
class MenuContentIItem(val data: MenuItem)
|
||||
: KauIItem<MenuContentIItem, MenuContentIItem.ViewHolder>(R.layout.iitem_menu, ::ViewHolder),
|
||||
class MenuContentIItem(val data: MenuItem) :
|
||||
KauIItem<MenuContentIItem, MenuContentIItem.ViewHolder>(R.layout.iitem_menu, ::ViewHolder),
|
||||
ClickableIItemContract {
|
||||
|
||||
override val url: String?
|
||||
@ -59,12 +75,11 @@ class MenuContentIItem(val data: MenuItem)
|
||||
}
|
||||
}
|
||||
|
||||
class MenuHeaderIItem(val data: MenuHeader) : HeaderIItem(data.header,
|
||||
itemId = R.id.item_menu_header)
|
||||
class MenuHeaderIItem(val data: MenuHeader) : HeaderIItem(
|
||||
data.header,
|
||||
itemId = R.id.item_menu_header
|
||||
)
|
||||
|
||||
class MenuFooterIItem(val data: MenuFooterItem)
|
||||
: TextIItem(data.name, data.url, R.id.item_menu_footer)
|
||||
|
||||
class MenuFooterSmallIItem(val data: MenuFooterItem)
|
||||
: TextIItem(data.name, data.url, R.id.item_menu_footer_small)
|
||||
class MenuFooterIItem(val data: MenuFooterItem) : TextIItem(data.name, data.url, R.id.item_menu_footer)
|
||||
|
||||
class MenuFooterSmallIItem(val data: MenuFooterItem) : TextIItem(data.name, data.url, R.id.item_menu_footer_small)
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.iitems
|
||||
|
||||
import android.view.View
|
||||
@ -26,9 +42,10 @@ import com.pitchedapps.frost.utils.launchWebOverlay
|
||||
/**
|
||||
* Created by Allan Wang on 27/12/17.
|
||||
*/
|
||||
class NotificationIItem(val notification: FrostNotif, val cookie: String) : KauIItem<NotificationIItem, NotificationIItem.ViewHolder>(
|
||||
class NotificationIItem(val notification: FrostNotif, val cookie: String) :
|
||||
KauIItem<NotificationIItem, NotificationIItem.ViewHolder>(
|
||||
R.layout.iitem_notification, ::ViewHolder
|
||||
) {
|
||||
) {
|
||||
|
||||
companion object {
|
||||
fun bindEvents(adapter: ItemAdapter<NotificationIItem>) {
|
||||
@ -57,7 +74,12 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : KauI
|
||||
override fun areContentsTheSame(oldItem: NotificationIItem, newItem: NotificationIItem) =
|
||||
oldItem.notification == newItem.notification
|
||||
|
||||
override fun getChangePayload(oldItem: NotificationIItem, oldItemPosition: Int, newItem: NotificationIItem, newItemPosition: Int): Any? {
|
||||
override fun getChangePayload(
|
||||
oldItem: NotificationIItem,
|
||||
oldItemPosition: Int,
|
||||
newItem: NotificationIItem,
|
||||
newItemPosition: Int
|
||||
): Any? {
|
||||
return newItem
|
||||
}
|
||||
}
|
||||
@ -75,8 +97,10 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : KauI
|
||||
|
||||
override fun bindView(item: NotificationIItem, payloads: MutableList<Any>) {
|
||||
val notif = item.notification
|
||||
frame.background = createSimpleRippleDrawable(Prefs.textColor,
|
||||
Prefs.nativeBgColor(notif.unread))
|
||||
frame.background = createSimpleRippleDrawable(
|
||||
Prefs.textColor,
|
||||
Prefs.nativeBgColor(notif.unread)
|
||||
)
|
||||
content.setTextColor(Prefs.textColor)
|
||||
date.setTextColor(Prefs.textColor.withAlpha(150))
|
||||
|
||||
|
@ -1,10 +1,30 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.iitems
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import ca.allanwang.kau.iitems.KauIItem
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.invisible
|
||||
import ca.allanwang.kau.utils.setIcon
|
||||
import ca.allanwang.kau.utils.visible
|
||||
import ca.allanwang.kau.utils.withAlpha
|
||||
import com.mikepenz.fastadapter.FastAdapter
|
||||
import com.mikepenz.fastadapter.IItem
|
||||
import com.mikepenz.fastadapter_extensions.drag.IDraggable
|
||||
@ -45,6 +65,5 @@ class TabIItem(val item: FbItem) : KauIItem<TabIItem, TabIItem.ViewHolder>(
|
||||
image.setImageDrawable(null)
|
||||
text.visible().text = null
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,14 +1,35 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.injectors
|
||||
|
||||
import android.graphics.Color
|
||||
import android.webkit.WebView
|
||||
import ca.allanwang.kau.kotlin.lazyContext
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.adjustAlpha
|
||||
import ca.allanwang.kau.utils.colorToBackground
|
||||
import ca.allanwang.kau.utils.colorToForeground
|
||||
import ca.allanwang.kau.utils.toRgbaString
|
||||
import ca.allanwang.kau.utils.use
|
||||
import ca.allanwang.kau.utils.withAlpha
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import java.io.BufferedReader
|
||||
import java.io.FileNotFoundException
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-05-31.
|
||||
@ -58,5 +79,4 @@ enum class CssAssets(val folder: String = "themes") : InjectorContract {
|
||||
fun reset() {
|
||||
injector.invalidate()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.injectors
|
||||
|
||||
import android.webkit.WebView
|
||||
@ -9,10 +25,14 @@ import android.webkit.WebView
|
||||
*/
|
||||
enum class CssHider(vararg val items: String) : InjectorContract {
|
||||
CORE("[data-sigil=m_login_upsell]", "[role=progressbar]"),
|
||||
HEADER("#header", "#mJewelNav", "[data-sigil=MTopBlueBarHeader]",
|
||||
"#header-notices", "[data-sigil*=m-promo-jewel-header]"),
|
||||
ADS("article[data-xt*=sponsor]",
|
||||
"article[data-store*=sponsor]"),
|
||||
HEADER(
|
||||
"#header", "#mJewelNav", "[data-sigil=MTopBlueBarHeader]",
|
||||
"#header-notices", "[data-sigil*=m-promo-jewel-header]"
|
||||
),
|
||||
ADS(
|
||||
"article[data-xt*=sponsor]",
|
||||
"article[data-store*=sponsor]"
|
||||
),
|
||||
PEOPLE_YOU_MAY_KNOW("article._d2r"),
|
||||
SUGGESTED_GROUPS("article[data-ft*=\"ei\":]"),
|
||||
COMPOSER("#MComposer"),
|
||||
@ -28,5 +48,4 @@ enum class CssHider(vararg val items: String) : InjectorContract {
|
||||
override fun inject(webView: WebView, callback: (() -> Unit)?) {
|
||||
injector.inject(webView, callback)
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.injectors
|
||||
|
||||
import android.webkit.WebView
|
||||
@ -28,7 +44,6 @@ enum class JsActions(body: String) : InjectorContract {
|
||||
|
||||
override fun inject(webView: WebView, callback: (() -> Unit)?) =
|
||||
JsInjector(function).inject(webView, callback)
|
||||
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.injectors
|
||||
|
||||
import android.webkit.WebView
|
||||
@ -5,7 +21,7 @@ import ca.allanwang.kau.kotlin.lazyContext
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import java.io.BufferedReader
|
||||
import java.io.FileNotFoundException
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-05-31.
|
||||
@ -31,5 +47,4 @@ enum class JsAssets : InjectorContract {
|
||||
override fun inject(webView: WebView, callback: (() -> Unit)?) {
|
||||
injector(webView.context).inject(webView, callback)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.injectors
|
||||
|
||||
import android.webkit.WebView
|
||||
@ -8,7 +24,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.subjects.SingleSubject
|
||||
import org.apache.commons.text.StringEscapeUtils
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
class JsBuilder {
|
||||
private val css = StringBuilder()
|
||||
@ -102,8 +118,10 @@ fun WebView.jsInject(vararg injectors: InjectorContract, callback: ((Int) -> Uni
|
||||
return disposable
|
||||
}
|
||||
|
||||
fun FrostWebViewClient.jsInject(vararg injectors: InjectorContract,
|
||||
callback: ((Int) -> Unit)? = null) = web.jsInject(*injectors, callback = callback)
|
||||
fun FrostWebViewClient.jsInject(
|
||||
vararg injectors: InjectorContract,
|
||||
callback: ((Int) -> Unit)? = null
|
||||
) = web.jsInject(*injectors, callback = callback)
|
||||
|
||||
/**
|
||||
* Wrapper class to convert a function into an injector
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.intro
|
||||
|
||||
import android.os.Bundle
|
||||
@ -17,7 +33,11 @@ class IntroFragmentTheme : BaseIntroFragment(R.layout.intro_theme) {
|
||||
val themeList
|
||||
get() = listOf(intro_theme_light, intro_theme_dark, intro_theme_amoled, intro_theme_glass)
|
||||
|
||||
override fun viewArray(): Array<Array<out View>> = arrayOf(arrayOf(title), arrayOf(intro_theme_light, intro_theme_dark), arrayOf(intro_theme_amoled, intro_theme_glass))
|
||||
override fun viewArray(): Array<Array<out View>> = arrayOf(
|
||||
arrayOf(title),
|
||||
arrayOf(intro_theme_light, intro_theme_dark),
|
||||
arrayOf(intro_theme_amoled, intro_theme_glass)
|
||||
)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
@ -40,5 +60,4 @@ class IntroFragmentTheme : BaseIntroFragment(R.layout.intro_theme) {
|
||||
themeList.forEach { it.animate().scaleXY(if (it == this) 1.6f else 0.8f).start() }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.intro
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
@ -5,7 +21,12 @@ import android.graphics.drawable.LayerDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.bindViewResettable
|
||||
import ca.allanwang.kau.utils.colorToForeground
|
||||
import ca.allanwang.kau.utils.setIcon
|
||||
import ca.allanwang.kau.utils.tint
|
||||
import ca.allanwang.kau.utils.visible
|
||||
import ca.allanwang.kau.utils.withAlpha
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
@ -98,7 +119,13 @@ class IntroTabTouchFragment : BaseImageIntroFragment(
|
||||
|
||||
override fun themeFragmentImpl() {
|
||||
super.themeFragmentImpl()
|
||||
themeImageComponent(Prefs.iconColor, R.id.intro_phone_icon_1, R.id.intro_phone_icon_2, R.id.intro_phone_icon_3, R.id.intro_phone_icon_4)
|
||||
themeImageComponent(
|
||||
Prefs.iconColor,
|
||||
R.id.intro_phone_icon_1,
|
||||
R.id.intro_phone_icon_2,
|
||||
R.id.intro_phone_icon_3,
|
||||
R.id.intro_phone_icon_4
|
||||
)
|
||||
themeImageComponent(Prefs.headerColor, R.id.intro_phone_tab)
|
||||
themeImageComponent(Prefs.textColor.withAlpha(80), R.id.intro_phone_icon_ripple)
|
||||
}
|
||||
@ -115,7 +142,12 @@ class IntroTabContextFragment : BaseImageIntroFragment(
|
||||
themeImageComponent(Prefs.bgColor.colorToForeground(0.2f), R.id.intro_phone_like, R.id.intro_phone_share)
|
||||
themeImageComponent(Prefs.bgColor.colorToForeground(0.3f), R.id.intro_phone_comment)
|
||||
themeImageComponent(Prefs.bgColor.colorToForeground(0.1f), R.id.intro_phone_card_1, R.id.intro_phone_card_2)
|
||||
themeImageComponent(Prefs.textColor, R.id.intro_phone_image_indicator, R.id.intro_phone_comment_indicator, R.id.intro_phone_card_indicator)
|
||||
themeImageComponent(
|
||||
Prefs.textColor,
|
||||
R.id.intro_phone_image_indicator,
|
||||
R.id.intro_phone_comment_indicator,
|
||||
R.id.intro_phone_card_indicator
|
||||
)
|
||||
}
|
||||
|
||||
override fun onPageScrolledImpl(positionOffset: Float) {
|
||||
|
@ -1,15 +1,31 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.intro
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import ca.allanwang.kau.kotlin.LazyResettableRegistry
|
||||
import ca.allanwang.kau.utils.Kotterknife
|
||||
import ca.allanwang.kau.utils.bindViewResettable
|
||||
@ -99,7 +115,6 @@ abstract class BaseIntroFragment(val layoutRes: Int) : Fragment() {
|
||||
}
|
||||
|
||||
protected open fun onPageSelectedImpl() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.rx
|
||||
|
||||
import io.reactivex.Single
|
||||
@ -82,5 +98,4 @@ abstract class RxFlyweight<in T : Any, C : Any, R : Any> {
|
||||
conditionals.clear()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.services
|
||||
|
||||
import android.app.Notification
|
||||
@ -26,8 +42,12 @@ import com.pitchedapps.frost.facebook.parsers.NotifParser
|
||||
import com.pitchedapps.frost.facebook.parsers.ParseNotification
|
||||
import com.pitchedapps.frost.glide.FrostGlide
|
||||
import com.pitchedapps.frost.glide.GlideApp
|
||||
import com.pitchedapps.frost.utils.*
|
||||
import java.util.*
|
||||
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.frostEvent
|
||||
import com.pitchedapps.frost.utils.isIndependent
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-07-08.
|
||||
@ -46,27 +66,32 @@ enum class NotificationType(
|
||||
private val parser: FrostParser<ParseNotification>,
|
||||
private val getTime: (notif: NotificationModel) -> Long,
|
||||
private val putTime: (notif: NotificationModel, time: Long) -> NotificationModel,
|
||||
private val ringtone: () -> String) {
|
||||
private val ringtone: () -> String
|
||||
) {
|
||||
|
||||
GENERAL(NOTIF_CHANNEL_GENERAL,
|
||||
GENERAL(
|
||||
NOTIF_CHANNEL_GENERAL,
|
||||
OverlayContext.NOTIFICATION,
|
||||
FbItem.NOTIFICATIONS,
|
||||
NotifParser,
|
||||
NotificationModel::epoch,
|
||||
{ notif, time -> notif.copy(epoch = time) },
|
||||
Prefs::notificationRingtone) {
|
||||
Prefs::notificationRingtone
|
||||
) {
|
||||
|
||||
override fun bindRequest(content: NotificationContent, cookie: String) =
|
||||
FrostRunnable.prepareMarkNotificationRead(content.id, cookie)
|
||||
},
|
||||
|
||||
MESSAGE(NOTIF_CHANNEL_MESSAGES,
|
||||
MESSAGE(
|
||||
NOTIF_CHANNEL_MESSAGES,
|
||||
OverlayContext.MESSAGE,
|
||||
FbItem.MESSAGES,
|
||||
MessageParser,
|
||||
NotificationModel::epochIm,
|
||||
{ notif, time -> notif.copy(epochIm = time) },
|
||||
Prefs::messageRingtone);
|
||||
Prefs::messageRingtone
|
||||
);
|
||||
|
||||
private val groupPrefix = "frost_${name.toLowerCase(Locale.CANADA)}"
|
||||
|
||||
@ -133,13 +158,15 @@ enum class NotificationType(
|
||||
}
|
||||
|
||||
fun debugNotification(context: Context, data: CookieModel) {
|
||||
val content = NotificationContent(data,
|
||||
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")
|
||||
"https://www.iconexperience.com/_img/v_collection_png/256x256/shadow/dog.png"
|
||||
)
|
||||
createNotification(context, content).notify(context)
|
||||
}
|
||||
|
||||
@ -185,7 +212,6 @@ enum class NotificationType(
|
||||
FrostNotification(group, notifId, notifBuilder)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a summary notification to wrap the previous ones
|
||||
* This will always produce sound, vibration, and lights based on preferences
|
||||
@ -211,31 +237,33 @@ enum class NotificationType(
|
||||
|
||||
return FrostNotification(group, 1, notifBuilder)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification data holder
|
||||
*/
|
||||
data class NotificationContent(val data: CookieModel,
|
||||
data class NotificationContent(
|
||||
val data: CookieModel,
|
||||
val id: Long,
|
||||
val href: String,
|
||||
val title: String? = null, // defaults to frost title
|
||||
val text: String,
|
||||
val timestamp: Long,
|
||||
val profileUrl: String?) {
|
||||
val profileUrl: String?
|
||||
) {
|
||||
|
||||
val notifId = Math.abs(id.toInt())
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for a complete notification builder and identifier
|
||||
* which can be immediately notified when given a [Context]
|
||||
*/
|
||||
data class FrostNotification(private val tag: String,
|
||||
data class FrostNotification(
|
||||
private val tag: String,
|
||||
private val id: Int,
|
||||
val notif: NotificationCompat.Builder) {
|
||||
val notif: NotificationCompat.Builder
|
||||
) {
|
||||
|
||||
fun withAlert(enable: Boolean, ringtone: String): FrostNotification {
|
||||
notif.setFrostAlert(enable, ringtone)
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.services
|
||||
|
||||
import android.app.job.JobInfo
|
||||
@ -39,8 +55,8 @@ private enum class FrostRequestCommands : EnumBundle<FrostRequestCommands> {
|
||||
override fun propagate(bundle: BaseBundle) =
|
||||
FrostRunnable.prepareMarkNotificationRead(
|
||||
bundle.getLong(ARG_0),
|
||||
bundle.getCookie())
|
||||
|
||||
bundle.getCookie()
|
||||
)
|
||||
};
|
||||
|
||||
override val bundleContract: EnumBundleCompanion<FrostRequestCommands>
|
||||
@ -58,7 +74,6 @@ private enum class FrostRequestCommands : EnumBundle<FrostRequestCommands> {
|
||||
abstract fun propagate(bundle: BaseBundle): BaseBundle.() -> Unit
|
||||
|
||||
companion object : EnumCompanion<FrostRequestCommands>("frost_arg_commands", values())
|
||||
|
||||
}
|
||||
|
||||
private const val ARG_COMMAND = "frost_request_command"
|
||||
@ -99,8 +114,10 @@ object FrostRunnable {
|
||||
L.d { "Invalid notification id $id for marking as read" }
|
||||
return false
|
||||
}
|
||||
return schedule(context, FrostRequestCommands.NOTIF_READ,
|
||||
prepareMarkNotificationRead(id, cookie))
|
||||
return schedule(
|
||||
context, FrostRequestCommands.NOTIF_READ,
|
||||
prepareMarkNotificationRead(id, cookie)
|
||||
)
|
||||
}
|
||||
|
||||
fun propagate(context: Context, intent: Intent?) {
|
||||
@ -112,9 +129,11 @@ object FrostRunnable {
|
||||
schedule(context, command, builder)
|
||||
}
|
||||
|
||||
private fun schedule(context: Context,
|
||||
private fun schedule(
|
||||
context: Context,
|
||||
command: FrostRequestCommands,
|
||||
bundleBuilder: PersistableBundle.() -> Unit): Boolean {
|
||||
bundleBuilder: PersistableBundle.() -> Unit
|
||||
): Boolean {
|
||||
val scheduler = context.getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler
|
||||
val serviceComponent = ComponentName(context, FrostRequestService::class.java)
|
||||
val bundle = PersistableBundle()
|
||||
@ -139,7 +158,6 @@ object FrostRunnable {
|
||||
L.d { "Scheduled ${command.name}" }
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FrostRequestService : JobService() {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.services
|
||||
|
||||
import android.app.job.JobParameters
|
||||
@ -31,10 +47,12 @@ class NotificationService : JobService() {
|
||||
override fun onStopJob(params: JobParameters?): Boolean {
|
||||
val time = System.currentTimeMillis() - startTime
|
||||
L.d { "Notification service has finished abruptly in $time ms" }
|
||||
frostEvent("NotificationTime",
|
||||
frostEvent(
|
||||
"NotificationTime",
|
||||
"Type" to "Service force stop",
|
||||
"IM Included" to Prefs.notificationsInstantMessages,
|
||||
"Duration" to time)
|
||||
"Duration" to time
|
||||
)
|
||||
future?.cancel(true)
|
||||
future = null
|
||||
return false
|
||||
@ -43,10 +61,12 @@ class NotificationService : JobService() {
|
||||
fun finish(params: JobParameters?) {
|
||||
val time = System.currentTimeMillis() - startTime
|
||||
L.i { "Notification service has finished in $time ms" }
|
||||
frostEvent("NotificationTime",
|
||||
frostEvent(
|
||||
"NotificationTime",
|
||||
"Type" to "Service",
|
||||
"IM Included" to Prefs.notificationsInstantMessages,
|
||||
"Duration" to time)
|
||||
"Duration" to time
|
||||
)
|
||||
jobFinished(params, false)
|
||||
future?.cancel(true)
|
||||
future = null
|
||||
@ -61,11 +81,13 @@ class NotificationService : JobService() {
|
||||
var notifCount = 0
|
||||
cookies.forEach {
|
||||
val current = it.id == currentId
|
||||
if (Prefs.notificationsGeneral
|
||||
&& (current || Prefs.notificationAllAccounts))
|
||||
if (Prefs.notificationsGeneral &&
|
||||
(current || Prefs.notificationAllAccounts)
|
||||
)
|
||||
notifCount += fetch(jobId, NotificationType.GENERAL, it)
|
||||
if (Prefs.notificationsInstantMessages
|
||||
&& (current || Prefs.notificationsImAllAccounts))
|
||||
if (Prefs.notificationsInstantMessages &&
|
||||
(current || Prefs.notificationsImAllAccounts)
|
||||
)
|
||||
notifCount += fetch(jobId, NotificationType.MESSAGE, it)
|
||||
}
|
||||
|
||||
@ -104,5 +126,4 @@ class NotificationService : JobService() {
|
||||
.setContentText(string(textRes))
|
||||
NotificationManagerCompat.from(this).notify(id, notifBuilder.build())
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.services
|
||||
|
||||
import android.app.Notification
|
||||
@ -32,8 +48,8 @@ fun setupNotificationChannels(c: Context) {
|
||||
val msg = c.string(R.string.messages)
|
||||
manager.notificationChannels
|
||||
.filter {
|
||||
it.id != NOTIF_CHANNEL_GENERAL
|
||||
&& it.id != NOTIF_CHANNEL_MESSAGES
|
||||
it.id != NOTIF_CHANNEL_GENERAL &&
|
||||
it.id != NOTIF_CHANNEL_MESSAGES
|
||||
}
|
||||
.forEach { manager.deleteNotificationChannel(it.id) }
|
||||
manager.createNotificationChannel(NOTIF_CHANNEL_GENERAL, appName)
|
||||
@ -43,8 +59,10 @@ fun setupNotificationChannels(c: Context) {
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun NotificationManager.createNotificationChannel(id: String, name: String): NotificationChannel {
|
||||
val channel = NotificationChannel(id,
|
||||
name, NotificationManager.IMPORTANCE_DEFAULT)
|
||||
val channel = NotificationChannel(
|
||||
id,
|
||||
name, NotificationManager.IMPORTANCE_DEFAULT
|
||||
)
|
||||
channel.enableLights(true)
|
||||
channel.lightColor = Prefs.accentColor
|
||||
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
@ -71,7 +89,8 @@ fun NotificationCompat.Builder.setFrostAlert(enable: Boolean, ringtone: String):
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
setGroupAlertBehavior(
|
||||
if (enable) NotificationCompat.GROUP_ALERT_CHILDREN
|
||||
else NotificationCompat.GROUP_ALERT_SUMMARY)
|
||||
else NotificationCompat.GROUP_ALERT_SUMMARY
|
||||
)
|
||||
} else if (!enable) {
|
||||
setDefaults(0)
|
||||
} else {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.services
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
@ -18,5 +34,4 @@ class UpdateReceiver : BroadcastReceiver() {
|
||||
L.d { "Frost has updated" }
|
||||
context.scheduleNotifications(Prefs.notificationFreq) //Update notifications
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.settings
|
||||
|
||||
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
|
||||
@ -10,7 +26,16 @@ import com.pitchedapps.frost.activities.SettingsActivity
|
||||
import com.pitchedapps.frost.enums.MainActivityLayout
|
||||
import com.pitchedapps.frost.enums.Theme
|
||||
import com.pitchedapps.frost.injectors.CssAssets
|
||||
import com.pitchedapps.frost.utils.*
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.REQUEST_NAV
|
||||
import com.pitchedapps.frost.utils.REQUEST_REFRESH
|
||||
import com.pitchedapps.frost.utils.REQUEST_TEXT_ZOOM
|
||||
import com.pitchedapps.frost.utils.frostEvent
|
||||
import com.pitchedapps.frost.utils.frostNavigationBar
|
||||
import com.pitchedapps.frost.utils.frostSnackbar
|
||||
import com.pitchedapps.frost.utils.launchTabCustomizerActivity
|
||||
import com.pitchedapps.frost.utils.materialDialogThemed
|
||||
import com.pitchedapps.frost.utils.setFrostTheme
|
||||
import com.pitchedapps.frost.views.KPrefTextSeekbar
|
||||
|
||||
/**
|
||||
@ -74,7 +99,6 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
allowCustomAlpha = false
|
||||
}
|
||||
|
||||
|
||||
colorPicker(R.string.background_color, Prefs::customBackgroundColor, {
|
||||
Prefs.customBackgroundColor = it
|
||||
bgCanvas.ripple(it, duration = 500L)
|
||||
@ -146,13 +170,16 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
descRes = R.string.tint_nav_desc
|
||||
}
|
||||
|
||||
list.add(KPrefTextSeekbar(
|
||||
list.add(
|
||||
KPrefTextSeekbar(
|
||||
KPrefSeekbar.KPrefSeekbarBuilder(
|
||||
globalOptions,
|
||||
R.string.web_text_scaling, Prefs::webTextScaling) {
|
||||
R.string.web_text_scaling, Prefs::webTextScaling
|
||||
) {
|
||||
Prefs.webTextScaling = it
|
||||
setFrostResult(REQUEST_TEXT_ZOOM)
|
||||
}))
|
||||
})
|
||||
)
|
||||
|
||||
checkbox(R.string.enforce_black_media_bg, Prefs::blackMediaBg, {
|
||||
Prefs.blackMediaBg = it
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.settings
|
||||
|
||||
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
|
||||
@ -15,7 +31,10 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
descRes = R.string.fancy_animations_desc
|
||||
}
|
||||
|
||||
checkbox(R.string.overlay_swipe, Prefs::overlayEnabled, { Prefs.overlayEnabled = it; setFrostResult(REQUEST_REFRESH) }) {
|
||||
checkbox(
|
||||
R.string.overlay_swipe,
|
||||
Prefs::overlayEnabled,
|
||||
{ Prefs.overlayEnabled = it; setFrostResult(REQUEST_REFRESH) }) {
|
||||
descRes = R.string.overlay_swipe_desc
|
||||
}
|
||||
|
||||
@ -46,5 +65,4 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
checkbox(R.string.analytics, Prefs::analytics, { Prefs.analytics = it }) {
|
||||
descRes = R.string.analytics_desc
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.settings
|
||||
|
||||
import android.content.Context
|
||||
@ -77,7 +93,6 @@ fun SettingsActivity.getDebugPrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,10 +107,12 @@ private const val ZIP_NAME = "debug"
|
||||
|
||||
fun SettingsActivity.sendDebug(url: String, html: String?) {
|
||||
|
||||
val downloader = OfflineWebsite(url, FbCookie.webCookie ?: "",
|
||||
val downloader = OfflineWebsite(
|
||||
url, FbCookie.webCookie ?: "",
|
||||
baseUrl = FB_URL_BASE,
|
||||
html = html,
|
||||
baseDir = DebugActivity.baseDir(this))
|
||||
baseDir = DebugActivity.baseDir(this)
|
||||
)
|
||||
|
||||
val md = materialDialog {
|
||||
title(R.string.parsing_data)
|
||||
@ -114,7 +131,8 @@ fun SettingsActivity.sendDebug(url: String, html: String?) {
|
||||
it.dismiss()
|
||||
if (success) {
|
||||
val zipUri = it.context.frostUriFromFile(
|
||||
File(downloader.baseDir, "$ZIP_NAME.zip"))
|
||||
File(downloader.baseDir, "$ZIP_NAME.zip")
|
||||
)
|
||||
L.i { "Sending debug zip with uri $zipUri" }
|
||||
sendFrostEmail(R.string.debug_report_email_title) {
|
||||
addItem("Url", url)
|
||||
@ -128,7 +146,5 @@ fun SettingsActivity.sendDebug(url: String, html: String?) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.settings
|
||||
|
||||
import android.util.Log
|
||||
@ -24,7 +40,6 @@ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
|
||||
// Experimental content starts here ------------------
|
||||
|
||||
|
||||
// Experimental content ends here --------------------
|
||||
|
||||
checkbox(R.string.verbose_logging, Prefs::verboseLogging, {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.settings
|
||||
|
||||
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.settings
|
||||
|
||||
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
|
||||
@ -10,8 +26,10 @@ import com.pitchedapps.frost.utils.Prefs
|
||||
*/
|
||||
fun SettingsActivity.getNetworkPrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
|
||||
checkbox(R.string.network_media_on_metered, { !Prefs.loadMediaOnMeteredNetwork }, { Prefs.loadMediaOnMeteredNetwork = !it }) {
|
||||
checkbox(
|
||||
R.string.network_media_on_metered,
|
||||
{ !Prefs.loadMediaOnMeteredNetwork },
|
||||
{ Prefs.loadMediaOnMeteredNetwork = !it }) {
|
||||
descRes = R.string.network_media_on_metered_desc
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.settings
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
@ -22,7 +38,6 @@ import com.pitchedapps.frost.utils.frostSnackbar
|
||||
import com.pitchedapps.frost.utils.materialDialogThemed
|
||||
import com.pitchedapps.frost.views.Keywords
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-06-29.
|
||||
*/
|
||||
@ -109,8 +124,10 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
} else {
|
||||
checkbox(R.string.notification_sound, Prefs::notificationSound, {
|
||||
Prefs.notificationSound = it
|
||||
reloadByTitle(R.string.notification_ringtone,
|
||||
R.string.message_ringtone)
|
||||
reloadByTitle(
|
||||
R.string.notification_ringtone,
|
||||
R.string.message_ringtone
|
||||
)
|
||||
})
|
||||
|
||||
fun KPrefText.KPrefTextContract<String>.ringtone(code: Int) {
|
||||
@ -170,5 +187,4 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
|
||||
frostSnackbar(text)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import android.content.Context
|
||||
|
@ -1,8 +1,24 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import android.graphics.drawable.AnimatedVectorDrawable
|
||||
import androidx.annotation.DrawableRes
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.DrawableRes
|
||||
import ca.allanwang.kau.utils.drawable
|
||||
|
||||
/**
|
||||
@ -70,15 +86,11 @@ class AnimatedVectorDelegate(
|
||||
|
||||
private fun animateImpl(toStart: Boolean) {
|
||||
if ((atStart == toStart)) return L.d { "AVD already at ${if (toStart) "start" else "end"}" }
|
||||
if (avd == null) return L.d { "AVD null resource" }//no longer using animated vector; do not modify
|
||||
if (avd == null) return L.d { "AVD null resource" } //no longer using animated vector; do not modify
|
||||
avd?.stop()
|
||||
view.setImageResource(if (toStart) avdEnd else avdStart)
|
||||
animatedVectorListener?.invoke(avd!!, !toStart)
|
||||
atStart = toStart
|
||||
avd?.start()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
object BuildUtils {
|
||||
@ -21,5 +37,4 @@ object BuildUtils {
|
||||
arrayOf(BUILD_PRODUCTION, BUILD_TEST, BUILD_GITHUB, BUILD_RELEASE, BUILD_UNNAMED)
|
||||
|
||||
fun getStage(build: String): String = build.takeIf { it in getAllStages() } ?: BUILD_UNNAMED
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import android.app.DownloadManager
|
||||
@ -16,26 +32,29 @@ import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.dbflow.loadFbCookie
|
||||
import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-08-04.
|
||||
*
|
||||
* With reference to <a href="https://stackoverflow.com/questions/33434532/android-webview-download-files-like-browsers-do">Stack Overflow</a>
|
||||
*/
|
||||
fun Context.frostDownload(url: String?,
|
||||
fun Context.frostDownload(
|
||||
url: String?,
|
||||
userAgent: String = USER_AGENT_BASIC,
|
||||
contentDisposition: String? = null,
|
||||
mimeType: String? = null,
|
||||
contentLength: Long = 0L) {
|
||||
contentLength: Long = 0L
|
||||
) {
|
||||
url ?: return
|
||||
frostDownload(Uri.parse(url), userAgent, contentDisposition, mimeType, contentLength)
|
||||
}
|
||||
|
||||
fun Context.frostDownload(uri: Uri?,
|
||||
fun Context.frostDownload(
|
||||
uri: Uri?,
|
||||
userAgent: String = USER_AGENT_BASIC,
|
||||
contentDisposition: String? = null,
|
||||
mimeType: String? = null,
|
||||
contentLength: Long = 0L) {
|
||||
contentLength: Long = 0L
|
||||
) {
|
||||
uri ?: return
|
||||
L.d { "Received download request" }
|
||||
if (uri.scheme != "http" && uri.scheme != "https") {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import android.content.Intent
|
||||
@ -39,12 +55,12 @@ interface EnumBundleCompanion<E : Enum<E>> {
|
||||
operator fun get(bundle: BaseBundle?) = get(bundle?.getString(argTag))
|
||||
|
||||
operator fun get(intent: Intent?) = get(intent?.getStringExtra(argTag))
|
||||
|
||||
}
|
||||
|
||||
open class EnumCompanion<E : Enum<E>>(
|
||||
final override val argTag: String,
|
||||
final override val values: Array<E>) : EnumBundleCompanion<E> {
|
||||
final override val values: Array<E>
|
||||
) : EnumBundleCompanion<E> {
|
||||
|
||||
final override val valueMap: Map<String, E> = values.map { it.name to it }.toMap()
|
||||
|
||||
@ -53,5 +69,4 @@ open class EnumCompanion<E : Enum<E>>(
|
||||
final override fun get(bundle: BaseBundle?) = super.get(bundle)
|
||||
|
||||
final override fun get(intent: Intent?) = super.get(intent)
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import org.jsoup.Jsoup
|
||||
@ -21,8 +37,10 @@ internal fun String.cleanJsoup(): String = Jsoup.clean(this, PrivacyWhitelist())
|
||||
class PrivacyWhitelist : Whitelist() {
|
||||
|
||||
val blacklistAttrs = arrayOf("style", "aria-label", "rel")
|
||||
val blacklistTags = arrayOf("body", "html", "head", "i", "b", "u", "style", "script",
|
||||
"br", "p", "span", "ul", "ol", "li")
|
||||
val blacklistTags = arrayOf(
|
||||
"body", "html", "head", "i", "b", "u", "style", "script",
|
||||
"br", "p", "span", "ul", "ol", "li"
|
||||
)
|
||||
|
||||
override fun isSafeAttribute(tagName: String, el: Element, attr: Attribute): Boolean {
|
||||
val key = attr.key
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import android.util.Log
|
||||
@ -5,7 +21,6 @@ import ca.allanwang.kau.logging.KauLogger
|
||||
import com.bugsnag.android.Bugsnag
|
||||
import com.pitchedapps.frost.BuildConfig
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-05-28.
|
||||
*
|
||||
@ -45,5 +60,4 @@ object L : KauLogger("Frost", {
|
||||
Bugsnag.notify(t)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import android.graphics.Color
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import ca.allanwang.kau.kpref.KPref
|
||||
@ -21,4 +37,3 @@ object Showcase : KPref() {
|
||||
|
||||
override fun deleteKeys() = arrayOf("shown_release")
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
@ -8,33 +24,59 @@ import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.net.Uri
|
||||
import androidx.annotation.StringRes
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.content.FileProvider
|
||||
import ca.allanwang.kau.email.EmailBuilder
|
||||
import ca.allanwang.kau.email.sendEmail
|
||||
import ca.allanwang.kau.mediapicker.createMediaFile
|
||||
import ca.allanwang.kau.mediapicker.createPrivateMediaFile
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.adjustAlpha
|
||||
import ca.allanwang.kau.utils.colorToForeground
|
||||
import ca.allanwang.kau.utils.darken
|
||||
import ca.allanwang.kau.utils.isColorDark
|
||||
import ca.allanwang.kau.utils.lighten
|
||||
import ca.allanwang.kau.utils.navigationBarColor
|
||||
import ca.allanwang.kau.utils.snackbar
|
||||
import ca.allanwang.kau.utils.startActivity
|
||||
import ca.allanwang.kau.utils.startActivityForResult
|
||||
import ca.allanwang.kau.utils.statusBarColor
|
||||
import ca.allanwang.kau.utils.string
|
||||
import ca.allanwang.kau.utils.with
|
||||
import ca.allanwang.kau.utils.withAlpha
|
||||
import ca.allanwang.kau.utils.withMinAlpha
|
||||
import ca.allanwang.kau.xml.showChangelog
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.snackbar.SnackbarContentLayout
|
||||
import com.pitchedapps.frost.BuildConfig
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.activities.*
|
||||
import com.pitchedapps.frost.activities.ImageActivity
|
||||
import com.pitchedapps.frost.activities.LoginActivity
|
||||
import com.pitchedapps.frost.activities.SelectorActivity
|
||||
import com.pitchedapps.frost.activities.SettingsActivity
|
||||
import com.pitchedapps.frost.activities.TabCustomizerActivity
|
||||
import com.pitchedapps.frost.activities.WebOverlayActivity
|
||||
import com.pitchedapps.frost.activities.WebOverlayActivityBase
|
||||
import com.pitchedapps.frost.activities.WebOverlayBasicActivity
|
||||
import com.pitchedapps.frost.dbflow.CookieModel
|
||||
import com.pitchedapps.frost.facebook.*
|
||||
import com.pitchedapps.frost.facebook.FACEBOOK_COM
|
||||
import com.pitchedapps.frost.facebook.FBCDN_NET
|
||||
import com.pitchedapps.frost.facebook.FbCookie
|
||||
import com.pitchedapps.frost.facebook.FbItem
|
||||
import com.pitchedapps.frost.facebook.FbUrlFormatter.Companion.VIDEO_REDIRECT
|
||||
import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
|
||||
import com.pitchedapps.frost.facebook.formattedFbUrl
|
||||
import org.apache.commons.text.StringEscapeUtils
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Element
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-06-03.
|
||||
@ -46,7 +88,10 @@ const val ARG_IMAGE_URL = "arg_image_url"
|
||||
const val ARG_TEXT = "arg_text"
|
||||
const val ARG_COOKIE = "arg_cookie"
|
||||
|
||||
inline fun <reified T : Activity> Context.launchNewTask(cookieList: ArrayList<CookieModel> = arrayListOf(), clearStack: Boolean = false) {
|
||||
inline fun <reified T : Activity> Context.launchNewTask(
|
||||
cookieList: ArrayList<CookieModel> = arrayListOf(),
|
||||
clearStack: Boolean = false
|
||||
) {
|
||||
startActivity<T>(clearStack, intentBuilder = {
|
||||
putParcelableArrayListExtra(EXTRA_COOKIES, cookieList)
|
||||
})
|
||||
@ -81,8 +126,10 @@ fun Context.launchWebOverlay(url: String) = launchWebOverlayImpl<WebOverlayActiv
|
||||
|
||||
fun Context.launchWebOverlayBasic(url: String) = launchWebOverlayImpl<WebOverlayBasicActivity>(url)
|
||||
|
||||
private fun Context.fadeBundle() = ActivityOptions.makeCustomAnimation(this,
|
||||
android.R.anim.fade_in, android.R.anim.fade_out).toBundle()
|
||||
private fun Context.fadeBundle() = ActivityOptions.makeCustomAnimation(
|
||||
this,
|
||||
android.R.anim.fade_in, android.R.anim.fade_out
|
||||
).toBundle()
|
||||
|
||||
fun Context.launchImageActivity(imageUrl: String, text: String? = null, cookie: String? = null) {
|
||||
startActivity<ImageActivity>(intentBuilder = {
|
||||
@ -174,7 +221,6 @@ inline fun Activity.setFrostColors(builder: ActivityThemeUtils.() -> Unit) {
|
||||
themer.theme(this)
|
||||
}
|
||||
|
||||
|
||||
fun frostEvent(name: String, vararg events: Pair<String, Any>) {
|
||||
// todo bind
|
||||
L.v { "Event: $name ${events.joinToString(", ")}" }
|
||||
@ -189,9 +235,11 @@ fun Throwable?.logFrostEvent(text: String) {
|
||||
frostEvent("Errors", "text" to text, "message" to (this?.message ?: "NA"))
|
||||
}
|
||||
|
||||
fun Activity.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder))
|
||||
fun Activity.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) =
|
||||
snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder))
|
||||
|
||||
fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) = snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder))
|
||||
fun View.frostSnackbar(@StringRes text: Int, builder: Snackbar.() -> Unit = {}) =
|
||||
snackbar(text, Snackbar.LENGTH_LONG, frostSnackbar(builder))
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snackbar.() -> Unit = {
|
||||
@ -297,16 +345,20 @@ fun Context.frostChangelog() = showChangelog(R.xml.frost_changelog, Prefs.textCo
|
||||
}
|
||||
|
||||
fun Context.frostUriFromFile(file: File): Uri =
|
||||
FileProvider.getUriForFile(this,
|
||||
FileProvider.getUriForFile(
|
||||
this,
|
||||
BuildConfig.APPLICATION_ID + ".provider",
|
||||
file)
|
||||
file
|
||||
)
|
||||
|
||||
inline fun Context.sendFrostEmail(@StringRes subjectId: Int, crossinline builder: EmailBuilder.() -> Unit) = sendFrostEmail(string(subjectId), builder)
|
||||
inline fun Context.sendFrostEmail(@StringRes subjectId: Int, crossinline builder: EmailBuilder.() -> Unit) =
|
||||
sendFrostEmail(string(subjectId), builder)
|
||||
|
||||
inline fun Context.sendFrostEmail(subjectId: String, crossinline builder: EmailBuilder.() -> Unit) = sendEmail(string(R.string.dev_email), subjectId) {
|
||||
inline fun Context.sendFrostEmail(subjectId: String, crossinline builder: EmailBuilder.() -> Unit) =
|
||||
sendEmail(string(R.string.dev_email), subjectId) {
|
||||
builder()
|
||||
addFrostDetails()
|
||||
}
|
||||
}
|
||||
|
||||
fun EmailBuilder.addFrostDetails() {
|
||||
addItem("Prev version", Prefs.prevVersionCode.toString())
|
||||
@ -318,7 +370,8 @@ fun EmailBuilder.addFrostDetails() {
|
||||
|
||||
fun frostJsoup(url: String) = frostJsoup(FbCookie.webCookie, url)
|
||||
|
||||
fun frostJsoup(cookie: String?, url: String) = Jsoup.connect(url).cookie(FACEBOOK_COM, cookie).userAgent(USER_AGENT_BASIC).get()!!
|
||||
fun frostJsoup(cookie: String?, url: String) =
|
||||
Jsoup.connect(url).cookie(FACEBOOK_COM, cookie).userAgent(USER_AGENT_BASIC).get()!!
|
||||
|
||||
fun Element.first(vararg select: String): Element? {
|
||||
select.forEach {
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.utils
|
||||
|
||||
import android.content.Context
|
||||
@ -41,7 +57,9 @@ class WebContext(val unformattedUrl: String, val text: String?) {
|
||||
enum class WebContextType(val textId: Int, val onClick: (c: Context, wc: WebContext) -> Unit) {
|
||||
OPEN_LINK(R.string.open_link, { c, wc -> c.launchWebOverlay(wc.unformattedUrl) }),
|
||||
COPY_LINK(R.string.copy_link, { c, wc -> c.copyToClipboard(wc.url) }),
|
||||
COPY_TEXT(R.string.copy_text, { c, wc -> if (wc.text != null) c.copyToClipboard(wc.text) else c.toast(R.string.no_text) }),
|
||||
COPY_TEXT(
|
||||
R.string.copy_text,
|
||||
{ c, wc -> if (wc.text != null) c.copyToClipboard(wc.text) else c.toast(R.string.no_text) }),
|
||||
SHARE_LINK(R.string.share_link, { c, wc -> c.shareText(wc.url) }),
|
||||
DEBUG_LINK(R.string.debug_link, { c, wc ->
|
||||
c.materialDialogThemed {
|
||||
|
@ -1,12 +1,32 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ca.allanwang.kau.iitems.KauIItem
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.fadeIn
|
||||
import ca.allanwang.kau.utils.invisible
|
||||
import ca.allanwang.kau.utils.toDrawable
|
||||
import ca.allanwang.kau.utils.visible
|
||||
import com.bumptech.glide.load.DataSource
|
||||
import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
@ -23,7 +43,7 @@ import com.pitchedapps.frost.utils.Prefs
|
||||
* Created by Allan Wang on 2017-06-05.
|
||||
*/
|
||||
class AccountItem(val cookie: CookieModel?) : KauIItem<AccountItem, AccountItem.ViewHolder>
|
||||
(R.layout.view_account, { ViewHolder(it) }, R.id.item_account) {
|
||||
(R.layout.view_account, { ViewHolder(it) }, R.id.item_account) {
|
||||
|
||||
override fun bindView(viewHolder: ViewHolder, payloads: MutableList<Any>) {
|
||||
super.bindView(viewHolder, payloads)
|
||||
@ -34,19 +54,36 @@ class AccountItem(val cookie: CookieModel?) : KauIItem<AccountItem, AccountItem.
|
||||
text.text = cookie.name
|
||||
GlideApp.with(itemView).load(profilePictureUrl(cookie.id))
|
||||
.transform(FrostGlide.roundCorner).listener(object : RequestListener<Drawable> {
|
||||
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
|
||||
override fun onResourceReady(
|
||||
resource: Drawable?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
dataSource: DataSource?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
text.fadeIn()
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
||||
override fun onLoadFailed(
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
text.fadeIn()
|
||||
return false
|
||||
}
|
||||
}).into(image)
|
||||
} else {
|
||||
text.visible()
|
||||
image.setImageDrawable(GoogleMaterial.Icon.gmd_add_circle_outline.toDrawable(itemView.context, 100, Prefs.textColor))
|
||||
image.setImageDrawable(
|
||||
GoogleMaterial.Icon.gmd_add_circle_outline.toDrawable(
|
||||
itemView.context,
|
||||
100,
|
||||
Prefs.textColor
|
||||
)
|
||||
)
|
||||
text.text = itemView.context.getString(R.string.kau_add_account)
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,50 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import android.util.AttributeSet
|
||||
import ca.allanwang.kau.utils.*
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import ca.allanwang.kau.utils.colorToForeground
|
||||
import ca.allanwang.kau.utils.dpToPx
|
||||
import ca.allanwang.kau.utils.gone
|
||||
import ca.allanwang.kau.utils.toDrawable
|
||||
import ca.allanwang.kau.utils.visible
|
||||
import ca.allanwang.kau.utils.withAlpha
|
||||
import com.mikepenz.iconics.typeface.IIcon
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import kotlinx.android.synthetic.main.view_badged_icon.view.*
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-06-19.
|
||||
*/
|
||||
class BadgedIcon @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.view_badged_icon, this)
|
||||
val badgeColor = Prefs.mainActivityLayout.backgroundColor().withAlpha(255).colorToForeground(0.2f)
|
||||
val badgeBackground = GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, intArrayOf(badgeColor, badgeColor))
|
||||
val badgeBackground =
|
||||
GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, intArrayOf(badgeColor, badgeColor))
|
||||
badgeBackground.cornerRadius = 13.dpToPx.toFloat()
|
||||
badge_text.background = badgeBackground
|
||||
badge_text.setTextColor(Prefs.mainActivityLayout.iconColor())
|
||||
@ -30,7 +53,13 @@ class BadgedIcon @JvmOverloads constructor(
|
||||
var iicon: IIcon? = null
|
||||
set(value) {
|
||||
field = value
|
||||
badge_image.setImageDrawable(value?.toDrawable(context, sizeDp = 20, color = Prefs.mainActivityLayout.iconColor()))
|
||||
badge_image.setImageDrawable(
|
||||
value?.toDrawable(
|
||||
context,
|
||||
sizeDp = 20,
|
||||
color = Prefs.mainActivityLayout.iconColor()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun setAllAlpha(alpha: Float) {
|
||||
@ -46,5 +75,4 @@ class BadgedIcon @JvmOverloads constructor(
|
||||
if (value != null && value != "0") badge_text.visible()
|
||||
else badge_text.gone()
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,36 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ProgressBar
|
||||
import ca.allanwang.kau.utils.*
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.circularReveal
|
||||
import ca.allanwang.kau.utils.fadeIn
|
||||
import ca.allanwang.kau.utils.fadeOut
|
||||
import ca.allanwang.kau.utils.invisibleIf
|
||||
import ca.allanwang.kau.utils.isVisible
|
||||
import ca.allanwang.kau.utils.tint
|
||||
import ca.allanwang.kau.utils.withAlpha
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.contracts.FrostContentContainer
|
||||
import com.pitchedapps.frost.contracts.FrostContentCore
|
||||
@ -24,23 +47,30 @@ import io.reactivex.subjects.BehaviorSubject
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
|
||||
class FrostContentWeb @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
) : FrostContentView<FrostWebView>(context, attrs, defStyleAttr, defStyleRes) {
|
||||
|
||||
override val layoutRes: Int = R.layout.view_content_base_web
|
||||
|
||||
}
|
||||
|
||||
class FrostContentRecycler @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
) : FrostContentView<FrostRecyclerView>(context, attrs, defStyleAttr, defStyleRes) {
|
||||
|
||||
override val layoutRes: Int = R.layout.view_content_base_recycler
|
||||
|
||||
}
|
||||
|
||||
abstract class FrostContentView<out T> @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes),
|
||||
FrostContentParent where T : View, T : FrostContentCore {
|
||||
|
||||
@ -96,7 +126,6 @@ abstract class FrostContentView<out T> @JvmOverloads constructor(
|
||||
refresh.setOnRefreshListener { coreView.reload(true) }
|
||||
|
||||
reloadThemeSelf()
|
||||
|
||||
}
|
||||
|
||||
override fun bind(container: FrostContentContainer) {
|
||||
|
@ -1,10 +1,26 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.content.Context
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ca.allanwang.kau.utils.circularReveal
|
||||
import ca.allanwang.kau.utils.fadeOut
|
||||
import com.pitchedapps.frost.contracts.FrostContentContainer
|
||||
@ -18,7 +34,9 @@ import com.pitchedapps.frost.utils.Prefs
|
||||
*
|
||||
*/
|
||||
class FrostRecyclerView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RecyclerView(context, attrs, defStyleAttr),
|
||||
FrostContentCore {
|
||||
|
||||
@ -102,5 +120,4 @@ class FrostRecyclerView @JvmOverloads constructor(
|
||||
override fun reloadTextSizeSelf() {
|
||||
// todo
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
@ -27,7 +43,9 @@ import com.pitchedapps.frost.utils.Prefs
|
||||
* Parent must have layout with both height & width as match_parent
|
||||
*/
|
||||
class FrostVideoView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : VideoView(context, attrs, defStyleAttr) {
|
||||
|
||||
/**
|
||||
@ -105,7 +123,10 @@ class FrostVideoView @JvmOverloads constructor(
|
||||
videoDimensions.set(dimen, dimen)
|
||||
}
|
||||
val portrait = height > width
|
||||
val scale = Math.min(height / (if (portrait) 4f else 2.3f) / videoDimensions.y, width / (if (portrait) 2.3f else 4f) / videoDimensions.x)
|
||||
val scale = Math.min(
|
||||
height / (if (portrait) 4f else 2.3f) / videoDimensions.y,
|
||||
width / (if (portrait) 2.3f else 4f) / videoDimensions.x
|
||||
)
|
||||
val desiredHeight = scale * videoDimensions.y
|
||||
val desiredWidth = scale * videoDimensions.x
|
||||
val padding = containerContract.lowerVideoPadding
|
||||
@ -151,8 +172,8 @@ class FrostVideoView @JvmOverloads constructor(
|
||||
/**
|
||||
* Only remap if not expanded and if dimensions have changed
|
||||
*/
|
||||
val shouldRemap = !isExpanded
|
||||
&& (videoDimensions.x != ratio * intrinsicWidth || videoDimensions.y != ratio * intrinsicHeight)
|
||||
val shouldRemap = !isExpanded &&
|
||||
(videoDimensions.x != ratio * intrinsicWidth || videoDimensions.y != ratio * intrinsicHeight)
|
||||
videoDimensions.set(ratio * intrinsicWidth, ratio * intrinsicHeight)
|
||||
if (shouldRemap) updateLocation()
|
||||
}
|
||||
@ -226,7 +247,8 @@ class FrostVideoView @JvmOverloads constructor(
|
||||
* -------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private inner class FrameTouchListener(context: Context) : GestureDetector.SimpleOnGestureListener(), View.OnTouchListener {
|
||||
private inner class FrameTouchListener(context: Context) : GestureDetector.SimpleOnGestureListener(),
|
||||
View.OnTouchListener {
|
||||
|
||||
private val gestureDetector: GestureDetector = GestureDetector(context, this)
|
||||
|
||||
@ -252,7 +274,8 @@ class FrostVideoView @JvmOverloads constructor(
|
||||
/**
|
||||
* Monitors the view click events to show and hide the video controls if they have been specified.
|
||||
*/
|
||||
private inner class VideoTouchListener(context: Context) : GestureDetector.SimpleOnGestureListener(), View.OnTouchListener {
|
||||
private inner class VideoTouchListener(context: Context) : GestureDetector.SimpleOnGestureListener(),
|
||||
View.OnTouchListener {
|
||||
|
||||
private val gestureDetector: GestureDetector = GestureDetector(context, this)
|
||||
private val downLoc = PointF()
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.content.Context
|
||||
@ -8,11 +24,22 @@ import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewTreeObserver
|
||||
import android.widget.FrameLayout
|
||||
import ca.allanwang.kau.utils.*
|
||||
import ca.allanwang.kau.utils.fadeIn
|
||||
import ca.allanwang.kau.utils.fadeOut
|
||||
import ca.allanwang.kau.utils.gone
|
||||
import ca.allanwang.kau.utils.goneIf
|
||||
import ca.allanwang.kau.utils.inflate
|
||||
import ca.allanwang.kau.utils.isColorDark
|
||||
import ca.allanwang.kau.utils.isGone
|
||||
import ca.allanwang.kau.utils.isVisible
|
||||
import ca.allanwang.kau.utils.setIcon
|
||||
import ca.allanwang.kau.utils.setMenuIcons
|
||||
import ca.allanwang.kau.utils.visible
|
||||
import ca.allanwang.kau.utils.withMinAlpha
|
||||
import com.devbrackets.android.exomedia.listener.VideoControlsVisibilityListener
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.frostDownload
|
||||
import kotlinx.android.synthetic.main.view_video.view.*
|
||||
@ -21,7 +48,9 @@ import kotlinx.android.synthetic.main.view_video.view.*
|
||||
* Created by Allan Wang on 2017-10-13.
|
||||
*/
|
||||
class FrostVideoViewer @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyleAttr), FrostVideoViewerContract {
|
||||
|
||||
companion object {
|
||||
@ -54,11 +83,13 @@ class FrostVideoViewer @JvmOverloads constructor(
|
||||
if (!Prefs.blackMediaBg && Prefs.bgColor.isColorDark)
|
||||
Prefs.bgColor.withMinAlpha(200)
|
||||
else
|
||||
Color.BLACK)
|
||||
Color.BLACK
|
||||
)
|
||||
video.setViewerContract(this)
|
||||
video.pause()
|
||||
video_toolbar.inflateMenu(R.menu.menu_video)
|
||||
context.setMenuIcons(video_toolbar.menu, Prefs.iconColor,
|
||||
context.setMenuIcons(
|
||||
video_toolbar.menu, Prefs.iconColor,
|
||||
R.id.action_pip to GoogleMaterial.Icon.gmd_picture_in_picture_alt,
|
||||
R.id.action_download to GoogleMaterial.Icon.gmd_file_download
|
||||
)
|
||||
@ -141,7 +172,6 @@ class FrostVideoViewer @JvmOverloads constructor(
|
||||
if (!video_toolbar.isGone)
|
||||
video_toolbar.fadeOut(duration = CONTROL_ANIMATION_DURATION) { video_toolbar.gone() }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface FrostVideoViewerContract : VideoControlsVisibilityListener {
|
||||
|
@ -1,10 +1,26 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
|
||||
/**
|
||||
@ -12,7 +28,8 @@ import com.pitchedapps.frost.utils.Prefs
|
||||
*
|
||||
* Basic override to allow us to control swiping
|
||||
*/
|
||||
class FrostViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ViewPager(context, attrs) {
|
||||
class FrostViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
ViewPager(context, attrs) {
|
||||
var enableSwipe = true
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent?) =
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
@ -16,14 +32,20 @@ import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
|
||||
import com.pitchedapps.frost.fragments.WebFragment
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.frostDownload
|
||||
import com.pitchedapps.frost.web.*
|
||||
import com.pitchedapps.frost.web.FrostChromeClient
|
||||
import com.pitchedapps.frost.web.FrostJSI
|
||||
import com.pitchedapps.frost.web.FrostWebViewClient
|
||||
import com.pitchedapps.frost.web.NestedWebView
|
||||
import com.pitchedapps.frost.web.shouldUseBasicAgent
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-05-29.
|
||||
*
|
||||
*/
|
||||
class FrostWebView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : NestedWebView(context, attrs, defStyleAttr),
|
||||
FrostContentCore {
|
||||
|
||||
@ -59,7 +81,6 @@ class FrostWebView @JvmOverloads constructor(
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper to the main userAgentString to cache it.
|
||||
* This decouples it from the UiThread
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
|
@ -1,15 +1,31 @@
|
||||
/*
|
||||
* Copyright 2018 Allan Wang
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.pitchedapps.frost.views
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ca.allanwang.kau.utils.bindView
|
||||
import ca.allanwang.kau.utils.string
|
||||
import ca.allanwang.kau.utils.tint
|
||||
@ -23,12 +39,13 @@ import com.mikepenz.iconics.typeface.IIcon
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-06-19.
|
||||
*/
|
||||
class Keywords @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
val editText: AppCompatEditText by bindView(R.id.edit_text)
|
||||
@ -51,7 +68,8 @@ class Keywords @JvmOverloads constructor(
|
||||
recycler.layoutManager = LinearLayoutManager(context)
|
||||
recycler.adapter = adapter
|
||||
adapter.withEventHook(object : ClickEventHook<KeywordItem>() {
|
||||
override fun onBind(viewHolder: RecyclerView.ViewHolder): View? = (viewHolder as? KeywordItem.ViewHolder)?.delete
|
||||
override fun onBind(viewHolder: RecyclerView.ViewHolder): View? =
|
||||
(viewHolder as? KeywordItem.ViewHolder)?.delete
|
||||
|
||||
override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<KeywordItem>, item: KeywordItem) {
|
||||
adapter.remove(position)
|
||||
@ -62,7 +80,6 @@ class Keywords @JvmOverloads constructor(
|
||||
fun save() {
|
||||
Prefs.notificationKeywords = adapter.adapterItems.mapTo(mutableSetOf()) { it.keyword }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun IIcon.keywordDrawable(context: Context): Drawable = toDrawable(context, 20, Prefs.textColor)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user