Beispiel #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            _persoon = Gegevens.GetPerson();
            _groep = Gegevens.CurrentGroup();

            SetContentView(Resource.Layout.Betaalscherm);

            _toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            ImageView Avatar = _toolbar.FindViewById<ImageView>(Resource.Id.Avatar);
            TextView Title = _toolbar.FindViewById<TextView>(Resource.Id.Title);
            Title.Text = _groep.groepsnaam;

            foreach (var lid in _persoon.KrijgSchuldGroep(_groep))
            {
                deelnemers.Add(new ListItem(lid.Key, Resource.Drawable.iconn, lid.Value, _groep));
            }

            _adapter = new ListItemAdapter(ListItem.Session, deelnemers);
            _adapter.ItemClick += OnItemClick;
            _adapter.ItemLongClick += (sender, e) => {};

            _recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerview);
            _recyclerView.SetMinimumHeight(ConvertDptoPx(listItemHeight*deelnemers.Count));
            _recyclerView.SetLayoutManager(new LinearLayoutManager(this));
            _recyclerView.SetScrollContainer(true);
            _recyclerView.NestedScrollingEnabled = false;
            _recyclerView.SetAdapter(_adapter);

            SetSupportActionBar(_toolbar);
            SupportActionBar.Title = "";
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            _persoon = Gegevens.GetPerson();
            _groep = Gegevens.CurrentGroup();

            SetContentView(Resource.Layout.Historyscherm);

            Toolbar toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.Title = "Debt History";

            _recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerview);
            _recyclerView.SetLayoutManager(new LinearLayoutManager(this));
        }
Beispiel #3
0
        public static Persoon GetServerData(string persoonid, string password)
        {
            Dictionary<string, int> Groups = DatabaseInterface.GetGroupsByUsername (persoonid, password);
            List<Debt> RequestFrom = DatabaseInterface.GetRequestedDebtFromUsername (persoonid, password);
            List<Debt> RequestTo = DatabaseInterface.GetRequestedDebtToUsername (persoonid, password);
            List<Debt> From = DatabaseInterface.GetDebtFromUsername (persoonid, password);
            List<Debt> To = DatabaseInterface.GetDebtToUsername (persoonid, password);
            List<Payment> PayFrom = DatabaseInterface.GetPaymentFromUsername (persoonid, password);
            List<Payment> PayTo = DatabaseInterface.GetPaymentToUsername (persoonid, password);
            List<Groep> Groepen = new List<Groep> ();
            List<PaidDebt> HistoryTo = DatabaseInterface.GetHistoryToUsername (persoonid, password);
            List<PaidDebt> HistoryFrom = DatabaseInterface.GetHistoryFromUsername (persoonid, password);
            List<string> Contacts = DatabaseInterface.GetContacts(persoonid, password);

            foreach (var groep in Groups)
            {
                Groep groepje = new Groep (DatabaseInterface.GetMembersByGroup (groep.Key, persoonid, password), groep.Value , groep.Key);
                Groepen.Add (groepje);
            }
            Persoon pers = new Persoon (persoonid, password, To, From,  Groepen, RequestTo, RequestFrom, HistoryTo, HistoryFrom, PayFrom, PayTo, Contacts);
            p = pers;

            return pers;
        }
Beispiel #4
0
        public List<Debt> KrijgDebtsVanGroep(Groep gr)
        {
            List<Debt> DebtsVanGroep = new List<Debt> ();

            foreach (string deelnemer in gr.Deelnemers)
                foreach (Debt debt in DebtVan)
                    if (debt.Payer == deelnemer)
                        DebtsVanGroep.Add (debt);
            return DebtsVanGroep;
        }
Beispiel #5
0
        public List<Debt> KrijgDebtsBijGroep(Groep gr)
        {
            List<Debt> DebtsBijGroep = new List<Debt> ();

            foreach (string deelnemer in gr.Deelnemers)
                foreach (Debt debt in DebtBij)
                    if (debt.Collector == deelnemer)
                        DebtsBijGroep.Add (debt);
            return DebtsBijGroep;
        }
 // session
 public ListItem(string sessionname, int sessionimageid, double sessionvalue, Groep groep)
 {
     Name = sessionname;
     ImageId = sessionimageid;
     Value = sessionvalue;
     Groep = groep;
 }
Beispiel #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            IsFirstInitialization = true;
            _persoon = Gegevens.GetPerson();
            _groep = Gegevens.CurrentGroup();

            SetContentView(Resource.Layout.Hoofdscherm);

            _toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            _totalDebt = _toolbar.FindViewById<TextView>(Resource.Id.TotalDebt);
            _title = _toolbar.FindViewById<TextView>(Resource.Id.Title);
            _title.Text = _persoon.Id;
            TotalDebt = _persoon.TotaalSchuld();

            SetSupportActionBar(_toolbar);
            SupportActionBar.Title = "";

            _fragments = new HoofdschermFragment[]
            {
                new SessionFragment(),
                new PayFragment(),
                new ContactFragment()
            };

            var titles = CharSequence.ArrayFromStringArray(new[]
                {
                    "Sessions",
                    "Payments",
                    "Contacts"
                });

            _viewPager = FindViewById<ViewPager>(Resource.Id.viewpager);
            _viewPager.Adapter = new TabsFragmentPagerAdapter(SupportFragmentManager, _fragments, titles);
            _viewPager.SetCurrentItem(1, true);

            _tabLayout = FindViewById<TabLayout>(Resource.Id.sliding_tabs);
            _tabLayout.SetupWithViewPager(_viewPager);

            _tabLayout.SetOnTabSelectedListener(this);
        }
Beispiel #8
0
        public double TotaalSchuldGroep(Groep gr)
        {
            double totSchuld = 0;

            foreach (string deelnemer in gr.Deelnemers)
            {
                foreach (var schuld in DebtVan)
                    if (schuld.Payer == deelnemer)
                        totSchuld += schuld.Amount;
                foreach (var schuld in DebtBij)
                    if (schuld.Collector == deelnemer)
                        totSchuld -= schuld.Amount;
            }
            return Math.Round(totSchuld, 2);
        }
Beispiel #9
0
 public Dictionary<string, double> PaymentsBij(Groep gr)
 {
     Dictionary<string, double> Paybij = new Dictionary<string, double> ();
     double value = 0;
     foreach (string deelnemer in gr.Deelnemers) {
         foreach (Payment pay in PaymentBij) {
             if (pay.Collector == deelnemer) {
                 Paybij.TryGetValue (pay.Collector, out value);
                 Paybij.Remove (pay.Collector);
                 Paybij.Add (pay.Collector, value + pay.Amount);
             }
         }
     }
     return Paybij;
 }
Beispiel #10
0
        public List<Debt> KrijgRequestVanGroep(Groep gr)
        {
            List<Debt> Verzoekgroep = new List<Debt> ();

            foreach (string deelnemer in gr.Deelnemers)
            {
                foreach (var schuld in RequestVan)
                    if (schuld.Payer == deelnemer)
                        Verzoekgroep.Add (schuld);
            }
            return Verzoekgroep;
        }
Beispiel #11
0
 public virtual void Refresh()
 {
     _persoon = Gegevens.GetServerData(_persoon.Id, _persoon.Password);
     _groep = Gegevens.CurrentGroup();
     CreateEnvironments();
     ((Payscherm) this.Activity).TotalDebt = _persoon.TotaalSchuldGroep(_groep);
     RefreshHandler.PostDelayed(CancelAnimation, 700);
 }
Beispiel #12
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            _persoon = Gegevens.GetPerson();
            _groep = Gegevens.CurrentGroup();

            SetContentView(Resource.Layout.Nieuwschuldscherm);

            _toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            ImageView Avatar = _toolbar.FindViewById<ImageView>(Resource.Id.Avatar);
            TextView Title = _toolbar.FindViewById<TextView>(Resource.Id.Title);
            TextView item = FindViewById<TextView>(Resource.Id.pending_text);
            CardView Boodschap = FindViewById<CardView>(Resource.Id.pending_card_view);
            CardView Schuld = FindViewById<CardView>(Resource.Id.participants_card_view);
            LinearLayout layout = FindViewById<LinearLayout>(Resource.Id.layout1);
            ScrollView Scroll = FindViewById<ScrollView>(Resource.Id.scrollSchuld);
            layout.RemoveView (Boodschap);

            Title.Text = _groep.groepsnaam;

            MakeRecycleViewList ();

            Button confirm = FindViewById<Button>(Resource.Id.buttonConfirm);
            Button add = FindViewById<Button>(Resource.Id.buttonAdd);
            bool keer = false;

            confirm.Click += (sender, e) =>
            {
                // check eerst of alle productprijzen ingevuld zijn
                foreach (var product in deelnemers)
                {
                    if (product.Name == "" || product.StringValue == "")
                    {
                        Toast.MakeText(this, "Please fill in all fields", ToastLength.Long).Show();
                        return;
                    }
                    //sommige toestellen kunnen geen komma's invoeren
                    product.StringValue = product.StringValue.Replace('.', ',');
                }
                //sluit als het nodig is het keyboard af
                InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(add.WindowToken, 0);
                layout.RemoveViewsInLayout(0, layout.ChildCount);
                if(!keer)
                {
                    //invullen van de reden van de debt
                    ReasonAlert();
                }
                for(int t = 0; t < deelnemers.Count; t++)
                    //verwijder producten die uitgevinkt zijn
                    if(!deelnemers[t].State || !IsNumber(deelnemers[t].StringValue))
                    {deelnemers.Remove(deelnemers[t]); t--;}
                    else if (!keer)
                    {
                        lijst += deelnemers[t].Name + "-" + (Math.Round(System.Convert.ToDouble(deelnemers[t].StringValue)*100)).ToString() + "-";
                    }
                layout.AddView(Boodschap);
                layout.AddView(Schuld);
                //als alle boodschappen zijn langs gekomen
                if (deelnemers.Count == 1 && keer)
                {
                    MaakNieuwSchuld();
                    confirm.Text = "Send";
                    deelnemers.Remove(deelnemers.First());
                }
                //versuren v/d schuld
                else if (deelnemers.Count == 0)
                {	VerstuurSchuld();
                    Finish();}
                else{
                    _adapter.NotifyDataSetChanged();
                    MaakNieuwSchuld();
                    groep.Clear();
                    if(keer)
                        deelnemers.Remove(deelnemers.First());
                    item.Text = deelnemers.First().Name + " " + deelnemers.First().StringValue;
                    confirm.Text = "Next";
                    keer = true;
                    MakeRecycleViewPayers();
                }
            };
            add.Click += (sender, e) =>
            {
                //haalt het toetsenbord weg
                InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(add.WindowToken, 0);
                _adapter.NotifyDataSetChanged();
                Scroll.PageScroll(FocusSearchDirection.Down);
                MakeRecycleViewList();
            };
        }
Beispiel #13
0
 public static bool ChangeCurrentGroup(Groep gr)
 {
     huidigegroep = gr;
     return true;
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AddParticipantsScherm);

            _persoon = Gegevens.GetPerson();
            _groep = Gegevens.CurrentGroup();

            // haal contectenlijst uit database en stop ze in ListItem lijst
            List<ListItem> contactList = DatabaseInterface.GetContacts(_persoon.Id, _persoon.Password).Select(contact => new ListItem(contact, Resource.Drawable.iconn)).ToList();

            contactList = contactList.OrderBy(x => x.Name).ToList();

            _adapter = new ListItemAdapter(ListItem.CheckBoxContact, contactList);
            _adapter.ItemClick += (sender, args) =>
            {
                Toast.MakeText(this, _adapter.Items[args.Position].Name, ToastLength.Short).Show();
            };

            _recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerview);
            _recyclerView.SetLayoutManager(new LinearLayoutManager(this));
            _recyclerView.SetAdapter(_adapter);

            string intentString = Intent.GetStringExtra("Current participants");

            if (intentString != string.Empty)
            {
                string[] contactStrings = intentString.Split('|');

                if (contactStrings[0] == "New Group")
                {
                    for (int i = 1; i < contactStrings.Length; i++)
                    {
                        string[] contactAttr = contactStrings[i].Split(',');

                        foreach (var item in _adapter.Items)
                        {
                            if (contactAttr[0] == item.Name)
                            {
                                item.State = true;
                            }
                        }
                    }
                }
                else if (contactStrings[0] == "Existing Group")
                {
                    for (int i = 1; i < contactStrings.Length; i++)
                    {
                        string[] contactAttr = contactStrings[i].Split(',');

                        for (int j = 0; j < _adapter.Items.Count; j++)
                        {
                            if (contactAttr[0] == _adapter.Items[j].Name)
                            {
                                _adapter.Items.RemoveAt(j);
                                break;
                            }
                        }
                    }
                }
                _adapter.NotifyDataSetChanged();
            }

            Toolbar toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.Title = "Add participants";
        }
Beispiel #15
0
 public List<PaidDebt> KrijgHistorieBijGroep(Groep gr)
 {
     List<PaidDebt> hisbij = new List<PaidDebt> ();
     foreach (string deelnemer in gr.Deelnemers)
     {
         foreach (PaidDebt pay in HistoryBij)
             if (pay.Collector == deelnemer)
                 hisbij.Add (pay);
     }
     return hisbij;
 }
Beispiel #16
0
 public List<PaidDebt> KrijgHistorieVanGroep(Groep gr)
 {
     List<PaidDebt> hisvan = new List<PaidDebt> ();
     foreach (string deelnemer in gr.Deelnemers)
     {
         foreach (PaidDebt pay in HistoryVan)
             if (pay.Payer == deelnemer)
                 hisvan.Add (pay);
     }
     return hisvan;
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.AddGroupScherm);

            _persoon = Gegevens.GetPerson();
            _groep = Gegevens.CurrentGroup ();

            Toolbar toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            EditText titleEditText = FindViewById<EditText>(Resource.Id.grouptitle_edit_text);
            titleEditText.Hint = "Group title";

            _scrollView = FindViewById<ScrollView> (Resource.Id.scrollview);

            _imageView = FindViewById<ImageView> (Resource.Id.groupavatar_image_view);
            _imageView.Click += (sender, e) =>
            {
                var myIntent = new Intent();
                myIntent.SetType("image/*");
                myIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(Intent.CreateChooser(myIntent, "Select Picture"), PickImageId);
            };
            CardView addCardView = FindViewById<CardView>(Resource.Id.add_card_view);
            addCardView.Click += (sender, e) =>
            {
                List<string> pStringList = new List<string>();
                foreach(var item in _participantsAdapter.Items)
                {
                    pStringList.Add(string.Join(",", item.Name, item.ImageId.ToString()));
                }

                var myIntent = new Intent(this, typeof(AddParticipantscherm));
                string intentString = "New Group|" + string.Join("|", pStringList);
                myIntent.PutExtra("Current participants", intentString);
                StartActivityForResult(myIntent, PickContactsId);
            };
            Button confimButton = FindViewById<Button> (Resource.Id.buttonConfirm);
            confimButton.Click += (sender, e) =>
            {
                if (titleEditText.Text.Length != 0)
                {
                    string groupName = titleEditText.Text.Replace(" ", "%20");

                    bool isCreated = DatabaseInterface.CreateGroup(_persoon.Id, groupName, _persoon.Id, _persoon.Password);
                    foreach (var item in _participantsAdapter.Items)
                    {
                        bool isAdded = DatabaseInterface.AddToGroup(item.Name, groupName, _persoon.Id, _persoon.Password);
                    }
                    Finish();
                }
                else
                {
                    Toast.MakeText(this, "Make sure you give the group a title/name!", ToastLength.Short).Show();
                }
            };

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "Add Group";
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);

            CreateParticipantsEnvironment();
        }
Beispiel #18
0
 public Dictionary<string, double> KrijgSchuldGroep(Groep gr)
 {
     Dictionary<string, double> SchuldGroep = new Dictionary<string, double>();
     foreach (string deelnemer in gr.Deelnemers)
     {
         double value = 0;
         foreach (var schuld in DebtBij)
             if (schuld.Collector == deelnemer)
             {
                 SchuldGroep.TryGetValue (schuld.Collector, out value);
                 SchuldGroep.Remove (schuld.Collector);
                 SchuldGroep.Add (schuld.Collector, value - schuld.Amount);
             }
         foreach (var schuld in DebtVan)
             if (schuld.Payer == deelnemer)
             {
                 SchuldGroep.TryGetValue (schuld.Payer, out value);
                 SchuldGroep.Remove (schuld.Payer);
                 SchuldGroep.Add (schuld.Payer, value + schuld.Amount);
             }
         //voor als iemand geen openstaande debt heeft
         if (!SchuldGroep.ContainsKey(deelnemer) && deelnemer != this.Id)
             SchuldGroep.Add(deelnemer, 0);
     }
     return SchuldGroep;
 }
Beispiel #19
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Groepscherm);

            _persoon = Gegevens.GetPerson();
            _groep = Gegevens.CurrentGroup();

            _toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);

            TextView title = _toolbar.FindViewById<TextView>(Resource.Id.Title);
            title.Text = _groep.groepsnaam;

            SetSupportActionBar(_toolbar);
            SupportActionBar.Title = "";
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);

            _participantsRecyclerView = FindViewById<RecyclerView>(Resource.Id.participantsrecyclerview);
            _participantsRecyclerView.SetLayoutManager(new LinearLayoutManager(this));
            _participantsRecyclerView.SetScrollContainer(false);
            _participantsRecyclerView.NestedScrollingEnabled = false;

            _swipeRefreshLayout = FindViewById<SwipeRefreshLayout>(Resource.Id.swipe_refresh);
            _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.mainColor);
            _swipeRefreshLayout.SetOnRefreshListener(this);

            CardView historyCardView = FindViewById<CardView>(Resource.Id.history_card_view);
            Button cameraButton = FindViewById<Button>(Resource.Id.buttonCamera);
            Button textButton = FindViewById<Button>(Resource.Id.buttonText);
            Button leaveButton = FindViewById<Button>(Resource.Id.buttonLeave);

            leaveButton.Click += (sender, e) =>
            {
                DatabaseInterface.RemoveFromGroup(_persoon.Id, _groep.groepsnaam, _persoon.Id, _persoon.Password);
                Finish();
            };
            historyCardView.Click += (sender, e) =>
            {
                var activity = new Intent(this, typeof(Historyscherm));
                StartActivity(activity);
            };
            cameraButton.Click += (sender, e) =>
            {
                var activity = new Intent(this, typeof(CameraActivity));
                StartActivityForResult(activity, 1);
            };
            textButton.Click += (sender, e) =>
            {
                var activity = new Intent(this, typeof(Nieuwschuld));
                StartActivity(activity);
            };

            CreateParticipantsEnvironment();
        }
Beispiel #20
0
 public Dictionary<string, double> PaymentsVan(Groep gr)
 {
     Dictionary<string, double> Payvan = new Dictionary<string, double> ();
     double value = 0;
     foreach (string deelnemer in gr.Deelnemers) {
         foreach (Payment pay in PaymentVan) {
             if (pay.Payer == deelnemer) {
                 Payvan.TryGetValue (pay.Payer, out value);
                 Payvan.Remove (pay.Payer);
                 Payvan.Add (pay.Payer, value + pay.Amount);
             }
         }
     }
     return Payvan;
 }
Beispiel #21
0
        public void Refresh()
        {
            _persoon = Gegevens.GetServerData(_persoon.Id, _persoon.Password);
            _groep = Gegevens.CurrentGroup();

            CreateParticipantsEnvironment();
            RefreshHandler.PostDelayed(CancelAnimation, 700);
        }
Beispiel #22
0
        public bool Checkserver()
        {
            //Voor als een persoon per ongeluk niet in een groep zit
            //wordt er een groep gemaakt met alleen die persoon
            Groep nieuw;
            foreach (Debt debtvan in DebtVan)
                if (!CheckGroep (debtvan.Payer))
                {
                    nieuw = new Groep (debtvan.Payer, 1, debtvan.Payer);
                    Groepen.Add (nieuw);
                }
            foreach (Debt debtbij in DebtBij)
                if (!CheckGroep (debtbij.Collector))
                {
                    nieuw = new Groep (debtbij.Collector, 1, debtbij.Payer);
                    Groepen.Add (nieuw);
                }

            //returned false als schulden niet weggestreept zijn in de database
            foreach (var debtvan in DebtVan)
            {
                foreach (var debtbij in DebtBij)
                {
                    if (debtvan.Payer == debtbij.Payer && debtvan.Collector == debtbij.Collector)
                        return false;
                }
            }
            return true;
        }
Beispiel #23
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            _persoon = Gegevens.GetPerson();
            _groep = Gegevens.CurrentGroup();

            SetContentView(Resource.Layout.Payscherm);

            _toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            _totalDebt = _toolbar.FindViewById<TextView>(Resource.Id.Title);
            TotalDebt = _persoon.TotaalSchuldGroep(_groep);

            SetSupportActionBar(_toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.Title = "";

            _fragments = new PaySchermFragment[]
            {
                new InboxFragment(),
                new OutboxFragment(),
            };
            var titles = CharSequence.ArrayFromStringArray(new[]
            {
                "Inbox",
                "Outbox"
            });

            _viewPager = FindViewById<ViewPager>(Resource.Id.viewpager);
            _viewPager.Adapter = new TabsFragmentPagerAdapter(SupportFragmentManager, _fragments, titles);
            _viewPager.SetCurrentItem(0, true);

            _tabLayout = FindViewById<TabLayout>(Resource.Id.sliding_tabs);
            _tabLayout.SetupWithViewPager(_viewPager);

            _tabLayout.SetOnTabSelectedListener(this);

            Button newPaymentButton = FindViewById<Button>(Resource.Id.buttonNewPayment);
            newPaymentButton.Click += (sender, e) =>
            {
                var activity = new Intent(this, typeof(Betaalscherm));
                StartActivity(activity);
            };
        }