예제 #1
0
        public FormDropDown(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus ReportStatus)
            : base(context)
        {
            contextx                = context;
            resource                = context.Resources;
            OwnerID                 = ownerID;
            VerifierID              = verifiedID;
            elementThis             = element;
            theme                   = new FormTheme(context, element.Title);
            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();
            firstTime               = true;
            Popup                   = new InformationPopup(context);
            reportStatus            = ReportStatus;
            selection               = 0;

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            dropDownValues = new List <KeyValue>();

            dropDownFrame = new LinearLayout(context);

            dropDownFrame.Orientation = Orientation.Vertical;

            indicatorImage = (ImageView)theme.GetChildAt(1);
            //activateElementInfo(element);
            Popup.activateElementInfo(theme, element);


            if (element.IsMultiSelect)
            {
                dropDownValues = element.Values;
            }

            else
            {
                KeyValue x = new KeyValue();
                x.Name  = "Choose One";
                x.Value = "false";
                dropDownValues.Add(x);
                dropDownValues.AddRange(element.Values);
            }


            if (element.IsMultiSelect)
            {
                CreateMultiDropDown(context, indicatorImage, userID);
            }
            else
            {
                CreateDropDown(context, indicatorImage, element, userID);
            }

            AddView(theme);
            AddView(dropDownFrame);
            SetPadding(45, 10, 45, 20);
        }
예제 #2
0
        public FormCheckBox(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus, string type, string sectionType, ImageLoader _imageLoader)
            : base(context)
        {
            contextx    = context;
            myElement   = element;
            UserID      = userID;
            OwnerID     = ownerID;
            VerifierID  = verifiedID;
            formType    = type;
            section     = sectionType;
            imageLoader = _imageLoader;

            theme                   = new FormTheme(context, element.Title);
            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();
            layoutID                = Id * 1000;
            Popup                   = new InformationPopup(context);
            reportStatus            = Reportstatus;

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            checkboxFrame  = new LinearLayout(context);
            checkHoriFrame = new FlowLayout(context);

            if (element.IsVertical)
            {
                checkboxFrame.Orientation = Orientation.Vertical;
            }

            ImageView indicatorImage = (ImageView)theme.GetChildAt(1);

            activateElementInfo(element);
            Popup.activateElementInfo(theme, element);

            checkBoxValues = element.Values;

            //CheckBox
            if (element.IsMultiSelect)
            {
                CreateCheckBox(context, indicatorImage);
            }
            //RadioButton
            else
            {
                CreateRadio(context, indicatorImage);
            }

            AddView(theme);

            if (element.IsVertical)
            {
                AddView(checkboxFrame);
            }
            else
            {
                AddView(checkHoriFrame);
            }
            SetPadding(45, 10, 45, 20);

            if (element.Values.Count > 0)
            {
                for (int i = 0; i < element.Values.Count; i++)
                {
                    if (element.Values[i].Condition && element.Values[i].Value.Equals("true"))
                    {
                        for (int j = 0; j < element.Values[i].Child[0].Count; j++)
                        {
                            AddView(getView(element.Values[i].Child[0][j], element.Values[i].Child[0]));
                        }
                    }
                }
            }
        }
예제 #3
0
        public FormTabular(Context contextt, ReportElement element, int ownerID, int VerifiedID, string type, Enum.ReportStatus ReportStatus)
            : base(contextt)
        {
            context            = contextt;
            resource           = context.Resources;
            verifierID         = VerifiedID;
            Orientation        = Orientation.Vertical;
            MainTabularElement = element;
            OwnerID            = ownerID;
            MainElenetType     = type;
            Popup        = new InformationPopup(context);
            reportStatus = ReportStatus;

            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();

            //currentSession = new SessionService(new SQLiteAndriod().GetConnection()).GetCurrentSession();

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            //userID = currentSession.Id;
            userID = 1;
            theme  = new FormTheme(context, MainTabularElement.Title);

            Popup.activateElementInfo(theme, element);

            listOfTabuarElementList = new List <LinearLayout>();
            tabularImages           = new List <string>();

            AddView(theme);

            TabularAddButton addButtonLayer     = new TabularAddButton(Context);
            ImageButton      MainTemplateButton = (ImageButton)addButtonLayer.GetChildAt(1);

            mainElementName = MainTabularElement.Title;
            //MainTemplateButton.Click += (sender1, e) => copyTabular(sender1, e, MainTabularElement.Child[0]);
            //globalReportElement = MainTabularElement.Child[0];

            if (OwnerID == 0 || OwnerID == userID)
            {
                if (verifierID != 0)
                {
                    MainTemplateButton.Enabled   = false;
                    MainTemplateButton.Clickable = false;

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        MainTemplateButton.Enabled   = true;
                        MainTemplateButton.Clickable = true;
                    }
                }

                else
                {
                    MainTemplateButton.Enabled   = true;
                    MainTemplateButton.Clickable = true;
                }
            }
            else
            {
                MainTemplateButton.Enabled   = false;
                MainTemplateButton.Clickable = false;
            }

            if (isArcheived)
            {
                MainTemplateButton.Enabled   = false;
                MainTemplateButton.Clickable = false;
            }


            AddView(addButtonLayer);

            //for (int i = 1; i < MainTabularElement.Child.Count; i++)
            //{
            //    RelativeLayout NewElementbutton = new TabularItemButton(Context);
            //    TextView nameTabular = (TextView)NewElementbutton.GetChildAt(0);
            //    TextView numberTabular = (TextView)NewElementbutton.GetChildAt(1);
            //    nameTabular.Text = MainTabularElement.Title;
            //    numberTabular.Text = i + "";
            //    NewElementbutton.Tag = i;

            //    int i1 = i;
            //    NewElementbutton.Click += (sender2, e) => openTabularActivity(sender2, e, MainTabularElement.Child[i1], i1, MainTabularElement.Title);
            //    AddView(NewElementbutton);
            //}

            SetPadding(45, 10, 45, 20);
        }
예제 #4
0
        public FormMultiLineEditText(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus)
            : base(context)
        {
            resource                = context.Resources;
            contextx                = context;
            OwnerID                 = ownerID;
            VerifierID              = verifiedID;
            theme                   = new FormTheme(context, element.Title);
            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();
            Popup                   = new InformationPopup(context);
            reportStatus            = Reportstatus;

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            EditText editText = new EditText(context);

            editText.Id   = element.Id;
            editText.Text = element.Value;
            editText.SetBackgroundResource(Resource.Drawable.custom_edit_text_color);
            editText.InputType = Android.Text.InputTypes.TextFlagCapSentences;
            //editText.SetSingleLine(true);

            ImageView indicatorImage = (ImageView)theme.GetChildAt(1);

            //activateElementInfo(element);
            Popup.activateElementInfo(theme, element);
            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);
            }

            TextView elementSplitLine = new TextView(context);

            elementSplitLine.TextSize = 0.5f;
            elementSplitLine.SetBackgroundColor(Color.ParseColor(resource.GetString(Resource.Color.grey)));

            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 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));
            }

            if (isArcheived)
            {
                editText.Enabled = false;
                editText.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }

            AddView(theme);
            AddView(editText);
            SetPadding(45, 10, 45, 20);
        }
예제 #5
0
        public FormDate(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus)
            : base(context)
        {
            resource                = context.Resources;
            OwnerID                 = ownerID;
            VerifierID              = verifiedID;
            theme                   = new FormTheme(context, element.Title);
            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();
            Popup                   = new InformationPopup(context);
            contextx                = context;
            isArcheived             = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);
            reportStatus            = Reportstatus;
            dateFrame               = new RelativeLayout(context);

            dateDisplay    = new EditText(context);
            dateDisplay.Id = element.Id;

            RelativeLayout.LayoutParams dateFrameParametere = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            dateFrame.LayoutParameters = dateFrameParametere;

            //datedisplay
            RelativeLayout.LayoutParams paramsOfDateDisplay = new RelativeLayout.LayoutParams(500, RelativeLayout.LayoutParams.WrapContent);
            paramsOfDateDisplay.AddRule(LayoutRules.AlignParentLeft);

            RelativeLayout.LayoutParams paramsOfWeekDisplay = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent);
            paramsOfWeekDisplay.AddRule(LayoutRules.AlignParentBottom);
            paramsOfWeekDisplay.AddRule(LayoutRules.Below, dateDisplay.Id);

            ImageView indicatorImage = (ImageView)theme.GetChildAt(1);

            Popup.activateElementInfo(theme, element);

            dateDisplay    = new EditText(context);
            dateDisplay.Id = element.Id;
            dateDisplay.SetTextColor(Color.Black);
            dateDisplay.LayoutParameters = paramsOfDateDisplay;
            dateDisplay.SetBackgroundResource(Resource.Drawable.custom_edit_text_color);
            dateDisplay.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;
            dateDisplay.Touch    += (s, e) => {
                var handled = false;
                if (e.Event.Action == MotionEventActions.Down)
                {
                    createDateDialog(context);
                    handled = true;
                }
                else if (e.Event.Action == MotionEventActions.Up)
                {
                    // do other stuff
                    handled = true;
                }
                e.Handled = handled;
            };

            //button
            RelativeLayout.LayoutParams paramsOfClearButton = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            //paramsOfClearButton.AddRule(LayoutRules.CenterVertical);
            paramsOfClearButton.AddRule(LayoutRules.RightOf, dateDisplay.Id);

            clearDateButton          = new Button(context);
            clearDateButton.Text     = "Clear";
            clearDateButton.TextSize = 12;
            clearDateButton.SetTextColor(Resources.GetColor(Resource.Color.theme_color));
            clearDateButton.SetBackgroundResource(0);
            clearDateButton.LayoutParameters = paramsOfClearButton;
            //clearDateButton.SetBackgroundResource(Resource.Drawable.clear_button);
            clearDateButton.Click += delegate { clearDate(); };

            if (string.IsNullOrEmpty(element.Value))
            {
                dateDisplay.Text = "";
                indicatorImage.SetImageResource(0);
                clearDateButton.Visibility = ViewStates.Gone;
            }
            else
            {
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                dateDisplay.Text = dateLogic(element.Value);
                //have to set week
            }

            dateDisplay.TextChanged += (sender, e) =>
            {
                if (!dateDisplay.Text.Equals(""))
                {
                    indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                    clearDateButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    indicatorImage.SetImageResource(0);
                    clearDateButton.Visibility = ViewStates.Gone;
                }
                sharedPreferencesEditor.PutBoolean("ReportEditFlag", true);
                sharedPreferencesEditor.Commit();
            };

            weekDisplay = new TextView(context);
            weekDisplay.SetWidth(80);
            weekDisplay.SetPadding(40, 0, 0, 0);

            if (element.Value == "")
            {
                //donothing
            }
            else
            {
                DateTime dateTime = Convert.ToDateTime(element.Value);
                weekDisplay.Text = resource.GetString(Resource.String.week) + getWeekNo(dateTime);
            }


            weekDisplay.SetTextColor(Color.Black);
            weekDisplay.LayoutParameters = paramsOfWeekDisplay;

            date = DateTime.Today;

            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 0)
                {
                    clearDateButton.Enabled    = false;
                    clearDateButton.Visibility = ViewStates.Gone;
                    dateDisplay.Enabled        = false;
                    dateDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));
                    weekDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        clearDateButton.Enabled    = true;
                        clearDateButton.Visibility = ViewStates.Gone;
                        dateDisplay.Enabled        = true;
                        dateDisplay.SetTextColor(Resources.GetColor(Resource.Color.black));
                        weekDisplay.SetTextColor(Resources.GetColor(Resource.Color.black));
                    }
                }

                else
                {
                    clearDateButton.Enabled    = true;
                    clearDateButton.Visibility = ViewStates.Gone;
                    dateDisplay.Enabled        = true;
                    dateDisplay.SetTextColor(Resources.GetColor(Resource.Color.black));
                    weekDisplay.SetTextColor(Resources.GetColor(Resource.Color.black));
                }
            }
            else
            {
                clearDateButton.Enabled    = false;
                clearDateButton.Visibility = ViewStates.Gone;
                dateDisplay.Enabled        = false;
                dateDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));
                weekDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }

            if (isArcheived)
            {
                clearDateButton.Enabled    = false;
                clearDateButton.Visibility = ViewStates.Gone;
                dateDisplay.Enabled        = false;
                dateDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }

            dateFrame.AddView(dateDisplay);
            dateFrame.AddView(clearDateButton);
            dateFrame.AddView(weekDisplay);

            AddView(theme);
            AddView(dateFrame);
            SetPadding(45, 10, 45, 20);
        }
예제 #6
0
        public FormSlider(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus)
            : base(context)
        {
            resource     = context.Resources;
            contextx     = context;
            OwnerID      = ownerID;
            VerifierID   = verifiedID;
            Popup        = new InformationPopup(context);
            reportStatus = Reportstatus;

            if (element.Value == "")
            {
                element.Value = "0";
            }

            theme = new FormTheme(context, element.Title);
            RelativeLayout countHolder = new RelativeLayout(context);

            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();

            EditText counterEditText = new EditText(context);

            counterEditText.Text      = element.Value;
            counterEditText.TextSize  = 30;
            counterEditText.InputType = Android.Text.InputTypes.ClassNumber;
            counterEditText.SetTextColor(Color.ParseColor((resource.GetString(Resource.Color.green_primary))));
            counterEditText.Gravity = GravityFlags.CenterHorizontal;
            counterEditText.SetPadding(10, 0, 10, 0);
            counterEditText.SetBackgroundResource(Resource.Drawable.back);
            counterEditText.SetWidth(200);

            RelativeLayout.LayoutParams paramsForSliderCounter = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            paramsForSliderCounter.AddRule(LayoutRules.CenterHorizontal);
            counterEditText.LayoutParameters = paramsForSliderCounter; //causes layout update
            counterEditText.SetPadding(20, 5, 20, 5);

            countHolder.AddView(counterEditText);

            ImageView indicatorImageView = (ImageView)theme.GetChildAt(1);

            indicatorImageView.SetImageResource(0);
            //activateElementInfo(element);
            Popup.activateElementInfo(theme, element);

            SeekBar slider = new SeekBar(context);

            slider.Progress = Integer.ParseInt(element.Value);
            slider.SetPadding(45, 15, 45, 20);
            slider.Id  = element.Id;
            slider.Max = 31;

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            slider.ProgressChanged += (sender, e) =>
            {
                if (e.FromUser)
                {
                    counterEditText.Text = $"{e.Progress}";

                    if (counterEditText.Text.Equals("0"))
                    {
                        indicatorImageView.SetImageResource(0);
                    }
                    else
                    {
                        indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                        sharedPreferencesEditor.PutBoolean("ReportEditFlag", true);
                        sharedPreferencesEditor.Commit();
                    }
                }
            };

            counterEditText.TextChanged += (sender, e) =>
            {
                if (!counterEditText.Text.Equals("0"))
                {
                    indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);

                    if (Integer.ParseInt(counterEditText.Text) > 31 || Integer.ParseInt(counterEditText.Text) < 0)
                    {
                        sliderValuePopUp(context);
                        counterEditText.Text = "0";
                        slider.Progress      = 0;
                    }
                    slider.Progress = Integer.ParseInt(counterEditText.Text);
                }
                else
                {
                    indicatorImageView.SetImageResource(0);
                }
            };

            //when opening a Draft or Archive
            if (!counterEditText.Text.Equals("0"))
            {
                indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
            }

            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 0)
                {
                    slider.Enabled          = false;
                    counterEditText.Enabled = false;

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        slider.Enabled          = true;
                        counterEditText.Enabled = true;
                    }
                }

                else
                {
                    slider.Enabled          = true;
                    counterEditText.Enabled = true;
                }
            }
            else
            {
                slider.Enabled          = false;
                counterEditText.Enabled = false;
            }

            if (isArcheived)
            {
                slider.Enabled          = false;
                counterEditText.Enabled = false;
            }

            AddView(theme);
            AddView(countHolder);
            AddView(slider);
            SetPadding(45, 10, 45, 20);
        }
예제 #7
0
        public FormTime(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus)
            : base(context)
        {
            resource                = context.Resources;
            contextx                = context;
            OwnerID                 = ownerID;
            VerifierID              = verifiedID;
            theme                   = new FormTheme(context, element.Title);
            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();
            Popup                   = new InformationPopup(context);
            reportStatus            = Reportstatus;

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            timeFrame = new RelativeLayout(context);

            RelativeLayout.LayoutParams parms2 = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            timeFrame.LayoutParameters = parms2;

            ImageView indicatorImage = (ImageView)theme.GetChildAt(1);

            //activateElementInfo(element);
            Popup.activateElementInfo(theme, element);

            RelativeLayout.LayoutParams paramsOfTimeDisplay = new RelativeLayout.LayoutParams(500, RelativeLayout.LayoutParams.WrapContent);
            paramsOfTimeDisplay.AddRule(LayoutRules.CenterVertical);
            paramsOfTimeDisplay.AddRule(LayoutRules.AlignParentLeft);

            timeDisplay    = new EditText(context);
            timeDisplay.Id = element.Id;
            timeDisplay.SetTextColor(Color.Black);
            timeDisplay.LayoutParameters = paramsOfTimeDisplay;
            timeDisplay.Focusable        = false;
            timeDisplay.SetBackgroundResource(Resource.Drawable.custom_edit_text_color);
            timeDisplay.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;

            RelativeLayout.LayoutParams paramsOfClearButton = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsOfClearButton.AddRule(LayoutRules.RightOf, timeDisplay.Id);

            timeDisplay.Touch += (s, e) =>
            {
                var handled = false;
                if (e.Event.Action == MotionEventActions.Down)
                {
                    createTimeDialog(context);
                    handled = true;
                }
                else if (e.Event.Action == MotionEventActions.Up)
                {
                    handled = true;
                }
                e.Handled = handled;
            };

            clearTimeButton          = new Button(context);
            clearTimeButton.Text     = "Clear";
            clearTimeButton.TextSize = 12;
            clearTimeButton.SetTextColor(Resources.GetColor(Resource.Color.theme_color));
            clearTimeButton.SetBackgroundResource(0);
            clearTimeButton.LayoutParameters = paramsOfClearButton;
            clearTimeButton.Click           += delegate { clearTime(); };

            hour   = DateTime.Now.Hour;
            minute = DateTime.Now.Minute;

            if (string.IsNullOrEmpty(element.Value))
            {
                timeDisplay.Text = "";
                indicatorImage.SetImageResource(0);
                clearTimeButton.Visibility = ViewStates.Gone;
            }
            else
            {
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                timeDisplay.Text = element.Value;
            }

            timeDisplay.TextChanged += (sender, e) =>
            {
                if (!timeDisplay.Text.Equals(""))
                {
                    indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                    clearTimeButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    indicatorImage.SetImageResource(0);
                    clearTimeButton.Visibility = ViewStates.Gone;
                }

                sharedPreferencesEditor.PutBoolean("ReportEditFlag", true);
                sharedPreferencesEditor.Commit();
            };

            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 0)
                {
                    clearTimeButton.Enabled    = false;
                    clearTimeButton.Visibility = ViewStates.Gone;
                    timeDisplay.Enabled        = false;
                    timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        clearTimeButton.Enabled    = true;
                        clearTimeButton.Visibility = ViewStates.Gone;
                        timeDisplay.Enabled        = true;
                        timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.black));
                    }
                }

                else
                {
                    clearTimeButton.Enabled    = true;
                    clearTimeButton.Visibility = ViewStates.Gone;
                    timeDisplay.Enabled        = true;
                    timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.black));
                }
            }
            else
            {
                clearTimeButton.Enabled    = false;
                clearTimeButton.Visibility = ViewStates.Gone;
                timeDisplay.Enabled        = false;
                timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }


            if (isArcheived)
            {
                timeDisplay.Enabled        = false;
                clearTimeButton.Visibility = ViewStates.Gone;
                timeDisplay.Enabled        = false;
                timeDisplay.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }

            timeFrame.AddView(timeDisplay);
            timeFrame.AddView(clearTimeButton);
            AddView(theme);
            AddView(timeFrame);
            SetPadding(45, 10, 45, 20);
        }
예제 #8
0
        public FormGPS(Context context, ReportElement element, int ownerID, int userID, int verifiedID, ReportStatus Reportstatus)
            : base(context)
        {
            resource    = context.Resources;
            contextx    = context;
            OwnerID     = userID;
            VerifierID  = verifiedID;
            theme       = new FormTheme(context, element.Title);
            Orientation = Orientation.Vertical;
            RelativeLayout gpsHolder = new RelativeLayout(contextx);

            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();
            List <KeyValue> existingValue = element.Values;

            Popup        = new InformationPopup(context);
            reportStatus = Reportstatus;

            editText = new EditText(context);
            Id       = element.Id;

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            if (existingValue != null)
            {
                foreach (var address in existingValue)
                {
                    if (address.Name == "address")
                    {
                        editText.Text = address.Value;
                        curaddress    = address.Value;
                    }

                    if (address.Name == "longitude")
                    {
                        longtitude = address.Value;
                    }

                    if (address.Name == "latitude")
                    {
                        latitude = address.Value;
                    }
                }
            }

            editText.SetBackgroundResource(Resource.Drawable.custom_edit_text_color);

            RelativeLayout.LayoutParams paramsForGPSHolder = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent);
            gpsHolder.LayoutParameters = paramsForGPSHolder;

            ImageButton locationBtn = new ImageButton(context);

            locationBtn.Id = 891;
            locationBtn.SetBackgroundResource(0);
            locationBtn.SetImageResource(Resource.Drawable.android_form_gps_icon);
            locationBtn.Click += (senderGPS, e) => AddressButton_OnClick(editText, this);

            RelativeLayout.LayoutParams paramsForlocationBtn = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsForlocationBtn.AddRule(LayoutRules.AlignParentTop);
            paramsForlocationBtn.AddRule(LayoutRules.AlignParentEnd);
            locationBtn.LayoutParameters = paramsForlocationBtn;

            RelativeLayout.LayoutParams paramsForEditText = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsForEditText.AddRule(LayoutRules.AlignParentTop);
            paramsForEditText.AddRule(LayoutRules.AlignParentStart);
            paramsForEditText.AddRule(LayoutRules.StartOf, locationBtn.Id);
            editText.LayoutParameters = paramsForEditText;
            //editText.Gravity = GravityFlags.CenterVertical;

            gpsHolder.AddView(editText);
            gpsHolder.AddView(locationBtn);

            ImageView indicatorImage = (ImageView)theme.GetChildAt(1);

            //activateElementInfo(element);
            Popup.activateElementInfo(theme, element);
            editText.TextChanged += (sender, e) =>
            {
                if (!editText.Text.Equals(""))
                {
                    indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                    curaddress = editText.Text;
                }
                else
                {
                    indicatorImage.SetImageResource(0);
                }
            };

            //when opening a Draft or Archive
            if (!editText.Text.Equals(""))
            {
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
            }


            if (string.IsNullOrEmpty(element.FilledBy))
            {
                //do nothing
            }
            else if (element.FilledBy == userID + "")
            {
                //do nothing
            }
            else
            {
                editText.Enabled = false;
                editText.SetTextColor(Resources.GetColor(Resource.Color.grey));
            }

            TextView elementSplitLine = new TextView(context);

            elementSplitLine.TextSize = 0.5f;
            elementSplitLine.SetBackgroundColor(Color.ParseColor(resource.GetString(Resource.Color.grey)));


            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 0)
                {
                    editText.Enabled = false;
                    editText.SetTextColor(Resources.GetColor(Resource.Color.grey));
                    locationBtn.Enabled = false;
                    locationBtn.Click  += null;

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        editText.Enabled = true;
                        editText.SetTextColor(Resources.GetColor(Resource.Color.black));
                        locationBtn.Enabled = true;
                    }
                }

                else
                {
                    editText.Enabled = true;
                    editText.SetTextColor(Resources.GetColor(Resource.Color.black));
                    locationBtn.Enabled = true;
                }
            }
            else
            {
                editText.Enabled = false;
                editText.SetTextColor(Resources.GetColor(Resource.Color.grey));
                locationBtn.Enabled = false;
                locationBtn.Click  += null;
            }

            if (isArcheived)
            {
                editText.Enabled = false;
                editText.SetTextColor(Resources.GetColor(Resource.Color.grey));
                locationBtn.Enabled = false;
                locationBtn.Click  += null;
            }


            AddView(theme);
            AddView(gpsHolder);
            SetPadding(45, 10, 45, 20);
        }
예제 #9
0
        public FormPlusMinusCounter(Context context, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus Reportstatus)
            : base(context)
        {
            resource     = context.Resources;
            contextx     = context;
            OwnerID      = ownerID;
            VerifierID   = verifiedID;
            Popup        = new InformationPopup(context);
            reportStatus = Reportstatus;

            if (element.Value == "")
            {
                element.Value = "0";
            }

            theme = new FormTheme(context, element.Title);
            RelativeLayout countHolder = new RelativeLayout(context);

            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();

            RelativeLayout stepperlayout = new RelativeLayout(context);

            stepperlayout.FocusableInTouchMode = true;
            stepperlayout.Focusable            = true;
            stepperlayout.SetPadding(0, 5, 0, 5);

            RelativeLayout.LayoutParams paramsForStepperLayout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent);
            paramsForStepperLayout.AddRule(LayoutRules.CenterHorizontal);
            stepperlayout.LayoutParameters = paramsForStepperLayout; //causes layout update

            ImageButton negativeButton = new ImageButton(context);

            negativeButton.SetImageResource(0);
            negativeButton.SetBackgroundResource(Resource.Drawable.decrement);

            ImageButton positiveButton = new ImageButton(context);

            positiveButton.SetImageResource(0);
            positiveButton.SetBackgroundResource(Resource.Drawable.increment);

            negativeButton.Click += (sender3, e) => decreaseCount(sender3, e, element.Info);
            positiveButton.Click += (sender4, e) => increaseCount(sender4, e, element.Info);

            counterEditText           = new EditText(context);
            counterEditText.Id        = element.Id;
            counterEditText.Text      = element.Value;
            counterEditText.TextSize  = 25;
            counterEditText.InputType = Android.Text.InputTypes.ClassNumber;
            counterEditText.SetTextColor(Color.ParseColor((resource.GetString(Resource.Color.green_primary))));

            counterEditText.Gravity = GravityFlags.Center;
            counterEditText.SetBackgroundResource(Resource.Drawable.back);
            counterEditText.SetPadding(10, 15, 10, 10);

            counterEditText.SetMaxWidth(350);
            counterEditText.SetMinWidth(220);
            counterEditText.SetMinimumWidth(220);

            counterEditText.SetMaxHeight(200);
            counterEditText.SetMinHeight(100);
            counterEditText.SetMinimumHeight(100);

            //counterEditText.Focusable = false;

            RelativeLayout.LayoutParams paramsForSliderCounter = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsForSliderCounter.AddRule(LayoutRules.CenterInParent);
            counterEditText.LayoutParameters = paramsForSliderCounter;

            RelativeLayout.LayoutParams paramsForNegative = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsForNegative.AddRule(LayoutRules.LeftOf, counterEditText.Id);
            paramsForNegative.AddRule(LayoutRules.AlignBottom, counterEditText.Id);
            paramsForNegative.AddRule(LayoutRules.AlignTop, counterEditText.Id);
            negativeButton.LayoutParameters = paramsForNegative;

            negativeButton.SetMinimumHeight(100);
            negativeButton.SetMaxHeight(150);
            negativeButton.SetMinimumWidth(200);
            negativeButton.SetMaxHeight(100);

            RelativeLayout.LayoutParams paramsForPositive = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsForPositive.AddRule(LayoutRules.RightOf, counterEditText.Id);
            paramsForPositive.AddRule(LayoutRules.AlignBottom, counterEditText.Id);
            paramsForPositive.AddRule(LayoutRules.AlignTop, counterEditText.Id);
            positiveButton.LayoutParameters = paramsForPositive;

            positiveButton.SetMinimumHeight(100);
            positiveButton.SetMaxHeight(150);
            positiveButton.SetMinimumWidth(200);
            positiveButton.SetMaxHeight(100);

            ImageView indicatorImageView = (ImageView)theme.GetChildAt(1);

            indicatorImageView.SetImageResource(0);
            Popup.activateElementInfo(theme, element);

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            counterEditText.TextChanged += (sender, e) =>
            {
                if (!counterEditText.Text.Equals("0"))
                {
                    indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                    sharedPreferencesEditor.PutBoolean("ReportEditFlag", true);
                    sharedPreferencesEditor.Commit();
                }
                else
                {
                    indicatorImageView.SetImageResource(0);
                }
            };

            //when opening a Draft or Archive
            if (!counterEditText.Text.Equals("0"))
            {
                indicatorImageView.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
            }

            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 0)
                {
                    negativeButton.Enabled  = false;
                    positiveButton.Enabled  = false;
                    counterEditText.Enabled = false;

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        negativeButton.Enabled  = true;
                        positiveButton.Enabled  = true;
                        counterEditText.Enabled = true;
                    }
                }

                else
                {
                    negativeButton.Enabled  = true;
                    positiveButton.Enabled  = true;
                    counterEditText.Enabled = true;
                }
            }
            else
            {
                negativeButton.Enabled  = false;
                positiveButton.Enabled  = false;
                counterEditText.Enabled = false;
            }

            if (isArcheived)
            {
                negativeButton.Enabled  = false;
                positiveButton.Enabled  = false;
                counterEditText.Enabled = false;
            }

            stepperlayout.AddView(negativeButton);
            stepperlayout.AddView(counterEditText);
            stepperlayout.AddView(positiveButton);

            AddView(theme);
            AddView(stepperlayout);
            SetPadding(45, 10, 45, 20);
        }
예제 #10
0
        public FormSwitch(Context context, ReportElement element, int userID, int ownerID, int verifiedID, String type, ReportStatus Reportstatus, string sectionType, ImageLoader imgLoader)
            : base(context)
        {
            resource                = context.Resources;
            contextx                = context;
            OwnerID                 = ownerID;
            UserID                  = userID;
            VerifierID              = verifiedID;
            formType                = type;
            section                 = sectionType;
            theme                   = new FormTheme(context, element.Title);
            Orientation             = Orientation.Vertical;
            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();
            Popup                   = new InformationPopup(context);
            reportStatus            = Reportstatus;
            imageLoader             = imgLoader;

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            Switch swch = new Switch(context);

            RelativeLayout.LayoutParams paramsOfSwitch = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsOfSwitch.AddRule(LayoutRules.AlignParentLeft);
            swch.LayoutParameters = paramsOfSwitch;

            swch.SetPadding(0, 30, 30, 30);
            swch.Id = element.Id;
            swch.SetTextColor(Color.White);

            switchState = element.Value;
            ImageView indicatorImage = (ImageView)theme.GetChildAt(1);

            //activateElementInfo(element);
            Popup.activateElementInfo(theme, element);

            if (switchState == "")
            {
                swch.Text = "1";
            }

            else if (switchState == "false")
            {
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                swch.Checked = false;
                swch.Text    = "";
            }
            else if (switchState == "true")
            {
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                swch.Checked = true;
                swch.Text    = "";
            }

            swch.CheckedChange += (sender, e) =>
            {
                swch.Text = "";
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);

                //if (element.Options != null && element.Options.FirstOrDefault(a => a.Code == "conditional").Value == "true")
                //{
                //    if (swch.Checked)
                //    {
                //        switchState = "true";
                //        element.Value = "true";

                //        if (ChildCount > 2)
                //        {
                //            RemoveViews(2, element.Rejected[0].Count);
                //        }

                //        for (int j = 0; j < element.Accepted[0].Count; j++)
                //        {
                //            AddView(getView(element.Accepted[0][j], element.Accepted[0]));
                //        }
                //    }
                //    else
                //    {
                //        switchState = "false";
                //        element.Value = "false";
                //        if (ChildCount > 2)
                //        {
                //            RemoveViews(2, element.Accepted[0].Count);
                //        }

                //        for (int k = 0; k < element.Rejected[0].Count; k++)
                //        {
                //            AddView(getView(element.Rejected[0][k], element.Rejected[0]));
                //        }
                //    }
                //}

                sharedPreferencesEditor.PutBoolean("ReportEditFlag", true);
                sharedPreferencesEditor.Commit();
            };

            //when opening a Draft or Archive
            if (swch.Checked)
            {
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
                switchState = "true";
            }

            if (OwnerID == 0 || OwnerID == userID)
            {
                if (VerifierID != 0)
                {
                    swch.Enabled = false;

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        swch.Enabled = true;
                    }
                }

                else
                {
                    swch.Enabled = true;
                }
            }
            else
            {
                swch.Enabled = false;
            }

            TextView elementSplitLine = new TextView(context);

            elementSplitLine.TextSize = 0.5f;
            elementSplitLine.SetBackgroundColor(Color.ParseColor(resource.GetString(Resource.Color.grey)));

            if (isArcheived)
            {
                swch.Enabled = false;
            }

            AddView(theme);
            AddView(swch);
            SetPadding(55, 10, 45, 20);

            //if (element.Options != null)
            //{
            //    var conditionalCode = element.Options.FirstOrDefault(a => a.Code == "conditional");
            //    if (conditionalCode == null || !Convert.ToBoolean(conditionalCode.Value)) return;
            //    if (switchState.Equals("true"))
            //    {
            //        for (int i = 0; i < element.Accepted[0].Count; i++)
            //        {
            //            AddView(getView(element.Accepted[0][i], element.Accepted[0]));
            //        }
            //    }
            //    else
            //    {
            //        for (int i = 0; i < element.Rejected[0].Count; i++)
            //        {
            //            AddView(getView(element.Rejected[0][i], element.Rejected[0]));
            //        }

            //    }
            //}
        }