Exemple #1
0
        private void ShowPopupMenu(Android.Views.View view)
        {
            Android.Support.V7.Widget.PopupMenu popupMenu;
            if (_extendedPopupMenuButton.IsXamlPopup)
            {
                popupMenu = new Android.Support.V7.Widget.PopupMenu(_context, view, 1, 0, Resource.Style.CustomPopupMenuStyle);
            }
            else
            {
                popupMenu = new Android.Support.V7.Widget.PopupMenu(_context, view, 1, 0, Resource.Style.PopupMenuStyle);
            }

            foreach (var item in _extendedPopupMenuButton.Options)
            {
                if (item.IsVisible)
                {
                    Java.Lang.ICharSequence option = new Java.Lang.String(item.Text);
                    popupMenu.Menu.Add(option);
                }
            }

            if (popupMenu.Menu.Size() > 0)
            {
                popupMenu.MenuItemClick -= PopupMenuItemClick;
                popupMenu.MenuItemClick += PopupMenuItemClick;
                popupMenu.Show();
            }
        }
Exemple #2
0
        //Menu Create Stories >>  Image , Video
        private void CreateStories_OnClick(object sender, EventArgs eventArgs)
        {
            try
            {
                var ctw   = new ContextThemeWrapper(this, Resource.Style.PopupMenuStyle);
                var popup = new PopupMenu(ctw, Btn_story);
                popup.MenuInflater.Inflate(Resource.Menu.CreateStories_Menu, popup.Menu);
                popup.Show();
                popup.MenuItemClick += (o, e) =>
                {
                    try
                    {
                        var Id = e.Item.ItemId;
                        switch (Id)
                        {
                        case Resource.Id.menu_Image:
                            OnImage_Button_Click();
                            break;

                        case Resource.Id.menu_Video:
                            OnVideo_Button_Click();
                            break;
                        }
                    }
                    catch (Exception exception)
                    {
                        Crashes.TrackError(exception);
                    }
                };
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
        //Menu More >>
        private void MoreButton_OnClick(object sender, EventArgs eventArgs)
        {
            try
            {
                ContextThemeWrapper ctw   = new ContextThemeWrapper(ActivityContext, Resource.Style.PopupMenuStyle);
                PopupMenu           popup = new PopupMenu(ctw, More_Button);
                popup.MenuInflater.Inflate(Resource.Menu.MoreCommunities_NotEdit_Menu, popup.Menu);
                popup.Show();
                popup.MenuItemClick += (o, popup_eventArgs) =>
                {
                    try
                    {
                        var Id = popup_eventArgs.Item.ItemId;
                        switch (Id)
                        {
                        case Resource.Id.menu_CopeLink:
                            OnMenu_CopeLink_Click(Videodata);
                            break;

                        case Resource.Id.menu_Share:
                            OnMenu_ShareIcon_Click(Videodata);
                            break;
                        }
                    }
                    catch (Exception exception)
                    {
                        Crashes.TrackError(exception);
                    }
                };
            }
            catch (Exception exception)
            {
                Crashes.TrackError(exception);
            }
        }
Exemple #4
0
        private async void ContinueActivityInitializationAsync()
        {
            if (!_application.IsInitialized)
            {
                if (!_application.Initialize())
                {
                    ShowSnackbar(Resource.String.applicationInitializationErrorMessage);
                    return;
                }

                ShowProgressBar();

                Boolean hasReadingErrors = await _application.Manager.ReadSchedulesAsync();

                if (hasReadingErrors)
                {
                    ShowSnackbar(Resource.String.schedulesReadingErrorMessage);
                    _application.SaveLog();
                }
            }

            _application.Preferences.Read();

            if (_application.Preferences.CheckUpdatesOnStart)
            {
                CheckForUpdatesAsync();
            }

            _toolbarTitle  = FindViewById <TextView>(Resource.Id.mainToolbarTitleTextView);
            _schedulesMenu = new PopupMenu(this, _toolbarTitle);
            _schedulesMenu.MenuItemClick += (s, e) => ShowSchedule(e.Item.ItemId);
            _toolbarTitle.Click          += (s, e) => _schedulesMenu.Show();
            _toolbarTitle.LongClick      += (s, e) => ShowCurrentScheduleRemovingDialog();

            _tabLayout = FindViewById <TabLayout>(Resource.Id.mainTabLayout);

            void UpdateSubjectsHighlighting()
            {
                // Перерисовка фрагмента посредством программного перемещения к текущей дате.
                if (_application.Preferences.CurrentScheduleDate == DateTime.Today)
                {
                    RunOnUiThread(() => ViewPagerMoveToDate(DateTime.Today));
                }
            }

            const Int32 UpdatingIntervalInMilliseconds = 60000;

            _currentSubjectHighlightTimer          = new Timer(UpdatingIntervalInMilliseconds);
            _currentSubjectHighlightTimer.Elapsed += (s, e) => UpdateSubjectsHighlighting();

            _fab        = FindViewById <FloatingActionButton>(Resource.Id.mainSelectScheduleDateFab);
            _fab.Click += (s, e) => ShowCustomDatePickerDialog();

            _activityState = MainActivityState.Initialized;

            RestartSchedulesRenderingSubsystem();
        }
        public PopupMenu BuildMenu(Context context, View anchorView)
        {
            var popup = new PopupMenu(context, anchorView);
            var order = 0;

            foreach (var commandAction in _commandActions)
            {
                popup.Menu.Add(0, commandAction.Key, order++, commandAction.Value.Title);
            }
            return(popup);
        }
Exemple #6
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            HasOptionsMenu = true;
            var ignored = base.OnCreateView(inflater, container, savedInstanceState);
            var view    = inflater.Inflate(Resource.Layout.NavDrawerFrag, null);

            view.FindViewById <Button>(Resource.Id.button).Click += (sender, args) =>
            {
                var popUp = new Android.Support.V7.Widget.PopupMenu(Activity, (Button)sender);
                popUp.Inflate(Resource.Menu.main_menu);
                popUp.Show();
            };

            view.FindViewById <TextView>(Resource.Id.main_text).Text = "This is BROWSE FRAGMENT";
            return(view);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            HasOptionsMenu = true;
            var ignored = base.OnCreateView(inflater, container, savedInstanceState);
            var view = inflater.Inflate(Resource.Layout.NavDrawerFrag, null);

            view.FindViewById<Button>(Resource.Id.button).Click += (sender, args) =>
            {
                var popUp = new Android.Support.V7.Widget.PopupMenu(Activity, (Button) sender);
                popUp.Inflate(Resource.Menu.main_menu);
                popUp.Show();
            };

            view.FindViewById<TextView>(Resource.Id.main_text).Text = "This is BROWSE FRAGMENT";
            return view;
        }
        void ShowPopupMenu(View view)
        {
            var adapter = (PopupAdapter)ListAdapter;

            // Retrieve the clicked item from view's tag
            var item = (string)view.Tag;

            // Create a PopupMenu, giving it the clicked view for an anchor
            Android.Support.V7.Widget.PopupMenu popup = new Android.Support.V7.Widget.PopupMenu(Activity, view);

            // Inflate our menu resource into the PopupMenu's Menu
            popup.MenuInflater.Inflate(Resource.Menu.popup, popup.Menu);

            // Set a listener so we are notified if a menu item is clicked
            popup.SetOnMenuItemClickListener(new MyOnMenuItemClickListener(adapter, item));

            // Finally show the PopupMenu
            popup.Show();
        }
Exemple #9
0
            public bool TryHandle(object sender, object message)
            {
                var view = _view;

                if (!view.IsAlive())
                {
                    Update(null);
                    return(false);
                }

                var activity = _view.Context.GetActivity();

                if (activity == null)
                {
                    Update(null);
                    Tracer.Warn("(PopupMenu) The contex of view is not an activity.");
                    return(false);
                }

                var  template = _view.GetBindingMemberValue(AttachedMembers.View.PopupMenuTemplate);
                var  path     = _view.GetBindingMemberValue(AttachedMembers.View.PopupMenuPlacementTargetPath);
                View itemView = null;

                if (!string.IsNullOrEmpty(path))
                {
                    itemView = (View)BindingExtensions.GetValueFromPath(message, path);
                }

                var menuPresenter = _view.GetBindingMemberValue(AttachedMembers.View.PopupMenuPresenter);

                if (menuPresenter == null)
                {
                    var menu = new PopupMenu(activity, itemView ?? view);
                    menu.Menu.ApplyMenuTemplate(template, activity, itemView ?? view);
                    menu.SetOnDismissListener(DismissListener);
                    menu.Show();
                    return(true);
                }
                return(menuPresenter.Show(view, itemView ?? view, template, message, (s, menu) => MenuTemplate.Clear(menu)));
            }
Exemple #10
0
        void PlaylistMore(object sender, System.EventArgs eventArgs)
        {
            PopupMenu menu = new PopupMenu(MainActivity.instance, MainActivity.instance.FindViewById <ImageButton>(Resource.Id.headerMore));

            menu.Inflate(Resource.Menu.playlist_header_more); //Contains "add to queue"

            if (item.SyncState == SyncState.True)
            {
                menu.Menu.Add(Menu.None, Resource.Id.download, 1, MainActivity.instance.GetString(Resource.String.sync_now));
                menu.Menu.Add(Menu.None, Resource.Id.sync, 5, MainActivity.instance.GetString(Resource.String.stop_sync));
            }
            else if (item.YoutubeID != null)
            {
                menu.Menu.Add(Menu.None, Resource.Id.download, 1, MainActivity.instance.GetString(Resource.String.sync));
            }

            if (item.YoutubeID != null)
            {
                if (isForked)
                {
                    menu.Menu.Add(Menu.None, Resource.Id.fork, 2, MainActivity.instance.GetString(Resource.String.unfork));
                }
                else
                {
                    menu.Menu.Add(Menu.None, Resource.Id.fork, 2, MainActivity.instance.GetString(Resource.String.add_to_library));
                }
            }

            if (item.HasWritePermission)
            {
                menu.Menu.Add(Menu.None, Resource.Id.name, 3, MainActivity.instance.GetString(Resource.String.rename));
            }

            menu.Menu.Add(Menu.None, Resource.Id.delete, 4, MainActivity.instance.GetString(Resource.String.delete));
            menu.SetOnMenuItemClickListener(this);
            menu.Show();
        }
Exemple #11
0
 public void OnDismiss(PopupMenu menu)
 {
     MenuTemplate.Clear(menu.Menu);
 }
        private async void ContinueActivityInitializationAsync()
        {
            if (!_application.IsInitialized)
            {
                if (!_application.Initialize())
                {
                    ShowSnackbar(Resource.String.applicationInitializationErrorMessage);
                    return;
                }

                ShowProgressBar();

                Boolean haveReadingErrors = await _application.Manager.ReadSchedulesAsync();

                if (haveReadingErrors)
                {
                    ShowSnackbar(Resource.String.schedulesReadingErrorMessage);
                    _application.SaveLog();
                }
            }

            Int32 currentVersion = _application.GetVersion();

            if (_application.Preferences.LastSeenUpdateVersion == 0)
            {
                _application.Preferences.SetLastSeenUpdateVersion(currentVersion);
            }

            MigrateSchedulesAsync(currentVersion);

            _toolbarTitle  = FindViewById <TextView>(Resource.Id.mainToolbarTitleTextView);
            _schedulesMenu = new PopupMenu(this, _toolbarTitle);
            _schedulesMenu.MenuItemClick += (s, e) => ShowSchedule(e.Item.ItemId);
            _toolbarTitle.Click          += (s, e) => _schedulesMenu.Show();
            _toolbarTitle.LongClick      += (s, e) => ShowCurrentScheduleActionsDialog();

            _tabLayout = FindViewById <TabLayout>(Resource.Id.mainTabLayout);

            void UpdateSubjectsHighlighting()
            {
                // Перерисовка фрагмента посредством программного перемещения к текущей дате.
                if (_application.Preferences.CurrentScheduleDate == DateTime.Today)
                {
                    RunOnUiThread(() => ViewPagerMoveToDate(DateTime.Today));
                }
            }

            const Int32 UpdatingIntervalInMilliseconds = 60000;

            _currentSubjectHighlightTimer          = new Timer(UpdatingIntervalInMilliseconds);
            _currentSubjectHighlightTimer.Elapsed += (s, e) => UpdateSubjectsHighlighting();

            _fab            = FindViewById <FloatingActionButton>(Resource.Id.mainSelectScheduleDateFab);
            _fab.Click     += (s, e) => ShowCustomDatePickerDialog();
            _fab.LongClick += (s, e) => ShowViewingWeekTypeSnackbar();

            _activityState = MainActivityState.Initialized;

            if (!IsPreferencesValid())
            {
                ShowDialogWithSuggestionToConfigureApplication();
                //return ;
            }

            RestartSchedulesRenderingSubsystem();

            if (_application.Preferences.CheckUpdatesOnStart)
            {
                CheckForUpdatesAsync(currentVersion);
            }

            if (_application.Preferences.LastSeenWelcomeVersion != currentVersion)
            {
                new CustomAlertDialog(this)
                .SetTitle(Resource.String.introductionDialogTitle)
                .SetMessage(Resource.String.introductionMessage)
                .SetPositiveButton(
                    Resource.String.gotItActionTitle,
                    () => _application.Preferences.SetLastSeenWelcomeVersion(currentVersion)
                    )
                .SetPositiveButtonEnabledOnlyWhenMessageScrolledToBottom()
                .Show();
            }
        }
Exemple #13
0
        private async void ContinueActivityInitializationAsync()
        {
            if (!_application.IsInitialized)
            {
                if (!_application.Initialize(out InitializationStatus status))
                {
                    String message = String.Format(
                        Resources.GetString(Resource.String.applicationInitializationErrorMessage),
                        status.ToString()
                        );

                    ShowLayoutMessage(message.FromMarkdown());
                    return;
                }

                // if (status == InitializationStatus.FailedToRemoveDirectory)
                // {
                //     ShowSnackbar(Resource.String.failedToRemoveDirectoryErrorMessage);
                // }

                ShowProgressBar();

                Boolean haveReadingErrors = await _application.Manager.ReadSchedulesAsync();

                if (haveReadingErrors)
                {
                    ShowSnackbar(Resource.String.schedulesReadingErrorMessage);
                    _ = _application.SaveLogAsync();
                }

                Int32 schedulesNumber = _application.Manager.Schedules.Count;
                if (_application.Preferences.UpdateSchedulesOnStart && schedulesNumber != 0)
                {
                    await UpdateSchedulesWithCheckPermissionAsync();
                }
            }

            Int64 currentVersion = _application.GetVersionCode();

            if (_application.Preferences.LastSeenUpdateVersion == 0)
            {
                _application.Preferences.SetLastSeenUpdateVersion(currentVersion);
            }

            _toolbarTitle  = FindViewById <TextView>(Resource.Id.mainToolbarTitleTextView);
            _schedulesMenu = new PopupMenu(this, _toolbarTitle);
            _schedulesMenu.MenuItemClick += (s, e) => ShowSchedule(e.Item.ItemId);

            _toolbarTitle.Click += (s, e) =>
            {
                if (_stateManager.CurrentState == MainActivityState.ScheduleDisplayed &&
                    _application.Manager.Schedules.Count != 0)
                {
                    _schedulesMenu.Show();
                }
            };

            _toolbarTitle.LongClick += (s, e) =>
            {
                if (_stateManager.CurrentState == MainActivityState.ScheduleDisplayed)
                {
                    ShowCurrentScheduleActionsDialog();
                }
            };

            _tabLayout = FindViewById <TabLayout>(Resource.Id.mainTabLayout);

            void UpdateSubjectsHighlighting()
            {
                // Перерисовка фрагмента посредством программного перемещения к текущей дате.
                if (_application.Preferences.CurrentScheduleDate == DateTime.Today)
                {
                    RunOnUiThread(() => ViewPagerMoveToDate(DateTime.Today));
                }
            }

            const Int32 UpdatingIntervalInMilliseconds = 60000;

            _currentSubjectHighlightTimer          = new Timer(UpdatingIntervalInMilliseconds);
            _currentSubjectHighlightTimer.Elapsed += (s, e) => UpdateSubjectsHighlighting();

            _fab            = FindViewById <FloatingActionButton>(Resource.Id.mainSelectScheduleDateFab);
            _fab.Click     += (s, e) => ShowCustomDatePickerDialog();
            _fab.LongClick += (s, e) => ShowViewingWeekTypeSnackbar();

            _stateManager.SetState(MainActivityState.Initialized);

            if (!IsPreferencesValid())
            {
                ShowDialogWithSuggestionToConfigureApplication();
                return;
            }

            RestartSchedulesRenderingSubsystem();

            _ = _application.ClearLogsAsync();

            // MigrateSchedulesAsync(currentVersion);
            CheckForCriticalUpdatesAsync(currentVersion);

#if DEBUG
            Log.Debug("Shults.SmtuSchedule.MessagingService", MessagingService.GetToken(this) ?? ":(");
#endif
        }