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/activities/ImageActivity.kt26
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MediaPickerActivity.kt24
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt1
7 files changed, 36 insertions, 26 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
index 31479d54..3593f6b5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
@@ -15,6 +15,7 @@ import android.widget.ProgressBar
import android.widget.TextView
import ca.allanwang.kau.email.sendEmail
import ca.allanwang.kau.internal.KauBaseActivity
+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.*
@@ -47,6 +48,7 @@ class ImageActivity : KauBaseActivity() {
val photo: SubsamplingScaleImageView by bindView(R.id.image_photo)
val caption: TextView? by bindOptionalView(R.id.image_text)
val fab: FloatingActionButton by bindView(R.id.image_fab)
+ var errorRef: Throwable? = null
/**
* Reference to the temporary file path
@@ -85,17 +87,16 @@ class ImageActivity : KauBaseActivity() {
caption?.text = text
progress.tint(Prefs.accentColor)
panel?.addPanelSlideListener(object : SlidingUpPanelLayout.SimplePanelSlideListener() {
-
override fun onPanelSlide(panel: View, slideOffset: Float) {
if (slideOffset == 0f && !fab.isShown) fab.show()
else if (slideOffset != 0f && fab.isShown) fab.hide()
caption?.alpha = slideOffset / 2 + 0.5f
}
-
})
fab.setOnClickListener { fabAction.onClick(this) }
photo.setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
override fun onImageLoadError(e: Exception?) {
+ errorRef = e
e.logFrostAnswers("Image load error")
imageCallback(null, false)
}
@@ -145,7 +146,8 @@ class ImageActivity : KauBaseActivity() {
var photoFile: File? = null
try {
photoFile = createPrivateMediaFile(".png")
- } catch (ignored: IOException) {
+ } catch (e: IOException) {
+ errorRef = e
} finally {
if (photoFile == null) {
callback(null)
@@ -173,8 +175,9 @@ class ImageActivity : KauBaseActivity() {
var success = true
try {
File(tempFilePath).copyTo(destination, true)
- scanFile(destination)
+ scanMedia(destination)
} catch (e: Exception) {
+ errorRef = e
success = false
} finally {
L.d("Download image async finished: $success")
@@ -189,17 +192,6 @@ class ImageActivity : KauBaseActivity() {
}
}
- /**
- * See <a href="https://developer.android.com/training/camera/photobasics.html#TaskGallery">Docs</a>
- */
- internal fun scanFile(file: File) {
- if (!file.exists()) return
- val mediaScanIntent = Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)
- val contentUri = Uri.fromFile(file)
- mediaScanIntent.data = contentUri
- this.sendBroadcast(mediaScanIntent)
- }
-
internal fun deleteTempFile() {
if (tempFilePath != null) {
File(tempFilePath!!).delete()
@@ -221,8 +213,11 @@ internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconC
content(R.string.bad_image_overlay)
positiveText(R.string.kau_yes)
onPositive { _, _ ->
+ if (activity.errorRef != null)
+ L.e(activity.errorRef, "ImageActivity error report")
activity.sendEmail(R.string.dev_email, R.string.debug_image_link_subject) {
addItem("Url", activity.imageUrl)
+ addItem("Message", activity.errorRef?.message ?: "Null")
}
}
negativeText(R.string.kau_no)
@@ -248,6 +243,7 @@ internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconC
}
activity.startActivity(intent)
} catch (e: Exception) {
+ activity.errorRef = e
e.logFrostAnswers("Image share failed")
activity.snackbar(R.string.image_share_failed)
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
index 67f07635..6b1f2c5c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
@@ -1,6 +1,5 @@
package com.pitchedapps.frost.activities
-import android.content.Intent
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.os.Handler
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
index 759be983..45488c94 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -368,6 +368,7 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
if (firstLoadFinished && hiddenSearchView == null) hiddenSearchView = SearchWebView(this, this)
if (searchView == null) searchView = bindSearchView(menu, R.id.action_search, Prefs.iconColor) {
textCallback = { query, _ -> runOnUiThread { hiddenSearchView?.query(query) } }
+ searchCallback = { query, _ -> launchWebOverlay("${FbItem.SEARCH.url}/?q=$query"); true }
foregroundColor = Prefs.textColor
backgroundColor = Prefs.bgColor.withMinAlpha(200)
openListener = { hiddenSearchView?.pauseLoad = false }
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MediaPickerActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MediaPickerActivity.kt
index 0d041e7a..9b73f9b7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MediaPickerActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MediaPickerActivity.kt
@@ -1,10 +1,26 @@
package com.pitchedapps.frost.activities
-import ca.allanwang.kau.mediapicker.MediaPickerActivityOverlayBase
-import ca.allanwang.kau.mediapicker.MediaType
+import android.content.Context
+import android.net.Uri
+import android.support.v4.content.FileProvider
+import ca.allanwang.kau.mediapicker.*
+import com.pitchedapps.frost.BuildConfig
+import com.pitchedapps.frost.utils.Prefs
+import java.io.File
/**
* Created by Allan Wang on 2017-07-23.
*/
-class ImagePickerActivity : MediaPickerActivityOverlayBase(MediaType.IMAGE)
-class VideoPickerActivity : MediaPickerActivityOverlayBase(MediaType.VIDEO) \ No newline at end of file
+private fun actions() = listOf(object : MediaActionCamera(Prefs.accentColor) {
+
+ override fun createFile(context: Context): File
+ = createMediaFile("Frost", ".jpg")
+
+ override fun createUri(context: Context, file: File): Uri
+ = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file)
+
+}, MediaActionGallery(color = Prefs.accentColor))
+
+class ImagePickerActivity : MediaPickerActivityOverlayBase(MediaType.IMAGE, actions())
+
+class VideoPickerActivity : MediaPickerActivityOverlayBase(MediaType.VIDEO, actions()) \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
index 733bc151..e979f8ce 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
@@ -25,13 +25,10 @@ enum class CssAssets(val folder: String = "themes") : InjectorContract {
try {
var content = webView.context.assets.open("css/$folder/$file").bufferedReader().use { it.readText() }
if (this == CUSTOM) {
- var bbt = Prefs.bgColor
val bt: String
- if (Color.alpha(bbt) == 255) {
- bbt = bbt.adjustAlpha(0.2f).colorToForeground(0.35f)
+ if (Color.alpha(Prefs.bgColor) == 255) {
bt = Prefs.bgColor.toRgbaString()
} else {
- bbt = bbt.adjustAlpha(0.05f).colorToForeground(0.5f)
bt = "transparent"
}
content = content
@@ -39,7 +36,7 @@ enum class CssAssets(val folder: String = "themes") : InjectorContract {
.replace("\$TT\$", Prefs.textColor.colorToBackground(0.05f).toRgbaString())
.replace("\$B\$", Prefs.bgColor.toRgbaString())
.replace("\$BT\$", bt)
- .replace("\$BBT\$", bbt.toRgbaString())
+ .replace("\$BBT\$", Prefs.bgColor.withAlpha(51).colorToForeground(0.35f).toRgbaString())
.replace("\$O\$", Prefs.bgColor.withAlpha(255).toRgbaString())
.replace("\$OO\$", Prefs.bgColor.colorToForeground(0.35f).withAlpha(255).toRgbaString())
.replace("\$D\$", Prefs.textColor.adjustAlpha(0.3f).toRgbaString())
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 4094a3ab..74e800df 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -13,6 +13,8 @@ import android.support.v7.widget.Toolbar
import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
+import ca.allanwang.kau.mediapicker.createMediaFile
+import ca.allanwang.kau.mediapicker.createPrivateMediaFile
import ca.allanwang.kau.utils.*
import com.afollestad.materialdialogs.MaterialDialog
import com.bumptech.glide.RequestBuilder
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
index 038eaaad..dd8e2390 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
@@ -8,7 +8,6 @@ import android.webkit.*
import ca.allanwang.kau.utils.fadeIn
import ca.allanwang.kau.utils.isVisible
import com.pitchedapps.frost.dbflow.CookieModel
-import com.pitchedapps.frost.facebook.FACEBOOK_COM
import com.pitchedapps.frost.facebook.FB_URL_BASE
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.injectors.CssHider