Loading play-services-base/core/src/main/kotlin/org/microg/gms/ui/SwitchBarPreference.kt +2 −13 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ package org.microg.gms.ui import android.content.Context import android.graphics.drawable.Drawable import android.util.AttributeSet import android.widget.Switch import androidx.appcompat.widget.SwitchCompat import androidx.core.content.res.TypedArrayUtils import androidx.preference.PreferenceViewHolder Loading Loading @@ -36,7 +37,7 @@ class SwitchBarPreference : TwoStatePreference { super.onBindViewHolder(holder) holder.isDividerAllowedBelow = false holder.isDividerAllowedAbove = false val switch = holder.findViewById(R.id.switch_widget) as SwitchCompat val switch = holder.findViewById(R.id.switch_widget) as Switch switch.setOnCheckedChangeListener(null) switch.isChecked = isChecked switch.setOnCheckedChangeListener { view, isChecked -> Loading @@ -46,17 +47,5 @@ class SwitchBarPreference : TwoStatePreference { } this.isChecked = isChecked } val frame = if (frameId == 0) null else holder.findViewById(frameId) val backgroundView = frame ?: holder.itemView val (backgroundDrawable, backgroundColorAttribute) = when { !isEnabled -> Pair(backgroundDisabled, androidx.appcompat.R.attr.colorControlHighlight) isChecked -> Pair(backgroundOn, androidx.appcompat.R.attr.colorControlActivated) else -> Pair(backgroundOff, androidx.appcompat.R.attr.colorButtonNormal) } if (backgroundDrawable != null) { backgroundView.setBackgroundDrawable(backgroundDrawable) } else { backgroundView.setBackgroundColorAttribute(backgroundColorAttribute) } } } No newline at end of file play-services-base/core/src/main/res/drawable/switchbar.xml 0 → 100644 +10 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:attr/colorControlHighlight"> <item> <shape android:shape="rectangle"> <solid android:color="@color/e_switchbar_color"/> <corners android:radius="28dp"/> </shape> </item> </ripple> play-services-base/core/src/main/res/layout/preference_switch_bar.xml +39 −27 Original line number Diff line number Diff line Loading @@ -7,36 +7,48 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:layout_height="wrap_content" android:gravity="center" android:minHeight="?android:attr/listPreferredItemHeight" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingTop="16dp" android:paddingBottom="16dp" android:orientation="horizontal" android:paddingStart="?attr/listPreferredItemPaddingStart" android:paddingLeft="?attr/listPreferredItemPaddingLeft" android:paddingEnd="?attr/listPreferredItemPaddingEnd" android:paddingRight="?attr/listPreferredItemPaddingRight" tools:background="?attr/colorControlActivated"> > <LinearLayout android:id="@+id/bg" android:minHeight="72dp" android:layout_height="wrap_content" android:layout_width="match_parent" android:paddingStart="20dp" android:paddingEnd="20dp" android:background="@drawable/switchbar"> <TextView android:id="@android:id/title" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_width="0dp" android:layout_weight="1" android:layout_marginEnd="24dp" android:layout_marginVertical="24dp" android:textSize="20sp" android:ellipsize="end" android:maxLines="2" android:paddingStart="56dp" android:paddingLeft="56dp" android:textAppearance="?attr/textAppearanceListItem" android:textColor="@android:color/white" tools:text="Enabled" /> android:textColor="?android:attr/textColorPrimary" android:hyphenationFrequency="normalFast" android:lineBreakWordStyle="phrase" android:visibility="visible" android:fontFamily="@*android:string/config_headlineFontFamily" android:textAppearance="?android:attr/textAppearanceListItem" style="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title.Inverse" /> <androidx.appcompat.widget.SwitchCompat <Switch android:id="@+id/switch_widget" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="48dp" android:layout_gravity="center_vertical" android:background="@null" app:thumbTint="@android:color/white" app:trackTint="@android:color/darker_gray" tools:checked="true" /> android:focusable="false" android:clickable="false" /> </LinearLayout> </LinearLayout> play-services-base/core/src/main/res/values-night/colors.xml 0 → 100644 +9 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ SPDX-FileCopyrightText: 2020, microG Project Team ~ SPDX-License-Identifier: Apache-2.0 --> <resources> <color name="e_switchbar_color">#272727</color> </resources> play-services-base/core/src/main/res/values/colors.xml 0 → 100644 +9 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ SPDX-FileCopyrightText: 2020, microG Project Team ~ SPDX-License-Identifier: Apache-2.0 --> <resources> <color name="e_switchbar_color">#f1f0f3</color> </resources> Loading
play-services-base/core/src/main/kotlin/org/microg/gms/ui/SwitchBarPreference.kt +2 −13 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ package org.microg.gms.ui import android.content.Context import android.graphics.drawable.Drawable import android.util.AttributeSet import android.widget.Switch import androidx.appcompat.widget.SwitchCompat import androidx.core.content.res.TypedArrayUtils import androidx.preference.PreferenceViewHolder Loading Loading @@ -36,7 +37,7 @@ class SwitchBarPreference : TwoStatePreference { super.onBindViewHolder(holder) holder.isDividerAllowedBelow = false holder.isDividerAllowedAbove = false val switch = holder.findViewById(R.id.switch_widget) as SwitchCompat val switch = holder.findViewById(R.id.switch_widget) as Switch switch.setOnCheckedChangeListener(null) switch.isChecked = isChecked switch.setOnCheckedChangeListener { view, isChecked -> Loading @@ -46,17 +47,5 @@ class SwitchBarPreference : TwoStatePreference { } this.isChecked = isChecked } val frame = if (frameId == 0) null else holder.findViewById(frameId) val backgroundView = frame ?: holder.itemView val (backgroundDrawable, backgroundColorAttribute) = when { !isEnabled -> Pair(backgroundDisabled, androidx.appcompat.R.attr.colorControlHighlight) isChecked -> Pair(backgroundOn, androidx.appcompat.R.attr.colorControlActivated) else -> Pair(backgroundOff, androidx.appcompat.R.attr.colorButtonNormal) } if (backgroundDrawable != null) { backgroundView.setBackgroundDrawable(backgroundDrawable) } else { backgroundView.setBackgroundColorAttribute(backgroundColorAttribute) } } } No newline at end of file
play-services-base/core/src/main/res/drawable/switchbar.xml 0 → 100644 +10 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:attr/colorControlHighlight"> <item> <shape android:shape="rectangle"> <solid android:color="@color/e_switchbar_color"/> <corners android:radius="28dp"/> </shape> </item> </ripple>
play-services-base/core/src/main/res/layout/preference_switch_bar.xml +39 −27 Original line number Diff line number Diff line Loading @@ -7,36 +7,48 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:layout_height="wrap_content" android:gravity="center" android:minHeight="?android:attr/listPreferredItemHeight" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:paddingTop="16dp" android:paddingBottom="16dp" android:orientation="horizontal" android:paddingStart="?attr/listPreferredItemPaddingStart" android:paddingLeft="?attr/listPreferredItemPaddingLeft" android:paddingEnd="?attr/listPreferredItemPaddingEnd" android:paddingRight="?attr/listPreferredItemPaddingRight" tools:background="?attr/colorControlActivated"> > <LinearLayout android:id="@+id/bg" android:minHeight="72dp" android:layout_height="wrap_content" android:layout_width="match_parent" android:paddingStart="20dp" android:paddingEnd="20dp" android:background="@drawable/switchbar"> <TextView android:id="@android:id/title" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_width="0dp" android:layout_weight="1" android:layout_marginEnd="24dp" android:layout_marginVertical="24dp" android:textSize="20sp" android:ellipsize="end" android:maxLines="2" android:paddingStart="56dp" android:paddingLeft="56dp" android:textAppearance="?attr/textAppearanceListItem" android:textColor="@android:color/white" tools:text="Enabled" /> android:textColor="?android:attr/textColorPrimary" android:hyphenationFrequency="normalFast" android:lineBreakWordStyle="phrase" android:visibility="visible" android:fontFamily="@*android:string/config_headlineFontFamily" android:textAppearance="?android:attr/textAppearanceListItem" style="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title.Inverse" /> <androidx.appcompat.widget.SwitchCompat <Switch android:id="@+id/switch_widget" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="48dp" android:layout_gravity="center_vertical" android:background="@null" app:thumbTint="@android:color/white" app:trackTint="@android:color/darker_gray" tools:checked="true" /> android:focusable="false" android:clickable="false" /> </LinearLayout> </LinearLayout>
play-services-base/core/src/main/res/values-night/colors.xml 0 → 100644 +9 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ SPDX-FileCopyrightText: 2020, microG Project Team ~ SPDX-License-Identifier: Apache-2.0 --> <resources> <color name="e_switchbar_color">#272727</color> </resources>
play-services-base/core/src/main/res/values/colors.xml 0 → 100644 +9 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ SPDX-FileCopyrightText: 2020, microG Project Team ~ SPDX-License-Identifier: Apache-2.0 --> <resources> <color name="e_switchbar_color">#f1f0f3</color> </resources>