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
import android.arch.lifecycle.Observer
import android.os.Bundle
import android.os.Parcelable
import android.support.annotation.ColorRes
import android.support.annotation.DrawableRes
import android.support.design.widget.FloatingActionButton
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter
......@@ -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.or
import de.kuschku.quasseldroid_ng.util.helper.switchMap
import de.kuschku.quasseldroid_ng.util.helper.updateRecentsHeaderIfExisting
abstract class SetupActivity : AppCompatActivity() {
@BindView(R.id.view_pager)
......@@ -32,6 +35,11 @@ abstract class SetupActivity : AppCompatActivity() {
private val currentPage = MutableLiveData<SlideFragment?>()
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 {
override fun onPageScrollStateChanged(state: Int) {
when (state) {
......@@ -54,6 +62,14 @@ abstract class SetupActivity : AppCompatActivity() {
button.setImageResource(drawable)
}
fun updateRecentsHeader()
= updateRecentsHeaderIfExisting(title.toString(), icon, recentsHeaderColor)
override fun setTitle(title: CharSequence?) {
super.setTitle(title)
updateRecentsHeader()
}
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.Theme_SetupTheme)
super.onCreate(savedInstanceState)
......@@ -81,6 +97,7 @@ abstract class SetupActivity : AppCompatActivity() {
})
viewPager.addOnPageChangeListener(pageChangeListener)
pageChanged()
updateRecentsHeader()
}
private fun onDoneInternal() {
......
......@@ -10,6 +10,22 @@ import android.support.annotation.ColorRes
import android.support.annotation.DrawableRes
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
* of Android supports doing so.
......@@ -51,6 +67,5 @@ fun Activity.updateRecentsHeaderIfExisting(label: String, icon: Bitmap, colorPri
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private fun Activity.updateRecentsHeader(label: String, icon: Bitmap,
colorPrimary: Int) {
setTaskDescription(ActivityManager.TaskDescription(label,
icon, colorPrimary))
setTaskDescription(ActivityManager.TaskDescription(label, icon, colorPrimary))
}
......@@ -6,13 +6,20 @@ import android.content.Intent
import android.content.ServiceConnection
import android.os.Bundle
import android.os.IBinder
import android.support.annotation.ColorRes
import android.support.annotation.DrawableRes
import android.support.v7.app.AppCompatActivity
import de.kuschku.libquassel.session.Backend
import de.kuschku.quasseldroid_ng.R
import de.kuschku.quasseldroid_ng.service.QuasselService
import de.kuschku.quasseldroid_ng.util.helper.updateRecentsHeaderIfExisting
abstract class ServiceBoundActivity : AppCompatActivity() {
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 {
override fun onServiceDisconnected(component: ComponentName?) {
......@@ -37,6 +44,15 @@ abstract class ServiceBoundActivity : AppCompatActivity() {
setTheme(R.style.Theme_ChatTheme_Quassel_Light)
super.onCreate(savedInstanceState)
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() {
......
......@@ -34,7 +34,7 @@ object CrashHandler {
buildConfig = buildConfig,
stackTraces = stackTraces
), config))
println(json)
// FIXME STOPSHIP Implement crash handling
} catch (e: Throwable) {
e.printStackTrace()
originalHandler?.uncaughtException(activeThread, throwable)
......@@ -48,5 +48,5 @@ object CrashHandler {
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