Demo code to show different ongoing notification types on the Huawei P50 Pocket external screen.
Currently the external screen provides THREE different templates
val bundle = Bundle()
val resJson = gson.toJson(templateDemo)
bundle.putString("res_id", resJson)
bundle.putInt("notification_index", templateIndex.ordinal) //0, 1, 2
bundle.putParcelable("extra_icon", Icon.createWithResource(this, iconRes))
. . .
notificationBuilder.setExtras(bundle)
{
"contentColor": 0,
"disColor": -16776961,
"disColorContent": "Arrive",
"secondlyColor": -1,
"templateContent": "Arrive at Cloud Park, Longgang District, Shenzhen City, Guangdong Province",
"titleColor": -1
}
{
"templateBottom": {
"disContents": [
{
"disContent": "2km",
"disContentColor": -1
},
{
"disContent": "2min",
"disContentColor": -1
}
],
"oriContent": "Distance: 2km, 2min",
"oriContentColor": -5592406
},
"templateContentFirst": {
"disContents": [],
"oriContent": "BD51-SMR",
"oriContentColor": -1
},
"templateContentSecondly": {
"disContents": [],
"oriContent": "Audi A3 - White",
"oriContentColor": -5592406
},
"templateTitle": "Driver on the way",
"titleColor": -246245
}
Icon is from Freepik: Taxi icons created by Freepik - Flaticon
{
"bottomContent": "934m",
"bottomContentColor": -1711276033,
"midContent": "1.315",
"midContentBigSize": true,
"midContentColor": -419430401,
"progress": 66,
"progressBgColor": -13816018,
"progressColor": -15292417,
"templateTitle": "Steps",
"titleColor": -419430401
}
Icon is from Freepik: Step icons created by Freepik - Flaticon
val listener = object : FoldableStateListener {
override fun onStateChange(bundle: Bundle?) {
val foldableState : Int = bundle?.getInt(EXTRA_FOLD_STATE, 0) ?: 0
if(foldableState == FOLD_STATE_FOLDED) {
notificationManager.notify(NOTIFICATION_ID, notification)
}
}
}
registerFoldStateListener(listener)
Make sure to exclude the JSON model object and com.huawei.android.fsm
classes
-keep class com.minkiapps.balidemo.domain.**{*;}
-keep class com.huawei.android.fsm.**{*;}
adb shell screencap -p -d 1 /sdcard/sc.png
adb pull /sdcard/sc.png ~/Desktop