Wear CWF: Add Warning icon for pref in WF selection

This commit is contained in:
Philoul 2023-08-20 11:53:30 +02:00
parent 5e407634b6
commit fd90deb43b
3 changed files with 59 additions and 35 deletions

View file

@ -88,30 +88,30 @@ typealias CustomWatchfaceMetadataMap = MutableMap<CustomWatchfaceMetadataKey, St
@Serializable
data class CustomWatchfaceData(val json: String, var metadata: CustomWatchfaceMetadataMap, val drawableDatas: CustomWatchfaceDrawableDataMap)
enum class CustomWatchfaceMetadataKey(val key: String, @StringRes val label: Int) {
enum class CustomWatchfaceMetadataKey(val key: String, @StringRes val label: Int, val isPref: Boolean) {
CWF_NAME("name", R.string.metadata_label_watchface_name),
CWF_FILENAME("filename", R.string.metadata_wear_import_filename),
CWF_AUTHOR("author", R.string.metadata_label_watchface_author),
CWF_CREATED_AT("created_at", R.string.metadata_label_watchface_created_at),
CWF_VERSION("cwf_version", R.string.metadata_label_plugin_version),
CWF_AUTHOR_VERSION("author_version", R.string.metadata_label_watchface_name_version),
CWF_COMMENT("comment", R.string.metadata_label_watchface_comment), // label not planed to be used for CWF_COMMENT
CWF_AUTHORIZATION("cwf_authorization", R.string.metadata_label_watchface_authorization),
CWF_PREF_WATCH_SHOW_DETAILED_IOB("key_show_detailed_iob", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_DETAILED_DELTA("key_show_detailed_delta", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_BGI("key_show_bgi", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_IOB("key_show_iob", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_COB("key_show_cob", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_DELTA("key_show_delta", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_AVG_DELTA("key_show_avg_delta", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_UPLOADER_BATTERY("key_show_uploader_battery", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_RIG_BATTERY("key_show_rig_battery", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_TEMP_BASAL("key_show_temp_basal", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_DIRECTION("key_show_direction", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_AGO("key_show_ago", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_BG("key_show_bg", R.string.metadata_label_watchface_pref),
CWF_PREF_WATCH_SHOW_LOOP_STATUS("key_show_loop_status", R.string.metadata_label_watchface_pref);
CWF_NAME("name", R.string.metadata_label_watchface_name, false),
CWF_FILENAME("filename", R.string.metadata_wear_import_filename, false),
CWF_AUTHOR("author", R.string.metadata_label_watchface_author, false),
CWF_CREATED_AT("created_at", R.string.metadata_label_watchface_created_at, false),
CWF_VERSION("cwf_version", R.string.metadata_label_plugin_version, false),
CWF_AUTHOR_VERSION("author_version", R.string.metadata_label_watchface_name_version, false),
CWF_COMMENT("comment", R.string.metadata_label_watchface_comment, false), // label not planed to be used for CWF_COMMENT
CWF_AUTHORIZATION("cwf_authorization", R.string.metadata_label_watchface_authorization, false),
CWF_PREF_WATCH_SHOW_DETAILED_IOB("key_show_detailed_iob", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_DETAILED_DELTA("key_show_detailed_delta", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_BGI("key_show_bgi", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_IOB("key_show_iob", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_COB("key_show_cob", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_DELTA("key_show_delta", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_AVG_DELTA("key_show_avg_delta", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_UPLOADER_BATTERY("key_show_uploader_battery", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_RIG_BATTERY("key_show_rig_battery", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_TEMP_BASAL("key_show_temp_basal", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_DIRECTION("key_show_direction", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_AGO("key_show_ago", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_BG("key_show_bg", R.string.metadata_label_watchface_pref, true),
CWF_PREF_WATCH_SHOW_LOOP_STATUS("key_show_loop_status", R.string.metadata_label_watchface_pref, true);
companion object {
fun fromKey(key: String): CustomWatchfaceMetadataKey? =
values().firstOrNull { it.key == key }

View file

@ -24,6 +24,7 @@ import info.nightscout.rx.weardata.CustomWatchfaceDrawableDataKey
import info.nightscout.rx.weardata.CustomWatchfaceMetadataKey.*
import info.nightscout.rx.weardata.CustomWatchfaceMetadataMap
import info.nightscout.rx.weardata.EventData
import info.nightscout.shared.extensions.toVisibility
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
@ -101,6 +102,7 @@ class CustomWatchfaceImportListActivity: TranslatedDaggerAppCompatActivity() {
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()
}
}
}

View file

@ -90,18 +90,24 @@
android:textSize="11sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/created_at"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="0dp"
android:paddingStart="0dp"
android:paddingEnd="10dp"
android:text="created at: lqkjdshflqkdjhflqdskfhlqdsf"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/importListFileNameColor"
android:textSize="11sp" />
<TextView
android:id="@+id/created_at"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="0dp"
android:paddingStart="0dp"
android:paddingEnd="10dp"
android:text="created at: lqkjdshflqkdjhflqdskfhlqdsf"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/importListFileNameColor"
android:textSize="11sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:orientation="horizontal">
<TextView
android:id="@+id/cwf_version"
@ -111,10 +117,26 @@
android:layout_marginTop="0dp"
android:paddingStart="0dp"
android:paddingEnd="10dp"
android:layout_weight="1"
android:text="CWF version:"
android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/importListFileNameColor"
android:textSize="11sp" />
<ImageView
android:id="@+id/pref_warning"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginStart="10dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="1dp"
android:foreground="@drawable/ic_meta_format"
android:foregroundTint="?attr/warningColor" />
</LinearLayout>
</LinearLayout>
</LinearLayout>