diff options
author | Allan Wang <me@allanwang.ca> | 2018-01-07 04:44:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-07 04:44:18 -0500 |
commit | afe7437e0a0f6c315d383e0b6133b13a461c92af (patch) | |
tree | 3312b4841af831fe89a4a283fda306c490178961 /app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt | |
parent | 8aece5e3f9209d7c161410c304655f0aec2d6054 (diff) | |
download | frost-afe7437e0a0f6c315d383e0b6133b13a461c92af.tar.gz frost-afe7437e0a0f6c315d383e0b6133b13a461c92af.tar.bz2 frost-afe7437e0a0f6c315d383e0b6133b13a461c92af.zip |
Enhancement/debug (#605)
* Finalize debugger
* Add video logging
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.kt | 35 |
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() { |