{
private TextLabel descriptionTextLabel = null;
+ private TapGestureDetector detector;
+
public SecurityTypeView(WifiUISecurityType wifiUISecurityType)
{
Size = DpUtils.ToPixels(new Size(768, 64));
InitializeSubelements();
}
+ public event Action Activated;
+
public WifiUISecurityType WifiUISecurityType { get; set; }
- public RadioButton Button { get; set; }
+ public SecurityRadioButton Button { get; set; }
private void InitializeSubelements()
{
- Button = new RadioButton
+ Button = new SecurityRadioButton
{
IsSelected = false,
Position = DpUtils.ToPixels(new Position(40, 20)),
VerticalAlignment = VerticalAlignment.Center,
};
this.Add(descriptionTextLabel);
+
+ detector = new TapGestureDetector();
+ detector.Detected += OnClicked;
+ detector.Attach(this);
+ }
+
+ private void OnClicked(object sender, TapGestureDetector.DetectedEventArgs args)
+ {
+ var selectedIndex = Button.ItemGroup.SelectedIndex;
+ Tizen.Log.Debug("oobe", $"Selected index {selectedIndex}");
+ if (Button.ItemGroup.GetItem(selectedIndex) is SecurityRadioButton selectedView)
+ {
+ selectedView.SetSelectionProgramatically(false);
+ Button.SetSelectionProgramatically(true);
+ Activated?.Invoke();
+ }
+ }
+
+ public class SecurityRadioButton : RadioButton
+ {
+ public void SetSelectionProgramatically(bool isSelected)
+ {
+ IsSelected = isSelected;
+ Tizen.Log.Debug("oobe", $"Button{this.ItemGroup.SelectedIndex}, isSelected={isSelected}");
+ // Unfortunatelly RadioButtonGroup has no public method to activate/deactivate its items
+ // Below sequence is a workaround way of informing manager (RadioButtonGroup) about change
+ // It is an equivalent of raising SelectedChanged event (this could be done by reflection)
+ OnKey(new Key()
+ {
+ State = Tizen.NUI.Key.StateType.Up,
+ KeyPressedName = "Return",
+ });
+ if (isSelected)
+ {
+ OnControlStateChanged(new ControlStateChangedEventArgs(ControlState.Normal, ControlState.Selected));
+ }
+ else
+ {
+ OnControlStateChanged(new ControlStateChangedEventArgs(ControlState.Selected, ControlState.Normal));
+ }
+ }
}
}
}