private void setCurrentClientTheme()
        {
            try
            {
                Typeface tf            = Typeface.CreateFromAsset(Assets, Joyces.Helpers.Settings.MainFont);
                EditText editTextEmail = FindViewById <EditText>(Resource.Id.txtRegisterViewEmail);
                editTextEmail.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                editTextEmail.Hint = Lang.EMAIL;

                EditText editTextMobileCountry = FindViewById <EditText>(Resource.Id.txtRegisterViewMobileNoCountry);
                editTextMobileCountry.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                editTextMobileCountry.Text = GeneralSettings.TelephoneNoMasking;

                EditText editTextMobile = FindViewById <EditText>(Resource.Id.txtRegisterViewMobileNo);
                editTextMobile.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                editTextMobile.Hint = Lang.MOBILEPHONE;

                EditText editTextPersonalNumber = FindViewById <EditText>(Resource.Id.txtRegisterViewPersonalNumber);
                editTextPersonalNumber.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                editTextPersonalNumber.Hint = Lang.PERSONALNUMBER;

                EditText editTextPassword1 = FindViewById <EditText>(Resource.Id.txtRegisterViewPassword1);
                editTextPassword1.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                editTextPassword1.Hint = Lang.PASSWORD;

                EditText editTextPassword2 = FindViewById <EditText>(Resource.Id.txtRegisterViewPassword2);
                editTextPassword2.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                editTextPassword2.Hint = Lang.PASSWORD_CONFIRM;

                TextView txtTermsHeader = FindViewById <TextView>(Resource.Id.txtTermsHeader);
                txtTermsHeader.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                txtTermsHeader.Text = Lang.CREATE_ACCOUNT_TERMS_HEADER;

                TextView txtTerms = FindViewById <TextView>(Resource.Id.txtTerms);
                txtTerms.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                txtTerms.Text = Lang.CREATE_ACCOUNT_TERMS;

                CheckBox chkAccept = FindViewById <CheckBox>(Resource.Id.chbRegisterViewTerms);
                chkAccept.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                chkAccept.Text = Lang.CREATE_ACCOUNT_ACCEPT_TERMS;


                Button btnRegister = FindViewById <Button>(Resource.Id.btnRegisterViewRegister);
                btnRegister.SetTypeface(tf, Android.Graphics.TypefaceStyle.Normal);
                btnRegister.Text = Lang.CREATE_ACCOUNT;
            }
            catch (Exception ex)
            {
            }
        }
Example #2
0
        public static CheckBox CreateAndAddCheckBoxRow(View view, int layoutID, String text, Boolean currval, Action <object, CompoundButton.CheckedChangeEventArgs, CheckBox> handler)
        {
            ISharedPreferences prefs = (view.Context).GetSharedPreferences("prefs.txt", FileCreationMode.Private);
            var fontsize             = float.Parse(prefs.GetString("fontsize2", "14"));

            // Get the screen's density scale
            float scale = view.Resources.DisplayMetrics.ScaledDensity;

            LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent, 1.0f);
            param.LeftMargin   = (int)(5 * scale + 0.5f);
            param.RightMargin  = (int)(5 * scale + 0.5f);
            param.TopMargin    = (int)(5 * scale + 0.5f);
            param.BottomMargin = (int)(5 * scale + 0.5f);
            param.Weight       = 1.0f;

            CheckBox txtName = new CheckBox(view.Context);

            txtName.Text = text;
            txtName.SetTextSize(ComplexUnitType.Sp, fontsize);
            txtName.SetTypeface(null, Android.Graphics.TypefaceStyle.Normal);
            txtName.LayoutParameters = param;
            txtName.Gravity          = GravityFlags.Left | GravityFlags.CenterVertical;
            txtName.TextAlignment    = TextAlignment.Gravity;
            txtName.Checked          = currval;
            txtName.SetTextColor(Android.Graphics.Color.White);

            txtName.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) =>
            {
                handler.Invoke(sender, e, txtName);
            };

            LinearLayout ll = new LinearLayout(view.Context);

            LinearLayout.LayoutParams param3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            ll.Id = new Random().Next();
            ll.LayoutParameters = param3;
            ll.Orientation      = Orientation.Horizontal;
            ll.AddView(txtName);

            LinearLayout l0 = view.FindViewById <LinearLayout>(layoutID);

            l0.AddView(ll);

            return(txtName);
        }
		public static void SetTheme(CheckBox checkBox, FlatTheme theme, 
			FlatUI.FlatFontFamily fontFamily, FlatUI.FlatFontWeight fontWeight, int radius, int size, int border)
		{
			// creating unchecked-enabled state drawable
			GradientDrawable uncheckedEnabled = new GradientDrawable();
			uncheckedEnabled.SetCornerRadius(radius);
			uncheckedEnabled.SetSize(size, size);
			uncheckedEnabled.SetColor(Color.Transparent);
			uncheckedEnabled.SetStroke(border, theme.LightAccentColor);

			// creating checked-enabled state drawable
			GradientDrawable checkedOutside = new GradientDrawable();
			checkedOutside.SetCornerRadius(radius);
			checkedOutside.SetSize(size, size);
			checkedOutside.SetColor(Color.Transparent);
			checkedOutside.SetStroke(border, theme.LightAccentColor);

			PaintDrawable checkedCore = new PaintDrawable(theme.LightAccentColor);
			checkedCore.SetCornerRadius(radius);
			checkedCore.SetIntrinsicHeight(size);
			checkedCore.SetIntrinsicWidth(size);
			InsetDrawable checkedInside = new InsetDrawable(checkedCore, border + 2, border + 2, border + 2, border + 2);

			Drawable[] checkedEnabledDrawable = {checkedOutside, checkedInside};
			LayerDrawable checkedEnabled = new LayerDrawable(checkedEnabledDrawable);

			// creating unchecked-enabled state drawable
			GradientDrawable uncheckedDisabled = new GradientDrawable();
			uncheckedDisabled.SetCornerRadius(radius);
			uncheckedDisabled.SetSize(size, size);
			uncheckedDisabled.SetColor(Color.Transparent);
			uncheckedDisabled.SetStroke(border, theme.VeryLightAccentColor);

			// creating checked-disabled state drawable
			GradientDrawable checkedOutsideDisabled = new GradientDrawable();
			checkedOutsideDisabled.SetCornerRadius(radius);
			checkedOutsideDisabled.SetSize(size, size);
			checkedOutsideDisabled.SetColor(Color.Transparent);
			checkedOutsideDisabled.SetStroke(border, theme.VeryLightAccentColor);

			PaintDrawable checkedCoreDisabled = new PaintDrawable(theme.VeryLightAccentColor);
			checkedCoreDisabled.SetCornerRadius(radius);
			checkedCoreDisabled.SetIntrinsicHeight(size);
			checkedCoreDisabled.SetIntrinsicWidth(size);
			InsetDrawable checkedInsideDisabled = new InsetDrawable(checkedCoreDisabled, border + 2, border + 2, border + 2, border + 2);

			Drawable[] checkedDisabledDrawable = {checkedOutsideDisabled, checkedInsideDisabled};
			LayerDrawable checkedDisabled = new LayerDrawable(checkedDisabledDrawable);


			StateListDrawable states = new StateListDrawable();
			states.AddState(new int[]{-Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled}, uncheckedEnabled);
			states.AddState(new int[]{Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled}, checkedEnabled);
			states.AddState(new int[]{-Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled}, uncheckedDisabled);
			states.AddState(new int[]{Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled}, checkedDisabled);
			checkBox.SetButtonDrawable(states);

			// setting padding for avoiding text to be appear on icon
			checkBox.SetPadding(size / 4 * 5, 0, 0, 0);
			checkBox.SetTextColor(theme.LightAccentColor);

			var typeface = FlatUI.GetFont(checkBox.Context, fontFamily, fontWeight);
			if (typeface != null) 
				checkBox.SetTypeface(typeface, TypefaceStyle.Normal);
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.RegisterScreen);

            TextView title                 = FindViewById <TextView> (Resource.Id.registerHeading);
            EditText studentIDInput        = FindViewById <EditText> (Resource.Id.registerStudentIDInput);
            EditText passwordInput         = FindViewById <EditText> (Resource.Id.registerPasswordInput);
            EditText rePasswordInput       = FindViewById <EditText> (Resource.Id.registerRePasswordInput);
            EditText nameInput             = FindViewById <EditText> (Resource.Id.registerStudentNameInput);
            EditText nationalityInput      = FindViewById <EditText> (Resource.Id.registerNationalityInput);
            Spinner  basicInterest         = FindViewById <Spinner> (Resource.Id.registerInterest);
            CheckBox agreeTac              = FindViewById <CheckBox> (Resource.Id.registerAgreeTac);
            Button   registerAccountButton = FindViewById <Button> (Resource.Id.registerAccountButton);
            Button   cancelButton          = FindViewById <Button> (Resource.Id.cancelButton);

            // Set up fonts.
            Typeface din     = Typeface.CreateFromAsset(this.Assets, "fonts/din-regular.ttf");
            Typeface dinBold = Typeface.CreateFromAsset(this.Assets, "fonts/din-bold.ttf");

            // Set font to "Din".
            agreeTac.SetTypeface(din, TypefaceStyle.Normal);

            // Set font to "Din Bold".
            title.SetTypeface(dinBold, TypefaceStyle.Normal);
            registerAccountButton.SetTypeface(dinBold, TypefaceStyle.Normal);
            cancelButton.SetTypeface(dinBold, TypefaceStyle.Normal);

            string studentID   = String.Empty;
            string password    = String.Empty;
            string rePassword  = String.Empty;
            string name        = String.Empty;
            string nationality = String.Empty;
            bool   tac         = false;

            string path      = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            var    accountDB = new SQLiteConnection(System.IO.Path.Combine(path, "Database.db"));

            registerAccountButton.Click += (object sender, EventArgs e) => {
                studentID   = studentIDInput.Text;
                password    = passwordInput.Text;
                rePassword  = rePasswordInput.Text;
                name        = nameInput.Text;
                nationality = nationalityInput.Text;
                tac         = agreeTac.Checked;

                string[] input = { studentID, password, rePassword, name, nationality };

                if (InputValidation.isFilled(input))
                {
                    string message = "";
                    var    result  = accountDB.Query <Account>("SELECT * FROM Account WHERE StudentID = '" + studentID + "'");

                    if (result.Count != 0)
                    {
                        message = GetString(Resource.String.account_exists);
                        DisplayUnsuccessfulAlert(message);
                    }

                    else if (!password.Equals(rePassword))
                    {
                        message = GetString(Resource.String.mismatched_passwords);
                        DisplayUnsuccessfulAlert(message);
                    }

                    else if (basicInterest.SelectedItem.ToString() == "Please select an interest...")
                    {
                        message = GetString(Resource.String.select_interest);
                        DisplayUnsuccessfulAlert(message);
                    }

                    else if (!tac)
                    {
                        message = GetString(Resource.String.must_agree);
                        DisplayUnsuccessfulAlert(message);
                    }

                    else
                    {
                        Account       acc       = new Account();
                        Profile       prof      = new Profile();
                        Accommodation accom     = new Accommodation();
                        var           accomList = accountDB.Query <Account> ("SELECT * FROM Accommodation");

                        acc.StudentID = studentID;
                        acc.Password  = password;
                        accountDB.Insert(acc);

                        prof.StudentID       = studentID;
                        prof.StudentName     = name;
                        prof.Nationality     = nationality;
                        prof.ContactNumber   = String.Empty;
                        prof.Degree          = String.Empty;
                        prof.Interest        = basicInterest.SelectedItem.ToString();
                        prof.Year            = String.Empty;
                        prof.AccommodationID = accomList.Count.ToString();
                        accountDB.Insert(prof);

                        accom.ID               = accomList.Count.ToString();
                        accom.Address          = String.Empty;
                        accom.Suburb           = String.Empty;
                        accom.RentAWeek        = String.Empty;
                        accom.PreferredContact = String.Empty;
                        accom.Description      = String.Empty;
                        accountDB.Insert(accom);

                        var successfulAlert = new AlertDialog.Builder(this);

                        successfulAlert.SetMessage(GetString(Resource.String.account_created));
                        successfulAlert.SetNeutralButton("OK", delegate {
                            var intent = new Intent(this, typeof(MainActivity));
                            StartActivity(intent);
                            // Stops user from pressing back button to return.
                            Finish();
                        });
                        successfulAlert.Show();
                    }
                }
                else
                {
                    var notFilledAlert = new AlertDialog.Builder(this);

                    notFilledAlert.SetMessage(GetString(Resource.String.required_fields));
                    notFilledAlert.SetNegativeButton("OK", delegate {});
                    notFilledAlert.Show();
                }
            };

            cancelButton.Click += (object sender, EventArgs e) => {
                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
            };
        }
Example #5
0
            public static void SetTypeFace(Activity context, CheckBox obj)
            {
                Typeface tf = Typeface.CreateFromAsset(context.Assets, "Font/Font_Normal.otf");

                obj.SetTypeface(tf, TypefaceStyle.Bold);
            }
Example #6
0
        public static void SetTheme(CheckBox checkBox, FlatTheme theme,
                                    FlatUI.FlatFontFamily fontFamily, FlatUI.FlatFontWeight fontWeight, int radius, int size, int border)
        {
            // creating unchecked-enabled state drawable
            GradientDrawable uncheckedEnabled = new GradientDrawable();

            uncheckedEnabled.SetCornerRadius(radius);
            uncheckedEnabled.SetSize(size, size);
            uncheckedEnabled.SetColor(Color.Transparent);
            uncheckedEnabled.SetStroke(border, theme.LightAccentColor);

            // creating checked-enabled state drawable
            GradientDrawable checkedOutside = new GradientDrawable();

            checkedOutside.SetCornerRadius(radius);
            checkedOutside.SetSize(size, size);
            checkedOutside.SetColor(Color.Transparent);
            checkedOutside.SetStroke(border, theme.LightAccentColor);

            PaintDrawable checkedCore = new PaintDrawable(theme.LightAccentColor);

            checkedCore.SetCornerRadius(radius);
            checkedCore.SetIntrinsicHeight(size);
            checkedCore.SetIntrinsicWidth(size);
            InsetDrawable checkedInside = new InsetDrawable(checkedCore, border + 2, border + 2, border + 2, border + 2);

            Drawable[]    checkedEnabledDrawable = { checkedOutside, checkedInside };
            LayerDrawable checkedEnabled         = new LayerDrawable(checkedEnabledDrawable);

            // creating unchecked-enabled state drawable
            GradientDrawable uncheckedDisabled = new GradientDrawable();

            uncheckedDisabled.SetCornerRadius(radius);
            uncheckedDisabled.SetSize(size, size);
            uncheckedDisabled.SetColor(Color.Transparent);
            uncheckedDisabled.SetStroke(border, theme.VeryLightAccentColor);

            // creating checked-disabled state drawable
            GradientDrawable checkedOutsideDisabled = new GradientDrawable();

            checkedOutsideDisabled.SetCornerRadius(radius);
            checkedOutsideDisabled.SetSize(size, size);
            checkedOutsideDisabled.SetColor(Color.Transparent);
            checkedOutsideDisabled.SetStroke(border, theme.VeryLightAccentColor);

            PaintDrawable checkedCoreDisabled = new PaintDrawable(theme.VeryLightAccentColor);

            checkedCoreDisabled.SetCornerRadius(radius);
            checkedCoreDisabled.SetIntrinsicHeight(size);
            checkedCoreDisabled.SetIntrinsicWidth(size);
            InsetDrawable checkedInsideDisabled = new InsetDrawable(checkedCoreDisabled, border + 2, border + 2, border + 2, border + 2);

            Drawable[]    checkedDisabledDrawable = { checkedOutsideDisabled, checkedInsideDisabled };
            LayerDrawable checkedDisabled         = new LayerDrawable(checkedDisabledDrawable);


            StateListDrawable states = new StateListDrawable();

            states.AddState(new int[] { -Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled }, uncheckedEnabled);
            states.AddState(new int[] { Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled }, checkedEnabled);
            states.AddState(new int[] { -Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled }, uncheckedDisabled);
            states.AddState(new int[] { Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled }, checkedDisabled);
            checkBox.SetButtonDrawable(states);

            // setting padding for avoiding text to be appear on icon
            checkBox.SetPadding(size / 4 * 5, 0, 0, 0);
            checkBox.SetTextColor(theme.LightAccentColor);

            var typeface = FlatUI.GetFont(checkBox.Context, fontFamily, fontWeight);

            if (typeface != null)
            {
                checkBox.SetTypeface(typeface, TypefaceStyle.Normal);
            }
        }