package Ġdev . hot wire . tur bo . demo . util Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . res . Configuration Ċ import Ġandroid . webkit . WebView Ċ import Ġandroidx . appcompat . widget . Toolbar Ċ import Ġandroidx . core . content . Context Compat Ċ import Ġandroidx . webkit . Web Settings Compat Ċ import Ġandroidx . webkit . WebView Feature Ċ import Ġdev . hot wire . tur bo . config . Tur bo Path Configuration Properties Ċ import Ġdev . hot wire . tur bo . demo . R Ċ Ċ val ĠTur bo Path Configuration Properties . description : ĠString ? ĊĠĠĠ Ġget () Ġ= Ġget (" description ") Ċ Ċ fun ĠToolbar . display Back Button As Close Icon () Ġ{ ĊĠĠĠ Ġnavigation Icon Ġ= ĠContext Compat . get Drawable ( context , ĠR . drawable . ic _ close ) Ċ } Ċ Ċ fun ĠWebView . init Day Night Theme () Ġ{ ĊĠĠĠ Ġif Ġ( WebView Feature . is Feature Supported ( WebView Feature . FORCE _ DARK _ STR ATE GY )) Ġ{ ĊĠĠĠĠĠĠĠ ĠWeb Settings Compat . set Force Dark Strategy ( settings , ĠWeb Settings Compat . DARK _ STR ATE GY _ WEB _ THEME _ D AR KEN ING _ ONLY ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġif Ġ( WebView Feature . is Feature Supported ( WebView Feature . FORCE _ DARK )) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( is Night Mode Enabled ( context )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtrue Ġ-> ĠWeb Settings Compat . set Force Dark ( settings , ĠWeb Settings Compat . FORCE _ DARK _ ON ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> ĠWeb Settings Compat . set Force Dark ( settings , ĠWeb Settings Compat . FORCE _ DARK _ AUTO ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġis Night Mode Enabled ( context : ĠContext ): ĠBoolean Ġ{ ĊĠĠĠ Ġval Ġcurrent Night Mode Ġ= Ġcontext . resources . configuration . ui Mode Ġand ĠConfiguration . UI _ MODE _ N IGHT _ MASK ĊĠĠĠ Ġreturn Ġcurrent Night Mode Ġ== ĠConfiguration . UI _ MODE _ N IGHT _ YES Ċ } Ċ