Improve single and basic layout.

This commit is contained in:
darken
2022-01-23 20:08:34 +01:00
parent 9cd4cea63d
commit a1c58e0a32
5 changed files with 105 additions and 29 deletions
@@ -38,11 +38,8 @@ class BasicSingleApplePodsCardVH(parent: ViewGroup) :
reception.append("\n(${getString(R.string.pods_yours)})")
}
headphones.apply {
val sb = StringBuilder(context.getString(R.string.pods_single_headphones_label))
sb.append("\n").append(device.getBatteryLevelHeadset(context))
text = sb
}
batteryLabel.text = device.getBatteryLevelHeadset(context)
batteryIcon.setImageResource(getBatteryDrawable(device.batteryHeadsetPercent))
status.apply {
val sb = StringBuilder()
@@ -3,6 +3,7 @@ package eu.darken.capod.main.ui.overview.cards.pods
import android.graphics.Typeface
import android.view.ViewGroup
import androidx.core.view.isGone
import androidx.core.view.isInvisible
import eu.darken.capod.R
import eu.darken.capod.common.lists.binding
import eu.darken.capod.databinding.OverviewPodsAppleSingleItemBinding
@@ -38,16 +39,14 @@ class SingleApplePodsCardVH(parent: ViewGroup) :
reception.append("\n(${getString(R.string.pods_yours)})")
}
headphones.apply {
val sb = StringBuilder(context.getString(R.string.pods_single_headphones_label))
sb.append("\n").append(device.getBatteryLevelHeadset(context))
when {
device.isHeadsetBeingCharged -> sb.append("\n").append("Charging")
device.isHeadphonesBeingWorn -> sb.append("\n").append("In ear")
else -> {}
}
text = sb
}
batteryLabel.text = device.getBatteryLevelHeadset(context)
batteryIcon.setImageResource(getBatteryDrawable(device.batteryHeadsetPercent))
chargingIcon.isInvisible = device.isHeadsetBeingCharged
chargingLabel.isInvisible = device.isHeadsetBeingCharged
wearIcon.isInvisible = device.isHeadphonesBeingWorn
wearLabel.isInvisible = device.isHeadphonesBeingWorn
status.apply {
val sb = StringBuilder()
@@ -90,21 +90,40 @@
app:constraint_referenced_ids="headphones"
tools:layout_editor_absoluteY="60dp" />
<com.google.android.material.textview.MaterialTextView
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/headphones"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:gravity="center_horizontal"
app:drawableTopCompat="@drawable/ic_device_generic_headphones"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="@id/barrier_bottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_goneMarginBottom="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrier_top"
app:layout_constraintVertical_bias="0.0"
tools:text="Headphones\n50%\nCharging" />
app:layout_goneMarginBottom="16dp">
<ImageView
android:id="@+id/battery_icon"
style="@style/MiniTextIcon"
android:src="@drawable/ic_baseline_battery_unknown_24"
app:layout_constraintBottom_toBottomOf="@id/battery_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/battery_label" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/battery_label"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="2dp"
android:text="@string/general_value_unknown_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/battery_icon"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_bottom"
@@ -90,21 +90,81 @@
app:constraint_referenced_ids="headphones"
tools:layout_editor_absoluteY="60dp" />
<com.google.android.material.textview.MaterialTextView
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/headphones"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:gravity="center_horizontal"
app:drawableTopCompat="@drawable/ic_device_generic_headphones"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:minHeight="64dp"
app:layout_constraintBottom_toTopOf="@id/barrier_bottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_goneMarginBottom="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrier_top"
app:layout_constraintVertical_bias="0.0"
tools:text="Headphones\n50%\nCharging" />
app:layout_goneMarginBottom="16dp">
<ImageView
android:id="@+id/battery_icon"
style="@style/MiniTextIcon"
android:src="@drawable/ic_baseline_battery_unknown_24"
app:layout_constraintBottom_toBottomOf="@id/battery_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/battery_label" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/battery_label"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="2dp"
android:text="@string/general_value_unknown_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/battery_icon"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/charging_icon"
style="@style/MiniTextIcon"
android:src="@drawable/ic_baseline_power_24"
app:layout_constraintBottom_toBottomOf="@id/charging_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/charging_label" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/charging_label"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="2dp"
android:text="@string/pods_charging_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/charging_icon"
app:layout_constraintTop_toBottomOf="@id/battery_label" />
<ImageView
android:id="@+id/wear_icon"
style="@style/MiniTextIcon"
android:src="@drawable/ic_baseline_hearing_24"
app:layout_constraintBottom_toBottomOf="@id/wear_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/wear_label" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/wear_label"
style="@style/TextAppearance.MaterialComponents.Body2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="2dp"
android:text="@string/headset_being_worn_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/wear_icon"
app:layout_constraintTop_toBottomOf="@id/charging_label" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_bottom"
+1
View File
@@ -70,6 +70,7 @@
<string name="pods_inear_label">In ear</string>
<string name="pods_microphone_label">Microphone</string>
<string name="pods_yours">Yours</string>
<string name="headset_being_worn_label">Being worn</string>
<string name="overview_nomaindevice_label">No primary device</string>
<string name="overview_nomaindevice_description">All detected devices are unlikely to be yours. Power on and connect your device or adjust the settings.</string>