Skip to content

Loading…

Event Fix to StringElement and SubCaption fix to CheckBox Element #1

Merged
merged 5 commits into from
This page is out of date. Refresh to see the latest.
View
67 DialogSampleApp/Resources/layout/dialog_achievements.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:paddingTop="5dp"
+ android:paddingBottom="8dp"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:orientation="horizontal"
+ >
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_weight="1"
+ >
+ <TextView android:id="@+id/dialog_LabelField"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:layout_marginTop="9dp"
+ android:layout_marginLeft="12dp"
+ android:text="FieldLabel"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ />
+ <TextView android:id="@+id/dialog_LabelSubtextField"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="2dp"
+ android:layout_marginLeft="12dp"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:text="Subtext"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ />
+ </LinearLayout>
+ <!--LinearLayout>
+ <ImageView
+ android:id="@+id/dialog_ImageRight"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right|center_vertical"
+ android:src="@drawable/dialog_disclosure"
+ android:layout_marginLeft="3dp"
+ android:layout_marginRight="3dp"
+ />
+ <TextView android:id="@+id/dialog_LabelPercentageField"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right|center_vertical"
+ android:layout_marginTop="2dp"
+ android:layout_marginLeft="2dp"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:text="0"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ />
+ </LinearLayout-->
+ <CheckBox
+ android:id="@+id/dialog_BoolField"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_gravity="right"
+ android:layout_marginRight="8dp"
+ android:focusable="false"
+ />
+</LinearLayout>
View
66 MonoDroid.Dialog/AchievementElement.cs
@@ -0,0 +1,66 @@
+using System;
+using Android.Content;
+using Android.Graphics;
+using Android.Views;
+using Android.Widget;
+
+namespace MonoDroid.Dialog
+{
+ public class AchievementElement : Element
+ {
+
+ public string Description
+ {
+ get;
+ set;
+ }
+
+ public int PercentageComplete
+ {
+ get;
+ set;
+ }
+
+ public Bitmap AchievementImage
+ {
+ get;
+ set;
+ }
+
+
+ private ImageView _achivementImage;
+ private TextView _caption;
+ private TextView _description;
+ private TextView _percentageComplete;
+
+ public string Group;
+
+ public AchievementElement(string caption, string description, int percentageComplete, Bitmap achievementImage)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_achievements)
+ {
+ Description = description;
+ PercentageComplete = percentageComplete;
+ AchievementImage = achievementImage;
+ }
+
+ public override View GetView(Context context, View convertView, ViewGroup parent)
+ {
+ View view = DroidResources.LoadAchievementsElementLayout(context, convertView, parent, LayoutId, out _caption, out _description, out _percentageComplete, out _achivementImage);
+ if (view != null)
+ {
+ _caption.Text = Caption;
+ _description.Text = Description;
+ _percentageComplete.Text = PercentageComplete.ToString();
+ if ( AchievementImage != null )
+ {
+ _achivementImage.SetImageBitmap(AchievementImage);
+ }
+ }
+ else
+ {
+ Android.Util.Log.Error("AchievementElement", "GetView failed to load template view");
+ }
+ return view;
+ }
+ }
+}
View
184 MonoDroid.Dialog/CheckboxElement.cs
@@ -1,79 +1,109 @@
-using System;
-using Android.Content;
-using Android.Views;
-using Android.Widget;
-
-namespace MonoDroid.Dialog
-{
- public class CheckboxElement : Element, CompoundButton.IOnCheckedChangeListener
- {
- public bool Value
- {
- get { return _val; }
- set
- {
- bool emit = _val != value;
- _val = value;
- if(_checkbox != null && _checkbox.Checked != _val)
- _checkbox.Checked = _val;
- else if (emit && ValueChanged != null)
- ValueChanged(this, EventArgs.Empty);
- }
- }
- private bool _val;
-
- public event EventHandler ValueChanged;
-
- private CheckBox _checkbox;
- private TextView _caption;
- private TextView _subCaption;
-
- public string Group;
-
- public CheckboxElement(string caption)
- : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldright)
- {
- Value = false;
- }
-
- public CheckboxElement(string caption, bool value)
- : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldright)
- {
- Value = value;
- }
-
- public CheckboxElement(string caption, bool value, string group)
- : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldright)
- {
- Value = value;
+using System;
+using Android.Content;
+using Android.Views;
+using Android.Widget;
+
+namespace MonoDroid.Dialog
+{
+ public class CheckboxElement : Element, CompoundButton.IOnCheckedChangeListener
+ {
+ public bool Value
+ {
+ get { return _val; }
+ set
+ {
+ bool emit = _val != value;
+ _val = value;
+ if(_checkbox != null && _checkbox.Checked != _val)
+ _checkbox.Checked = _val;
+ else if (emit && ValueChanged != null)
+ ValueChanged(this, EventArgs.Empty);
+ }
+ }
+ private bool _val;
+
+ public string SubCaption
+ {
+ get
+ {
+ return subCap;
+ }
+ set
+ {
+ subCap = value;
+ }
+ }
+ private string subCap;
+
+ public bool ReadOnly
+ {
+ get;
+ set;
+ }
+
+ public event EventHandler ValueChanged;
+
+ private CheckBox _checkbox;
+ private TextView _caption;
+ private TextView _subCaption;
+
+ public string Group;
+
+ public CheckboxElement(string caption)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldright)
+ {
+ Value = false;
+ }
+
+ public CheckboxElement(string caption, bool value)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldright)
+ {
+ Value = value;
+ }
+
+ public CheckboxElement(string caption, bool value, string subCaption, string group)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldsubright)
+ {
+ Value = value;
Group = group;
- }
-
- public CheckboxElement(string caption, bool value, string group, int layoutId)
- : base(caption, layoutId)
- {
- Value = value;
- Group = group;
- }
-
- public override View GetView(Context context, View convertView, ViewGroup parent)
- {
- View checkboxView;
- View view = DroidResources.LoadBooleanElementLayout(context, convertView, parent, LayoutId, out _caption, out _subCaption, out checkboxView);
- if (view != null)
- {
- _caption.Text = Caption;
- _checkbox = checkboxView as CheckBox;
- _checkbox.SetOnCheckedChangeListener(null);
- _checkbox.Checked = Value;
- _checkbox.SetOnCheckedChangeListener(this);
- }
- return view;
- }
-
- public void OnCheckedChanged(CompoundButton buttonView, bool isChecked)
- {
- this.Value = isChecked;
- }
- }
+ SubCaption = subCaption;
+ }
+
+ public CheckboxElement(string caption, bool value, string group)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_boolfieldright)
+ {
+ Value = value;
+ Group = group;
+ }
+
+ public CheckboxElement(string caption, bool value, string group, int layoutId)
+ : base(caption, layoutId)
+ {
+ Value = value;
+ Group = group;
+ }
+
+ public override View GetView(Context context, View convertView, ViewGroup parent)
+ {
+ View checkboxView;
+ View view = DroidResources.LoadBooleanElementLayout(context, convertView, parent, LayoutId, out _caption, out _subCaption, out checkboxView);
+ if (view != null)
+ {
+ _caption.Text = Caption;
+
+ _checkbox = checkboxView as CheckBox;
+ _checkbox.SetOnCheckedChangeListener(null);
+ _checkbox.Checked = Value;
+ _checkbox.Clickable = !ReadOnly;
+
+ _subCaption.Text = SubCaption;
+ }
+ return view;
+ }
+
+ public void OnCheckedChanged(CompoundButton buttonView, bool isChecked)
+ {
+ this.Value = isChecked;
+ }
+ }
}
View
4 MonoDroid.Dialog/HtmlElement.cs
@@ -29,7 +29,8 @@ void OpenUrl(Context context)
{
Intent intent = new Intent(context, typeof(HtmlActivity));
intent.PutExtra("URL",this.Url.ToString());
- intent.AddFlags(ActivityFlags.NewTask);
+ intent.PutExtra("Title",Caption);
+ intent.AddFlags(ActivityFlags.NewTask);
context.StartActivity(intent);
}
@@ -52,6 +53,7 @@ protected override void OnCreate(Bundle bundle)
Intent i = this.Intent;
string url = i.GetStringExtra("URL");
+ this.Title = i.GetStringExtra("Title");
WebView webview = new WebView(this);
webview.Settings.JavaScriptEnabled = true;
View
9 MonoDroid.Dialog/StringElement.cs
@@ -53,6 +53,13 @@ public StringElement(string caption, string value, int layoutId)
{
Value = value;
}
+
+ public StringElement(string caption, EventHandler clicked)
+ : base(caption, (int)DroidResources.ElementLayout.dialog_labelfieldright)
+ {
+ Value = null;
+ this.Click = clicked;
+ }
public override View GetView(Context context, View convertView, ViewGroup parent)
{
@@ -63,6 +70,8 @@ public override View GetView(Context context, View convertView, ViewGroup parent
_caption.TextSize = FontSize;
_text.Text = Value;
_text.TextSize = FontSize;
+ if (Click != null)
+ view.Click += Click;
}
return view;
}
Something went wrong with that request. Please try again.