aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt35
1 files changed, 28 insertions, 7 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
index b6becf90..685e6532 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
@@ -1,6 +1,7 @@
package com.pitchedapps.frost.activities
import android.app.Activity
+import android.content.Context
import android.content.Intent
import android.content.res.ColorStateList
import android.os.Bundle
@@ -15,13 +16,15 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.pitchedapps.frost.R
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.utils.Prefs
+import com.pitchedapps.frost.utils.createFreshDir
import com.pitchedapps.frost.utils.setFrostColors
import com.pitchedapps.frost.web.DebugWebView
+import java.io.File
/**
* Created by Allan Wang on 05/01/18.
*/
-class DebugActivity : KauBaseActivity(), SwipeRefreshLayout.OnRefreshListener {
+class DebugActivity : KauBaseActivity() {
private val toolbar: Toolbar by bindView(R.id.toolbar)
private val web: DebugWebView by bindView(R.id.debug_webview)
@@ -30,30 +33,48 @@ class DebugActivity : KauBaseActivity(), SwipeRefreshLayout.OnRefreshListener {
companion object {
const val RESULT_URL = "extra_result_url"
+ fun baseDir(context: Context) = File(context.externalCacheDir, "offline_debug")
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_debug)
setSupportActionBar(toolbar)
+ supportActionBar?.apply {
+ setDisplayHomeAsUpEnabled(true)
+ setDisplayShowHomeEnabled(true)
+ }
setTitle(R.string.debug_frost)
+
setFrostColors {
toolbar(toolbar)
}
web.loadUrl(FbItem.FEED.url)
web.onPageFinished = { swipeRefresh.isRefreshing = false }
+
+ swipeRefresh.setOnRefreshListener(web::reload)
+
fab.visible().setIcon(GoogleMaterial.Icon.gmd_bug_report, Prefs.iconColor)
fab.backgroundTintList = ColorStateList.valueOf(Prefs.accentColor)
fab.setOnClickListener {
- val intent = Intent()
- intent.putExtra(RESULT_URL, web.url)
- setResult(Activity.RESULT_OK, intent)
- finish()
+ fab.hide()
+
+ val parent = baseDir(this)
+ parent.createFreshDir()
+ val file = File(parent, "screenshot.png")
+ web.getScreenshot(file) {
+ val intent = Intent()
+ intent.putExtra(RESULT_URL, web.url)
+ setResult(Activity.RESULT_OK, intent)
+ finish()
+ }
}
+
}
- override fun onRefresh() {
- web.reload()
+ override fun onSupportNavigateUp(): Boolean {
+ finish()
+ return true
}
override fun onResume() {