Skip to content
Snippets Groups Projects
Commit 148c9e58 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Improves readability of recents menu by changing the background color of

the header to the primaryDark color by default, removes debug statement
in crash handler
parent a9abb9c5
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,8 @@ import android.arch.lifecycle.MutableLiveData ...@@ -4,6 +4,8 @@ import android.arch.lifecycle.MutableLiveData
import android.arch.lifecycle.Observer import android.arch.lifecycle.Observer
import android.os.Bundle import android.os.Bundle
import android.os.Parcelable import android.os.Parcelable
import android.support.annotation.ColorRes
import android.support.annotation.DrawableRes
import android.support.design.widget.FloatingActionButton import android.support.design.widget.FloatingActionButton
import android.support.v4.app.FragmentManager import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter import android.support.v4.app.FragmentStatePagerAdapter
...@@ -17,6 +19,7 @@ import de.kuschku.quasseldroid_ng.R ...@@ -17,6 +19,7 @@ import de.kuschku.quasseldroid_ng.R
import de.kuschku.quasseldroid_ng.util.helper.observeSticky import de.kuschku.quasseldroid_ng.util.helper.observeSticky
import de.kuschku.quasseldroid_ng.util.helper.or import de.kuschku.quasseldroid_ng.util.helper.or
import de.kuschku.quasseldroid_ng.util.helper.switchMap import de.kuschku.quasseldroid_ng.util.helper.switchMap
import de.kuschku.quasseldroid_ng.util.helper.updateRecentsHeaderIfExisting
abstract class SetupActivity : AppCompatActivity() { abstract class SetupActivity : AppCompatActivity() {
@BindView(R.id.view_pager) @BindView(R.id.view_pager)
...@@ -32,6 +35,11 @@ abstract class SetupActivity : AppCompatActivity() { ...@@ -32,6 +35,11 @@ abstract class SetupActivity : AppCompatActivity() {
private val currentPage = MutableLiveData<SlideFragment?>() private val currentPage = MutableLiveData<SlideFragment?>()
private val isValid = currentPage.switchMap(SlideFragment::valid).or(false) private val isValid = currentPage.switchMap(SlideFragment::valid).or(false)
@DrawableRes
protected val icon: Int = R.mipmap.ic_launcher
@ColorRes
protected val recentsHeaderColor: Int = R.color.colorPrimaryDark
private val pageChangeListener = object : ViewPager.OnPageChangeListener { private val pageChangeListener = object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) { override fun onPageScrollStateChanged(state: Int) {
when (state) { when (state) {
...@@ -54,6 +62,14 @@ abstract class SetupActivity : AppCompatActivity() { ...@@ -54,6 +62,14 @@ abstract class SetupActivity : AppCompatActivity() {
button.setImageResource(drawable) button.setImageResource(drawable)
} }
fun updateRecentsHeader()
= updateRecentsHeaderIfExisting(title.toString(), icon, recentsHeaderColor)
override fun setTitle(title: CharSequence?) {
super.setTitle(title)
updateRecentsHeader()
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.Theme_SetupTheme) setTheme(R.style.Theme_SetupTheme)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
...@@ -81,6 +97,7 @@ abstract class SetupActivity : AppCompatActivity() { ...@@ -81,6 +97,7 @@ abstract class SetupActivity : AppCompatActivity() {
}) })
viewPager.addOnPageChangeListener(pageChangeListener) viewPager.addOnPageChangeListener(pageChangeListener)
pageChanged() pageChanged()
updateRecentsHeader()
} }
private fun onDoneInternal() { private fun onDoneInternal() {
......
...@@ -10,6 +10,22 @@ import android.support.annotation.ColorRes ...@@ -10,6 +10,22 @@ import android.support.annotation.ColorRes
import android.support.annotation.DrawableRes import android.support.annotation.DrawableRes
import android.support.annotation.StringRes import android.support.annotation.StringRes
/**
* Modifies the display of an {@see Activity} in the Android Recents menu if the current version
* of Android supports doing so.
*
* @param label The text shown as label
* @param icon The icon displayed in recents - passed as Android Drawable Resource
* @param colorPrimary The color used as background for the header of the recents card - passed as Android
* Color Resource
*/
fun Activity.updateRecentsHeaderIfExisting(
label: String, @DrawableRes icon: Int, @ColorRes colorPrimary: Int) {
val iconRaw = BitmapFactory.decodeResource(resources, icon)
val colorPrimaryRaw = resources.getColorBackport(colorPrimary, theme)
updateRecentsHeaderIfExisting(label, iconRaw, colorPrimaryRaw)
}
/** /**
* Modifies the display of an {@see Activity} in the Android Recents menu if the current version * Modifies the display of an {@see Activity} in the Android Recents menu if the current version
* of Android supports doing so. * of Android supports doing so.
...@@ -51,6 +67,5 @@ fun Activity.updateRecentsHeaderIfExisting(label: String, icon: Bitmap, colorPri ...@@ -51,6 +67,5 @@ fun Activity.updateRecentsHeaderIfExisting(label: String, icon: Bitmap, colorPri
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
private fun Activity.updateRecentsHeader(label: String, icon: Bitmap, private fun Activity.updateRecentsHeader(label: String, icon: Bitmap,
colorPrimary: Int) { colorPrimary: Int) {
setTaskDescription(ActivityManager.TaskDescription(label, setTaskDescription(ActivityManager.TaskDescription(label, icon, colorPrimary))
icon, colorPrimary))
} }
...@@ -6,13 +6,20 @@ import android.content.Intent ...@@ -6,13 +6,20 @@ import android.content.Intent
import android.content.ServiceConnection import android.content.ServiceConnection
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.support.annotation.ColorRes
import android.support.annotation.DrawableRes
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import de.kuschku.libquassel.session.Backend import de.kuschku.libquassel.session.Backend
import de.kuschku.quasseldroid_ng.R import de.kuschku.quasseldroid_ng.R
import de.kuschku.quasseldroid_ng.service.QuasselService import de.kuschku.quasseldroid_ng.service.QuasselService
import de.kuschku.quasseldroid_ng.util.helper.updateRecentsHeaderIfExisting
abstract class ServiceBoundActivity : AppCompatActivity() { abstract class ServiceBoundActivity : AppCompatActivity() {
protected val backend = MutableLiveData<Backend?>() protected val backend = MutableLiveData<Backend?>()
@DrawableRes
protected val icon: Int = R.mipmap.ic_launcher
@ColorRes
protected val recentsHeaderColor: Int = R.color.colorPrimaryDark
private val connection = object : ServiceConnection { private val connection = object : ServiceConnection {
override fun onServiceDisconnected(component: ComponentName?) { override fun onServiceDisconnected(component: ComponentName?) {
...@@ -37,6 +44,15 @@ abstract class ServiceBoundActivity : AppCompatActivity() { ...@@ -37,6 +44,15 @@ abstract class ServiceBoundActivity : AppCompatActivity() {
setTheme(R.style.Theme_ChatTheme_Quassel_Light) setTheme(R.style.Theme_ChatTheme_Quassel_Light)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
startService(Intent(this, QuasselService::class.java)) startService(Intent(this, QuasselService::class.java))
updateRecentsHeader()
}
fun updateRecentsHeader()
= updateRecentsHeaderIfExisting(title.toString(), icon, recentsHeaderColor)
override fun setTitle(title: CharSequence?) {
super.setTitle(title)
updateRecentsHeader()
} }
override fun onStart() { override fun onStart() {
......
...@@ -34,7 +34,7 @@ object CrashHandler { ...@@ -34,7 +34,7 @@ object CrashHandler {
buildConfig = buildConfig, buildConfig = buildConfig,
stackTraces = stackTraces stackTraces = stackTraces
), config)) ), config))
println(json) // FIXME STOPSHIP Implement crash handling
} catch (e: Throwable) { } catch (e: Throwable) {
e.printStackTrace() e.printStackTrace()
originalHandler?.uncaughtException(activeThread, throwable) originalHandler?.uncaughtException(activeThread, throwable)
...@@ -48,5 +48,5 @@ object CrashHandler { ...@@ -48,5 +48,5 @@ object CrashHandler {
myHandler?.uncaughtException(Thread.currentThread(), throwable) myHandler?.uncaughtException(Thread.currentThread(), throwable)
} }
var myHandler: Thread.UncaughtExceptionHandler? = null private var myHandler: Thread.UncaughtExceptionHandler? = null
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment