diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt index cfc15e4c8..72b18a43e 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt @@ -54,6 +54,7 @@ import org.mariotaku.ktextension.systemWindowInsets import org.mariotaku.ktextension.unregisterReceiverSafe import org.mariotaku.restfu.http.RestHttpClient import org.mariotaku.twidere.BuildConfig +import org.mariotaku.twidere.R import org.mariotaku.twidere.TwidereConstants.SHARED_PREFERENCES_NAME import org.mariotaku.twidere.activity.iface.IBaseActivity import org.mariotaku.twidere.activity.iface.IControlBarActivity @@ -126,6 +127,9 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity, IThe protected val gifShareProvider: GifShareProvider? get() = gifShareProviderFactory.newInstance(this) + protected val isDialogTheme: Boolean + get() = ThemeUtils.getBooleanFromAttribute(this, R.attr.isDialogTheme) + override final val currentThemeBackgroundAlpha by lazy { themeBackgroundAlpha } @@ -381,7 +385,7 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity, IThe } private fun onApplyNavigationStyle(navbarStyle: String, themeColor: Int) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || isDialogTheme) return when (navbarStyle) { NavbarStyle.TRANSPARENT -> { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/ThemeUtils.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/ThemeUtils.kt index a97914769..9db5a9ea5 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/ThemeUtils.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/ThemeUtils.kt @@ -27,6 +27,7 @@ import android.graphics.PorterDuff import android.graphics.drawable.ColorDrawable import android.graphics.drawable.Drawable import android.os.Build +import android.support.annotation.AttrRes import android.support.annotation.ColorInt import android.support.annotation.StyleRes import android.support.v4.content.ContextCompat @@ -448,7 +449,7 @@ object ThemeUtils { } } - fun getColorFromAttribute(context: Context, attr: Int, styleRes: Int = 0, def: Int = 0): Int { + fun getColorFromAttribute(context: Context, @AttrRes attr: Int, styleRes: Int = 0, def: Int = 0): Int { val a = context.obtainStyledAttributes(null, intArrayOf(attr), 0, styleRes) try { return a.getColor(0, def) @@ -457,7 +458,16 @@ object ThemeUtils { } } - fun getDrawableFromThemeAttribute(context: Context, attr: Int): Drawable { + fun getBooleanFromAttribute(context: Context, @AttrRes attr: Int, styleRes: Int = 0, def: Boolean = false): Boolean { + val a = context.obtainStyledAttributes(null, intArrayOf(attr), 0, styleRes) + try { + return a.getBoolean(0, def) + } finally { + a.recycle() + } + } + + fun getDrawableFromThemeAttribute(context: Context, @AttrRes attr: Int): Drawable { val a = TintTypedArray.obtainStyledAttributes(context, null, intArrayOf(attr)) try { return a.getDrawable(0) diff --git a/twidere/src/main/res/values/attrs.xml b/twidere/src/main/res/values/attrs.xml index e0e4df030..33de4ee06 100644 --- a/twidere/src/main/res/values/attrs.xml +++ b/twidere/src/main/res/values/attrs.xml @@ -13,7 +13,7 @@ - + diff --git a/twidere/src/main/res/values/themes_base_dark.xml b/twidere/src/main/res/values/themes_base_dark.xml index 61d05a339..f51952735 100644 --- a/twidere/src/main/res/values/themes_base_dark.xml +++ b/twidere/src/main/res/values/themes_base_dark.xml @@ -62,8 +62,8 @@ @style/Widget.ProfileImage.Large @color/background_color_card_item_dark - + true @color/action_icon_light @color/message_bubble_color_dark @color/quote_indicator_background_dark diff --git a/twidere/src/main/res/values/themes_base_light.xml b/twidere/src/main/res/values/themes_base_light.xml index c35e3d2a1..597f1a875 100644 --- a/twidere/src/main/res/values/themes_base_light.xml +++ b/twidere/src/main/res/values/themes_base_light.xml @@ -63,8 +63,8 @@ @style/Widget.Light.ProfileImage.Large @color/background_color_card_item_light - + true @color/action_icon_dark @color/message_bubble_color_light @color/quote_indicator_background_light