예제 #1
0
        private void CheckServerNotifications(Context pContext, string sClan, string sName)
        {
            XElement pResponse = null;
            //try
            //{
            string sPrevClan = Master.GetActiveClan();
            string sPrevUser = Master.GetActiveUserName();

            Master.SetActiveClan(sClan);
            Master.SetActiveUserName(sName);
            string sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetServerURL() + "GetUnseenNotifications", Master.BuildCommonBody(), true);

            pResponse = Master.ReadResponse(sResponse);
            Master.SetActiveClan(sPrevClan);
            Master.SetActiveUserName(sPrevUser);
            //}
            //catch (Exception e) { return; }

            if (pResponse.Element("Data") != null && pResponse.Element("Data").Element("Notifications").Value != "")
            {
                List <XElement> pNotifications = pResponse.Element("Data").Element("Notifications").Elements("Notification").ToList();
                foreach (XElement pNotification in pNotifications)
                {
                    string sContent  = pNotification.Value;
                    string sGameID   = pNotification.Attribute("GameID").Value;
                    string sGameName = pNotification.Attribute("GameName").Value;

                    Notification.Builder pBuilder = new Notification.Builder(pContext);
                    pBuilder.SetContentTitle(sClan + " - " + sGameName);
                    pBuilder.SetContentText(sContent);
                    pBuilder.SetSmallIcon(Resource.Drawable.Icon);
                    pBuilder.SetVibrate(new long[] { 200, 50, 200, 50 });
                    pBuilder.SetVisibility(NotificationVisibility.Public);
                    pBuilder.SetPriority((int)NotificationPriority.Default);

                    Intent pIntent = null;
                    if (sGameID.Contains("Zendo"))
                    {
                        pIntent = new Intent(pContext, typeof(ZendoActivity));
                    }
                    pIntent.SetAction(sGameID);
                    pIntent.PutExtra("GameName", sGameName);

                    pBuilder.SetContentIntent(PendingIntent.GetActivity(pContext, 0, pIntent, 0));
                    pBuilder.SetStyle(new Notification.BigTextStyle().BigText(sContent));

                    Notification        pNotif   = pBuilder.Build();
                    NotificationManager pManager = (NotificationManager)pContext.GetSystemService(Context.NotificationService);
                    pManager.Notify((int)Java.Lang.JavaSystem.CurrentTimeMillis(), pNotif);                     // using time to make different ID every time, so doesn't replace old notification
                    //pManager.Notify(DateTime.Now.Millisecond, pNotif); // using time to make different ID every time, so doesn't replace old notification
                }
            }
        }
예제 #2
0
        protected void CreateDrawer()
        {
            m_lNavTitles = new List <string>()
            {
                "Home", "Games", /*"Chats", "Profile",*/ "Notifications", "Clans", "Settings"
            };
            string sActive = Master.GetActiveClan();

            if (sActive != "")
            {
                m_lNavTitles[0] = sActive;
                //m_lNavTitles[2] = Master.GetActiveUserName() + "'s Profile";
            }

            m_pDrawerLayout       = FindViewById <DrawerLayout>(Resource.Id.appDrawerLayout);
            m_pDrawerList         = FindViewById <ListView>(Resource.Id.appDrawerList);
            m_pDrawerList.Adapter = new DrawerItemCustomAdapter(this, Resource.Layout.ListViewItemRow, m_lNavTitles.ToArray());

            m_pDrawerList.ItemClick += (object sender, Android.Widget.AdapterView.ItemClickEventArgs e) =>
            {
                int iChoice = e.Position;
                //string sChoice = m_lNavTitles[iChoice];
                Intent pIntent = null;
                switch (iChoice)
                {
                case 0:                         // home
                    pIntent = new Intent(this, typeof(MainActivity));
                    break;

                case 1:                         // games
                    pIntent = new Intent(this, typeof(GamesActivity));
                    break;

                case 2:                         // notifications
                    pIntent = new Intent(this, typeof(NotificationsActivity));
                    break;

                case 3:                         // groups
                    pIntent = new Intent(this, typeof(GroupListActivity));
                    break;

                case 4:                         // settings
                    pIntent = new Intent(this, typeof(SettingsActivity));
                    break;
                }
                if (pIntent == null)
                {
                    return;
                }
                this.Finish();
                StartActivity(pIntent);
            };
        }
예제 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            _hidden.InitializeWeb();

            _RunTempCommands();             // TODO: REMOVE

            if (!this.CheckVersion())
            {
                return;
            }

            // make sure that all the necessary files exist
            if (!File.Exists(Master.GetBaseDir() + "_clans.dat"))
            {
                File.Create(Master.GetBaseDir() + "_clans.dat").Dispose();
            }
            if (!File.Exists(Master.GetBaseDir() + "_settings.dat"))
            {
                File.WriteAllText(Master.GetBaseDir() + "_settings.dat", "notifications=on");
            }
            if (!File.Exists(Master.GetBaseDir() + "_key.dat"))
            {
                //Intent pIntent = new Intent(this, (new KeyActivity().Class));
                Intent pIntent = new Intent(this, typeof(RegisterOrLogInActivity));
                StartActivity(pIntent);
            }
            else
            {
                Master.FillKeyEmail();
            }

            // TODO: save temp currently active clan so persistent between app open times, and load it here
            if (File.Exists(Master.GetBaseDir() + "_active.dat"))
            {
                string[] aLines = File.ReadAllLines(Master.GetBaseDir() + "_active.dat");
                Master.SetActiveClan(aLines[0]);
                Master.SetActiveUserName(aLines[1]);
            }

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            base.CreateDrawer();

            if (Master.GetActiveClan() != "")
            {
                this.Title = Master.GetActiveClan() + " - " + Master.GetActiveUserName();
                this.BuildHomeDashboard();
            }

            //StartService(new Intent(this, typeof(NotificationsService)));
        }
예제 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Games);

            // Create your application here
            base.CreateDrawer();

            // get the games list
            if (Master.GetActiveClan() != "")
            {
                //string sResponse = WebCommunications.SendPostRequest("http://dwlapi.azurewebsites.net/api/reflection/GameClansServer/GameClansServer/ClanServer/ListActiveGames", Master.BuildCommonBody(), true);
                this.RefreshGameList();

                Button pNew = FindViewById <Button>(Resource.Id.btnNewGame);
                pNew.Click += delegate
                {
                    Intent pIntent = new Intent(this, typeof(NewGameActivity));
                    this.StartActivityForResult(pIntent, 0);
                };
            }
        }