fixed dialog theme window attribute
This commit is contained in:
parent
c2000055f2
commit
56d21301d2
|
@ -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<BaseActivity>, 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<BaseActivity>, 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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<attr name="quoteIndicatorBackgroundColor" format="color"/>
|
||||
<attr name="linePageIndicatorStyle" format="reference"/>
|
||||
<attr name="mediaLabelBackground" format="color"/>
|
||||
|
||||
<attr name="isDialogTheme" format="boolean"/>
|
||||
</declare-styleable>
|
||||
<declare-styleable name="TwidereTheme">
|
||||
<attr name="darkThemeResource" format="reference"/>
|
||||
|
|
|
@ -62,8 +62,8 @@
|
|||
<item name="profileImageStyleLarge">@style/Widget.ProfileImage.Large</item>
|
||||
<item name="cardItemBackgroundColor">@color/background_color_card_item_dark</item>
|
||||
|
||||
|
||||
<!-- Twidere specific styles -->
|
||||
<item name="isDialogTheme">true</item>
|
||||
<item name="menuIconColor">@color/action_icon_light</item>
|
||||
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
|
||||
<item name="quoteIndicatorBackgroundColor">@color/quote_indicator_background_dark</item>
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
<item name="profileImageStyleLarge">@style/Widget.Light.ProfileImage.Large</item>
|
||||
<item name="cardItemBackgroundColor">@color/background_color_card_item_light</item>
|
||||
|
||||
|
||||
<!-- Twidere specific styles -->
|
||||
<item name="isDialogTheme">true</item>
|
||||
<item name="menuIconColor">@color/action_icon_dark</item>
|
||||
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
|
||||
<item name="quoteIndicatorBackgroundColor">@color/quote_indicator_background_light</item>
|
||||
|
|
Loading…
Reference in New Issue