示例#1
0
        private void SetupMenu()
        {
            _drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.hamburgerMenu_layout);
            _drawerList     = FindViewById <ListView>(Resource.Id.hamburgerMenu_menu);
            _drawerTitle    = FindViewById <ImageView>(Resource.Id.DrawerAppName);
            _drawerTopText  = FindViewById <TextView>(Resource.Id.DrawerTopText);
            _drawerButton   = FindViewById <Button>(Resource.Id.DrawerFooterButton);
            _drawerSubtitle = FindViewById <TextView>(Resource.Id.DrawerSubTitle);

            _drawerSubtitle.Visibility = _menuViewModel.ShowSubtitle ? ViewStates.Visible : ViewStates.Gone;

            _drawerButton.SetCommand("Click", _menuViewModel.PrimaryCommand);
            _drawerButton.Text = _menuViewModel.PrimaryButtonText;

            _drawerTitle.Visibility = _menuViewModel.ShowTitleLogo ? ViewStates.Visible : ViewStates.Invisible;
            _drawerTopText.Text     = _menuViewModel.Title;

            _drawerList.Adapter = new ObservableAdapter <IListItem>
            {
                DataSource          = _menuViewModel.ItemViewModels,
                GetTemplateDelegate = AdapterHelpers.SetupMenuCell
            };

            _drawerToggle = new ActionBarDrawerToggle(this, _drawerLayout, _toolbar, Resource.String.abc_action_bar_home_description, Resource.String.abc_toolbar_collapse_description);
            _drawerLayout.SetDrawerListener(_drawerToggle);
            _drawerLayout.DrawerClosed += RaiseOnDrawerClosed;
            _drawerToggle.SyncState();
        }
 protected override void OnPostCreate(Bundle savedInstanceState)
 {
     base.OnPostCreate(savedInstanceState);
     if (drawerToggle != null)
     {
         drawerToggle.SyncState();
     }
     SupportFragmentManager.AddOnBackStackChangedListener(this);
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            this.HideKeyboard();

            SetContentView(Resource.Layout.main_activity);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.myDrawer);


            mDrawerToggle = new Android.Support.V7.App.ActionBarDrawerToggle(this, mDrawerLayout, Resource.String.open_drawer, Resource.String.close_drawer);
            mDrawerToggle.DrawerIndicatorEnabled = true;

            mDrawerLayout.SetDrawerListener(mDrawerToggle);
            mDrawerToggle.SyncState();

            if (ChadderApp.UIHelper.Source.IsOnline == false)
            {
                ChadderApp.UIHelper.Source_OnNotAuthorized();
            }
            else
            {
                if (fragmentNavigater == null)
                {
                    fragmentNavigater = new ProfileFragment();
                    SupportFragmentManager.BeginTransaction().Replace(Resource.Id.navigation_drawer, fragmentNavigater).Commit();
                }
                if (this.Intent.GetBooleanExtra("new_user", false))
                {
                    SupportFragmentManager.BeginTransaction()
                    .Replace(Resource.Id.content_frame, new RegisterNameFragment())
                    .Commit();
                }
                else if (ChadderApp.UIHelper.Source.HasUserKey == false)
                {
                    var newFragment = new NewKeySplashScreenFragment();
                    SupportFragmentManager.BeginTransaction()
                    .Replace(Resource.Id.content_frame, newFragment)
                    .Commit();
                }
                else
                {
                    SupportFragmentManager.BeginTransaction()
                    .Replace(Resource.Id.content_frame, new ConversationListFragment())
                    .Commit();
                }
            }
        }
示例#4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.activity_main);
            var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            var drawer = FindViewById<Android.Support.V4.Widget.DrawerLayout>(Resource.Id.drawer_layout);
            var toggle = new Android.Support.V7.App.ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            toggle.SyncState();

            var navigationView = FindViewById<Android.Support.Design.Widget.NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(this);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.side_bar);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            _drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            var drawerToggle = new Android.Support.V7.App.ActionBarDrawerToggle(this, _drawerLayout, toolbar, Resource.String.SideBar_OpenMenu, Resource.String.SideBar_CloseMenu);

            _drawerLayout.AddDrawerListener(drawerToggle);
            drawerToggle.SyncState();

            SupportFragmentManager.BackStackChangedWeakSubscribe(SupportFragmentManager_BackStackChanged);
            ViewModel.CloseMenuInteraction.RequestedWeakSubscribe(CloseMenuInteraction_Requested);
        }
示例#6
0
        //IMenuItem menuSearch;
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            StringResource = this.MyApplication.CurrentLangSetting.GetStringResourceContents();
            toolbar        = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            drawer = FindViewById <Android.Support.V4.Widget.DrawerLayout>(Resource.Id.drawer_layout);
            Android.Support.V7.App.ActionBarDrawerToggle toggle = new Android.Support.V7.App.ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            drawer.AddDrawerListener(toggle);
            toggle.SyncState();
            leftNav = FindViewById <NavigationView>(Resource.Id.nav_view);
            leftNav.NavigationItemSelected += LeftNav_NavigationItemSelected;

            InitMenuTitle();
            tabLayout = FindViewById <TabLayout>(Resource.Id.tabContent);
            InitTabLayout();
            CURRENT_FRAGMENT = FRAGMENT_TYPE.FRAGMENT_EMPTY;
            SetFragment(FRAGMENT_TYPE.FRAGMENT_CHAT);
            SetMeOnline();
        }
        private void OpenMainview()
        {
            SetContentView(Resource.Layout.activity_main);
            Android.Support.V7.Widget.Toolbar toolbar =
                FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            Android.Support.V7.App.ActionBarDrawerToggle toggle =
                new Android.Support.V7.App.ActionBarDrawerToggle(
                    this, drawer, toolbar, Resource.String.navigation_drawer_open,
                    Resource.String.navigation_drawer_close);
            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);

            ChangeNavigationView(Resource.Id.nav_submit);
            Toast.MakeText(this, Resource.String.auth_success, ToastLength.Short).Show();
        }
示例#8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            // Action bar
            v7.Widget.Toolbar toolbar = (v7.Widget.Toolbar)FindViewById(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            // App drawer
            drawer = (DrawerLayout)FindViewById(Resource.Id.drawer_layout);
            v7.App.ActionBarDrawerToggle toggle = new v7.App.ActionBarDrawerToggle(
                this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_open
                );
            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            navigation = (NavigationView)FindViewById(Resource.Id.nav_view);
            navigation.NavigationItemSelected += (sender, e) =>
            {
                Navigate(e.MenuItem.ItemId);
            };

            inboxListener = new InboxListener(this);

            // message center stuff
            if (savedInstanceState != null)
            {
                Navigate(savedInstanceState.GetInt(NavId));
                Title = savedInstanceState.GetString(TitleKey);
            }
            else
            {
                navigation.SetCheckedItem(Resource.Id.nav_home);
                Navigate(Resource.Id.nav_home);
            }
        }
示例#9
0
        void UpdateToolbar()
        {
            if (_disposed)
            {
                return;
            }

            Context  context             = Context;
            var      activity            = (FormsAppCompatActivity)context;
            AToolbar bar                 = _toolbar;
            ActionBarDrawerToggle toggle = _drawerToggle;

            if (bar == null)
            {
                return;
            }

            bool isNavigated = NavigationPageController.StackDepth > 1;

            bar.NavigationIcon = null;
            Page currentPage = Element.CurrentPage;

            if (isNavigated)
            {
                if (toggle != null)
                {
                    toggle.DrawerIndicatorEnabled = false;
                    toggle.SyncState();
                }

                if (NavigationPage.GetHasBackButton(currentPage))
                {
                    var icon = new DrawerArrowDrawable(activity.SupportActionBar.ThemedContext);
                    icon.Progress      = 1;
                    bar.NavigationIcon = icon;

                    var prevPage = Element.Peek(1);
                    _defaultNavigationContentDescription = bar.SetNavigationContentDescription(prevPage, _defaultNavigationContentDescription);
                }
            }
            else
            {
                if (toggle != null && _masterDetailPage != null)
                {
                    toggle.DrawerIndicatorEnabled = _masterDetailPage.ShouldShowToolbarButton();
                    toggle.SyncState();
                }
            }

            Color tintColor = Element.BarBackgroundColor;

            if (Forms.IsLollipopOrNewer)
            {
                if (tintColor.IsDefault)
                {
                    bar.BackgroundTintMode = null;
                }
                else
                {
                    bar.BackgroundTintMode = PorterDuff.Mode.Src;
                    bar.BackgroundTintList = ColorStateList.ValueOf(tintColor.ToAndroid());
                }
            }
            else
            {
                if (tintColor.IsDefault && _backgroundDrawable != null)
                {
                    bar.SetBackground(_backgroundDrawable);
                }
                else if (!tintColor.IsDefault)
                {
                    if (_backgroundDrawable == null)
                    {
                        _backgroundDrawable = bar.Background;
                    }
                    bar.SetBackgroundColor(tintColor.ToAndroid());
                }
            }

            Color textColor = Element.BarTextColor;

            if (!textColor.IsDefault)
            {
                bar.SetTitleTextColor(textColor.ToAndroid().ToArgb());
            }

            bar.Title = currentPage.Title ?? "";

            UpdateTitleIcon();

            UpdateTitleView();
        }
 protected override void OnPostCreate(Bundle savedInstanceState)
 {
     base.OnPostCreate(savedInstanceState);
     drawerToggle.SyncState();
 }
示例#11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            var navigationView = FindViewById <NavigationView>(Resource.Id.left_navigationView);

            drawerLayout.DrawerOpened += DrawerLayout_DrawerOpened;
            drawerLayout.DrawerClosed += DrawerLayout_DrawerClosed;
            //drawerLayout.SetBackgroundResource(Resource.Drawable.loginbackground);
            //navigationView.SetItemTextAppearance(Resource.Color.loginButton);
            var toggle = new Android.Support.V7.App.ActionBarDrawerToggle
                         (
                this,
                drawerLayout,
                Resource.String.drawer_open,
                Resource.String.drawer_close
                         );

            drawerLayout.AddDrawerListener(toggle);
            toggle.SyncState();

            navigationView.NavigationItemSelected += (sender, e) =>
            {
                if (previousItem != null)
                {
                    previousItem.SetChecked(false);
                }

                navigationView.SetCheckedItem(e.MenuItem.ItemId);

                previousItem = e.MenuItem;
                MenuItemClicked(e.MenuItem.ItemId);
                drawerLayout.CloseDrawers();
            };
            navigationView.ItemIconTintList = null;
            adapter = new TabsAdapter(this, SupportFragmentManager);
            pager   = FindViewById <ViewPager>(Resource.Id.viewpager);
            var tabs = FindViewById <TabLayout>(Resource.Id.tabs);

            pager.Adapter = adapter;
            tabs.SetupWithViewPager(pager);
            pager.OffscreenPageLimit = 3;

            pager.PageSelected += (sender, args) =>
            {
                var fragment = adapter.InstantiateItem(pager, args.Position) as IFragmentVisible;

                fragment?.BecameVisible();
            };

            Toolbar.MenuItemClick += (sender, e) =>
            {
            };
            int menuId = Intent.GetIntExtra("menuId", 0);

            if (menuId != 0)
            {
                if (previousItem != null)
                {
                    previousItem.SetChecked(false);
                }

                navigationView.SetCheckedItem(menuId);
                MenuItemClicked(menuId);
                Intent.RemoveExtra("menuId");
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            _drawerLayout            = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            _contentLayout           = FindViewById <ViewGroup>(Resource.Id.main);
            _toolbar                 = FindViewById <Toolbar>(Resource.Id.toolbar);
            _chbTranslucent          = FindViewById <CheckBox>(Resource.Id.chb_translucent);
            _btnSetColor             = FindViewById <Button>(Resource.Id.btn_set_color);
            _btnSetTransparent       = FindViewById <Button>(Resource.Id.btn_set_transparent);
            _btnSetTranslucent       = FindViewById <Button>(Resource.Id.btn_set_translucent);
            _btnSetForImageView      = FindViewById <Button>(Resource.Id.btn_set_for_image_view);
            _btnUseInFragment        = FindViewById <Button>(Resource.Id.btn_use_in_fragment);
            _btnSetColorForSwipeBack = FindViewById <Button>(Resource.Id.btn_set_color_for_swipe_back);
            _sbChangeAlpha           = FindViewById <SeekBar>(Resource.Id.sb_change_alpha);
            _tvStatusAlpha           = FindViewById <TextView>(Resource.Id.tv_status_alpha);
            SetSupportActionBar(_toolbar);

            var toggle = new ActionBarDrawerToggle(this, _drawerLayout, _toolbar, Resource.String.navigation_drawer_open,
                                                   Resource.String.navigation_drawer_close);

            _drawerLayout.SetDrawerListener(toggle);
            toggle.SyncState();

            _btnSetColor.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(ColorStatusBarActivity));
                StartActivity(intent);
            };

            _btnSetTransparent.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(ImageStatusBarActivity));
                intent.PutExtra(ImageStatusBarActivity.ExtraIsTransparent, true);
                StartActivity(intent);
            };

            _btnSetTranslucent.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(ImageStatusBarActivity));
                intent.PutExtra(ImageStatusBarActivity.ExtraIsTransparent, false);
                StartActivity(intent);
            };

            _btnSetForImageView.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(ImageViewActivity));
                StartActivity(intent);
            };

            _btnUseInFragment.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(UseInFragmentActivity));
                StartActivity(intent);
            };

            _btnSetColorForSwipeBack.Click += (s, e) =>
            {
                var intent = new Intent(this, typeof(SwipeBackActivity));
                StartActivity(intent);
            };

            _chbTranslucent.Click += (s, e) =>
            {
                if (_chbTranslucent.Checked)
                {
                    _contentLayout.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.bg_monkey));
                    Jaeger.StatusBarUtil.SetTranslucentForDrawerLayout(this, _drawerLayout, _alpha);
                    _toolbar.SetBackgroundColor(Resources.GetColor(Android.Resource.Color.Transparent));
                }
                else
                {
                    _contentLayout.SetBackgroundDrawable(null);
                    _toolbar.SetBackgroundColor(Resources.GetColor(Resource.Color.colorPrimary));
                    Jaeger.StatusBarUtil.SetColorForDrawerLayout(this, _drawerLayout, Resources.GetColor(Resource.Color.colorPrimary), _alpha);
                }
            };

            _sbChangeAlpha.Max              = 255;
            _sbChangeAlpha.ProgressChanged += (s, e) =>
            {
                _alpha = e.Progress;
                if (_chbTranslucent.Checked)
                {
                    Jaeger.StatusBarUtil.SetTranslucentForDrawerLayout(this, _drawerLayout, _alpha);
                }
                else
                {
                    Jaeger.StatusBarUtil.SetColorForDrawerLayout(this, _drawerLayout, _statusBarColor, _alpha);
                }
                _tvStatusAlpha.Text = _alpha.ToString();
            };
            _sbChangeAlpha.Progress = Jaeger.StatusBarUtil.DefaultStatusBarAlpha;
        }