From 3807f185d6bde62353a9a7cef2d0fc3fbce81732 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 26 Aug 2016 18:42:28 -0400 Subject: [PATCH] Android listview cell background set via drawable so that we can retain the selected state coloring. Adjustments to style separator for tableview cells. --- src/Android/Android.csproj | 3 + .../Controls/ExtendedSwitchCellRenderer.cs | 10 ++- .../Controls/ExtendedTableViewRenderer.cs | 10 +-- .../Controls/ExtendedTextCellRenderer.cs | 9 ++- .../Controls/ExtendedViewCellRenderer.cs | 9 ++- src/Android/Resources/Resource.Designer.cs | 67 ++++++++++--------- .../Resources/drawable/list_selector.xml | 5 ++ 7 files changed, 73 insertions(+), 40 deletions(-) create mode 100644 src/Android/Resources/drawable/list_selector.xml diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index c4657a0b3..19527e39d 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -717,6 +717,9 @@ + + + diff --git a/src/Android/Controls/ExtendedSwitchCellRenderer.cs b/src/Android/Controls/ExtendedSwitchCellRenderer.cs index b41ba0b9f..270e8c015 100644 --- a/src/Android/Controls/ExtendedSwitchCellRenderer.cs +++ b/src/Android/Controls/ExtendedSwitchCellRenderer.cs @@ -22,7 +22,15 @@ namespace Bit.Android.Controls if(View != null) { - View.SetBackgroundColor(extendedCell.BackgroundColor.ToAndroid()); + if(extendedCell.BackgroundColor != Color.White) + { + View.SetBackgroundColor(extendedCell.BackgroundColor.ToAndroid()); + } + else + { + View.SetBackgroundResource(Resource.Drawable.list_selector); + } + if(item.IsEnabled) { View.SetMainTextColor(Color.Black); diff --git a/src/Android/Controls/ExtendedTableViewRenderer.cs b/src/Android/Controls/ExtendedTableViewRenderer.cs index 338e7f127..d6f0e2119 100644 --- a/src/Android/Controls/ExtendedTableViewRenderer.cs +++ b/src/Android/Controls/ExtendedTableViewRenderer.cs @@ -61,7 +61,6 @@ namespace Bit.Android.Controls { private readonly ExtendedTableView _view; private readonly AListView _listView; - private bool _removedHeader; public CustomTableViewModelRenderer(Context context, AListView listView, TableView view) : base(context, listView, view) @@ -93,8 +92,7 @@ namespace Bit.Android.Controls if(isHeader) { - layout.SetBackgroundColor(Color.Transparent.ToAndroid()); - var textCell = layout?.GetChildAt(0) as BaseCellView; + var textCell = layout.GetChildAt(0) as BaseCellView; if(textCell != null) { if(position == 0 && _view.NoHeader) @@ -108,9 +106,11 @@ namespace Bit.Android.Controls } } } - else + + var bline = layout.GetChildAt(1); + if(bline != null) { - layout.SetBackgroundColor(_view.SeparatorColor.ToAndroid()); + bline.SetBackgroundColor(_view.SeparatorColor.ToAndroid()); } return layout; diff --git a/src/Android/Controls/ExtendedTextCellRenderer.cs b/src/Android/Controls/ExtendedTextCellRenderer.cs index 261cffc7c..cd8aba9cb 100644 --- a/src/Android/Controls/ExtendedTextCellRenderer.cs +++ b/src/Android/Controls/ExtendedTextCellRenderer.cs @@ -23,7 +23,14 @@ namespace Bit.Android.Controls if(View != null) { - View.SetBackgroundColor(extendedCell.BackgroundColor.ToAndroid()); + if(extendedCell.BackgroundColor != Color.White) + { + View.SetBackgroundColor(extendedCell.BackgroundColor.ToAndroid()); + } + else + { + View.SetBackgroundResource(Resource.Drawable.list_selector); + } if(extendedCell.ShowDisclousure) { diff --git a/src/Android/Controls/ExtendedViewCellRenderer.cs b/src/Android/Controls/ExtendedViewCellRenderer.cs index 7fcdf712e..a98e552ec 100644 --- a/src/Android/Controls/ExtendedViewCellRenderer.cs +++ b/src/Android/Controls/ExtendedViewCellRenderer.cs @@ -21,7 +21,14 @@ namespace Bit.Android.Controls if(View != null) { - View.SetBackgroundColor(extendedCell.BackgroundColor.ToAndroid()); + if(extendedCell.BackgroundColor != Color.White) + { + View.SetBackgroundColor(extendedCell.BackgroundColor.ToAndroid()); + } + else + { + View.SetBackgroundResource(Resource.Drawable.list_selector); + } } return View; diff --git a/src/Android/Resources/Resource.Designer.cs b/src/Android/Resources/Resource.Designer.cs index 66d81f3ac..46d8e2e29 100644 --- a/src/Android/Resources/Resource.Designer.cs +++ b/src/Android/Resources/Resource.Designer.cs @@ -2672,94 +2672,97 @@ namespace Bit.Android public const int lightbulb = 2130837708; // aapt resource value: 0x7f0200cd - public const int @lock = 2130837709; + public const int list_selector = 2130837709; // aapt resource value: 0x7f0200ce - public const int logo = 2130837710; + public const int @lock = 2130837710; // aapt resource value: 0x7f0200cf - public const int more = 2130837711; + public const int logo = 2130837711; // aapt resource value: 0x7f0200d0 - public const int mr_dialog_material_background_dark = 2130837712; + public const int more = 2130837712; // aapt resource value: 0x7f0200d1 - public const int mr_dialog_material_background_light = 2130837713; + public const int mr_dialog_material_background_dark = 2130837713; // aapt resource value: 0x7f0200d2 - public const int mr_ic_audiotrack_light = 2130837714; + public const int mr_dialog_material_background_light = 2130837714; // aapt resource value: 0x7f0200d3 - public const int mr_ic_cast_dark = 2130837715; + public const int mr_ic_audiotrack_light = 2130837715; // aapt resource value: 0x7f0200d4 - public const int mr_ic_cast_light = 2130837716; + public const int mr_ic_cast_dark = 2130837716; // aapt resource value: 0x7f0200d5 - public const int mr_ic_close_dark = 2130837717; + public const int mr_ic_cast_light = 2130837717; // aapt resource value: 0x7f0200d6 - public const int mr_ic_close_light = 2130837718; + public const int mr_ic_close_dark = 2130837718; // aapt resource value: 0x7f0200d7 - public const int mr_ic_media_route_connecting_mono_dark = 2130837719; + public const int mr_ic_close_light = 2130837719; // aapt resource value: 0x7f0200d8 - public const int mr_ic_media_route_connecting_mono_light = 2130837720; + public const int mr_ic_media_route_connecting_mono_dark = 2130837720; // aapt resource value: 0x7f0200d9 - public const int mr_ic_media_route_mono_dark = 2130837721; + public const int mr_ic_media_route_connecting_mono_light = 2130837721; // aapt resource value: 0x7f0200da - public const int mr_ic_media_route_mono_light = 2130837722; + public const int mr_ic_media_route_mono_dark = 2130837722; // aapt resource value: 0x7f0200db - public const int mr_ic_pause_dark = 2130837723; + public const int mr_ic_media_route_mono_light = 2130837723; // aapt resource value: 0x7f0200dc - public const int mr_ic_pause_light = 2130837724; + public const int mr_ic_pause_dark = 2130837724; // aapt resource value: 0x7f0200dd - public const int mr_ic_play_dark = 2130837725; + public const int mr_ic_pause_light = 2130837725; // aapt resource value: 0x7f0200de - public const int mr_ic_play_light = 2130837726; - - // aapt resource value: 0x7f0200ea - public const int notification_template_icon_bg = 2130837738; + public const int mr_ic_play_dark = 2130837726; // aapt resource value: 0x7f0200df - public const int plus = 2130837727; + public const int mr_ic_play_light = 2130837727; + + // aapt resource value: 0x7f0200eb + public const int notification_template_icon_bg = 2130837739; // aapt resource value: 0x7f0200e0 - public const int refresh = 2130837728; + public const int plus = 2130837728; // aapt resource value: 0x7f0200e1 - public const int roundedbg = 2130837729; + public const int refresh = 2130837729; // aapt resource value: 0x7f0200e2 - public const int roundedbgdark = 2130837730; + public const int roundedbg = 2130837730; // aapt resource value: 0x7f0200e3 - public const int splash_screen = 2130837731; + public const int roundedbgdark = 2130837731; // aapt resource value: 0x7f0200e4 - public const int star = 2130837732; + public const int splash_screen = 2130837732; // aapt resource value: 0x7f0200e5 - public const int star_selected = 2130837733; + public const int star = 2130837733; // aapt resource value: 0x7f0200e6 - public const int tools = 2130837734; + public const int star_selected = 2130837734; // aapt resource value: 0x7f0200e7 - public const int tools_selected = 2130837735; + public const int tools = 2130837735; // aapt resource value: 0x7f0200e8 - public const int upload = 2130837736; + public const int tools_selected = 2130837736; // aapt resource value: 0x7f0200e9 - public const int user = 2130837737; + public const int upload = 2130837737; + + // aapt resource value: 0x7f0200ea + public const int user = 2130837738; static Drawable() { diff --git a/src/Android/Resources/drawable/list_selector.xml b/src/Android/Resources/drawable/list_selector.xml new file mode 100644 index 000000000..30309cea3 --- /dev/null +++ b/src/Android/Resources/drawable/list_selector.xml @@ -0,0 +1,5 @@ + + + + +