lets control the actionbar colors too to avoid surprises
This commit is contained in:
parent
9bae1a8e06
commit
3d75d21bdf
3 changed files with 12 additions and 16 deletions
|
@ -22,7 +22,6 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
@ -202,14 +201,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
|
||||
var color = baseColor.getContrastColor()
|
||||
if (baseConfig.isUsingSystemTheme) {
|
||||
val views = ArrayList<View>()
|
||||
try {
|
||||
window.decorView.rootView.findViewsWithText(views, supportActionBar?.title, View.FIND_VIEWS_WITH_TEXT)
|
||||
views.firstOrNull { it is TextView && it.id == -1 }?.apply {
|
||||
color = (this as TextView).currentTextColor
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
color = getProperTextColor()
|
||||
}
|
||||
|
||||
for (i in 0 until menu.size()) {
|
||||
|
|
|
@ -48,19 +48,23 @@ import java.io.OutputStream
|
|||
import java.util.*
|
||||
|
||||
fun AppCompatActivity.updateActionBarTitle(text: String, color: Int = baseConfig.primaryColor) {
|
||||
if (baseConfig.isUsingSystemTheme) {
|
||||
supportActionBar?.title = text
|
||||
val colorToUse = if (baseConfig.isUsingSystemTheme) {
|
||||
getProperTextColor()
|
||||
} else {
|
||||
supportActionBar?.title = Html.fromHtml("<font color='${color.getContrastColor().toHex()}'>$text</font>")
|
||||
color.getContrastColor()
|
||||
}
|
||||
|
||||
supportActionBar?.title = Html.fromHtml("<font color='${colorToUse.toHex()}'>$text</font>")
|
||||
}
|
||||
|
||||
fun AppCompatActivity.updateActionBarSubtitle(text: String) {
|
||||
if (baseConfig.isUsingSystemTheme) {
|
||||
supportActionBar?.subtitle = text
|
||||
val colorToUse = if (baseConfig.isUsingSystemTheme) {
|
||||
getProperTextColor()
|
||||
} else {
|
||||
supportActionBar?.subtitle = Html.fromHtml("<font color='${baseConfig.primaryColor.getContrastColor().toHex()}'>$text</font>")
|
||||
baseConfig.primaryColor.getContrastColor()
|
||||
}
|
||||
|
||||
supportActionBar?.subtitle = Html.fromHtml("<font color='${colorToUse.toHex()}'>$text</font>")
|
||||
}
|
||||
|
||||
fun Activity.appLaunched(appId: String) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<resources>
|
||||
<color name="you_status_bar_color">@android:color/system_accent2_50</color>
|
||||
<color name="you_background_color">@android:color/system_neutral1_10</color>
|
||||
<color name="you_neutral_text_color">@android:color/system_accent1_800</color>
|
||||
<color name="you_neutral_text_color">@android:color/system_accent1_900</color>
|
||||
<color name="you_primary_color">@android:color/system_accent1_400</color>
|
||||
<color name="you_primary_dark_color">@android:color/system_accent1_600</color>
|
||||
<color name="you_dialog_background_color">@android:color/system_accent2_10</color>
|
||||
|
|
Loading…
Reference in a new issue