From db014fe13d51a3f555ff5a88a851b6c0a007617e Mon Sep 17 00:00:00 2001 From: Amine Bou Date: Thu, 31 May 2018 12:42:06 +0200 Subject: [PATCH] Fixed issue on pre lolipop devices. --- .../bou/readerforselfoss/AddSourceActivity.kt | 9 +++++---- .../amine/bou/readerforselfoss/HomeActivity.kt | 18 ++++++++++++------ .../bou/readerforselfoss/ReaderActivity.kt | 9 ++++++--- .../bou/readerforselfoss/SourcesActivity.kt | 9 ++++++--- .../settings/AppCompatPreferenceActivity.java | 10 ++++++---- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/AddSourceActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/AddSourceActivity.kt index d0640ba..eb321c3 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/AddSourceActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/AddSourceActivity.kt @@ -44,10 +44,11 @@ class AddSourceActivity : AppCompatActivity() { setContentView(R.layout.activity_add_source) - // TODO: input bubble cursor - Scoop.getInstance() - .bind(this, Toppings.PRIMARY.value, toolbar) - .bindStatusBar(this, Toppings.PRIMARY_DARK.value) + val scoop = Scoop.getInstance() + scoop.bind(this, Toppings.PRIMARY.value, toolbar) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + scoop.bindStatusBar(this, Toppings.PRIMARY_DARK.value) + } val drawable = nameInput.background drawable.setColorFilter(appColors.colorAccent, PorterDuff.Mode.SRC_ATOP) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt index 43d18c2..822b38e 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/HomeActivity.kt @@ -6,6 +6,7 @@ import android.content.SharedPreferences import android.graphics.Color import android.graphics.drawable.GradientDrawable import android.net.Uri +import android.os.Build import android.os.Bundle import android.preference.PreferenceManager import android.support.v4.view.MenuItemCompat @@ -389,16 +390,21 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener { } private fun handleThemeBinding() { - Scoop.getInstance() - .bind(this, Toppings.PRIMARY.value, toolBar) - .bindStatusBar(this, Toppings.PRIMARY_DARK.value) + val scoop = Scoop.getInstance() + scoop.bind(this, Toppings.PRIMARY.value, toolBar) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + scoop.bindStatusBar(this, Toppings.PRIMARY_DARK.value) + } } private fun handleThemeUpdate() { - Scoop.getInstance() - .update(Toppings.PRIMARY.value, appColors.colorPrimary) - .update(Toppings.PRIMARY_DARK.value, appColors.colorPrimaryDark) + val scoop = Scoop.getInstance() + scoop.update(Toppings.PRIMARY.value, appColors.colorPrimary) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + scoop.update(Toppings.PRIMARY_DARK.value, appColors.colorPrimaryDark) + } } private fun handleDrawer() { diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt index f44bc12..421fe6e 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt @@ -3,6 +3,7 @@ package apps.amine.bou.readerforselfoss import android.content.Context import android.content.res.Resources import android.graphics.drawable.ColorDrawable +import android.os.Build import android.os.Bundle import android.preference.PreferenceManager import android.support.v4.app.FragmentManager @@ -62,9 +63,11 @@ class ReaderActivity : AppCompatActivity() { setContentView(R.layout.activity_reader) - Scoop.getInstance() - .bind(this, Toppings.PRIMARY.value, toolBar) - .bindStatusBar(this, Toppings.PRIMARY_DARK.value) + val scoop = Scoop.getInstance() + scoop.bind(this, Toppings.PRIMARY.value, toolBar) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + scoop.bindStatusBar(this, Toppings.PRIMARY_DARK.value) + } setSupportActionBar(toolBar) supportActionBar?.setDisplayHomeAsUpEnabled(true) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/SourcesActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/SourcesActivity.kt index 929ade2..3c96dc7 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/SourcesActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/SourcesActivity.kt @@ -2,6 +2,7 @@ package apps.amine.bou.readerforselfoss import android.content.Intent import android.content.res.ColorStateList +import android.os.Build import android.os.Bundle import android.preference.PreferenceManager import android.support.v7.app.AppCompatActivity @@ -29,9 +30,11 @@ class SourcesActivity : AppCompatActivity() { setContentView(R.layout.activity_sources) - Scoop.getInstance() - .bind(this, Toppings.PRIMARY.value, toolbar) - .bindStatusBar(this, Toppings.PRIMARY_DARK.value) + val scoop = Scoop.getInstance() + scoop.bind(this, Toppings.PRIMARY.value, toolbar) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + scoop.bindStatusBar(this, Toppings.PRIMARY_DARK.value) + } setSupportActionBar(toolbar) supportActionBar?.setDisplayHomeAsUpEnabled(true) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/settings/AppCompatPreferenceActivity.java b/app/src/main/java/apps/amine/bou/readerforselfoss/settings/AppCompatPreferenceActivity.java index 4eb1061..a2f84e2 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/settings/AppCompatPreferenceActivity.java +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/settings/AppCompatPreferenceActivity.java @@ -1,6 +1,7 @@ package apps.amine.bou.readerforselfoss.settings; import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.preference.PreferenceActivity; import android.support.annotation.LayoutRes; @@ -48,10 +49,11 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { AppBarLayout bar = (AppBarLayout) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); Toolbar toolbar = bar.findViewById(R.id.toolbar); - // TODO: all switches - Scoop.getInstance() - .bind(this, Toppings.PRIMARY.getValue(), toolbar) - .bindStatusBar(this, Toppings.PRIMARY_DARK.getValue()); + Scoop scoop = Scoop.getInstance(); + scoop.bind(this, Toppings.PRIMARY.getValue(), toolbar); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + scoop.bindStatusBar(this, Toppings.PRIMARY_DARK.getValue()); + } setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true);