Wear Plugin Color Pref info/Warning according to cwf authorization

This commit is contained in:
Philoul 2023-09-05 00:12:20 +02:00
parent 9c3cf0b46b
commit 76e48486cc
2 changed files with 26 additions and 9 deletions

View file

@ -96,8 +96,8 @@ class CustomWatchfaceImportListActivity: TranslatedDaggerAppCompatActivity() {
filelistName.tag = customWatchfaceFile filelistName.tag = customWatchfaceFile
customWatchface.setImageDrawable(drawable) customWatchface.setImageDrawable(drawable)
customName.text = rh.gs(CWF_NAME.label, metadata[CWF_NAME]) customName.text = rh.gs(CWF_NAME.label, metadata[CWF_NAME])
metadata[CWF_AUTHOR_VERSION]?.let { author_version -> metadata[CWF_AUTHOR_VERSION]?.let { authorVersion ->
customName.text = rh.gs(CWF_AUTHOR_VERSION.label, metadata[CWF_NAME], author_version) customName.text = rh.gs(CWF_AUTHOR_VERSION.label, metadata[CWF_NAME], authorVersion)
} }
author.text = rh.gs(CWF_AUTHOR.label, metadata[CWF_AUTHOR] ?: "") author.text = rh.gs(CWF_AUTHOR.label, metadata[CWF_AUTHOR] ?: "")
@ -105,9 +105,14 @@ class CustomWatchfaceImportListActivity: TranslatedDaggerAppCompatActivity() {
cwfVersion.text = rh.gs(CWF_VERSION.label, metadata[CWF_VERSION] ?: "") cwfVersion.text = rh.gs(CWF_VERSION.label, metadata[CWF_VERSION] ?: "")
val colorAttr = if (checkCustomVersion(metadata)) info.nightscout.core.ui.R.attr.metadataTextOkColor else info.nightscout.core.ui.R.attr.metadataTextWarningColor val colorAttr = if (checkCustomVersion(metadata)) info.nightscout.core.ui.R.attr.metadataTextOkColor else info.nightscout.core.ui.R.attr.metadataTextWarningColor
cwfVersion.setTextColor(rh.gac(cwfVersion.context, colorAttr)) cwfVersion.setTextColor(rh.gac(cwfVersion.context, colorAttr))
prefWarning.visibility = metadata.keys.any { it.isPref }.toVisibility() val prefExisting = metadata.keys.any { it.isPref }
val prefSetting = sp.getBoolean(info.nightscout.core.utils.R.string.key_wear_custom_watchface_autorization, false)
val prefColor = if (prefSetting) info.nightscout.core.ui.R.attr.metadataTextWarningColor else info.nightscout.core.ui.R.attr.importListFileNameColor
prefWarning.visibility = (prefExisting && prefSetting).toVisibility()
prefInfo.visibility = (prefExisting && !prefSetting).toVisibility()
cwfPrefNumber.text = "${metadata.count { it.key.isPref }}" cwfPrefNumber.text = "${metadata.count { it.key.isPref }}"
cwfPrefNumber.visibility=prefWarning.visibility cwfPrefNumber.visibility = prefExisting.toVisibility()
cwfPrefNumber.setTextColor(rh.gac(cwfPrefNumber.context, prefColor))
} }
} }
} }

View file

@ -134,7 +134,7 @@
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/warningColor" android:textColor="?attr/metadataTextWarningColor"
android:textSize="11sp" /> android:textSize="11sp" />
<ImageView <ImageView
@ -146,7 +146,19 @@
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginBottom="1dp" android:layout_marginBottom="1dp"
android:foreground="@drawable/ic_meta_format" android:foreground="@drawable/ic_meta_format"
android:foregroundTint="?attr/warningColor" /> android:foregroundTint="?attr/metadataTextWarningColor" />
<ImageView
android:id="@+id/pref_info"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginStart="5dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="1dp"
android:visibility="gone"
android:foreground="@drawable/ic_meta_format"
android:foregroundTint="?attr/importListFileNameColor" />
</LinearLayout> </LinearLayout>