Example #1
0
        private void SetupMenu()
        {
            _menuManager = new ContextMenuManager <ChadderMessage>(this, _listView);

            _menuManager.InsertItem("ConversationMessageDelete".t(),
                                    async(ChadderMessage msg) => await ChadderUI.DeleteMessage(msg, _conversation));

            _menuManager.InsertItem("ConversationMessageDeleteRemote".t(),
                                    async(ChadderMessage msg) => await ChadderUI.TakeBack(msg, _conversation),
                                    msg => msg.MyMessage == true && (msg.Status == ChadderMessage.MESSAGE_STATUS.SENT));

            _menuManager.InsertItem("ConversationMessageCopy".t(), (ChadderMessage msg) =>
            {
                ClipboardManager clipboard = (ClipboardManager)Activity.GetSystemService(Context.ClipboardService);
                ClipData clip         = ClipData.NewPlainText("Chadder Message", msg.Body);
                clipboard.PrimaryClip = clip;
                DisplayToast("Copied");
            }, msg => msg.Type == ChadderMessage.MESSAGE_TYPE.TEXT);
        }
        private void SetupMenu()
        {
            _menuManager = new ContextMenuManager <ChadderUserDevice>(this, grid);

            _menuManager.InsertItem("Rename", (ChadderUserDevice device) =>
            {
                ChadderUI.ChangeDeviceName(device);
            });


            _menuManager.InsertItem(GetString(Resource.String.DevicePair), (ChadderUserDevice device) =>
            {
                ChadderUI.PairDevice(device);
            }, (d) => ChadderUI.Source.HasUserKey && d.HasUserKey == false);

            _menuManager.InsertItem("Delete", (ChadderUserDevice device) =>
            {
                ChadderUI.DeleteDevice(device);
            }, (d) => d.CurrentDevice == false);
        }
Example #3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.fragment_contact_list, container, false);

            try
            {
                _contactListView = view.FindViewById <Android.Widget.ListView>(Resource.Id.contact_list);

                searchText = view.FindViewById <EditText>(Resource.Id.contact_list_searchview);

                _noEntryText = view.FindViewById <TextView>(Resource.Id.no_friends_textview);
                _noEntryText.TextFormatted = Html.FromHtml("To add friends you can type their name in the search bar and if they have enabled </br>\"Public Name\" they will appear here");

                searchText.TextChanged += (s, e) =>
                {
                    _adapter.Collection.SetSearch(searchText.Text);
                };

                _adapter = new FindFriendAdapter(this.Activity, _noEntryText, new UIHelper.FindContactObservableCollection(ChadderApp.UIHelper.Source));
                _contactListView.Adapter    = _adapter;
                _contactListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
                {
                    var contact = _adapter[e.Position];
                    if (contact == null)
                    {
                        return;
                    }
                    if (contact.IsTemporary)
                    {
                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, ViewProfileFragment.ViewProfile(contact))
                        .AddToBackStack(null)
                        .Commit();
                    }
                    else
                    {
                        SupportFragmentManager.PopBackStack();
                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, ChatFragment.OpenChat(contact))
                        .AddToBackStack(null)
                        .Commit();
                    }
                };

                _menuManager = new ContextMenuManager <ChadderContact>(this, _contactListView);

                _menuManager.InsertItem("View profile", (ChadderContact contact) =>
                {
                    Android.Support.V4.App.FragmentTransaction transaction = this.Activity.SupportFragmentManager.BeginTransaction();
                    transaction.Replace(Resource.Id.content_frame, ViewProfileFragment.ViewProfile(contact));
                    transaction.AddToBackStack(null);
                    transaction.Commit();
                });

                _menuManager.InsertItem(c => c.Type == Chadder.Data.RelationshipType.BLOCKED ? "Unblock" : "Block",
                                        (ChadderContact contact) => ChadderUI.ToggleBlock(contact));

                _menuManager.InsertItem("Report",
                                        (ChadderContact contact) => ChadderUI.ReportContact(contact));
            }
            catch (Exception e)
            {
                Insight.Report(e);
            }

            return(view);
        }