aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt17
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt2
10 files changed, 36 insertions, 19 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
index 35d7153f..f9a597db 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
@@ -49,7 +49,6 @@ import com.pitchedapps.frost.facebook.FbCookie.switchUser
import com.pitchedapps.frost.facebook.FbTab
import com.pitchedapps.frost.facebook.PROFILE_PICTURE_URL
import com.pitchedapps.frost.fragments.WebFragment
-import com.pitchedapps.frost.services.NotificationContent
import com.pitchedapps.frost.utils.*
import com.pitchedapps.frost.utils.iab.validatePro
import com.pitchedapps.frost.views.BadgedIcon
@@ -59,7 +58,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
-import org.jetbrains.anko.doAsync
import org.jsoup.Jsoup
import java.util.concurrent.TimeUnit
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
index d197918d..6c1fb5bd 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
@@ -37,10 +37,6 @@ open class WebOverlayActivity : AppCompatActivity(),
val frostWeb: FrostWebView by bindView(R.id.overlay_frost_webview)
val coordinator: CoordinatorLayout by bindView(R.id.overlay_main_content)
- companion object {
- const val ARG_USER_ID = "arg_user_id"
- }
-
val urlTest: String?
get() = intent.extras?.getString(ARG_URL) ?: intent.dataString
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
index 2cea55b4..7b60a718 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
@@ -19,13 +19,10 @@ import com.bumptech.glide.request.transition.Transition
import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.FrostWebActivity
import com.pitchedapps.frost.R
-import com.pitchedapps.frost.WebOverlayActivity
import com.pitchedapps.frost.dbflow.CookieModel
import com.pitchedapps.frost.dbflow.fetchUsername
import com.pitchedapps.frost.facebook.FB_URL_BASE
-import com.pitchedapps.frost.utils.GlideApp
-import com.pitchedapps.frost.utils.L
-import com.pitchedapps.frost.utils.withRoundIcon
+import com.pitchedapps.frost.utils.*
import org.jetbrains.anko.runOnUiThread
/**
@@ -38,6 +35,12 @@ val Context.frostNotification: NotificationCompat.Builder
color = color(R.color.frost_notification_accent)
}
+fun Notification.frostConfig() = apply {
+ if (Prefs.notificationVibrate) defaults = defaults or Notification.DEFAULT_VIBRATE
+ if (Prefs.notificationSound) defaults = defaults or Notification.DEFAULT_SOUND
+ if (Prefs.notificationLights) defaults = defaults or Notification.DEFAULT_LIGHTS
+}
+
val NotificationCompat.Builder.withBigText: NotificationCompat.BigTextStyle
get() = NotificationCompat.BigTextStyle(this)
@@ -54,7 +57,7 @@ class FrostNotificationTarget(val context: Context,
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>) {
builder.setLargeIcon(resource)
- NotificationManagerCompat.from(context).notify(notifTag, notifId, builder.withBigText.build())
+ NotificationManagerCompat.from(context).notify(notifTag, notifId, builder.withBigText.build().frostConfig())
}
}
@@ -78,7 +81,7 @@ data class NotificationContent(val data: CookieModel,
} else {
val intent = Intent(context, FrostWebActivity::class.java)
intent.data = Uri.parse("${FB_URL_BASE}$href")
- intent.putExtra(WebOverlayActivity.ARG_USER_ID, data.id)
+ intent.putExtra(ARG_USER_ID, data.id)
val group = "frost_${data.id}"
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
val notifBuilder = context.frostNotification
@@ -91,7 +94,7 @@ data class NotificationContent(val data: CookieModel,
if (timestamp != -1L) notifBuilder.setWhen(timestamp * 1000)
L.v("Notif load $this")
- NotificationManagerCompat.from(context).notify(group, notifId, notifBuilder.withBigText.build())
+ NotificationManagerCompat.from(context).notify(group, notifId, notifBuilder.withBigText.build().frostConfig())
if (profileUrl.isNotBlank()) {
context.runOnUiThread {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
index f9d0c63c..38282bf7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -174,7 +174,7 @@ class NotificationService : JobService() {
val notifBuilder = frostNotification
.setContentTitle(string(R.string.app_name))
.setContentText(text)
- NotificationManagerCompat.from(this).notify(999, notifBuilder.build())
+ NotificationManagerCompat.from(this).notify(999, notifBuilder.build().frostConfig())
}
fun summaryNotification(userId: Long, count: Int) {
@@ -185,7 +185,7 @@ class NotificationService : JobService() {
.setGroup("frost_$userId")
.setGroupSummary(true)
- NotificationManagerCompat.from(this).notify("frost_$userId", userId.toInt(), notifBuilder.build())
+ NotificationManagerCompat.from(this).notify("frost_$userId", userId.toInt(), notifBuilder.build().frostConfig())
}
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
index b912c103..7ce546b3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
@@ -1,6 +1,7 @@
package com.pitchedapps.frost.settings
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
+import com.pitchedapps.frost.MainActivity
import com.pitchedapps.frost.R
import com.pitchedapps.frost.SettingsActivity
import com.pitchedapps.frost.utils.Prefs
@@ -14,6 +15,10 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.fancy_animations_desc
}
+ checkbox(R.string.overlay_swipe, { Prefs.overlayEnabled }, { Prefs.overlayEnabled = it; setResult(MainActivity.REQUEST_REFRESH) }) {
+ descRes = R.string.overlay_swipe_desc
+ }
+
checkbox(R.string.overlay_full_screen_swipe, { Prefs.overlayFullScreenSwipe }, { Prefs.overlayFullScreenSwipe = it }) {
descRes = R.string.overlay_full_screen_swipe_desc
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
index 86cfcc16..b6105054 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
@@ -55,6 +55,12 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.notification_all_accounts_desc
}
+ checkbox(R.string.notification_sound, { Prefs.notificationSound }, { Prefs.notificationSound = it })
+
+ checkbox(R.string.notification_vibrate, { Prefs.notificationVibrate }, { Prefs.notificationVibrate = it })
+
+ checkbox(R.string.notification_lights, { Prefs.notificationLights }, { Prefs.notificationLights = it })
+
plainText(R.string.notification_fetch_now) {
descRes = R.string.notification_fetch_now_desc
onClick = {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
index 64ec08cd..d2e04898 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -89,6 +89,12 @@ object Prefs : KPref() {
var notificationsInstantMessages: Boolean by kpref("notification_im", true)
+ var notificationVibrate: Boolean by kpref("notification_vibrate", true)
+
+ var notificationSound: Boolean by kpref("notification_sound", true)
+
+ var notificationLights: Boolean by kpref("notification_lights", true)
+
/**
* Cache like value to determine if user has or had pro
* In most cases, [com.pitchedapps.frost.utils.iab.IS_FROST_PRO] should be looked at instead
@@ -105,6 +111,8 @@ object Prefs : KPref() {
var searchBar: Boolean by kpref("search_bar", Showcase.experimentalDefault)
+ var overlayEnabled: Boolean by kpref("overlay_enabled", true)
+
var overlayFullScreenSwipe: Boolean by kpref("overlay_full_screen_swipe", true)
var viewpagerSwipe: Boolean by kpref("viewpager_swipe", true)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index 3d3025cf..9a599945 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -28,8 +28,9 @@ import com.pitchedapps.frost.facebook.formattedFbUrl
/**
* Created by Allan Wang on 2017-06-03.
*/
-internal const val EXTRA_COOKIES = "extra_cookies"
-internal const val ARG_URL = "arg_url"
+const val EXTRA_COOKIES = "extra_cookies"
+const val ARG_URL = "arg_url"
+const val ARG_USER_ID = "arg_user_id"
@GlideModule
class FrostGlideModule : AppGlideModule()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
index ce2daa07..5e5dc597 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
@@ -65,7 +65,7 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() {
refreshObservable.onNext(false)
webCore.jsInject(
JsActions.LOGIN_CHECK,
- JsAssets.CLICK_A.maybe(webCore.baseEnum != null),
+ JsAssets.CLICK_A.maybe(webCore.baseEnum != null && Prefs.overlayEnabled),
JsAssets.CONTEXT_A,
JsAssets.HEADER_BADGES.maybe(webCore.baseEnum != null)
)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt
index d4d08958..b3b1cfe5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt
@@ -64,7 +64,7 @@ class FrostWebViewSearch(context: Context, val contract: SearchContract) : WebVi
element ->
//split text into separate items
L.v("Search element ${element.attr("href")}")
- val texts = element.select("div").map { (it.ownText()) }.filter { it.isNotBlank() }
+ val texts = element.select("div").map { (it.text()) }.filter { it.isNotBlank() }
val pair = Pair(texts, element.attr("href"))
L.v("Search element potential $pair")
pair