//private ReportDataService reportDataService; public FormSignature(Context context, ReportElement element, string section, int userID, int ownerID, int verifierID, string formType, ReportStatus statusReport, List <ReportElement> elementList) : base(context) { contextx = context; ISharedPreferences sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); ISharedPreferencesEditor sharedPreferencesEditor = sharedPreferences.Edit(); cameraIndicatorView = new List <ImageView>(); cameraPreviewView = new List <GridView>(); //reportDataService = rds; RelativeLayout theme = new FormTheme(context, element.Title); LinearLayout btnLayer = new LinearLayout(context); btnLayer.Orientation = Orientation.Vertical; var sign = new ImageButton(context); sign.Id = element.Id; var line = new ImageView(context); line.SetBackgroundResource(Resource.Drawable.dottedlines); LayoutParams parmsofline = new LayoutParams( ViewGroup.LayoutParams.MatchParent, 1); line.LayoutParameters = parmsofline; LayoutParams parms = new LayoutParams(ViewGroup.LayoutParams.WrapContent, 300); sign.LayoutParameters = parms; string img = element.Value; string sdCardPath = Environment.ExternalStorageDirectory.AbsolutePath; string sigPath = Path.Combine(sdCardPath, "Checkd/" + img); File file = new File(sigPath); sign.SetBackgroundResource(Resource.Drawable.ic_signature); //sign.SetBackgroundResource(0); if (img == "empty" || string.IsNullOrEmpty(img)) { sign.Tag = ""; } else { sign.Tag = img; if (file.Exists()) { SetImage(sigPath, sign); } else { DownloadImage(img, sigPath, sign); } } ImageView indicatorImage = (ImageView)theme.GetChildAt(1); activateElementInfo(element, theme); int artificial_ID = SIGNATURE_INDICATOR_ID + element.Id; indicatorImage.Id = artificial_ID; cameraIndicatorView.Add(indicatorImage); cameraPreviewView.Add(new GridView(contextx)); if (!element.Value.Equals("")) { indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } if (ownerID == 0 || ownerID == userID) { if (verifierID != 0) { sign.Enabled = false; sign.Clickable = false; if (statusReport == ReportStatus.Rejected) { sign.Enabled = true; sign.Clickable = true; } } else { sign.Enabled = true; sign.Clickable = true; } } else { sign.Enabled = false; sign.Clickable = false; } sign.Click += (sender, e) => { sharedPreferencesEditor.PutString("ImageButtonID", element.Id + ""); sharedPreferencesEditor.PutString("ImageButtonType", section); sharedPreferencesEditor.Commit(); string filePath = Path.Combine(sdCardPath, "Checkd/signature_" + Guid.NewGuid() + ".jpg"); Intent intent = new Intent(context, typeof(SignatureActivity)); intent.PutExtra("URI", filePath); intent.PutExtra("ElementList", JsonConvert.SerializeObject(elementList)); ((Activity)contextx).StartActivityForResult(intent, 2); }; isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false); if (isArcheived) { sign.Clickable = false; } btnLayer.AddView(theme); btnLayer.AddView(sign); btnLayer.AddView(line); btnLayer.SetPadding(45, 10, 45, 20); AddView(btnLayer); }
public FormEditText(Context context, ReportElement element, int userId, int ownerId, int verifiedId, ReportStatus reportStatus) : base(context) { RelativeLayout theme = new FormTheme(context, element.Title); Orientation = Orientation.Vertical; ISharedPreferences sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); ISharedPreferencesEditor sharedPreferencesEditor = sharedPreferences.Edit(); EditText editText = new EditText(context); editText.Id = element.Id; editText.Text = element.Value; editText.SetSingleLine(true); editText.SetBackgroundResource(Resource.Drawable.custom_edit_text_color); editText.InputType = Android.Text.InputTypes.TextFlagCapSentences; ImageView indicatorImage = (ImageView)theme.GetChildAt(1); editText.TextChanged += (sender, e) => { if (!editText.Text.Equals("")) { indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } else { indicatorImage.SetImageResource(0); } sharedPreferencesEditor.PutBoolean("ReportEditFlag", true); sharedPreferencesEditor.Commit(); }; //when opening a Draft or Archive if (!editText.Text.Equals("")) { indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } if (ownerId == 0 || ownerId == userId) { if (verifiedId != 0) { editText.Enabled = false; editText.SetTextColor(Resources.GetColor(Resource.Color.grey)); if (reportStatus == ReportStatus.Rejected) { editText.Enabled = true; editText.SetTextColor(Resources.GetColor(Resource.Color.black)); } } else { editText.Enabled = true; editText.SetTextColor(Resources.GetColor(Resource.Color.black)); } } else { editText.Enabled = false; editText.SetTextColor(Resources.GetColor(Resource.Color.grey)); } TextView elementSplitLine = new TextView(context); elementSplitLine.TextSize = 0.5f; elementSplitLine.SetBackgroundColor(Color.ParseColor(context.Resources.GetString(Resource.Color.grey))); if (sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false)) { editText.Enabled = false; editText.SetTextColor(Resources.GetColor(Resource.Color.grey)); } AddView(theme); AddView(editText); SetPadding(45, 10, 45, 20); }
public FormCamera(Context contxt, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus reportStatus, string typeFlag, string type, List <ReportElement> elementList) : base(contxt) { imageDownloadArray = new List <string>(); if (cameraPreviewView == null) { cameraPreviewView = new List <GridView>(); } else { for (int i = 0; i < cameraPreviewView.Count; i++) { if (IMAGE_PREVIEW_Header_ID + element.Id == cameraPreviewView[i].Id || IMAGE_PREVIEW_Info_ID + element.Id == cameraPreviewView[i].Id) { cameraPreviewView.RemoveAt(i); } } } if (cameraIndicatorView == null) { cameraIndicatorView = new List <ImageView>(); } else { for (int i = 0; i < cameraIndicatorView.Count; i++) { if (IMAGE_INDICATOR_ID + element.Id == cameraIndicatorView[i].Id) { cameraIndicatorView.RemoveAt(i); } } } imageJPGFile = new ImageFile(); context = contxt; resource = context.Resources; sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context); sharedPreferencesEditor = sharedPreferences.Edit(); InitImageLoader(); LinearLayout imageLay = new LinearLayout(context); imageLay.Orientation = Orientation.Vertical; var addImageButton = new ImageButton(context); addImageButton.Id = element.Id; addImageButton.SetPadding(20, 5, 5, 5); RelativeLayout.LayoutParams paramsForImageButton = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForImageButton.AddRule(LayoutRules.AlignParentLeft); addImageButton.LayoutParameters = paramsForImageButton; GridView gridGallery = new ExpandingGrid(context); RelativeLayout.LayoutParams paramsForgridGallery = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent); paramsForgridGallery.AddRule(LayoutRules.Above, addImageButton.Id); gridGallery.LayoutParameters = paramsForgridGallery; gridGallery.SetNumColumns(6); List <CustomGallery> dataT = new List <CustomGallery>(); string sdCardPath2 = Environment.ExternalStorageDirectory.AbsolutePath; foreach (var VARIABLE in element.Values) { CustomGallery item = new CustomGallery(); item.SdCardPath = "/storage/emulated/0/Checkd/" + VARIABLE.Value; dataT.Add(item); String fileExist = Path.Combine(sdCardPath2, "Checkd/" + VARIABLE.Value); File existFile = new File(fileExist); if (!existFile.Exists()) { imageDownloadArray.Add(VARIABLE.Value); } } MultipleImageDownloader(imageDownloadArray); MiniGallerAdapter adapter = new MiniGallerAdapter(Application.Context, imageLoader); if (dataT.Count != 0) { adapter.AddAll(dataT); } gridGallery.Adapter = adapter; if (typeFlag == "Info") { int artificial_Preview_ID = IMAGE_PREVIEW_Info_ID + element.Id; gridGallery.Id = artificial_Preview_ID; cameraPreviewView.Add(gridGallery); } else { int artificial_header_Preview_ID = IMAGE_PREVIEW_Header_ID + element.Id; gridGallery.Id = artificial_header_Preview_ID; cameraPreviewView.Add(gridGallery); } gridGallery.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args) { List <CustomGallery> items = new List <CustomGallery>(); MiniGallerAdapter adapter3 = (MiniGallerAdapter)gridGallery.Adapter; items = adapter3.getList(); Object obj = items[args.Position].SdCardPath; String value = obj.ToString().Substring(obj.ToString().LastIndexOf('/') + 1); GalleryImagePreview(value); }; imageLay.AddView(gridGallery); imageLay.AddView(addImageButton); RelativeLayout theme = new FormTheme(context, element.Title); LinearLayout btnLayer = new LinearLayout(context); btnLayer.Orientation = Orientation.Vertical; String img = element.Value; String sdCardPath = Environment.ExternalStorageDirectory.AbsolutePath; String filePath = Path.Combine(sdCardPath, "Checkd/" + img); File file = new File(filePath); addImageButton.SetImageResource(Resource.Drawable.android_camera_grey); addImageButton.SetBackgroundResource(0); ImageView indicatorImage = (ImageView)theme.GetChildAt(1); activateElementInfo(element, theme); int artificial_ID = IMAGE_INDICATOR_ID + element.Id; indicatorImage.Id = artificial_ID; cameraIndicatorView.Add(indicatorImage); addImageButton.Click += (sender2, e) => ImageSelectionChoiceDialog(sender2, e, element.Id + "", type); if (!element.Value.Equals("")) { indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); } if (ownerID == 0 || ownerID == userID) { if (verifiedID != 0) { addImageButton.Enabled = false; addImageButton.Clickable = false; if (reportStatus == ReportStatus.Rejected) { addImageButton.Enabled = true; addImageButton.Clickable = true; } } else { addImageButton.Enabled = true; addImageButton.Clickable = true; } } else { addImageButton.Enabled = false; addImageButton.Clickable = false; } isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false); if (isArcheived) { addImageButton.Clickable = false; addImageButton.Enabled = false; addImageButton.Click += null; } btnLayer.AddView(theme); btnLayer.AddView(imageLay); btnLayer.SetPadding(45, 10, 45, 20); AddView(btnLayer); }