コード例 #1
0
        private void Sort()
        {
            var oldSort = Settings.SortBy;

            PopUpHelpers.ShowListPopup(this, Resource.String.sort_title, Resource.Array.sort_by_options, (newSort) =>
            {
                if (oldSort == (SortOption)newSort)
                {
                    return;
                }

                Settings.SortBy = (SortOption)newSort;
                ReloadData(0);
            });
        }
コード例 #2
0
        protected override void OnResume()
        {
            base.OnResume();
            if (m_OriginalTheme != Settings.ThemeSetting || m_OriginalAccent != Settings.ThemeAccent)
            {
                PopUpHelpers.ShowOKCancelPopup(this, Resource.String.theme_changed_title,
                                               Resource.String.theme_changed_message, (reload) =>
                {
                    if (!reload)
                    {
                        return;
                    }


                    OverridePendingTransition(0, 0);
                    Intent.AddFlags(ActivityFlags.NoAnimation);
                    Finish();

                    OverridePendingTransition(0, 0);
                    StartActivity(Intent);
                });
            }
        }
コード例 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            SetTheme(Settings.ThemeSetting == 0 ? Resource.Style.MyTheme : Resource.Style.MyThemeDark);

            base.OnCreate(bundle);

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

            m_OriginalTheme  = Settings.ThemeSetting;
            m_OriginalAccent = Settings.ThemeAccent;

            Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);

            m_AllTasks         = new JavaList <TaskModel>();
            m_EditTaskPosition = 0;

            m_AddButton        = FindViewById <ImageButton>(Resource.Id.button_add_task);
            m_MicrophoneButton = FindViewById <ImageButton>(Resource.Id.button_microphone);
            m_TaskEditText     = FindViewById <EditText>(Resource.Id.edit_text_new_task);


            ActionBar = FindViewById <ActionBar.ActionBar>(Resource.Id.actionbar);

            //ActionBar.BackgroundDrawable = Resources.GetDrawable(Resource.Drawable.actionbar_background_blue);
            //ActionBar.ItemBackgroundDrawable = Resources.GetDrawable(Resource.Drawable.actionbar_btn_blue);
            //ActionBar.SeparatorColor = Resources.GetColor(Resource.Color.actionbar_separatorcolor_blue);
            ActionBar.Title           = "Tasks";
            ActionBar.CurrentActivity = this;
            ActionBar.SetHomeLogo(Resource.Drawable.ic_launcher);
            RegisterForContextMenu(ListView);


            m_TaskEditText.SetOnEditorActionListener(this);


            ListView.ChoiceMode = ChoiceMode.Multiple;

            m_AddButton.Click += (sender, args) => AddNewTask();

            m_AddButton.SetImageResource(Settings.ThemeSetting == 0 ? Resource.Drawable.ic_action_add : Resource.Drawable.ic_action_add_dark);
            m_MicrophoneButton.SetImageResource(Settings.ThemeSetting == 0 ? Resource.Drawable.ic_action_microphone : Resource.Drawable.ic_action_microphone_dark);

            m_AddButton.SetBackgroundResource(Settings.ImageButtonDrawable);
            m_MicrophoneButton.SetBackgroundResource(Settings.ImageButtonDrawable);

            // remove speech if it doesn't exist
            var activities = PackageManager.QueryIntentActivities(new Intent(RecognizerIntent.ActionRecognizeSpeech), 0);

            if (activities.Count == 0)
            {
                m_MicrophoneButton.Visibility = ViewStates.Gone;
            }
            else
            {
                m_MicrophoneButton.Click += (sender, args) => StartVoiceRecognitionActivity();
            }

            m_TextToSpeech = new TextToSpeech(this, this);

            var saveState = LastNonConfigurationInstance as SaveState;

            if (saveState != null)
            {
                m_AllTasks                      = new JavaList <TaskModel>(saveState.Tasks);
                ListView.Visibility             = ViewStates.Visible;
                RunOnUiThread(() => ListAdapter = new TaskAdapter(this, m_AllTasks));
                RunOnUiThread(() => ListView.SetSelection(saveState.LastPosition));
                SetChecks();
                m_TaskEditText.Text = saveState.NewTaskText;
                m_Editing           = saveState.Editing;
                m_EditTaskPosition  = saveState.EditIndex;
            }
            else
            {
                FlurryAgent.OnPageView();
                FlurryAgent.LogEvent("MainActivity");
                ReloadData(0);
            }

            SetActionBar();
            try
            {
                if (Intent.GetBooleanExtra("CameFromWidget", false))
                {
                    FocusMainText();
                    return;
                }

                if (Intent.Action == TaskWidgetProvider.UpdateIntent)
                {
                    if (Intent.ActionSend != Intent.Action || Intent.Type == null)
                    {
                        return;
                    }
                }

                if ("text/plain" != Intent.Type)
                {
                    return;
                }

                var sharedText = Intent.GetStringExtra(Intent.ExtraText);
                if (!string.IsNullOrEmpty(sharedText))
                {
                    m_TaskEditText.Text = sharedText;
                    m_Editing           = false;
                    SetActionBar();
                }
            }
            finally
            {
                var version = Resources.GetString(Resource.String.VersionNumber);
                if (Settings.CurrentVersionNumber != version)
                {
                    Settings.CurrentVersionNumber = version;
                    PopUpHelpers.ShowOKPopup(this, Resource.String.update_title, Resource.String.update_message, (ok) => { });
                }
            }
        }