From d9de334c67dc34dec3a93055c1b198db7d3eb3cb Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 16 Jun 2017 16:07:55 -0700 Subject: Add toolbar back button by default --- library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'library/src/main') diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt index 5b26eb0..6a188cc 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt @@ -26,6 +26,14 @@ abstract class KPrefActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.kau_activity_kpref) setSupportActionBar(toolbar) + if (supportActionBar != null) + with(supportActionBar!!) { + setDisplayHomeAsUpEnabled(true) + setDisplayShowHomeEnabled(true) + toolbar.setNavigationOnClickListener { + onBackPressed() + } + } window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION statusBarColor = 0x30000000 toolbarCanvas.set(resolveColor(R.attr.colorPrimary)) -- cgit v1.2.3