Custom v0.5 modification Add Metadata keys fir Author_Version and Comment
This commit is contained in:
parent
5cac5526c4
commit
5bf787bdc0
4 changed files with 19 additions and 8 deletions
|
@ -17,7 +17,7 @@ import java.util.zip.ZipEntry
|
|||
import java.util.zip.ZipInputStream
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
||||
val CUSTOM_VERSION = "0.4"
|
||||
val CUSTOM_VERSION = "0.5"
|
||||
enum class CustomWatchfaceDrawableDataKey(val key: String, @DrawableRes val icon: Int?, val fileName: String) {
|
||||
UNKNOWN("unknown", null, "Unknown"),
|
||||
CUSTOM_WATCHFACE("customWatchface", R.drawable.watchface_custom, "CustomWatchface"),
|
||||
|
@ -31,13 +31,12 @@ enum class CustomWatchfaceDrawableDataKey(val key: String, @DrawableRes val icon
|
|||
companion object {
|
||||
fun fromKey(key: String): CustomWatchfaceDrawableDataKey =
|
||||
values().firstOrNull { it.key == key } ?: UNKNOWN
|
||||
fun fromFileName(file: String): CustomWatchfaceDrawableDataKey = values().firstOrNull { it.fileName == file } ?: UNKNOWN
|
||||
fun fromFileName(file: String): CustomWatchfaceDrawableDataKey = values().firstOrNull { it.fileName == file.substringBeforeLast(".") } ?: UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
enum class DrawableFormat(val extension: String) {
|
||||
UNKNOWN(""),
|
||||
|
||||
//XML("xml"),
|
||||
//SVG("svg"),
|
||||
JPG("jpg"),
|
||||
|
@ -93,13 +92,14 @@ enum class CustomWatchfaceMetadataKey(val key: String, @StringRes val label: Int
|
|||
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_watchface_version);
|
||||
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
|
||||
|
||||
companion object {
|
||||
fun fromKey(key: String): CustomWatchfaceMetadataKey? =
|
||||
values().firstOrNull { it.key == key }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ZipWatchfaceFormat {
|
||||
|
|
|
@ -44,7 +44,10 @@
|
|||
<string name="metadata_label_watchface_author">Author: %1$s</string>
|
||||
<string name="metadata_label_watchface_name">Name: %1$s</string>
|
||||
<string name="metadata_wear_import_filename">File name: %1$s</string>
|
||||
<string name="metadata_label_watchface_version">Watchface version: %1$s</string>
|
||||
<string name="metadata_label_plugin_version">Plugin version: %1$s</string>
|
||||
<string name="metadata_label_watchface_name_version">Name: %1$s (%2$s)</string>
|
||||
<string name="metadata_label_watchface_comment" translatable="false">%1$s</string>
|
||||
<string name="default_custom_watchface_comment">Default watchface, you can click on EXPORT WATCHFACE button to generate a template</string>
|
||||
<string name="wear_default_watchface">Default Watchface</string>
|
||||
|
||||
</resources>
|
|
@ -92,6 +92,10 @@ 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)
|
||||
}
|
||||
|
||||
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] ?:"")
|
||||
|
|
|
@ -29,6 +29,7 @@ import androidx.viewbinding.ViewBinding
|
|||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.ActivityCustomBinding
|
||||
import info.nightscout.androidaps.watchfaces.utils.BaseWatchFace
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.rx.weardata.CUSTOM_VERSION
|
||||
import info.nightscout.rx.weardata.CustomWatchfaceData
|
||||
import info.nightscout.rx.weardata.CustomWatchfaceDrawableDataKey
|
||||
|
@ -199,8 +200,10 @@ class CustomWatchface : BaseWatchFace() {
|
|||
}
|
||||
}
|
||||
}
|
||||
binding.background.visibility = View.VISIBLE
|
||||
updateSecondVisibility()
|
||||
} catch (e:Exception) {
|
||||
aapsLogger.debug(LTag.WEAR, "Crash during Custom watch load")
|
||||
persistence.store(defaultWatchface(), false) // relaod correct values to avoid crash of watchface
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +215,9 @@ class CustomWatchface : BaseWatchFace() {
|
|||
.put(CustomWatchfaceMetadataKey.CWF_FILENAME.key, getString(info.nightscout.shared.R.string.wear_default_watchface))
|
||||
.put(CustomWatchfaceMetadataKey.CWF_AUTHOR.key, "Philoul")
|
||||
.put(CustomWatchfaceMetadataKey.CWF_CREATED_AT.key, dateUtil.dateString(dateUtil.now()))
|
||||
.put(CustomWatchfaceMetadataKey.CWF_AUTHOR_VERSION.key, CUSTOM_VERSION)
|
||||
.put(CustomWatchfaceMetadataKey.CWF_VERSION.key, CUSTOM_VERSION)
|
||||
.put(CustomWatchfaceMetadataKey.CWF_COMMENT.key,getString(info.nightscout.shared.R.string.default_custom_watchface_comment))
|
||||
val json = JSONObject()
|
||||
.put("metadata", metadata)
|
||||
.put("highColor", String.format("#%06X", 0xFFFFFF and highColor))
|
||||
|
@ -247,7 +252,6 @@ class CustomWatchface : BaseWatchFace() {
|
|||
)
|
||||
}
|
||||
if (view is ImageView) {
|
||||
//view.backgroundTintList =
|
||||
json.put(
|
||||
it.key,
|
||||
JSONObject()
|
||||
|
|
Loading…
Reference in a new issue