private MainActivityBinding(Activity activity, int layoutId)
        {
            activity.SetContentView(layoutId);
            toolbar = activity.FindViewById<Toolbar>(Resource.Id.toolbar);
            drawer  = activity.FindViewById<DrawerLayout>(Resource.Id.drawer);
            navView = activity.FindViewById<NavigationView>(Resource.Id.nav_view);

            var decorView = activity.Window.DecorView;
            Root = (ViewGroup) decorView.FindViewById(global::Android.Resource.Id.Content);
        }
        private WebViewActivityBinding(Activity activity, int layoutId)
        {
            activity.SetContentView(layoutId);

            webview = activity.FindViewById<WebView>(Resource.Id.webview);
            toolbar = activity.FindViewById<Toolbar>(Resource.Id.toolbar);

            var decorView = activity.Window.DecorView;
            Root = (ViewGroup) decorView.FindViewById(global::Android.Resource.Id.Content);
        }
        public void Bind(Activity activity)
        {
            if (activity == null)
                throw new ArgumentNullException();

            activity.SetContentView(ResourceId);

            if (BindOutlets)
            {
                FieldInfo[] fields = activity.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
                foreach (FieldInfo field in fields)
                {
                    object[] outlets = field.GetCustomAttributes(typeof(OutletAttribute), false);
                    if (outlets.Length == 0)
                        continue;

                    OutletAttribute outlet = (OutletAttribute) outlets[0];
                    field.SetValue(activity, activity.FindViewById(outlet.ResourceId));
                }
            }

            if (BindActions)
            {
                MethodInfo[] methods = activity.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);
                foreach (MethodInfo method in methods)
                {
                    object[] actions = method.GetCustomAttributes(typeof(ActionAttribute), false);
                    if (actions.Length == 0)
                        continue;

                    foreach (ActionAttribute action in actions)
                    {
                        try
                        {
                            FieldInfo field = activity.GetType().GetField(action.Field, BindingFlags.NonPublic | BindingFlags.Instance);
                            if (field == null)
                                throw new Exception();

                            EventInfo handler = field.FieldType.GetEvent(action.Handler, BindingFlags.Public | BindingFlags.Instance);
                            if (handler == null)
                                throw new Exception();

                            handler.AddEventHandler(field.GetValue(activity), Delegate.CreateDelegate(handler.EventHandlerType, activity, method));
                        }
                        catch
                        {
                            Console.WriteLine("Can't bind {0}.{1} with {2}", action.Field, action.Handler, method.Name);
                            continue;
                        }
                    }
                }
            }
        }
Example #4
0
        public AndroidDevice(Activity activity, ConnectionType connectionType, string connectionString)
            : base(connectionType, connectionString, new JsonProvider())
        {
            // Setup the WebView/Browser
            _activity = activity;
            Browser = new AndroidBrowser(new WebView(activity));
            _activity.SetContentView(WebView);

            // Populate device info
            Wifi = (WifiManager)activity.GetSystemService(Context.WifiService);
            DeviceInfo = new DeviceInfo();
            DeviceInfo.MobileOs = MobileOs.Android;
            DeviceInfo.DeviceModel = Build.Model;
            DeviceInfo.OsVersion = Build.VERSION.Release;
            DeviceInfo.IP = IP;
            var tm = (TelephonyManager)activity.GetSystemService(Context.TelephonyService);
            DeviceInfo.UniqueId = tm.DeviceId;
        }
Example #5
0
        public void addSlideUpSheet(CustomPin pin, CustomMap map)
        {
            Android.App.Activity mainActivity = CrossCurrentActivity.Current.Activity;

            Android.Views.View            view    = mainActivity.CurrentFocus;
            Android.Views.View            root    = view.RootView;
            Android.Views.View            altRoot = mainActivity.Window.DecorView.FindViewById(Android.Resource.Id.Content);
            Android.Widget.RelativeLayout parent  = view.Parent as Android.Widget.RelativeLayout;
            parent.RemoveView(view);
            Console.WriteLine("Retrieved current focus...");
            //LinearLayout BottomSheetPage = new LinearLayout(mainActivity);
            Console.WriteLine("Created a new layout...");
            if (Android.App.Application.Context.GetSystemService(Context.LayoutInflaterService) is Android.Views.LayoutInflater inflater)
            {
                Android.Views.View bottomSheetView = inflater.Inflate(Resource.Layout.BottomSheet, null);
                Android.Views.View test            = inflater.Inflate(Resource.Layout.XamarinMapInfoWindow, null);
                Console.WriteLine("Created a bsheet...");
                Cheesebaron.SlidingUpPanel.SlidingUpPanelLayout main = bottomSheetView as Cheesebaron.SlidingUpPanel.SlidingUpPanelLayout;
                Android.Widget.RelativeLayout bottom = main.FindViewById <Android.Widget.RelativeLayout>(Resource.Id.mainWindow);
                bottom.AddView(view);
                mainActivity.SetContentView(main);


                //parent.AddView(bottomSheetView);
                //inflate to bsheet

                //add the two views

                //BottomSheetPage.AddView(view.RootView);
                //Console.WriteLine("Added the currentfocus...");
                //BottomSheetPage.AddView(bottomSheetView);
                //Console.WriteLine("Added the bsheet...");
                //// $$$$$$ PROFIT $$$$$$$
                //mainActivity.SetContentView(BottomSheetPage);
                //Console.WriteLine("Set content view!!!!");
            }
        }
        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.Page> e)
        {
            base.OnElementChanged (e);

            mActivity = this.Context as Activity;
            mActivity.SetContentView (Resource.Layout.ConferencePageLayout);

            mPublisherViewContainer = (RelativeLayout) mActivity.FindViewById(Resource.Id.publisherview);
            mSubscriberViewContainer = (RelativeLayout) mActivity.FindViewById(Resource.Id.subscriberview);

            mStreams = new List<Stream>();
            SessionConnect();

            /*
            var activity = this.Context as Activity;
            var conferenceActivity = new Intent (activity, typeof (ConferenceActivity));
            activity.StartActivity (conferenceActivity);
            */
        }