aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt17
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostWebActivity.kt27
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt17
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt2
8 files changed, 47 insertions, 30 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index 3a559bc2..dc9f0c11 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -48,18 +48,11 @@ class FrostApp : Application() {
FbCookie()
super.onCreate()
//Drawer profile loading logic
-// DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
-// override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String) {
-// Glide.with(imageView.context).load(uri).apply(RequestOptions().placeholder(placeholder)).into(imageView)
-// }
-//
-// override fun placeholder(ctx: Context, tag: String): Drawable {
-// when (tag) {
-// DrawerImageLoader.Tags.PROFILE.name, DrawerImageLoader.Tags.ACCOUNT_HEADER.name -> DrawerUIUtils.getPlaceHolder(ctx)
-// }
-// return super.placeholder(ctx, tag);
-// }
-// })
+ DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
+ override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String) {
+ Glide.with(imageView.context).load(uri).apply(RequestOptions().placeholder(placeholder)).into(imageView)
+ }
+ })
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostWebActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostWebActivity.kt
new file mode 100644
index 00000000..31ebfda2
--- /dev/null
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostWebActivity.kt
@@ -0,0 +1,27 @@
+package com.pitchedapps.frost
+
+import android.os.Bundle
+import android.support.design.widget.CoordinatorLayout
+import android.support.v7.app.AppCompatActivity
+import android.support.v7.widget.Toolbar
+import ca.allanwang.kau.utils.*
+import com.jude.swipbackhelper.SwipeBackHelper
+import com.pitchedapps.frost.facebook.FbTab
+import com.pitchedapps.frost.utils.ARG_URL
+import com.pitchedapps.frost.utils.Prefs
+import com.pitchedapps.frost.utils.formattedFbUrl
+import com.pitchedapps.frost.utils.setFrostColors
+import com.pitchedapps.frost.web.FrostWebView
+
+
+/**
+ * Created by Allan Wang on 2017-06-19.
+ *
+ * Replica of [WebOverlayActivity] with a different base url
+ * Didn't use activity-alias because it causes issues when only one activity has the singleInstance mode
+ */
+class FrostWebActivity:WebOverlayActivity() {
+ override val url: String
+ get() = intent.dataString!!.formattedFbUrl
+
+} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
index 303b9987..ecc27946 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
@@ -87,7 +87,6 @@ class LoginActivity : BaseActivity() {
.observeOn(AndroidSchedulers.mainThread()).subscribe {
(foundImage, name) ->
refresh = false
- L.d("Zip done")
if (!foundImage) L.e("Could not get profile photo; Invalid userId?\n\t$cookie")
textview.setTextWithFade(String.format(getString(R.string.welcome), name), duration = 500)
/*
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
index b4320ba3..f7648243 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
@@ -61,6 +61,10 @@ class MainActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ if (BuildConfig.VERSION_CODE > Prefs.versionCode) {
+ Prefs.versionCode = BuildConfig.VERSION_CODE
+ showChangelog(R.xml.changelog, { theme() })
+ }
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
adapter = SectionsPagerAdapter(supportFragmentManager, loadFbTabs())
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
index 260db298..320e4028 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
@@ -6,7 +6,6 @@ import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import ca.allanwang.kau.utils.*
import com.jude.swipbackhelper.SwipeBackHelper
-import com.pitchedapps.frost.facebook.FbTab
import com.pitchedapps.frost.utils.ARG_URL
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.formattedFbUrl
@@ -17,14 +16,14 @@ import com.pitchedapps.frost.web.FrostWebView
/**
* Created by Allan Wang on 2017-06-01.
*/
-class WebOverlayActivity : AppCompatActivity() {
+open class WebOverlayActivity : AppCompatActivity() {
val toolbar: Toolbar by bindView(R.id.overlay_toolbar)
val frostWeb: FrostWebView by bindView(R.id.overlay_frost_webview)
val coordinator: CoordinatorLayout by bindView(R.id.overlay_main_content)
- val url: String
- get() = (intent.extras?.getString(ARG_URL) ?: intent.dataString)?.formattedFbUrl ?: FbTab.FEED.url
+ open val url: String
+ get() = intent.extras!!.getString(ARG_URL).formattedFbUrl
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
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 cd66b9c2..3f3805a9 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -6,20 +6,17 @@ import android.app.job.JobParameters
import android.app.job.JobService
import android.content.Context
import android.content.Intent
-import android.os.Looper
-import android.support.v4.app.ActivityOptionsCompat
+import android.net.Uri
import android.support.v4.app.NotificationCompat
import android.support.v4.app.NotificationManagerCompat
-import ca.allanwang.kau.utils.checkThread
import ca.allanwang.kau.utils.string
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.*
import com.pitchedapps.frost.facebook.FACEBOOK_COM
import com.pitchedapps.frost.facebook.FB_URL_BASE
import com.pitchedapps.frost.facebook.FbTab
-import com.pitchedapps.frost.utils.ARG_URL
import com.pitchedapps.frost.utils.L
import org.jetbrains.anko.doAsync
import org.jsoup.Jsoup
@@ -105,13 +102,10 @@ class NotificationService : JobService() {
data class NotificationContent(val data: CookieModel, val notifId: Int, val href: String, val text: String, val timestamp: Long) {
fun createNotification(context: Context) {
- val intent = Intent(context, WebOverlayActivity::class.java)
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
- intent.putExtra(ARG_URL, "$FB_URL_BASE$href")
- intent.action = System.currentTimeMillis().toString() //dummy action
+ val intent = Intent(context, FrostWebActivity::class.java)
+ intent.data = Uri.parse("$FB_URL_BASE$href")
val group = "frost_${data.id}"
- val bundle = ActivityOptionsCompat.makeCustomAnimation(context, R.anim.slide_in_right, R.anim.slide_out_right).toBundle()
- val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT, bundle)
+ val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
val notifBuilder = NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.frost_f_24)
.setContentTitle(context.string(R.string.app_name))
@@ -121,7 +115,6 @@ class NotificationService : JobService() {
.setSubText(data.name)
.setGroup(group)
.setAutoCancel(true)
-// .setColor(context.color(R.color.facebook_blue))
if (timestamp != -1L) notifBuilder.setWhen(timestamp * 1000)
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 b319fcc3..62ed3cdd 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -33,6 +33,8 @@ object Prefs : KPref() {
var notificationFreq: Long by kpref("notification_freq", -1L)
+ var versionCode:Int by kpref("version_code", -1)
+
private val loader = lazyResettable { Theme.values[Prefs.theme] }
private val t: Theme by loader
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
index bc932480..cc96758b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
@@ -24,7 +24,7 @@ class BadgedIcon @JvmOverloads constructor(
init {
inflate(context, R.layout.view_badged_icon, this)
- val badgeColor = Prefs.headerColor.withAlpha(255).colorToForeground(0.1f)
+ val badgeColor = Prefs.headerColor.withAlpha(255).colorToForeground(0.2f)
val badgeBackground = GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, intArrayOf(badgeColor, badgeColor))
badgeBackground.cornerRadius = 13.dpToPx.toFloat()
badgeTextView.background = badgeBackground