예제 #1
0
 // Call to update the share intent
 void SetShareIntent(Intent shareIntent)
 {
     if (_shareActionProvider != null)
     {
         _shareActionProvider.SetShareIntent(shareIntent);
     }
 }
예제 #2
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.ActionBarMenu, menu);

            var       overflow_item = menu.FindItem(Resource.Id.overflowMenuShare);
            IMenuItem checkItem     = menu.FindItem(Resource.Id.overFlowMenuDarkTheme);

            if (mThemeId != Resource.Style.Black)
            {
                checkItem.SetChecked(checkItem.IsChecked);
            }
            else
            {
                checkItem.SetChecked(!checkItem.IsChecked);
            }

            var actionprov = new Android.Support.V7.Widget.ShareActionProvider(this);

            MenuItemCompat.SetActionProvider(overflow_item, actionprov);
            var test = MenuItemCompat.GetActionProvider(overflow_item);

            shareActionProvider = test.JavaCast <Android.Support.V7.Widget.ShareActionProvider>();

            shareActionProvider.SetShareIntent(CreateShareIntent());

            return(true);
        }
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            this.MenuInflater.Inflate(Resource.Menu.main_menu, menu);

            var shareItem = menu.FindItem(Resource.Id.action_share);
            var test = MenuItemCompat.GetActionProvider (shareItem);
            actionProvider = test.JavaCast<Android.Support.V7.Widget.ShareActionProvider>();

            var intent = new Intent(Intent.ActionSend);
            intent.SetType("text/plain");
            intent.PutExtra(Intent.ExtraText, "ActionBarCompat is Awesome! Support Lib v7 #Xamarin");

            actionProvider.SetShareIntent (intent);

            return base.OnCreateOptionsMenu(menu);
        }
예제 #4
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            this.MenuInflater.Inflate(Resource.Menu.main_menu, menu);

            var shareItem = menu.FindItem(Resource.Id.action_share);
            var test      = MenuItemCompat.GetActionProvider(shareItem);

            actionProvider = test.JavaCast <Android.Support.V7.Widget.ShareActionProvider>();

            var intent = new Intent(Intent.ActionSend);

            intent.SetType("text/plain");
            intent.PutExtra(Intent.ExtraText, "ActionBarCompat is Awesome! Support Lib v7 #Xamarin");

            actionProvider.SetShareIntent(intent);


            return(base.OnCreateOptionsMenu(menu));
        }
예제 #5
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            //change menu_share1 to your name
            MenuInflater.Inflate(Resource.Menu.menu_details, menu);
            var shareItem = menu.FindItem(Resource.Id.action_share);
            var provider  = MenuItemCompat.GetActionProvider(shareItem);

            actionProvider = provider.JavaCast <Android.Support.V7.Widget.ShareActionProvider> ();
            var intent = new Intent(Intent.ActionSend);

            intent.SetType("text/plain");
            var shareText = string.Format(Resources.GetString(Resource.String.share_text), viewModel.Place.Name);

            if (!string.IsNullOrWhiteSpace(viewModel.Place.Website))
            {
                shareText += " " + viewModel.Place.Website;
            }

            intent.PutExtra(Intent.ExtraText, shareText);
            actionProvider.SetShareIntent(intent);
            return(base.OnCreateOptionsMenu(menu));
        }
예제 #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            if (bundle != null && bundle.GetInt("theme", -1) != -1)
            {
                mThemeId = bundle.GetInt("theme");
                this.SetTheme(mThemeId);
            }
            if (bundle != null && bundle.GetInt("themeChange", -1) != -1)
            {
                mThemechange = bundle.GetInt("themeChange");
            }

            themePrefs = GetSharedPreferences(PREFS_THEME, 0);

            if (themePrefs.GetInt("0", 0) != null && themePrefs.GetInt("0", 0) != 0)
            {
                prefsThemeId = themePrefs.GetInt("0", 0);
                this.SetTheme(prefsThemeId);
                mThemeId = prefsThemeId;
            }

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            listItems = new List <ListItem>();

            layout = FindViewById(Resource.Id.container);


            if (IsThereAnAppToTakePictures())
            {
                CreateDirectoryForPictures();
            }

            _shortAnimationDuration = this.Resources.GetInteger(Android.Resource.Integer.ConfigShortAnimTime);

            // Get our RecyclerView layout:
            mRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            //............................................................
            // Layout Manager Setup:

            // Use the built-in linear layout manager:
            mLayoutManager = new LinearLayoutManager(this);


            // Plug the layout manager into the RecyclerView:
            mRecyclerView.SetLayoutManager(mLayoutManager);

            //............................................................
            // Adapter Setup:

            // Create an adapter for the RecyclerView, and pass it the
            // data set (the shopping list) to manage:
            mAdapter = new ShoppingListAdapter(listItems);

            // Register the item click handlers with the adapter:
            mAdapter.ItemClick     += OnItemClick;
            mAdapter.ChkBoxClick   += OnChkBoxClick;
            mAdapter.ItemLongClick += OnItemLongClick;
            mAdapter.ImageClick    += ZoomImageFromThumb;

            // Plug the adapter into the RecyclerView:
            mRecyclerView.SetAdapter(mAdapter);

            prefs = GetSharedPreferences(PREFS_NAME, 0);

            // Get elements from the layout resource,
            // and attach events to them
            EditText itemName = FindViewById <EditText>(Resource.Id.itemName);
            Button   addItem  = FindViewById <Button>(Resource.Id.addItem);

            // Check if there is an existing shopping list when the app was last closed
            if (prefs.GetString("0", "null") != null && prefs.GetString("0", "null") != "null" && mThemechange == -1)
            {
                Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(this);

                var continueTitleText   = Resources.GetText(Resource.String.continueTitleText);
                var continueMessageText = Resources.GetText(Resource.String.continueMessageText);
                var cancelText          = Resources.GetText(Resource.String.cancelText);

                builder.SetTitle(continueTitleText);
                builder.SetMessage(continueMessageText);
                builder.SetPositiveButton("Ok", async(senderAlert, args) =>
                {
                    string stringList   = prefs.GetString("0", "null");
                    IList <string> list = new List <string>();
                    list = JsonConvert.DeserializeObject <List <string> >(stringList);
                    foreach (var myimage in list)
                    {
                        var convert = JsonConvert.DeserializeObject <ListItem>(myimage);

                        ListItem testi = convert;
                        if (testi.path != "test")
                        {
                            if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) != (int)Permission.Granted)
                            {
                                // Camera permission has not been granted
                                RequestReadPermission();
                            }
                            else
                            {
                                BitmapFactory.Options options = await GetBitmapOptionsOfImageAsync(Uri.Parse(testi.path));
                                testi.bm = await LoadScaledDownBitmapForDisplayAsync((Uri.Parse(testi.path)), options, 32, 32);
                            }
                        }
                        listItems.Add(convert);
                    }
                    mAdapter.NotifyDataSetChanged();
                    ISharedPreferencesEditor editor = prefs.Edit();
                    editor.Commit();
                    if (shareActionProvider != null)
                    {
                        shareActionProvider.SetShareIntent(CreateShareIntent());
                    }
                });

                builder.SetNegativeButton(cancelText, (senderAlert, args) =>
                {
                    ISharedPreferencesEditor editor = prefs.Edit();
                    listItems.Clear();
                    editor.Clear();
                    editor.Commit();
                });

                Dialog dialog = builder.Create();
                dialog.Show();
            }
            // if application was recreated via theme change, use the old list without asking
            else if (mThemechange == 0)
            {
                GetOldList();
            }

            // Plug the adapter into the RecycleViewer
            mRecyclerView.SetAdapter(mAdapter);

            addItem.Click += (sender, e) =>
            {
                ListItem item = new ListItem();
                item.title = itemName.Text;
                listItems.Add(item);
                mAdapter.NotifyDataSetChanged();
                itemName.Text = ("");
                if (shareActionProvider != null)
                {
                    shareActionProvider.SetShareIntent(CreateShareIntent());
                }
            };
        }
예제 #7
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            //change menu_share1 to your name
            MenuInflater.Inflate (Resource.Menu.menu_details, menu);
            var shareItem = menu.FindItem (Resource.Id.action_share);
            var provider = MenuItemCompat.GetActionProvider (shareItem);
            actionProvider = provider.JavaCast<Android.Support.V7.Widget.ShareActionProvider> ();
            var intent = new Intent (Intent.ActionSend);
            intent.SetType ("text/plain");
            var shareText = string.Format (Resources.GetString (Resource.String.share_text), viewModel.Place.Name);
            if (!string.IsNullOrWhiteSpace (viewModel.Place.Website))
                shareText += " " + viewModel.Place.Website;

            intent.PutExtra (Intent.ExtraText, shareText);
            actionProvider.SetShareIntent (intent);
            return base.OnCreateOptionsMenu (menu);
        }