style: customize v31 splash screen

Remove the icon background from the Android 12 splash screen, making it
alot more cleaner than it was before.
This commit is contained in:
OxygenCobalt 2021-08-07 19:55:23 -06:00
parent 64c9a4a4a7
commit 2f0df83cb2
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
6 changed files with 15 additions and 14 deletions

View file

@ -117,12 +117,11 @@ class WidgetProvider : AppWidgetProvider() {
) {
check(views.isNotEmpty()) { "Must provide a non-empty map" }
val name = ComponentName(context, WidgetProvider::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// Widgets are automatically responsive on Android 12, no need to do anything.
updateAppWidget(
ComponentName(context, WidgetProvider::class.java),
RemoteViews(views)
)
updateAppWidget(name, RemoteViews(views))
} else {
// Otherwise, we try our best to backport the responsive behavior to older versions.
// This is mostly a guess based on RemoteView's documentation, and it has some
@ -131,15 +130,11 @@ class WidgetProvider : AppWidgetProvider() {
// Each widget has independent dimensions, so we iterate through them all
// and do this for each.
val ids = getAppWidgetIds(ComponentName(context, WidgetProvider::class.java))
val ids = getAppWidgetIds(name)
// Most of the major launchers seem to provide widget sizes that don't include
// padding. Query for the padding here so we can get a sane result later on.
val padding = AppWidgetHostView.getDefaultPaddingForWidget(
context,
ComponentName(context, WidgetProvider::class.java),
null
)
val padding = AppWidgetHostView.getDefaultPaddingForWidget(context, name, null)
val density = context.resources.displayMetrics.density
val padW = ((padding.left + padding.right) / density).toInt()

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Template theme that handles edge-to-edge on other styles variants -->
<style name="Theme.Template" parent="Theme.Master">
<style name="Theme.Edge" parent="Theme.Master">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@color/nav_color</item>
<item name="android:windowLightStatusBar">false</item>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Template theme that handles edge-to-edge on other styles variants -->
<style name="Theme.Template" parent="Theme.Master">
<style name="Theme.Edge" parent="Theme.Master">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@color/nav_color</item>
<item name="android:windowLightStatusBar">true</item>

View file

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Splash" parent="Theme.Edge">
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
</style>
<style name="Theme.Widget" parent="@android:style/Theme.DeviceDefault.DayNight">
<item name="colorAccent">?android:attr/colorAccent</item>

View file

@ -68,6 +68,7 @@
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:fontFamily">@font/inter_semibold</item>
<item name="android:textColor">?attr/colorAccent</item>
<item name="android:textAppearance">?android:attr/textAppearanceButton</item>
<item name="rippleColor">?android:attr/colorControlHighlight</item>
<item name="cornerRadius">0dp</item>

View file

@ -3,10 +3,12 @@
<!-- Master parent theme based off of Theme.MaterialComponents.DayNight.NoActionBar.Bridge -->
<style name="Theme.Master" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge" />
<!-- Template theme that handles edge-to-edge on other styles variants -->
<style name="Theme.Template" parent="Theme.Master" />
<style name="Theme.Edge" parent="Theme.Master" />
<!-- Android-12 Splashscreen config -->
<style name="Theme.Splash" parent="Theme.Edge" />
<!-- Base theme -->
<style name="Theme.Base" parent="Theme.Template">
<style name="Theme.Base" parent="Theme.Splash">
<!-- Colors -->
<item name="colorSurface">@color/surface_color</item>
<item name="colorAccent">@color/design_default_color_primary</item>