From 3f3423873cbac12911c5bf811bf337ee5a747c3a Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 13 Mar 2019 21:31:51 -0600 Subject: [PATCH] Automatically change the color of the navigation bar in the Receive Home and Send screens to green blue and red respectively. --- .../bitsybitshareswallet/fragments/HomeFragment.kt | 10 +++++++--- .../fragments/ReceiveTransactionFragment.kt | 10 +++++++--- .../fragments/SendTransactionFragment.kt | 10 +++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt index 0bbc399..e87a3f3 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt @@ -51,9 +51,13 @@ class HomeFragment : Fragment() { val window = activity?.window window?.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) window?.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) - // Sets the status bar background color to a primaryColorDark - window?.statusBarColor = ContextCompat.getColor(context!!, - if (!nightMode) R.color.colorPrimaryDark else R.color.colorStatusBarDark) + // Sets the status and navigation bars background color to a dark blue or just dark + context?.let { context -> + val statusBarColor = ContextCompat.getColor(context, + if (!nightMode) R.color.colorPrimaryDark else R.color.colorStatusBarDark) + window?.statusBarColor = statusBarColor + window?.navigationBarColor = statusBarColor + } return inflater.inflate(R.layout.fragment_home, container, false) } diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt index a27e9be..6e44dd1 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt @@ -91,10 +91,14 @@ class ReceiveTransactionFragment : ConnectedFragment() { val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar) toolbar?.setBackgroundResource(if (!nightMode) R.color.colorReceive else R.color.colorToolbarDark) - // Sets the status bar background color to a dark green + // Sets the status and navigation bars background color to a dark green or just dark val window = activity?.window - window?.statusBarColor = ContextCompat.getColor(context!!, - if (!nightMode) R.color.colorReceiveDark else R.color.colorStatusBarDark) + context?.let { context -> + val statusBarColor = ContextCompat.getColor(context, + if (!nightMode) R.color.colorReceiveDark else R.color.colorStatusBarDark) + window?.statusBarColor = statusBarColor + window?.navigationBarColor = statusBarColor + } return inflater.inflate(R.layout.fragment_receive_transaction, container, false) } diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt index 75f1494..b59d52d 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt @@ -122,10 +122,14 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar) toolbar?.setBackgroundResource(if (!nightMode) R.color.colorSend else R.color.colorToolbarDark) - // Sets the status bar background color to a dark red + // Sets the status and navigation bars background color to a dark red or just dark val window = activity?.window - window?.statusBarColor = ContextCompat.getColor(context!!, - if (!nightMode) R.color.colorSendDark else R.color.colorStatusBarDark) + context?.let { context -> + val statusBarColor = ContextCompat.getColor(context, + if (!nightMode) R.color.colorSendDark else R.color.colorStatusBarDark) + window?.statusBarColor = statusBarColor + window?.navigationBarColor = statusBarColor + } return inflater.inflate(R.layout.fragment_send_transaction, container, false) }