Skip to content

Commit

Permalink
feat: Tonal badge style for main preference icons
Browse files Browse the repository at this point in the history
  • Loading branch information
axel358 committed Oct 1, 2024
1 parent 4315508 commit 8d2d023
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cu.axel.smartdock.preferences

import android.content.Context
import android.util.AttributeSet
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import com.google.android.material.button.MaterialButton
import cu.axel.smartdock.R

class PreferenceHeader(private val context: Context, attrs: AttributeSet?) : Preference(context, attrs) {
init {
layoutResource = R.layout.preference_header
}
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val iconBtn = holder.findViewById(R.id.preference_icon_btn) as MaterialButton
iconBtn.icon = icon
}
}
26 changes: 26 additions & 0 deletions app/src/main/res/layout/preference_header.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:orientation="horizontal">

<com.google.android.material.button.MaterialButton
android:id="@+id/preference_icon_btn"
style="?attr/materialIconButtonFilledTonalStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false" />

<TextView
android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1.0"
android:textAppearance="?attr/textAppearanceTitleMedium" />
</LinearLayout>
22 changes: 11 additions & 11 deletions app/src/main/res/xml/preferences_main.xml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_appearance"
android:title="@string/appearance"
app:fragment="cu.axel.smartdock.fragments.AppearancePreferences" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_apps_menu"
app:fragment="cu.axel.smartdock.fragments.AppMenuPreferences"
android:title="@string/app_menu" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_dock"
android:fragment="cu.axel.smartdock.fragments.DockPreferences"
android:title="@string/dock" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_desktop"
android:fragment="cu.axel.smartdock.fragments.DesktopPreferences"
android:title="@string/desktop" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_star"
android:fragment="cu.axel.smartdock.fragments.DefaultAppsPreferences"
android:title="@string/default_apps" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_keyboard"
android:fragment="cu.axel.smartdock.fragments.KeyboardPreferences"
android:title="@string/keyboard" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_corners"
android:fragment="cu.axel.smartdock.fragments.HotCornersPreferences"
android:title="@string/hot_corners" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_notifications"
android:fragment="cu.axel.smartdock.fragments.NotificationPreferences"
android:title="@string/notifications" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_sounds"
android:fragment="cu.axel.smartdock.fragments.SoundsPreferences"
android:title="@string/sounds" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_advanced"
android:fragment="cu.axel.smartdock.fragments.AdvancedPreferences"
android:title="@string/advanced" />
<Preference
<cu.axel.smartdock.preferences.PreferenceHeader
android:icon="@drawable/ic_info"
android:fragment="cu.axel.smartdock.fragments.HelpAboutPreferences"
android:title="@string/help_and_about" />
Expand Down

0 comments on commit 8d2d023

Please sign in to comment.