Merge pull request #2739 from Philoul/wear/new_custom_watchface

Wear Plugin in CWF selection screen, Color Pref infos/warning according to CWF authorization
This commit is contained in:
Milos Kozak 2023-09-05 10:20:36 +02:00 committed by GitHub
commit 06c1ab0ec3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 9 deletions

View file

@ -96,18 +96,23 @@ class CustomWatchfaceImportListActivity: TranslatedDaggerAppCompatActivity() {
filelistName.tag = customWatchfaceFile
customWatchface.setImageDrawable(drawable)
customName.text = rh.gs(CWF_NAME.label, metadata[CWF_NAME])
metadata[CWF_AUTHOR_VERSION]?.let { author_version ->
customName.text = rh.gs(CWF_AUTHOR_VERSION.label, metadata[CWF_NAME], author_version)
metadata[CWF_AUTHOR_VERSION]?.let { authorVersion ->
customName.text = rh.gs(CWF_AUTHOR_VERSION.label, metadata[CWF_NAME], authorVersion)
}
author.text = rh.gs(CWF_AUTHOR.label, metadata[CWF_AUTHOR] ?:"")
createdAt.text = rh.gs(CWF_CREATED_AT.label, metadata[CWF_CREATED_AT] ?:"")
cwfVersion.text = rh.gs(CWF_VERSION.label, metadata[CWF_VERSION] ?:"")
author.text = rh.gs(CWF_AUTHOR.label, metadata[CWF_AUTHOR] ?: "")
createdAt.text = rh.gs(CWF_CREATED_AT.label, metadata[CWF_CREATED_AT] ?: "")
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
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.visibility=prefWarning.visibility
cwfPrefNumber.visibility = prefExisting.toVisibility()
cwfPrefNumber.setTextColor(rh.gac(cwfPrefNumber.context, prefColor))
}
}
}

View file

@ -134,7 +134,7 @@
android:paddingEnd="5dp"
android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/warningColor"
android:textColor="?attr/metadataTextWarningColor"
android:textSize="11sp" />
<ImageView
@ -146,7 +146,19 @@
android:layout_marginEnd="8dp"
android:layout_marginBottom="1dp"
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>