protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.SetContentView(Resource.Layout.activity_main);

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

            this.SetSupportActionBar(toolbar);
            this.SupportActionBar.SetDisplayHomeAsUpEnabled(false);

            List <IDrawerItem> items = new List <IDrawerItem>(Iconics.RegisteredFonts.Count);

            foreach (var font in Iconics.RegisteredFonts)
            {
                var item = new PrimaryDrawerItem();

                item.WithName(font.FontName);
                items.Add(item);
            }

            new DrawerBuilder().WithActivity(this)
            .WithToolbar(toolbar)
            .WithDrawerItems(items)
            .WithOnDrawerItemClickListener(new DrawerListener(this))
            .WithFireOnInitialOnClick(true)
            .WithSelectedItem(1)
            .Build();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
              this.SetContentView(Resource.Layout.activity_main);

              Toolbar toolbar = this.FindViewById<Toolbar>(Resource.Id.toolbar);
              this.SetSupportActionBar(toolbar);
              this.SupportActionBar.SetDisplayHomeAsUpEnabled(false);

              List<IDrawerItem> items = new List<IDrawerItem>(Iconics.RegisteredFonts.Count);

              foreach (var font in Iconics.RegisteredFonts)
              {
            var item = new PrimaryDrawerItem();

            item.WithName(font.FontName);
            items.Add(item);
              }

              new DrawerBuilder().WithActivity(this)
              .WithToolbar(toolbar)
              .WithDrawerItems(items)
              .WithOnDrawerItemClickListener(new DrawerListener(this))
              .WithFireOnInitialOnClick(true)
              .WithSelectedItem(1)
              .Build();
        }
Exemplo n.º 3
0
        private void InicializarItemsLoginRegisto()
        {
            itemLogin = new PrimaryDrawerItem();
            itemLogin.WithName("Login");
            itemLogin.WithIcon(GoogleMaterial.Icon.GmdPerson);
            itemLogin.WithIdentifier(1);
            itemLogin.WithSelectable(true);

            itemRegCliente = new PrimaryDrawerItem();
            itemRegCliente.WithName("Registar Cliente");
            itemRegCliente.WithIcon(GoogleMaterial.Icon.GmdPersonAdd);
            itemRegCliente.WithIdentifier(2);
            itemRegCliente.WithTag("RegCliente");
            itemRegCliente.WithSelectable(true);

            itemRegProprietario = new PrimaryDrawerItem();
            itemRegProprietario.WithName("Registar Proprietário");
            itemRegProprietario.WithIcon(GoogleMaterial.Icon.GmdPersonAdd);
            itemRegProprietario.WithIdentifier(2);
            itemRegProprietario.WithTag("RegProprietário");
            itemRegProprietario.WithSelectable(true);
            drawerBuilder.AddDrawerItems(
                itemLogin,
                itemRegCliente,
                itemRegProprietario,
                new DividerDrawerItem(),
                itemTendencias,
                itemDefinicoes,
                itemSobre,
                new DividerDrawerItem()
                );
        }
Exemplo n.º 4
0
 private void InicializarItemsUtilizador()
 {
     itemTendencias = new PrimaryDrawerItem();
     itemTendencias.WithName("Tendências");
     //itemTendencias.WithIcon(GoogleMaterial.Icon.GmdPersonAdd);
     itemTendencias.WithIdentifier(8);
     itemTendencias.WithSelectable(true);
 }
Exemplo n.º 5
0
 private PrimaryDrawerItem GetBasePrimaryItem()
 {
     var btn = new PrimaryDrawerItem();
     btn.WithIconTintingEnabled(true);
     btn.WithTextColorRes(Resource.Color.BrushText);
     btn.WithIconColorRes(Resource.Color.BrushNoSearchResults);
     btn.WithSelectedColorRes(Resource.Color.BrushAnimeItemBackground);
     btn.WithSelectedTextColorRes(Resource.Color.AccentColour);
     btn.WithSelectedIconColorRes(Resource.Color.AccentColourDark);
     return btn;
 }
Exemplo n.º 6
0
        public static PrimaryDrawerItem GetBasePrimaryItem()
        {
            var btn = new PrimaryDrawerItem();

            btn.WithIconTintingEnabled(true);
            btn.WithTextColorRes(ResourceExtension.BrushTextRes);
            btn.WithIconColorRes(ResourceExtension.BrushTextRes);
            btn.WithSelectedColorRes(ResourceExtension.BrushAnimeItemBackgroundRes);
            btn.WithSelectedTextColorRes(Resource.Color.AccentColour);
            btn.WithSelectedIconColorRes(Resource.Color.AccentColourDark);
            return(btn);
        }
Exemplo n.º 7
0
        public static PrimaryDrawerItem GetBasePrimaryItem(Action <View> moreButtonAction = null)
        {
            var btn = new PrimaryDrawerItem();

            btn.WithIconTintingEnabled(true);
            btn.WithTextColorRes(ResourceExtension.BrushTextRes);
            btn.WithIconColorRes(ResourceExtension.BrushTextRes);
            btn.WithSelectedColorRes(ResourceExtension.BrushAnimeItemBackgroundRes);
            btn.WithSelectedTextColorRes(ResourceExtension.AccentColourRes);
            btn.WithSelectedIconColorRes(ResourceExtension.AccentColourDarkRes);
            if (moreButtonAction != null)
            {
                btn.WithPostOnBindViewListener(new BindListener(moreButtonAction));
                btn.WithTag(true);
            }
            else
            {
                btn.WithPostOnBindViewListener(new CleanerListener());
            }
            return(btn);
        }
Exemplo n.º 8
0
        private void InicializarItemsCliente()
        {
            itemPrefs = new PrimaryDrawerItem();
            itemPrefs.WithName("Preferências");
            //itemPrefs.WithIcon(GoogleMaterial.Icon.GmdPersonAdd);
            itemPrefs.WithIdentifier(3);
            itemPrefs.WithSelectable(true);

            itemNaoPrefs = new PrimaryDrawerItem();
            itemNaoPrefs.WithName("Não Preferências");
            //itemNaoPrefs.WithIcon(GoogleMaterial.Icon.GmdPersonAdd);
            itemNaoPrefs.WithIdentifier(4);
            itemNaoPrefs.WithSelectable(true);

            itemTerminarSessao = new PrimaryDrawerItem();
            itemTerminarSessao.WithName("Terminar sessão");
            itemTerminarSessao.WithIcon(GoogleMaterial.Icon.GmdExitToApp);
            itemTerminarSessao.WithIdentifier(5);
            itemTerminarSessao.WithSelectable(true);

            itemHistorico = new PrimaryDrawerItem();
            itemHistorico.WithName("Histórico");
            //itemTerminarSessao.WithIcon(GoogleMaterial.Icon.GmdExitToApp);
            itemHistorico.WithIdentifier(9);
            itemHistorico.WithSelectable(true);

            drawerBuilder.AddDrawerItems(
                itemPrefs,
                itemNaoPrefs,
                itemTendencias,
                itemHistorico,
                itemTerminarSessao,
                new DividerDrawerItem(),
                itemDefinicoes,
                itemSobre,
                new DividerDrawerItem()
                );
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            receiver = new NetworkBroadcastReceiver(this);
            receiver.SetListener(this);
            intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
            RegisterReceiver(receiver, intentFilter);

            tvNetworkNotification = (TextView)FindViewById(Resource.Id.network_notification);
            ConnectivityManager cm = (ConnectivityManager)this.GetSystemService(Context.ConnectivityService);

            if (cm.ActiveNetworkInfo == null)
            {
                var ad = new Android.Support.V7.App.AlertDialog.Builder(this);
                ad.SetTitle("No Connection");
                ad.SetMessage("Looks like there's a problem with your network connection. Try again later.");
                ad.SetCancelable(false);
                ad.SetPositiveButton("OK", this);
                Android.Support.V7.App.AlertDialog dialog = ad.Create();
                dialog.Show();
            }
            else
            {
                MapFragment mapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.googlemap);
                mapFragment.GetMapAsync(this);

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

                // Deserialize the member object
                ISharedPreferences pref = GetSharedPreferences(GetString(Resource.String.PreferenceFileName), FileCreationMode.Private);
                var member = pref.GetString(GetString(Resource.String.PreferenceSavedMember), "");
                user = JsonConvert.DeserializeObject <Member>(member);

                var profile = new ProfileDrawerItem();
                profile.WithName(user.username);
                profile.WithIdentifier(100);

                headerResult = new AccountHeaderBuilder()
                               .WithActivity(this)
                               .WithHeaderBackground(Resource.Drawable.profilebackground)
                               .WithSelectionListEnabledForSingleProfile(false)
                               .AddProfiles(profile)
                               .WithOnAccountHeaderListener(this)
                               .WithSavedInstance(bundle)
                               .Build();

                var header = new PrimaryDrawerItem();
                header.WithName(Resource.String.Drawer_Item_Trips);
                header.WithIcon(GoogleMaterial.Icon.GmdDirectionsCar);
                header.WithIdentifier(1);

                var logoutDrawer = new SecondaryDrawerItem();
                logoutDrawer.WithName(Resource.String.Drawer_Item_Logout);
                logoutDrawer.WithIcon(GoogleMaterial.Icon.GmdSettingsPower);
                logoutDrawer.WithIdentifier(4);

                //create the drawer and remember the `Drawer` result object
                Drawer result = new DrawerBuilder()
                                .WithActivity(this)
                                .WithToolbar(toolbar)
                                .WithAccountHeader(headerResult)
                                .AddDrawerItems(
                    header,
                    new DividerDrawerItem(),
                    logoutDrawer
                    )
                                .WithOnDrawerItemClickListener(this)
                                .Build();

                originAutocompleteFragment = (PlaceAutocompleteFragment)
                                             FragmentManager.FindFragmentById(Resource.Id.place_autocomplete_origin_fragment);
                originAutocompleteFragment.SetHint("Enter the origin");
                originAutocompleteFragment.PlaceSelected += OnOriginSelected;

                destAutocompleteFragment = (PlaceAutocompleteFragment)
                                           FragmentManager.FindFragmentById(Resource.Id.place_autocomplete_destination_fragment);
                destAutocompleteFragment.SetHint("Enter the destination");
                destAutocompleteFragment.PlaceSelected += OnDestinationSelected;

                progress = new ProgressDialog(this);
                progress.Indeterminate = true;
                progress.SetProgressStyle(ProgressDialogStyle.Spinner);
                progress.SetMessage("Getting location...");
                progress.SetCancelable(false);
                RunOnUiThread(() =>
                {
                    progress.Show();
                });

                // Request Update request
                locationManager = (LocationManager)GetSystemService(Context.LocationService);
                IList <string> providers    = locationManager.AllProviders;
                Criteria       criteria     = new Criteria();
                string         bestProvider = locationManager.GetBestProvider(criteria, true);
                locationManager.RequestLocationUpdates(bestProvider, MIN_TIME, MIN_DISTANCE, this);
            }
        }
Exemplo n.º 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

              var toolbar = this.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
              this.SetSupportActionBar(toolbar);

              // Create a few sample profile
              // NOTE you have to define the loader logic too. See the CustomApplication for more details

              var profile = new ProfileDrawerItem().WithName("Mike Penz").WithEmail("*****@*****.**").WithIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460");
              var profile2 = new ProfileDrawerItem().WithName("Bernat Borras").WithEmail("*****@*****.**").WithIcon(Uri.Parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460"));
              var profile3 = new ProfileDrawerItem().WithName("Max Muster").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile2));
              var profile4 = new ProfileDrawerItem().WithName("Felix House").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile3));
              var profile5 = new ProfileDrawerItem().WithName("Mr. X").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile4)).WithIdentifier(4);
              var profile6 = new ProfileDrawerItem().WithName("Batman").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile5));

              headerResult = new AccountHeaderBuilder()
            .WithActivity(this)
            .WithHeaderBackground(Resource.Drawable.header)
            .AddProfiles(
              profile,
              profile2,
              profile3,
              profile4,
              profile5,
              profile6,
              //don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account)
              new ProfileSettingDrawerItem().WithName("Add Account").WithDescription("Add new GitHub Account").WithIcon(new IconicsDrawable(this, GoogleMaterial.Icon.GmdAdd)
            .PaddingDp(5).ColorRes(Resource.Color.material_drawer_primary_text)).WithIdentifier(PROFILE_SETTING),
              new ProfileSettingDrawerItem().WithName("Manage Account").WithIcon(GoogleMaterial.Icon.GmdSettings)
            )
            .WithOnAccountHeaderListener(this)
            .WithSavedInstance(savedInstanceState)
            .Build();

              var item1 = new PrimaryDrawerItem();
              item1.WithName(Resource.String.drawer_item_compact_header);
              item1.WithIcon(GoogleMaterial.Icon.GmdWbSunny);
              item1.WithIdentifier(1);
              item1.WithCheckable(false);

              var item2 = new PrimaryDrawerItem();
              item2.WithName(Resource.String.drawer_item_action_bar);
              item2.WithIcon(FontAwesome.Icon.FawHome);
              item2.WithIdentifier(2);
              item2.WithCheckable(false);

              var item3 = new PrimaryDrawerItem();
              item3.WithName(Resource.String.drawer_item_multi_drawer);
              item3.WithIcon(FontAwesome.Icon.FawGamepad);
              item3.WithIdentifier(3);
              item3.WithCheckable(false);

              var item4 = new PrimaryDrawerItem();
              item4.WithName(Resource.String.drawer_item_non_translucent_status_drawer);
              item4.WithIcon(FontAwesome.Icon.FawEye);
              item4.WithIdentifier(4);
              item4.WithCheckable(false);

              var item5 = new PrimaryDrawerItem();
              item5.WithDescription("A more complex sample");
              item5.WithName(Resource.String.drawer_item_complex_header_drawer);
              item5.WithIcon(GoogleMaterial.Icon.GmdAdb);
              item5.WithIdentifier(5);
              item5.WithCheckable(false);

              var item6 = new PrimaryDrawerItem();
              item6.WithName(Resource.String.drawer_item_simple_fragment_drawer);
              item6.WithIcon(GoogleMaterial.Icon.GmdStyle);
              item6.WithIdentifier(6);
              item6.WithCheckable(false);

              var item7 = new PrimaryDrawerItem();
              item7.WithName(Resource.String.drawer_item_embedded_drawer_dualpane);
              item7.WithIcon(GoogleMaterial.Icon.GmdBatteryChargingFull);
              item7.WithIdentifier(7);
              item7.WithCheckable(false);

              var item8 = new PrimaryDrawerItem();
              item8.WithName(Resource.String.drawer_item_fullscreen_drawer);
              item8.WithIcon(GoogleMaterial.Icon.GmdStyle);
              item8.WithIdentifier(8);
              item8.WithCheckable(false);

              var item9 = new PrimaryDrawerItem();
              item9.WithName(Resource.String.drawer_item_custom_container_drawer);
              item9.WithIcon(GoogleMaterial.Icon.GmdMyLocation);
              item9.WithIdentifier(9);
              item9.WithCheckable(false);

              var item10 = new SecondaryDrawerItem();
              item10.WithName(Resource.String.drawer_item_open_source);
              item10.WithIcon(FontAwesome.Icon.FawGithub);
              item10.WithIdentifier(20);
              item10.WithCheckable(false);

              var item11 = new SecondaryDrawerItem();
              item11.WithName(Resource.String.drawer_item_contact);
              item11.WithIcon(GoogleMaterial.Icon.GmdFormatColorFill);
              item11.WithIdentifier(10);
              item11.WithTag("Bullhorn");

              var item12 = new SwitchDrawerItem();
              item12.WithName("Switch");
              item12.WithIcon(Octicons.Icon.OctTools);
              item12.WithChecked(true);
              item12.WithOnCheckedChangeListener(this);

              var item13 = new SwitchDrawerItem();
              item13.WithName("Switch2");
              item13.WithIcon(Octicons.Icon.OctTools);
              item13.WithChecked(true);
              item13.WithOnCheckedChangeListener(this);

              var item14 = new ToggleDrawerItem();
              item14.WithName("Toggle");
              item14.WithIcon(Octicons.Icon.OctTools);
              item14.WithChecked(true);
              item14.WithOnCheckedChangeListener(this);

              result = new DrawerBuilder()
            .WithActivity(this)
            .WithToolbar(toolbar)
            .WithAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
            .AddDrawerItems(
              item1,
              item2,
              item3,
              item4,
              item5,
              item6,
              item7,
              item8,
              item9,
              new SectionDrawerItem().WithName(Resource.String.drawer_item_section_header),
              item10,
              item11,
              new DividerDrawerItem(),
              item12,
              item13,
              item14
            ) // add the items we want to use With our Drawer
            .WithOnDrawerItemClickListener(this)
            .WithSavedInstance(savedInstanceState)
            .WithShowDrawerOnFirstLaunch(true)
            .Build();

              if (savedInstanceState == null) {
            // set the selection to the item with the identifier 10
            result.SetSelectionByIdentifier(10, false);

            //set the active profile
            headerResult.SetActiveProfile(profile3);
              }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_sample_dark_toolbar);

            var toolbar = this.FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            this.SetSupportActionBar(toolbar);

            // Create a few sample profile
            // NOTE you have to define the loader logic too. See the CustomApplication for more details

            var profile = new ProfileDrawerItem();

            profile.WithName("Mike Penz");
            profile.WithEmail("*****@*****.**");
            profile.WithIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460");
            profile.WithIdentifier(100);

            var profile2 = new ProfileDrawerItem();

            profile2.WithName("Bernat Borras");
            profile2.WithEmail("*****@*****.**");
            profile2.WithIcon(Uri.Parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460"));
            profile2.WithIdentifier(101);

            var profile3 = new ProfileDrawerItem();

            profile3.WithName("Max Muster");
            profile3.WithEmail("*****@*****.**");
            profile3.WithIcon(Resource.Drawable.profile2);
            profile3.WithIdentifier(102);

            var profile4 = new ProfileDrawerItem();

            profile4.WithName("Felix House");
            profile4.WithEmail("*****@*****.**");
            profile4.WithIcon(Resource.Drawable.profile3);
            profile4.WithIdentifier(103);

            var profile5 = new ProfileDrawerItem();

            profile5.WithName("Mr. X");
            profile5.WithEmail("*****@*****.**");
            profile5.WithIcon(Resource.Drawable.profile4);
            profile5.WithIdentifier(104);

            var profile6 = new ProfileDrawerItem();

            profile6.WithName("Batman");
            profile6.WithEmail("*****@*****.**");
            profile6.WithIcon(Resource.Drawable.profile5);
            profile6.WithIdentifier(105);

            var profileSettingItem = new ProfileSettingDrawerItem();

            profileSettingItem.WithName("Add Account");
            profileSettingItem.WithDescription("Add new GitHub Account");
            profileSettingItem.WithIcon(new IconicsDrawable(this, GoogleMaterial.Icon.GmdPlusOne).ActionBar().PaddingDp(5).ColorRes(Resource.Color.material_drawer_primary_text));
            profileSettingItem.WithIdentifier(PROFILE_SETTING);

            headerResult = new AccountHeaderBuilder()
                           .WithActivity(this)
                           .WithHeaderBackground(Resource.Drawable.header)
                           .AddProfiles(
                profile,
                profile2,
                profile3,
                profile4,
                profile5,
                profile6,
                //don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account)
                profileSettingItem,
                new ProfileSettingDrawerItem()
                .WithName("Manage Account")
                .WithIcon(GoogleMaterial.Icon.GmdSettings)
                )
                           .WithOnAccountHeaderListener(this)
                           .WithSavedInstance(savedInstanceState)
                           .Build();

            var item1 = new PrimaryDrawerItem();

            item1.WithName(Resource.String.drawer_item_compact_header);
            item1.WithIcon(GoogleMaterial.Icon.GmdWbSunny);
            item1.WithIdentifier(1);
            item1.WithSelectable(false);
//
            var item2 = new PrimaryDrawerItem();

            item2.WithName(Resource.String.drawer_item_action_bar_drawer);
            item2.WithIcon(FontAwesome.Icon.FawHome);
            item2.WithIdentifier(2);
            item2.WithSelectable(false);
//
            var item10 = new SecondaryDrawerItem();

            item10.WithName(Resource.String.drawer_item_open_source);
            item10.WithIcon(FontAwesome.Icon.FawGithub);
            item10.WithIdentifier(20);
            item10.WithSelectable(false);
//
            var item11 = new SecondaryDrawerItem();

            item11.WithName(Resource.String.drawer_item_contact);
            item11.WithIcon(GoogleMaterial.Icon.GmdFormatColorFill);
            item11.WithIdentifier(10);
            item11.WithTag("Bullhorn");

//
            result = new DrawerBuilder()
                     .WithActivity(this)
                     .WithToolbar(toolbar)
                     .WithAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
                     .AddDrawerItems(
                item1,
                item2,
                new SectionDrawerItem().WithName(Resource.String.drawer_item_section_header),
                item10,
                item11,
                new DividerDrawerItem()
                ) // add the items we want to use With our Drawer
                     .WithOnDrawerItemClickListener(this)
                     .WithSavedInstance(savedInstanceState)
                     .WithShowDrawerOnFirstLaunch(true)
                     .Build();

            //if you have many different types of DrawerItems you can magically pre-cache those items to get a better scroll performance
            //make sure to init the cache after the DrawerBuilder was created as this will first clear the cache to make sure no old elements are in
            RecyclerViewCacheUtil.Instance.WithCacheSize(2).Init(result);

            //only set the active selection or active profile if we do not recreate the activity
            if (savedInstanceState == null)
            {
                // set the selection to the item with the identifier 11
                result.SetSelection(21, false);

                //set the active profile
                headerResult.SetActiveProfile(profile3, false);
            }

            result.UpdateBadge(4, new StringHolder(10 + ""));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            var toolbar = this.FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            this.SetSupportActionBar(toolbar);

            // Create a few sample profile
            // NOTE you have to define the loader logic too. See the CustomApplication for more details

            var profile  = new ProfileDrawerItem().WithName("Mike Penz").WithEmail("*****@*****.**").WithIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460");
            var profile2 = new ProfileDrawerItem().WithName("Bernat Borras").WithEmail("*****@*****.**").WithIcon(Uri.Parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460"));
            var profile3 = new ProfileDrawerItem().WithName("Max Muster").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile2));
            var profile4 = new ProfileDrawerItem().WithName("Felix House").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile3));
            var profile5 = new ProfileDrawerItem().WithName("Mr. X").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile4)).WithIdentifier(4);
            var profile6 = new ProfileDrawerItem().WithName("Batman").WithEmail("*****@*****.**").WithIcon(Resources.GetDrawable(Resource.Drawable.profile5));

            headerResult = new AccountHeaderBuilder()
                           .WithActivity(this)
                           .WithHeaderBackground(Resource.Drawable.header)
                           .AddProfiles(
                profile,
                profile2,
                profile3,
                profile4,
                profile5,
                profile6,
                //don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account)
                new ProfileSettingDrawerItem().WithName("Add Account").WithDescription("Add new GitHub Account").WithIcon(new IconicsDrawable(this, GoogleMaterial.Icon.GmdAdd)
                                                                                                                          .PaddingDp(5).ColorRes(Resource.Color.material_drawer_primary_text)).WithIdentifier(PROFILE_SETTING),
                new ProfileSettingDrawerItem().WithName("Manage Account").WithIcon(GoogleMaterial.Icon.GmdSettings)
                )
                           .WithOnAccountHeaderListener(this)
                           .WithSavedInstance(savedInstanceState)
                           .Build();


            var item1 = new PrimaryDrawerItem();

            item1.WithName(Resource.String.drawer_item_compact_header);
            item1.WithIcon(GoogleMaterial.Icon.GmdWbSunny);
            item1.WithIdentifier(1);
            item1.WithCheckable(false);

            var item2 = new PrimaryDrawerItem();

            item2.WithName(Resource.String.drawer_item_action_bar);
            item2.WithIcon(FontAwesome.Icon.FawHome);
            item2.WithIdentifier(2);
            item2.WithCheckable(false);

            var item3 = new PrimaryDrawerItem();

            item3.WithName(Resource.String.drawer_item_multi_drawer);
            item3.WithIcon(FontAwesome.Icon.FawGamepad);
            item3.WithIdentifier(3);
            item3.WithCheckable(false);

            var item4 = new PrimaryDrawerItem();

            item4.WithName(Resource.String.drawer_item_non_translucent_status_drawer);
            item4.WithIcon(FontAwesome.Icon.FawEye);
            item4.WithIdentifier(4);
            item4.WithCheckable(false);

            var item5 = new PrimaryDrawerItem();

            item5.WithDescription("A more complex sample");
            item5.WithName(Resource.String.drawer_item_complex_header_drawer);
            item5.WithIcon(GoogleMaterial.Icon.GmdAdb);
            item5.WithIdentifier(5);
            item5.WithCheckable(false);

            var item6 = new PrimaryDrawerItem();

            item6.WithName(Resource.String.drawer_item_simple_fragment_drawer);
            item6.WithIcon(GoogleMaterial.Icon.GmdStyle);
            item6.WithIdentifier(6);
            item6.WithCheckable(false);

            var item7 = new PrimaryDrawerItem();

            item7.WithName(Resource.String.drawer_item_embedded_drawer_dualpane);
            item7.WithIcon(GoogleMaterial.Icon.GmdBatteryChargingFull);
            item7.WithIdentifier(7);
            item7.WithCheckable(false);

            var item8 = new PrimaryDrawerItem();

            item8.WithName(Resource.String.drawer_item_fullscreen_drawer);
            item8.WithIcon(GoogleMaterial.Icon.GmdStyle);
            item8.WithIdentifier(8);
            item8.WithCheckable(false);

            var item9 = new PrimaryDrawerItem();

            item9.WithName(Resource.String.drawer_item_custom_container_drawer);
            item9.WithIcon(GoogleMaterial.Icon.GmdMyLocation);
            item9.WithIdentifier(9);
            item9.WithCheckable(false);


            var item10 = new SecondaryDrawerItem();

            item10.WithName(Resource.String.drawer_item_open_source);
            item10.WithIcon(FontAwesome.Icon.FawGithub);
            item10.WithIdentifier(20);
            item10.WithCheckable(false);

            var item11 = new SecondaryDrawerItem();

            item11.WithName(Resource.String.drawer_item_contact);
            item11.WithIcon(GoogleMaterial.Icon.GmdFormatColorFill);
            item11.WithIdentifier(10);
            item11.WithTag("Bullhorn");

            var item12 = new SwitchDrawerItem();

            item12.WithName("Switch");
            item12.WithIcon(Octicons.Icon.OctTools);
            item12.WithChecked(true);
            item12.WithOnCheckedChangeListener(this);

            var item13 = new SwitchDrawerItem();

            item13.WithName("Switch2");
            item13.WithIcon(Octicons.Icon.OctTools);
            item13.WithChecked(true);
            item13.WithOnCheckedChangeListener(this);

            var item14 = new ToggleDrawerItem();

            item14.WithName("Toggle");
            item14.WithIcon(Octicons.Icon.OctTools);
            item14.WithChecked(true);
            item14.WithOnCheckedChangeListener(this);

            result = new DrawerBuilder()
                     .WithActivity(this)
                     .WithToolbar(toolbar)
                     .WithAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
                     .AddDrawerItems(
                item1,
                item2,
                item3,
                item4,
                item5,
                item6,
                item7,
                item8,
                item9,
                new SectionDrawerItem().WithName(Resource.String.drawer_item_section_header),
                item10,
                item11,
                new DividerDrawerItem(),
                item12,
                item13,
                item14
                ) // add the items we want to use With our Drawer
                     .WithOnDrawerItemClickListener(this)
                     .WithSavedInstance(savedInstanceState)
                     .WithShowDrawerOnFirstLaunch(true)
                     .Build();

            if (savedInstanceState == null)
            {
                // set the selection to the item with the identifier 10
                result.SetSelectionByIdentifier(10, false);

                //set the active profile
                headerResult.SetActiveProfile(profile3);
            }
        }
Exemplo n.º 13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            _controller = ConnectionManager.Current.CurrentController;
            SetContentView(Resource.Layout.MainDrawerLayout);

            this.Window.SetTitle(string.Format("{0} - {1}", _controller.Client.UserName, _controller.Client.IpAddress));

            _fragments = new List <Fragment> {
                new HomeFragment(),
                new FunFragment(),
                new TaskManagerFragment(),
                new PasswordFragment(),
                new DownloadAndExecuteFragment(),
                new ConsoleFragment(),
                new RemoteDesktopFragment()
            };

            toolbar = this.FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            var headerResult = new AccountHeaderBuilder()
                               .WithActivity(this)
                               .WithHeaderBackground(Resource.Drawable.header)
                               .Build();

            var homeItem = new PrimaryDrawerItem();

            homeItem.WithName("Home");
            homeItem.WithIdentifier(0);
            homeItem.WithIcon(FontAwesome.Icon.FawHome);
            homeItem.WithTag("Home");

            var funItem = new PrimaryDrawerItem();

            funItem.WithName("Fun");
            funItem.WithIdentifier(1);
            funItem.WithIcon(FontAwesome.Icon.FawMagic);
            funItem.WithTag("Fun");

            var taskManagerItem = new PrimaryDrawerItem();

            taskManagerItem.WithName("Task manager");
            taskManagerItem.WithIdentifier(2);
            taskManagerItem.WithIcon(FontAwesome.Icon.FawCogs);
            taskManagerItem.WithTag("Task manager");

            var passwordsItem = new PrimaryDrawerItem();

            passwordsItem.WithName("Passwords");
            passwordsItem.WithIdentifier(3);
            passwordsItem.WithIcon(FontAwesome.Icon.FawKey);
            passwordsItem.WithTag("Passwords");

            var downloadExecuteItem = new PrimaryDrawerItem();

            downloadExecuteItem.WithName("Download & Execute");
            downloadExecuteItem.WithIdentifier(4);
            downloadExecuteItem.WithIcon(FontAwesome.Icon.FawDownload);
            downloadExecuteItem.WithTag("Download & Execute");

            var consoleItem = new PrimaryDrawerItem();

            consoleItem.WithName("Console");
            consoleItem.WithIdentifier(5);
            consoleItem.WithIcon(FontAwesome.Icon.FawTerminal);
            consoleItem.WithTag("Console");

            var remoteDesktopItem = new PrimaryDrawerItem();

            remoteDesktopItem.WithName("Remote Desktop");
            remoteDesktopItem.WithIdentifier(6);
            remoteDesktopItem.WithIcon(FontAwesome.Icon.FawDesktop);
            remoteDesktopItem.WithTag("Remote Desktop");

            result = new DrawerBuilder()
                     .WithActivity(this)
                     .WithToolbar(toolbar)
                     .WithAccountHeader(headerResult)
                     .AddDrawerItems(
                homeItem,
                new DividerDrawerItem(),
                funItem,
                taskManagerItem,
                passwordsItem,
                downloadExecuteItem,
                consoleItem,
                new DividerDrawerItem(),
                remoteDesktopItem
                )                 // add the items we want to use With our Drawer
                     .WithOnDrawerItemClickListener(this)
                     .WithSavedInstance(savedInstanceState)
                     .WithShowDrawerOnFirstLaunch(true)
                     .Build();

            RecyclerViewCacheUtil.Instance.WithCacheSize(2).Init(result);

            if (savedInstanceState == null)
            {
                // set the selection to the item with the identifier 1
                result.SetSelection(0, true);
            }
            else
            {
                result.SetSelection(result.CurrentSelection, true);
            }

            ConnectionManager.Current.ClientDisconnected += ConnectionManager_Current_ClientDisconnected;
            ConnectionManager.Current.Disconnected       += ConnectionManager_Current_Disconnected;
            toolbar.MenuItemClick += Toolbar_MenuItemClick;

            Window.SetSoftInputMode(SoftInput.AdjustPan);
        }