Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material You design changes and widgets update #209

Merged
merged 11 commits into from
Jun 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/bluetooth_label"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.TitleMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
Expand All @@ -20,7 +20,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/bluetooth_description"
style="@style/TextAppearance.MaterialComponents.Body2"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
Expand Down
4 changes: 2 additions & 2 deletions app-wear/src/main/res/layout/overview_nomaindevice_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/title"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.TitleMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
Expand All @@ -31,7 +31,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/body"
style="@style/TextAppearance.MaterialComponents.Body2"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
Expand Down
9 changes: 5 additions & 4 deletions app-wear/src/main/res/layout/overview_permission_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/request_description"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Material3.LabelMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
Expand All @@ -20,7 +20,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/permission_label"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.BodyLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
Expand All @@ -32,7 +32,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/permission_description"
style="@style/TextAppearance.MaterialComponents.Body2"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
Expand All @@ -44,11 +44,12 @@

<com.google.android.material.button.MaterialButton
android:id="@+id/grant_action"
style="@style/Widget.MaterialComponents.Button"
style="@style/Widget.Material3.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:text="@string/general_grant_permission_action"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/permission_description" />
Expand Down
24 changes: 22 additions & 2 deletions app/src/main/java/eu/darken/capod/main/ui/widget/WidgetProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import kotlinx.coroutines.withTimeout
import java.time.Duration
import javax.inject.Inject


@AndroidEntryPoint
class WidgetProvider : AppWidgetProvider() {

Expand Down Expand Up @@ -95,6 +96,14 @@ class WidgetProvider : AppWidgetProvider() {
}
}

private fun getCellsForSize(size: Int): Int {
var n = 2
while (70 * n - 30 < size) {
rcky844 marked this conversation as resolved.
Show resolved Hide resolved
++n
}
return n - 1
}

private suspend fun updateWidget(
context: Context,
widgetManager: AppWidgetManager,
Expand All @@ -107,7 +116,17 @@ class WidgetProvider : AppWidgetProvider() {

val layout = when {
!upgradeRepo.isPro() -> createUpgradeRequiredLayout(context)
device is DualPodDevice -> createDualPodLayout(context, device)
device is DualPodDevice -> {
val minWidth = widgetManager.getAppWidgetOptions(widgetId)
.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH)
val columns = getCellsForSize(minWidth)
val layout = when (columns) {
2, 3 -> R.layout.widget_pod_dual_compact_layout
else -> R.layout.widget_pod_dual_wide_layout
}

createDualPodLayout(context, device, layout)
}
device is SinglePodDevice -> createSinglePodLayout(context, device)
device is PodDevice -> createUnknownPodLayout(context, device)
else -> createNoDeviceLayout(context)
Expand Down Expand Up @@ -169,7 +188,8 @@ class WidgetProvider : AppWidgetProvider() {
private fun createDualPodLayout(
context: Context,
podDevice: DualPodDevice,
): RemoteViews = RemoteViews(context.packageName, R.layout.widget_pod_dual_layout).apply {
layout: Int
rcky844 marked this conversation as resolved.
Show resolved Hide resolved
): RemoteViews = RemoteViews(context.packageName, layout).apply {
log(TAG, VERBOSE) { "createSinglePodLayout(context=$context, podDevice=$podDevice)" }
val pendingIntent: PendingIntent = PendingIntent.getActivity(
context,
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/debug_recording_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<TextView
android:id="@+id/label_path"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Material3.TitleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
Expand All @@ -30,7 +30,7 @@

<TextView
android:id="@+id/recording_path"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
Expand All @@ -44,7 +44,7 @@

<TextView
android:id="@+id/label_size"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Material3.TitleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
Expand All @@ -58,7 +58,7 @@

<TextView
android:id="@+id/recording_size"
style="@style/TextAppearance.AppCompat.Body1"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
Expand All @@ -70,7 +70,7 @@

<TextView
android:id="@+id/label_compressed_size"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Material3.TitleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
Expand All @@ -83,7 +83,7 @@

<TextView
android:id="@+id/recording_size_compressed"
style="@style/TextAppearance.AppCompat.Body1"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@+id/label_compressed_size"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/main_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
style="@style/Widget.Material3.Toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/onboarding_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/body1"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.BodyLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
Expand All @@ -41,7 +41,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/body2"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.BodyLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
Expand All @@ -50,7 +50,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/body3"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.BodyLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
Expand All @@ -59,7 +59,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/body4"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.BodyLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/overview_bluetooth_disabled_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/bluetooth_label"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.TitleMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
Expand All @@ -27,7 +27,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/bluetooth_description"
style="@style/TextAppearance.MaterialComponents.Body2"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/overview_nomaindevice_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/permission_label"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.TitleMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
Expand All @@ -27,7 +27,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/permission_description"
style="@style/TextAppearance.MaterialComponents.Body2"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/overview_permission_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/request_description"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Material3.LabelMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
Expand All @@ -27,7 +27,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/permission_label"
style="@style/TextAppearance.MaterialComponents.Body1"
style="@style/TextAppearance.Material3.BodyLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
Expand All @@ -39,7 +39,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/permission_description"
style="@style/TextAppearance.MaterialComponents.Body2"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="match_parent"
android:layout_marginTop="4dp"
android:layout_marginHorizontal="16dp"
Expand All @@ -51,7 +51,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/privacy_policy"
style="@style/TextAppearance.MaterialComponents.Tooltip"
style="@style/TextAppearance.Material3.BodySmall"
android:layout_width="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_height="wrap_content"
Expand All @@ -63,7 +63,7 @@

<com.google.android.material.button.MaterialButton
android:id="@+id/grant_action"
style="@style/Widget.MaterialComponents.Button"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_height="wrap_content"
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/overview_pods_dual_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/name"
style="@style/TextAppearance.MaterialComponents.Body2"
style="@style/TextAppearance.Material3.TitleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
Expand All @@ -44,7 +44,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/last_seen"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Material3.LabelMedium"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/first_seen"
Expand All @@ -56,7 +56,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/first_seen"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Material3.LabelMedium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
Expand All @@ -68,7 +68,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/reception"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Material3.LabelMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
Expand All @@ -82,7 +82,7 @@

<ImageView
android:id="@+id/reception_icon"
style="@style/TextAppearance.MaterialComponents.Caption"
style="@style/TextAppearance.Material3.LabelMedium"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginHorizontal="16dp"
Expand Down Expand Up @@ -432,7 +432,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/status"
style="@style/TextAppearance.MaterialComponents.Body2"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
Expand Down
Loading
Loading