Implemented widget configuration for multiple profiles

This commit is contained in:
darken
2025-09-29 19:29:43 +02:00
committed by Matthias Urhahn
parent ad7089ea7c
commit 49fc0f018a
14 changed files with 583 additions and 43 deletions
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="32dp"
android:layout_weight="1"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/widget_configuration_title"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:text="@string/widget_configuration_description"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/profiles_recycler"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/widget_configuration_profile_item" />
</LinearLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/pro_required_caption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="32dp"
android:text="@string/common_feature_requires_pro_msg"
android:gravity="center"
android:textAppearance="@style/TextAppearance.Material3.TitleSmall"
android:textColor="?colorOnSurfaceVariant"
android:visibility="gone"
tools:visibility="visible" />
<LinearLayout
android:id="@+id/buttons_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="32dp"
android:gravity="end"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/cancel_button"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@android:string/cancel" />
<com.google.android.material.button.MaterialButton
android:id="@+id/confirm_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="@android:string/ok" />
</LinearLayout>
</LinearLayout>
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="4dp"
app:cardCornerRadius="12dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:id="@+id/profile_icon"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
tools:src="@drawable/devic_airpods_gen1_both" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/profile_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge"
android:textStyle="bold"
tools:text="AirPods Pro" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/profile_model"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
android:textColor="?attr/colorOnSurfaceVariant"
tools:text="AirPods Pro (2nd generation)" />
</LinearLayout>
<RadioButton
android:id="@+id/profile_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:clickable="false"
android:focusable="false" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
+5
View File
@@ -114,6 +114,11 @@
<string name="translators_thanks_description">darken</string>
<string name="widget_description">A widget showing the last known device status.</string>
<string name="widget_configuration_title">Select Device</string>
<string name="widget_configuration_description">Choose which device profile this widget should display.</string>
<string name="common_feature_requires_pro_msg">This feature requires CAPod Pro.</string>
<string name="widget_no_data_label">No data</string>
<string name="settings_compat_indirectcallback_title">Indirect data delivery</string>
<string name="settings_compat_indirectcallback_summary">Use an alternative method to receive BLE data from the system (broadcast instead of callback).</string>
+2 -1
View File
@@ -11,5 +11,6 @@
android:initialLayout="@layout/widget_loading_layout"
android:resizeMode="horizontal|vertical"
android:widgetCategory="home_screen"
android:widgetFeatures="reconfigurable|configuration_optional"
android:widgetFeatures="reconfigurable"
android:configure="eu.darken.capod.main.ui.widget.WidgetConfigurationActivity"
tools:targetApi="s" />