24
24
import android .content .Context ;
25
25
import android .content .res .Resources ;
26
26
import android .content .res .TypedArray ;
27
- import android .graphics . Color ;
27
+ import android .support . design . chip . Chip ;
28
28
import android .support .v4 .content .ContextCompat ;
29
29
import android .support .v7 .widget .RecyclerView ;
30
30
import android .view .LayoutInflater ;
35
35
import android .widget .Button ;
36
36
import android .widget .CompoundButton ;
37
37
import android .widget .Filter ;
38
- import android .widget .ImageButton ;
39
38
import android .widget .ImageView ;
40
39
import android .widget .LinearLayout ;
41
40
import android .widget .SeekBar ;
@@ -78,7 +77,7 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Data
78
77
79
78
public ArrayList <DevicesInfo > data = null ;
80
79
public ArrayList <DevicesInfo > filteredData = null ;
81
- private boolean showAsList = false ;
80
+ private boolean showAsList ;
82
81
private Domoticz domoticz ;
83
82
private Context context ;
84
83
private switchesClickListener listener ;
@@ -98,7 +97,6 @@ public DashboardAdapter(Context context,
98
97
99
98
this .context = context ;
100
99
domoticz = new Domoticz (context , AppController .getInstance ().getRequestQueue ());
101
-
102
100
mConfigInfo = serverUtil .getActiveServer ().getConfigInfo (context );
103
101
this .listener = listener ;
104
102
@@ -149,33 +147,19 @@ public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) {
149
147
.inflate (R .layout .dashboard_row , parent , false );
150
148
151
149
if (mSharedPrefs .darkThemeEnabled ()) {
152
- ((android .support .v7 .widget .CardView ) row .findViewById (R .id .card_global_wrapper )).setCardBackgroundColor (Color .parseColor ("#3F3F3F" ));
150
+ if ((row .findViewById (R .id .card_global_wrapper )) != null )
151
+ row .findViewById (R .id .card_global_wrapper ).setBackgroundColor (ContextCompat .getColor (context , R .color .card_background_dark ));
153
152
if ((row .findViewById (R .id .row_wrapper )) != null )
154
- (row .findViewById (R .id .row_wrapper )).setBackground (ContextCompat .getDrawable (context , R .drawable . bordershadowdark ));
153
+ (row .findViewById (R .id .row_wrapper )).setBackground (ContextCompat .getDrawable (context , R .color . card_background_dark ));
155
154
if ((row .findViewById (R .id .row_global_wrapper )) != null )
156
- (row .findViewById (R .id .row_global_wrapper )).setBackgroundColor (ContextCompat .getColor (context , R .color .background_dark ));
157
- if ((row .findViewById (R .id .day_button )) != null )
158
- (row .findViewById (R .id .day_button )).setBackground (ContextCompat .getDrawable (context , R .drawable .button_dark_status ));
159
- if ((row .findViewById (R .id .year_button )) != null )
160
- (row .findViewById (R .id .year_button )).setBackground (ContextCompat .getDrawable (context , R .drawable .button_dark_status ));
161
- if ((row .findViewById (R .id .month_button )) != null )
162
- (row .findViewById (R .id .month_button )).setBackground (ContextCompat .getDrawable (context , R .drawable .button_dark_status ));
163
- if ((row .findViewById (R .id .week_button )) != null )
164
- (row .findViewById (R .id .week_button )).setBackground (ContextCompat .getDrawable (context , R .drawable .button_dark_status ));
165
- if ((row .findViewById (R .id .log_button )) != null )
166
- (row .findViewById (R .id .log_button )).setBackground (ContextCompat .getDrawable (context , R .drawable .button_dark_status ));
167
- if ((row .findViewById (R .id .timer_button )) != null )
168
- (row .findViewById (R .id .timer_button )).setBackground (ContextCompat .getDrawable (context , R .drawable .button_dark_status ));
169
- if ((row .findViewById (R .id .notifications_button )) != null )
170
- (row .findViewById (R .id .notifications_button )).setBackground (ContextCompat .getDrawable (context , R .drawable .button_dark_status ));
155
+ (row .findViewById (R .id .row_global_wrapper )).setBackgroundColor (ContextCompat .getColor (context , R .color .card_background_dark ));
171
156
if ((row .findViewById (R .id .on_button )) != null )
172
- (row .findViewById (R .id .on_button )).setBackground (ContextCompat .getDrawable (context , R .drawable . button_status_dark ));
157
+ (row .findViewById (R .id .on_button )).setBackgroundColor (ContextCompat .getColor (context , R .color . button_dark ));
173
158
if ((row .findViewById (R .id .off_button )) != null )
174
- (row .findViewById (R .id .off_button )).setBackground (ContextCompat .getDrawable (context , R .drawable . button_status_dark ));
159
+ (row .findViewById (R .id .off_button )).setBackgroundColor (ContextCompat .getColor (context , R .color . button_dark ));
175
160
if ((row .findViewById (R .id .color_button )) != null )
176
- (row .findViewById (R .id .color_button )).setBackground (ContextCompat .getDrawable (context , R .drawable .button_dark_status ));
161
+ (row .findViewById (R .id .color_button )).setBackgroundColor (ContextCompat .getColor (context , R .color .button_dark_status ));
177
162
}
178
-
179
163
return new DataObjectHolder (row );
180
164
}
181
165
@@ -187,8 +171,9 @@ public void onBindViewHolder(DataObjectHolder holder, final int position) {
187
171
if (!this .mSharedPrefs .darkThemeEnabled ()) {
188
172
holder .pieView .setInnerBackgroundColor (ContextCompat .getColor (context , R .color .white ));
189
173
holder .pieView .setTextColor (ContextCompat .getColor (context , R .color .black ));
190
- holder .pieView .setPercentageTextSize (17 );
191
174
}
175
+ holder .pieView .setPercentageTextSize (16 );
176
+ holder .pieView .setPercentageBackgroundColor (ContextCompat .getColor (context , R .color .material_orange_600 ));
192
177
193
178
setSwitchRowData (extendedStatusInfo , holder );
194
179
holder .itemView .setOnClickListener (new View .OnClickListener () {
@@ -204,6 +189,12 @@ public boolean onLongClick(View v) {
204
189
return true ;
205
190
}
206
191
});
192
+ holder .infoIcon .setOnClickListener (new View .OnClickListener () {
193
+ @ Override
194
+ public void onClick (View v ) {
195
+ listener .onItemLongClicked (position );
196
+ }
197
+ });
207
198
}
208
199
}
209
200
@@ -254,6 +245,7 @@ private void setSwitchRowData(DevicesInfo mDeviceInfo,
254
245
case DomoticzValues .Device .Type .Value .ON_OFF :
255
246
case DomoticzValues .Device .Type .Value .MEDIAPLAYER :
256
247
case DomoticzValues .Device .Type .Value .DOORLOCK :
248
+ case DomoticzValues .Device .Type .Value .DOORLOCKINVERTED :
257
249
case DomoticzValues .Device .Type .Value .DOORCONTACT :
258
250
switch (mDeviceInfo .getSwitchType ()) {
259
251
case DomoticzValues .Device .Type .Name .SECURITY :
@@ -308,7 +300,8 @@ private void setSwitchRowData(DevicesInfo mDeviceInfo,
308
300
case DomoticzValues .Device .Type .Value .DIMMER :
309
301
case DomoticzValues .Device .Type .Value .BLINDPERCENTAGE :
310
302
case DomoticzValues .Device .Type .Value .BLINDPERCENTAGEINVERTED :
311
- if (mDeviceInfo .getSubType ().startsWith (DomoticzValues .Device .SubType .Name .RGB )) {
303
+ if (mDeviceInfo .getSubType ().startsWith (DomoticzValues .Device .SubType .Name .RGB ) ||
304
+ mDeviceInfo .getSubType ().startsWith (DomoticzValues .Device .SubType .Name .WW )) {
312
305
if (mSharedPrefs .showSwitchesAsButtons ()) {
313
306
setButtons (holder , Buttons .DIMMER_BUTTONS );
314
307
setDimmerOnOffButtonRowData (mDeviceInfo , holder , true );
@@ -507,7 +500,7 @@ private void setSecurityPanelSwitchRowData(DevicesInfo mDeviceInfo, DataObjectHo
507
500
holder .buttonOn .setText (context .getString (R .string .button_arm ));
508
501
509
502
if (mSharedPrefs .darkThemeEnabled ())
510
- holder .buttonOn .setBackground (ContextCompat .getDrawable (context , R .drawable . button_status_dark ));
503
+ holder .buttonOn .setBackgroundColor (ContextCompat .getColor (context , R .color . button_dark ));
511
504
else
512
505
holder .buttonOn .setBackground (ContextCompat .getDrawable (context , R .drawable .button_on ));
513
506
@@ -1692,6 +1685,14 @@ public void setButtons(DataObjectHolder holder, int button) {
1692
1685
holder .signal_level .setVisibility (View .GONE );
1693
1686
holder .switch_battery_level .setVisibility (View .GONE );
1694
1687
}
1688
+ if (!mSharedPrefs .showExtraData ()) {
1689
+ holder .infoIcon .setVisibility (View .GONE );
1690
+ } else {
1691
+ if (showAsList ) {
1692
+ ViewGroup .MarginLayoutParams p = (ViewGroup .MarginLayoutParams ) holder .iconRow .getLayoutParams ();
1693
+ p .leftMargin = -15 ;
1694
+ }
1695
+ }
1695
1696
1696
1697
switch (button ) {
1697
1698
case Buttons .SWITCH :
@@ -1810,40 +1811,42 @@ public static class DataObjectHolder extends RecyclerView.ViewHolder {
1810
1811
1811
1812
TextView switch_name , signal_level , switch_status , switch_battery_level , switch_dimmer_level ;
1812
1813
Switch onOffSwitch , dimmerOnOffSwitch ;
1813
- ImageButton buttonUp , buttonDown , buttonStop ;
1814
- Button buttonOn , buttonLog , buttonTimer , buttonColor , buttonSetStatus , buttonSet , buttonOff ;
1814
+ ImageView buttonUp , buttonDown , buttonStop ;
1815
+ Button buttonOn , buttonColor , buttonSetStatus , buttonSet , buttonOff ;
1816
+ Chip buttonLog , buttonTimer ;
1815
1817
Boolean isProtected ;
1816
1818
ImageView iconRow , iconMode ;
1817
1819
SeekBar dimmer ;
1818
1820
Spinner spSelector ;
1819
1821
LinearLayout extraPanel ;
1820
1822
PieView pieView ;
1823
+ ImageView infoIcon ;
1821
1824
1822
1825
public DataObjectHolder (View itemView ) {
1823
1826
super (itemView );
1824
1827
1825
- extraPanel = ( LinearLayout ) itemView .findViewById (R .id .extra_panel );
1826
- pieView = ( PieView ) itemView .findViewById (R .id .pieView );
1827
- buttonOn = ( Button ) itemView .findViewById (R .id .on_button );
1828
- buttonOff = ( Button ) itemView .findViewById (R .id .off_button );
1829
- onOffSwitch = ( Switch ) itemView .findViewById (R .id .switch_button );
1830
- signal_level = ( TextView ) itemView .findViewById (R .id .switch_signal_level );
1831
- iconRow = ( ImageView ) itemView .findViewById (R .id .rowIcon );
1832
- switch_name = ( TextView ) itemView .findViewById (R .id .switch_name );
1833
- switch_battery_level = ( TextView ) itemView .findViewById (R .id .switch_battery_level );
1834
-
1835
- switch_dimmer_level = ( TextView ) itemView .findViewById (R .id .switch_dimmer_level );
1836
- dimmerOnOffSwitch = ( Switch ) itemView .findViewById (R .id .switch_dimmer_switch );
1837
- dimmer = ( SeekBar ) itemView .findViewById (R .id .switch_dimmer );
1838
- spSelector = ( Spinner ) itemView .findViewById (R .id .spSelector );
1839
- buttonColor = ( Button ) itemView .findViewById (R .id .color_button );
1840
- buttonLog = ( Button ) itemView .findViewById (R .id .log_button );
1841
- buttonTimer = ( Button ) itemView .findViewById (R .id .timer_button );
1842
- buttonUp = ( ImageButton ) itemView .findViewById (R .id .switch_button_up );
1843
- buttonStop = ( ImageButton ) itemView .findViewById (R .id .switch_button_stop );
1844
- buttonDown = ( ImageButton ) itemView .findViewById (R .id .switch_button_down );
1845
- buttonSet = ( Button ) itemView .findViewById (R .id .set_button );
1846
- buttonSetStatus = ( Button ) itemView .findViewById (R .id .set_button );
1828
+ extraPanel = itemView .findViewById (R .id .extra_panel );
1829
+ pieView = itemView .findViewById (R .id .pieView );
1830
+ buttonOn = itemView .findViewById (R .id .on_button );
1831
+ buttonOff = itemView .findViewById (R .id .off_button );
1832
+ onOffSwitch = itemView .findViewById (R .id .switch_button );
1833
+ signal_level = itemView .findViewById (R .id .switch_signal_level );
1834
+ iconRow = itemView .findViewById (R .id .rowIcon );
1835
+ switch_name = itemView .findViewById (R .id .switch_name );
1836
+ switch_battery_level = itemView .findViewById (R .id .switch_battery_level );
1837
+ infoIcon = itemView . findViewById ( R . id . widget_info_icon );
1838
+ switch_dimmer_level = itemView .findViewById (R .id .switch_dimmer_level );
1839
+ dimmerOnOffSwitch = itemView .findViewById (R .id .switch_dimmer_switch );
1840
+ dimmer = itemView .findViewById (R .id .switch_dimmer );
1841
+ spSelector = itemView .findViewById (R .id .spSelector );
1842
+ buttonColor = itemView .findViewById (R .id .color_button );
1843
+ buttonLog = itemView .findViewById (R .id .log_button );
1844
+ buttonTimer = itemView .findViewById (R .id .timer_button );
1845
+ buttonUp = itemView .findViewById (R .id .switch_button_up );
1846
+ buttonStop = itemView .findViewById (R .id .switch_button_stop );
1847
+ buttonDown = itemView .findViewById (R .id .switch_button_down );
1848
+ buttonSet = itemView .findViewById (R .id .set_button );
1849
+ buttonSetStatus = itemView .findViewById (R .id .set_button );
1847
1850
1848
1851
if (buttonLog != null )
1849
1852
buttonLog .setVisibility (View .GONE );
0 commit comments