66import android .content .Context ;
77import android .content .Intent ;
88import android .graphics .Color ;
9+ import android .graphics .drawable .ColorDrawable ;
910import android .os .Vibrator ;
1011import android .widget .Button ;
1112import android .widget .EditText ;
1213import android .widget .ImageView ;
1314import android .widget .ListView ;
1415
1516import net .servicestack .android .AsyncUtils ;
17+ import net .servicestack .client .Utils ;
1618import net .servicestack .func .Func ;
1719
1820import java .util .ArrayList ;
@@ -123,7 +125,7 @@ private void cancelNotification(NotificationManager notificationManager)
123125 public void changeBackground (String message )
124126 {
125127 String url = message .startsWith ("url(" )
126- ? message .substring (4 , message .length () - 5 )
128+ ? message .substring (4 , message .length () - 1 )
127129 : message ;
128130
129131 App .get ().readBitmap (url , bitmap -> {
@@ -132,18 +134,31 @@ public void changeBackground(String message)
132134 });
133135 }
134136
135- public void changeBackgroundColor (String message )
136- {
137+ public void changeBackgroundColor (String message , String cssSelector ){
137138 // Inject alpha values
138139 String color = message .replace ("#" , "#AA" );
139140 ListView chatLayout = (ListView )parentActivity .findViewById (R .id .messageHistory );
140141 EditText editText = (EditText )parentActivity .findViewById (R .id .message );
141142 Button sendButton = (Button )parentActivity .findViewById (R .id .sendMessageButton );
142143
144+ int colorVal = Color .parseColor (color );
143145 parentActivity .runOnUiThread (() -> {
144- chatLayout .setBackgroundColor (Color .parseColor (color ));
145- editText .setBackgroundColor (Color .parseColor (color ));
146- sendButton .setBackgroundColor (Color .parseColor (color ));
146+ if (Objects .equals (cssSelector , "#top" )){
147+ parentActivity .getSupportActionBar ().setBackgroundDrawable (
148+ new ColorDrawable (colorVal )
149+ );
150+ }
151+
152+ if (Objects .equals (cssSelector , "#body" ) || cssSelector == null ){
153+ chatLayout .setBackgroundColor (colorVal );
154+ ImageView chatBackground = (ImageView )parentActivity .findViewById (R .id .chat_background );
155+ chatBackground .setImageDrawable (null );
156+ }
157+
158+ if (Objects .equals (cssSelector , "#bottom" )){
159+ editText .setBackgroundColor (colorVal );
160+ sendButton .setBackgroundColor (colorVal );
161+ }
147162 });
148163 }
149164}
0 commit comments