public CustomAlertDialog(Context context) : base(context)
        {
            // Вместо "?android:attr/dialogPreferredPadding" в customDialogLayout.axml для уровней API ниже 22.
            _preferredPadding = Build.VERSION.SdkInt < BuildVersionCodes.LollipopMr1
                ? Context.Resources.GetDimensionPixelSize(Resource.Dimension.dialogPreferredPaddingApiLess22)
                : UiUtilities.GetAttributeValuePixelSize(Context, Resource.Attribute.dialogPreferredPadding);

            ShowEvent += (s, e) =>
            {
                WindowManagerLayoutParams layoutParameters = new WindowManagerLayoutParams();
                layoutParameters.CopyFrom(Window.Attributes);

                IWindowManager windowManager = (context as AppCompatActivity).WindowManager;
                (Int32 width, Int32 height) = UiUtilities.GetScreenPixelSize(windowManager);

                Int32 maxDialogHeight = (Int32)(height * 0.9);
                if (Window.DecorView.Height > maxDialogHeight)
                {
                    layoutParameters.Height = maxDialogHeight;
                }

                Window.Attributes = layoutParameters;
            };

            _layout = View.Inflate(Context, Resource.Layout.customDialogLayout, null) as ViewGroup;
            _layout.SetPadding(_preferredPadding, _preferredPadding, _preferredPadding, _preferredPadding);

            SetView(_layout);
        }
        /// <summary>
        /// 根据方向选择
        /// </summary>
        /// <param name="attrs"></param>
        protected override void SetDialogWindowPosition(WindowManagerLayoutParams attrs)
        {
            base.SetDialogWindowPosition(attrs);

            int lastX = 0, lastY = 0;
            int xoffset = (int)Math.Ceiling(_dialogConfig.XOffset * Density);
            int yoffset = (int)Math.Ceiling(_dialogConfig.YOffset * Density);

            switch (_dialogConfig.DialogPosition)
            {
            case DialogPosition.Top:
                lastX = _baseViewRect.X + xoffset;
                lastY = _baseViewRect.Y - _dialogViewSize.Height - yoffset;
                break;

            case DialogPosition.Buttom:
                lastX = _baseViewRect.X + xoffset;
                lastY = _baseViewRect.Y + _baseViewRect.Height + yoffset;
                break;

            default:
                lastX = _baseViewRect.X + xoffset;
                lastY = _baseViewRect.Y + _baseViewRect.Height + yoffset;
                break;
            }
            int differenceX = lastX + _dialogViewSize.Width - this.WindowSize.X;

            if (differenceX > 0)
            {
                lastX = lastX - differenceX;
            }
            attrs.Gravity = GravityFlags.Top | GravityFlags.Left;
            attrs.X       = lastX;
            attrs.Y       = lastY;
        }
Beispiel #3
0
        protected override void OnStart()
        {
            base.OnStart();

            if (!Utility.IsTablet(this))
            {
                return;
            }

            Rect frame = new Rect();

            Window.DecorView.GetWindowVisibleDisplayFrame(frame);

            Window.SetGravity(GravityFlags.Center | GravityFlags.Center);

            WindowManagerLayoutParams par = Window.Attributes;

            //par.Y = Utility.dpToPx(this, 50);
            par.Height             = frame.Bottom - Utility.dpToPx(this, 121);
            par.Width              = Utility.dpToPx(this, 530);
            par.DimAmount          = 0;
            this.Window.Attributes = par;

            Window.AddFlags(WindowManagerFlags.DimBehind);
        }
Beispiel #4
0
        protected override void OnCreate(Bundle bundle)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(bundle);
            this.Window.AddFlags(WindowManagerFlags.Fullscreen);
            this.Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn);
            this.Window.AddFlags(WindowManagerFlags.DismissKeyguard);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var sp   = PreferenceManager.GetDefaultSharedPreferences(this);
            var edit = sp.Edit();

            edit.PutBoolean(PrefKioskMode, true);
            edit.Commit();

            WindowManagerLayoutParams localLayoutParams = new WindowManagerLayoutParams();

            localLayoutParams.Type    = WindowManagerTypes.SystemError;
            localLayoutParams.Gravity = GravityFlags.Top;
            localLayoutParams.Flags   = WindowManagerFlags.NotFocusable |
                                        WindowManagerFlags.NotTouchModal | WindowManagerFlags.LayoutInScreen;
            localLayoutParams.Width  = WindowManagerLayoutParams.MatchParent;
            localLayoutParams.Height = (int)(50 * Resources.DisplayMetrics.ScaledDensity);
            localLayoutParams.Format = Format.Transparent;

            IWindowManager  manager = ApplicationContext.GetSystemService(Context.WindowService).JavaCast <IWindowManager>();
            CustomViewGroup view    = new CustomViewGroup(this);

            manager.AddView(view, localLayoutParams);
        }
Beispiel #5
0
        public override void OnCreate()
        {
            base.OnCreate();
            WindowManagerTypes layoutType = WindowManagerTypes.Phone;

            if (Build.VERSION.SdkInt > BuildVersionCodes.NMr1)      //Nougat 7.1
            {
                layoutType = WindowManagerTypes.ApplicationOverlay; //Android Oreo does not allow to add windows of WindowManagerTypes.Phone
            }

            windowManager = GetSystemService(WindowService).JavaCast <IWindowManager>();

            var layoutInflater = LayoutInflater.From(this);

            View view = null;

            //view =  (LinearLayout)layoutInflater.Inflate(Resource.Layout.Floating, null); //Replace with your custom axml view in resources.
            floatingView = view as LinearLayout;

            int width = 200;
            var floatingNotificationWidth = TypedValue.ApplyDimension(ComplexUnitType.Dip, width, Resources.DisplayMetrics); //To fit all screen sizes.

            WindowManagerLayoutParams layoutParams = new WindowManagerLayoutParams
            {
                Width   = (int)floatingNotificationWidth,
                Height  = ViewGroup.LayoutParams.WrapContent,
                Type    = layoutType,
                Flags   = WindowManagerFlags.NotFocusable,                            //If you are using it on immersive apps, this will avoid that app from losing the Immersive mode.
                Format  = Format.Translucent,
                Gravity = GravityFlags.CenterHorizontal | GravityFlags.CenterVertical //Location of the view.
            };

            windowManager.AddView(floatingView, layoutParams);
        }
        private void Add_more_device_Click(object sender, EventArgs e)
        {
            // create a WebView
            WebView webView = new WebView(Context);

            // populate the WebView with an HTML string
            webView.LoadUrl("file:///android_asset/" + Context.GetString(Resource.String.add_more_device_html));

            webView.SetWebViewClient(new MyWebViewClient(Context));

            FrameLayout container = new FrameLayout(Context);
            var         @params   = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            webView.LayoutParameters = @params;
            container.AddView(webView);

            // create an AlertDialog.Builder
            AlertDialog.Builder builder = new AlertDialog.Builder(Context);

            // set the WebView as the AlertDialog.Builder’s view
            builder.SetView(container);

            var dialog = builder.Show();

            WindowManagerLayoutParams layoutParams = new WindowManagerLayoutParams();

            layoutParams.CopyFrom(dialog.Window.Attributes);
            layoutParams.Width       = WindowManagerLayoutParams.MatchParent;
            layoutParams.Height      = WindowManagerLayoutParams.MatchParent;
            dialog.Window.Attributes = layoutParams;

            dialog.Show();
        }
        //Metodo principal en el cual se creara el servicio y pintaremos nuestro imageview sobre la ventana
        public override void OnCreate()
        {
            base.OnCreate();



            windowManager = GetSystemService("window").JavaCast <IWindowManager>();

            chatHead = new ImageView(this);

            chatHead.SetImageResource(Resource.Drawable.IcNotificationClearAll);

            chatHead.SetOnTouchListener(this);

            param = new WindowManagerLayoutParams(
                WindowManagerLayoutParams.WrapContent,
                WindowManagerLayoutParams.WrapContent,
                WindowManagerTypes.Phone,
                WindowManagerFlags.NotFocusable
                | WindowManagerFlags.NotTouchModal
                | WindowManagerFlags.WatchOutsideTouch
                | WindowManagerFlags.LayoutNoLimits,
                Format.Translucent);

            param.Gravity = GravityFlags.Top | GravityFlags.Left;

            param.X = 0;

            param.Y = 100;

            windowManager.AddView(chatHead, param);
        }
Beispiel #8
0
        protected override void OnStart()
        {
            base.OnStart();

            var param = new WindowManagerLayoutParams(
                WindowManagerLayoutParams.WrapContent,
                WindowManagerLayoutParams.WrapContent,
                WindowManagerTypes.DrawnApplication,
                WindowManagerFlags.NotFocusable | WindowManagerFlags.NotTouchable | WindowManagerFlags.NotTouchModal,
                Format.Translucent);


            var layout = LayoutInflater.Inflate(Resource.Layout.test, null);

            GetSystemService(WindowService).JavaCast <IWindowManager>().AddView(layout, param);
            var aaa = layout.FindViewById <TextView>(Resource.Id.textView1);

            FindViewById <Button>(Resource.Id.button1).Click += (sender, e) => {
                aaa.Text = (++cnt).ToString();
                if (cnt == 101)
                {
                    GetSystemService(WindowService).JavaCast <IWindowManager>().RemoveView(layout);
                }
            };
        }
        /// <summary>
        /// 设置弹出动画
        /// </summary>
        /// <returns></returns>
        protected virtual void SetDialogAnimation(WindowManagerLayoutParams attrs)
        {
            var dialogAnimateResId = this._context.Resources.GetIdentifier(_dialogConfig.DialogAnimationConfig, "style",
                                                                           _context.PackageName);

            attrs.WindowAnimations = dialogAnimateResId;
        }
Beispiel #10
0
        // Overridden from IAlertDialog.Builder
        public override AlertDialog Create()
        {
            View v = LayoutInflater.From(Context).Inflate(Resource.Layout.dialog_title, null, false);

            TextView titleView = v.FindViewById <TextView>(Resource.Id.title);
            View     closeView = v.FindViewById(Resource.Id.close);

            if (truncate)
            {
                titleView.SetSingleLine(true);
                titleView.Ellipsize = TextUtils.TruncateAt.End;
            }

            SetCustomTitle(v);
            titleView.Text = title;

            AlertDialog ret = base.Create();

            closeView.SetOnClickListener(new CloseDialogAction(ret));
            closeView.Visibility = (isCancelable) ? ViewStates.Visible : ViewStates.Gone;

            WindowManagerLayoutParams lp = new WindowManagerLayoutParams();

            lp.CopyFrom(ret.Window.Attributes);
            lp.Width = ViewGroup.LayoutParams.MatchParent;

            return(ret);
        }
Beispiel #11
0
		//Metodo principal en el cual se creara el servicio y pintaremos nuestro imageview sobre la ventana
		public override void OnCreate ()
		{
			base.OnCreate ();
			//incializaremos en windowmanager obteniendo el servicio directo de la ventan del sistema y haremos
			//un casting de tipo JavaCast<IWindowManager>
			windowManager = GetSystemService ("window").JavaCast<IWindowManager> ();
			//inicializaremos nuestro imageview dandole los atributos de nuestra clase para que obtenga los metodos
			//de touch
			chatHead = new ImageView(this);
			//definimos la imagen del imageview
			chatHead.SetImageResource (Resource.Drawable.ic_launcher);
			//Asignamos el listener del touch nuestra clase del tipo View.IOnTouchListener
			chatHead.SetOnTouchListener (this);
			//instanciamos los parametros que necesitamos para poder tomar la pantalla y asi poder mostrar nuestro imageview
			param = new WindowManagerLayoutParams(
				WindowManagerLayoutParams.WrapContent,
				WindowManagerLayoutParams.WrapContent,
				WindowManagerTypes.Phone,
				WindowManagerFlags.NotFocusable,
				Format.Translucent);
			//Agregamos la propiedad de gravedad en la parte de arriba hacia la izquieda
			param.Gravity = GravityFlags.Top | GravityFlags.Left;
			//Asignamos la posicion X del imageview
			param.X = 0;
			//Asignamos la posicion Y del imageview
			param.Y = 100;
			//Agregamos una vista a la ventana del sistema con nuestro imageview y los parametros generados
			windowManager.AddView (chatHead, param);
		}
        public override void OnCreate()
        {
            base.OnCreate();

            mFloatingView = LayoutInflater.From(this).Inflate(Resource.Layout.floating_widget, null, false);

            var layoutParams = new WindowManagerLayoutParams(
                ViewGroup.LayoutParams.WrapContent,
                ViewGroup.LayoutParams.WrapContent,
                WindowManagerTypes.Phone,
                WindowManagerFlags.NotFocusable,
                Format.Translucent
                );


            mWindowManager = GetSystemService(WindowService).JavaCast <IWindowManager>();
            mWindowManager.AddView(mFloatingView, layoutParams);

            collapsedView = mFloatingView.FindViewById(Resource.Id.floating_widget_layout_collapsed);
            expandedView  = mFloatingView.FindViewById(Resource.Id.floating_widget_layout_expanded);

            var collapseButton = expandedView.FindViewById <RelativeLayout>(Resource.Id.widget_collapse_button);

            collapseButton.SetOnClickListener(this);

            var touchListener = new FloatingWidgetTouchListener(mWindowManager, mFloatingView, collapsedView, expandedView);

            mFloatingView.FindViewById(Resource.Id.floating_widget_layout).SetOnTouchListener(touchListener);
        }
Beispiel #13
0
        /**
         * 设置Flyme4+的darkMode,darkMode时候字体颜色及icon变黑
         * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI
         */
        public static bool darkModeForFlyme4(Window window, bool dark)
        {
            bool result = false;

            if (window != null)
            {
                try {
                    WindowManagerLayoutParams e = window.Attributes;
                    Field darkFlag   = e.Class.GetDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
                    Field meizuFlags = e.Class.GetDeclaredField("meizuFlags");
                    darkFlag.Accessible   = true;
                    meizuFlags.Accessible = true;
                    int bit   = darkFlag.GetInt(null);
                    int value = meizuFlags.GetInt(e);
                    if (dark)
                    {
                        value |= bit;
                    }
                    else
                    {
                        value &= ~bit;
                    }

                    meizuFlags.SetInt(e, value);
                    window.Attributes = e;
                    result            = true;
                } catch (Java.Lang.Exception var8) {
                    Log.Error("StatusBar", "darkIcon: failed");
                }
            }

            return(result);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.Extra_BeSmart_AdvancedSearch_DialogFragment, null, false);

            Dialog.Window.RequestFeature(WindowFeatures.NoTitle);

            RelativeLayout Container = v.FindViewById <RelativeLayout>(Resource.Id.relativeLayout2);
            TextView       CategoriePrimara_TView   = v.FindViewById <TextView>(Resource.Id.textView1);
            TextView       CategorieSecundara_TView = v.FindViewById <TextView>(Resource.Id.textView2);
            TextView       Firma_TView      = v.FindViewById <TextView>(Resource.Id.textView3);
            TextView       NumeProdus_TView = v.FindViewById <TextView>(Resource.Id.textView4);
            TextView       Cauta_TView      = v.FindViewById <TextView>(Resource.Id.textView5);

            SetTypeface.Normal.SetTypeFace(Activity, CategoriePrimara_TView);
            SetTypeface.Normal.SetTypeFace(Activity, CategorieSecundara_TView);
            SetTypeface.Normal.SetTypeFace(Activity, Firma_TView);
            SetTypeface.Normal.SetTypeFace(Activity, NumeProdus_TView);
            SetTypeface.Normal.SetTypeFace(Activity, Cauta_TView);

            WindowManagerLayoutParams lp = new WindowManagerLayoutParams();

            lp.CopyFrom(Dialog.Window.Attributes);
            lp.Height = Container.LayoutParameters.Height;
            lp.Width  = Container.LayoutParameters.Width;

            Dialog.Show();

            Dialog.Window.Attributes = lp;

            return(v);
        }
        public override void OnCreate()
        {
            base.OnCreate();

            floatingView                 = LayoutInflater.From(this).Inflate(Resource.Layout.floatingWidget, null);
            closeFloatingView            = LayoutInflater.From(this).Inflate(Resource.Layout.closeWidget, null);
            closeFloatingView.Visibility = ViewStates.Invisible;

            SetTouchListener();

            closeLayoutParams = new WindowManagerLayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                              ViewGroup.LayoutParams.WrapContent,
                                                              WindowManagerTypes.ApplicationOverlay,
                                                              WindowManagerFlags.NotFocusable,
                                                              Format.Translucent)
            {
                Gravity = GravityFlags.Center
            };

            windowManager = GetSystemService(WindowService).JavaCast <IWindowManager>();
            windowManager.AddView(closeFloatingView, closeLayoutParams);

            layoutParams = new WindowManagerLayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                         ViewGroup.LayoutParams.WrapContent,
                                                         WindowManagerTypes.ApplicationOverlay,
                                                         WindowManagerFlags.NotFocusable,
                                                         Format.Translucent)
            {
                Gravity = GravityFlags.Left | GravityFlags.Top
            };

            windowManager.AddView(floatingView, layoutParams);

            SetCenter();
        }
Beispiel #16
0
        public TurnOnOffScreen(Window window)
        {
            m_Window = window;
            WindowManagerFlags screenFlags = WindowManagerFlags.ShowWhenLocked | WindowManagerFlags.TurnScreenOn | WindowManagerFlags.KeepScreenOn | WindowManagerFlags.DismissKeyguard;

            m_TurnOff = new ExecuteAction(() =>
            {
                try
                {
                    m_Window.AddFlags(screenFlags);
                    var attributes = new WindowManagerLayoutParams();
                    attributes.CopyFrom(m_Window.Attributes);
                    attributes.ScreenBrightness = 0f;
                    m_Window.Attributes         = attributes;
                }
                catch
                {
                }
            });
            m_TurnOn = new ExecuteAction(() =>
            {
                try
                {
                    m_Window.ClearFlags(screenFlags);
                    var attributes = new WindowManagerLayoutParams();
                    attributes.CopyFrom(m_Window.Attributes);
                    attributes.ScreenBrightness = -1f;
                    m_Window.Attributes         = attributes;
                }
                catch
                {
                }
            });
        }
Beispiel #17
0
        public override void OnStart()
        {
            base.OnStart();

            Rect frame = new Rect();

            Activity.Window.DecorView.GetWindowVisibleDisplayFrame(frame);

            WindowManagerLayoutParams lp = Dialog.Window.Attributes;

            Dialog.Window.SetGravity(GravityFlags.Bottom | GravityFlags.CenterHorizontal);

            lp.DimAmount = 0;
            lp.Width     = Utility.dpToPx(this.Activity, frame.Right - 300);         // 600;
            //lp.X = 25;
            //lp.Y = frame.Top;
            lp.Height = Utility.dpToPx(this.Activity, 150);

            Dialog.Window.Attributes = lp;

            Dialog.Window.AddFlags(WindowManagerFlags.DimBehind);

            _txtNota.Text = _nota.Testo;
            _txtNota.RequestFocus();

            Dialog.Window.SetSoftInputMode(SoftInput.StateAlwaysVisible);

            //Dialog.Window.SetLayout(240, 300);
            //Dialog.Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent));
        }
Beispiel #18
0
        private void lighton()
        {
            WindowManagerLayoutParams lp = mActivity.Window.Attributes;

            lp.Alpha = 1.0f;
            mActivity.Window.Attributes = (lp);
        }
Beispiel #19
0
 //Metodo principal en el cual se creara el servicio y pintaremos nuestro imageview sobre la ventana
 public override void OnCreate()
 {
     base.OnCreate();
     //incializaremos en windowmanager obteniendo el servicio directo de la ventan del sistema y haremos
     //un casting de tipo JavaCast<IWindowManager>
     windowManager = GetSystemService("window").JavaCast <IWindowManager> ();
     //inicializaremos nuestro imageview dandole los atributos de nuestra clase para que obtenga los metodos
     //de touch
     chatHead = new ImageView(this);
     //definimos la imagen del imageview
     chatHead.SetImageResource(Resource.Drawable.ic_launcher);
     //Asignamos el listener del touch nuestra clase del tipo View.IOnTouchListener
     chatHead.SetOnTouchListener(this);
     //instanciamos los parametros que necesitamos para poder tomar la pantalla y asi poder mostrar nuestro imageview
     param = new WindowManagerLayoutParams(
         WindowManagerLayoutParams.WrapContent,
         WindowManagerLayoutParams.WrapContent,
         WindowManagerTypes.Phone,
         WindowManagerFlags.NotFocusable,
         Format.Translucent);
     //Agregamos la propiedad de gravedad en la parte de arriba hacia la izquieda
     param.Gravity = GravityFlags.Top | GravityFlags.Left;
     //Asignamos la posicion X del imageview
     param.X = 0;
     //Asignamos la posicion Y del imageview
     param.Y = 100;
     //Agregamos una vista a la ventana del sistema con nuestro imageview y los parametros generados
     windowManager.AddView(chatHead, param);
 }
        public override void OnWindowAttributesChanged(WindowManagerLayoutParams @params)
        {
            //if(@params.Flags.HasFlag(WindowManagerFlags.LayoutNoLimits))
            //	return;

            base.OnWindowAttributesChanged(@params);
        }
        private void lightoff()
        {
            WindowManagerLayoutParams lp = mActivity.Window.Attributes;

            lp.Alpha = 0.3f;
            mActivity.Window.Attributes = lp;
        }
 private static bool setMeizuStatusBarFont(Activity activity, bool darkFont)
 {
     try
     {
         WindowManagerLayoutParams lp = activity.Window.Attributes;
         var darkFlag   = Java.Lang.Class.FromType(typeof(WindowManagerLayoutParams)).GetField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
         var meizuFlags = Java.Lang.Class.FromType(typeof(WindowManagerLayoutParams)).GetField("meizuFlags");
         darkFlag.Accessible   = true;
         meizuFlags.Accessible = true;
         int bit   = darkFlag.GetInt(null);
         int value = meizuFlags.GetInt(lp);
         if (darkFont)
         {
             value |= bit;
         }
         else
         {
             value &= ~bit;
         }
         meizuFlags.SetInt(lp, value);
         activity.Window.Attributes = lp;
         return(true);
     }
     catch (Exception)
     {
     }
     return(false);
 }
Beispiel #23
0
        private void resizeDialog()
        {
            WindowManagerLayoutParams _params = Window.Attributes;

            _params.Width     = (int)(DisplayUtil.getScreenSize(_context).X * 0.7);
            Window.Attributes = _params;
        }
        public override void OnWindowAttributesChanged(WindowManagerLayoutParams @params)
        {
            base.OnWindowAttributesChanged(@params);

            if (Xamarin.Forms.Application.Current == null || Xamarin.Forms.Application.Current.MainPage == null)
            {
                return;
            }

            // sync between Window flag and Forms property
            if (@params.Flags.HasFlag(WindowManagerFlags.Fullscreen))
            {
                if (Forms.TitleBarVisibility != AndroidTitleBarVisibility.Never)
                {
                    Forms.TitleBarVisibility = AndroidTitleBarVisibility.Never;
                }
            }
            else
            {
                if (Forms.TitleBarVisibility != AndroidTitleBarVisibility.Default)
                {
                    Forms.TitleBarVisibility = AndroidTitleBarVisibility.Default;
                }
            }
        }
Beispiel #25
0
        public object ShowProgress()
        {
            var  top  = Mvx.Resolve <IMvxAndroidCurrentTopActivity>();
            var  act  = top.Activity;
            View view = act.LayoutInflater.Inflate(Resource.Layout.ProgressView, null);

            AlertDialog.Builder builder = new AlertDialog.Builder(act);
            builder.SetCancelable(false);
            builder.SetView(view);

            AlertDialog dialog = builder.Create();

            dialog.Show();
            Window window = dialog.Window;

            if (window != null)
            {
                WindowManagerLayoutParams layoutParams = new WindowManagerLayoutParams();
                layoutParams.CopyFrom(dialog.Window.Attributes);
                layoutParams.Width       = ViewGroup.LayoutParams.WrapContent;
                layoutParams.Height      = ViewGroup.LayoutParams.WrapContent;
                dialog.Window.Attributes = layoutParams;
                Drawable drawable = new ColorDrawable(Android.Graphics.Color.Transparent);
                dialog.Window.SetBackgroundDrawable(drawable);
            }

            return(dialog);
        }
        public void DisplayInvisibleLayout() //Muestra el layout invisible para los eventos outside TOUCH
        {
            transparentLayout = new LinearLayout(this);

            _action = DisplayAdvertising;

            StartTimer();

            transparentLayout.Touch += (s, e) =>
            {
                StartTimer();
            };

            _param = new WindowManagerLayoutParams( //layout params de la vista "invisible" solo para el evento touch
                1,
                1,
                WindowManagerTypes.Phone,
                WindowManagerFlags.NotFocusable |
                WindowManagerFlags.NotTouchModal |
                WindowManagerFlags.WatchOutsideTouch,
                Format.Transparent);
            _param.Gravity = GravityFlags.Top | GravityFlags.Left;

            if (_advertisingView != null)
            {
                _windowManager.RemoveViewImmediate(_advertisingView);
                mVideoView.Suspend();
            }
            _windowManager.AddView(transparentLayout, _param);
        }
        /// <summary>
        /// OverrayするViewの描写範囲設定とフォントサイズを設定し描写
        /// </summary>
        public void OverrayViewReSet()
        {
            // カスタムViewにアダプターをセット(フォントの大きさ変更のため)
            customMemoAdapter = new CustomMemoAdapter(this, customViewItem, getFontSize());
            listView.Adapter  = customMemoAdapter;

            // 描写位置決定のため画面サイズを取得
            var psize = new Android.Graphics.Point();

            WindowManager.DefaultDisplay.GetSize(psize);

            // 重ね合わせる画面を指定
            param = new WindowManagerLayoutParams(
                (int)(psize.X * 0.8),
                (int)(psize.Y * 0.9),
                WindowManagerTypes.ApplicationOverlay, // タッチ操作ありのため
                WindowManagerFlags.Fullscreen,         //フルスクリーン表示
                Android.Graphics.Format.Translucent    //半透明
                )
            {
                Gravity = GravityFlags.Top
            };

            // Viewを画面上に重ね合わせする
            WindowManager.AddView(view, param);
            // オーバーレイViewの存在フラグを立てる
            _isViewPresenceCheck = true;
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			mRemoveWindow = delegate { RemoveWindow (); };

			// Use an existing ListAdapter that will map an array
			// of strings to TextViews
			ListAdapter = new ArrayAdapter<string> (this,Android.Resource.Layout.SimpleListItem1, mStrings);

			ListView.Scroll += OnListScroll;

			LayoutInflater inflate = (LayoutInflater)GetSystemService (Context.LayoutInflaterService);

			mDialogText = (TextView) inflate.Inflate (Resource.Layout.list_position, null);
			mDialogText.Visibility = ViewStates.Invisible;

			mHandler.Post (() => {
				mReady = true;
				var lp = new WindowManagerLayoutParams (
					WindowManagerLayoutParams.WrapContent, WindowManagerLayoutParams.WrapContent,
					WindowManagerTypes.Application,
					WindowManagerFlags.NotTouchable
					| WindowManagerFlags.NotFocusable,
					Format.Translucent);

				WindowManager.AddView (mDialogText, lp);
			});
		}
        private void Start()
        {
            _floatingView = LayoutInflater.From(this).Inflate(Resource.Layout.layout_floating_widget, null);
            SetTouchListener();

            WindowManagerTypes managerType;

            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
            {
                managerType = WindowManagerTypes.ApplicationOverlay;
            }
            else
            {
                managerType = WindowManagerTypes.Phone;
            }

            _layoutParams = new WindowManagerLayoutParams(
                ViewGroup.LayoutParams.WrapContent,
                ViewGroup.LayoutParams.WrapContent,
                managerType,
                WindowManagerFlags.NotFocusable,
                Format.Translucent)
            {
                Gravity = GravityFlags.Left | GravityFlags.Center
            };

            _windowManager = GetSystemService(WindowService).JavaCast <IWindowManager>();
            _windowManager.AddView(_floatingView, _layoutParams);
            //_expandedContainer = _floatingView.FindViewById(Resource.Id.flyout);
            txtSpeed = _floatingView.FindViewById(Resource.Id.txtSpeed) as TextView;
            txtKmh   = _floatingView.FindViewById(Resource.Id.txtKmh) as TextView;
        }
Beispiel #30
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.Organizator_Trip_ViewQuestionPool_DialogAdapter, null, false);

            Dialog.Window.RequestFeature(WindowFeatures.NoTitle);

            RelativeLayout Frame          = v.FindViewById <RelativeLayout>(Resource.Id.relativeLayout2);
            ListView       ListaIntrebari = v.FindViewById <ListView>(Resource.Id.listView1);
            ListView       ListaVariante  = v.FindViewById <ListView>(Resource.Id.listView2);

            ListaIntrebari.Adapter = new Organizator_Trip_ViewQuestionPool_Adapters.Organizator_Trip_ViewQuestionPool_ListaIntrebari_Adapter(Activity, ListaVariante, Votes);

            WindowManagerLayoutParams lp = new WindowManagerLayoutParams();

            lp.CopyFrom(Dialog.Window.Attributes);
            lp.Height = Frame.LayoutParameters.Height;
            lp.Width  = Frame.LayoutParameters.Width;
            lp.Alpha  = 0.8f;

            Dialog.SetCanceledOnTouchOutside(true);
            Dialog.Show();

            Dialog.Window.Attributes = lp;
            return(v);
        }
Beispiel #31
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="flags">显示黑屏:true,  关闭黑屏:false</param>
        void FloatWindow(bool flags)
        {
            MainThread.BeginInvokeOnMainThread(() =>
            {
                if (floatButton == null)
                {
                    WindowManagerLayoutParams layoutParams = new WindowManagerLayoutParams();
                    // 判断当前Android系统版本
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
                    {
                        layoutParams.Type = WindowManagerTypes.ApplicationOverlay;
                    }
                    else
                    {
                        layoutParams.Type = WindowManagerTypes.Application;
                    }
                    layoutParams.Format  = Format.Rgba8888;
                    layoutParams.Gravity = GravityFlags.Left | GravityFlags.Top;
                    layoutParams.Flags   = WindowManagerFlags.NotTouchModal | WindowManagerFlags.NotFocusable | WindowManagerFlags.Fullscreen;
                    // 窗口的宽高和位置
                    DisplayMetrics dm = new DisplayMetrics();
                    WindowManager.DefaultDisplay.GetMetrics(dm);
                    layoutParams.Width  = dm.WidthPixels;
                    layoutParams.Height = dm.HeightPixels;
                    layoutParams.X      = 0;
                    layoutParams.Y      = 0;
                    // 生成一个按钮
                    floatButton = new Button(this.ApplicationContext);
                    // floatButton.Text =
                    floatButton.Text = System.DateTime.Now.ToString("HH:mm:ss");
                    floatButton.SetTextSize(ComplexUnitType.Sp, 200);
                    floatButton.SetBackgroundColor(Color.Black);
                    floatButton.SetTextColor(Color.White);
                    // floatButton.Visibility = ViewStates.Invisible;
                    floatButton.Click += (s, e) =>
                    {
                        floatButton.Visibility = ViewStates.Invisible;
                        Settings.System.PutInt(this.ContentResolver, Settings.System.ScreenBrightness, 200);
                    };
                    WindowManager.AddView(floatButton, layoutParams);

                    Timer timer = new Timer((state) =>
                    {
                        MainThread.BeginInvokeOnMainThread(() =>
                        {
                            if (floatButton.Visibility == ViewStates.Visible)
                            {
                                floatButton.Text = System.DateTime.Now.ToString("HH:mm:ss");
                            }
                        });
                    }, null, 0, 1000);
                }
                floatButton.Visibility = flags ? ViewStates.Visible : ViewStates.Invisible;
                if (flags)
                {
                    Settings.System.PutInt(this.ContentResolver, Settings.System.ScreenBrightness, 1);
                }
            });
        }
Beispiel #32
0
		public PopupView (Activity activity, IWindowManager WindowManager) : base (activity)
		{
			this.WindowManager = WindowManager;
			windowManagerLayoutParams = new WindowManagerLayoutParams ();
			windowManagerLayoutParams.Width = ViewGroup.LayoutParams.MatchParent;
			windowManagerLayoutParams.Height = ViewGroup.LayoutParams.MatchParent;
			windowManagerLayoutParams.Type = WindowManagerTypes.Application;
			windowManagerLayoutParams.Format = Format.Transparent;
		}
Beispiel #33
0
        public void Show()
        {
            var viewGroup = FormsViewHelper.ConvertFormsToNative(_popup, DisplayHelper.GetSize());
            _dialog.SetContentView(viewGroup);

            // to show dialog container 'fullscreen'
            WindowManagerLayoutParams lp = new WindowManagerLayoutParams();
            lp.CopyFrom(_dialog.Window.Attributes);
            lp.Width = ViewGroup.LayoutParams.MatchParent;
            lp.Height = ViewGroup.LayoutParams.MatchParent;
            _dialog.Window.SetBackgroundDrawable(new ColorDrawable(Android.Graphics.Color.Transparent));
            _dialog.Window.SetSoftInputMode(SoftInput.StateVisible);
            _dialog.Show();
            _dialog.Window.Attributes = lp;
        }
        public MaterialDialog(Builder builder)
            : base(builder.Context, DialogInit.GetTheme(builder))
        {
            mHandler = new Handler();
            MBuilder = builder;
            LayoutInflater inflater = LayoutInflater.From(builder.Context);
            view = (MDRootLayout)inflater.Inflate(DialogInit.GetInflateLayout(builder), null);
            DialogInit.Init(this);

            if (builder.Context.Resources.GetBoolean(Resource.Boolean.sino_droid_md_is_tablet))
            {
                WindowManagerLayoutParams lp = new WindowManagerLayoutParams();
                lp.CopyFrom(Window.Attributes);
                lp.Width = builder.Context.Resources.GetDimensionPixelSize(Resource.Dimension.sino_droid_md_default_dialog_width);
                Window.Attributes = lp;
            }
        }
		public async Task Show(TopAlert alert)
		{
			await Stop ();

			this._Token = new CancellationTokenSource ();

			this._Delay = alert.Duration;

			var activity = Xamarin.Forms.Forms.Context as Android.App.Activity;
			IWindowManager windowManager = Xamarin.Forms.Forms.Context.GetSystemService(Android.App.Service.WindowService).JavaCast<IWindowManager>();
			this._Layout = (LinearLayout)activity.LayoutInflater.Inflate(Resource.Layout.AlertBox, null, false);
			this._Layout.LayoutParameters = new ViewGroup.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

			var submain = this._Layout.FindViewById<LinearLayout> (Resource.Id.linearLayout3);
			submain.SetBackgroundColor (alert.BackgroundColor.ToAndroid());

			var main = _Layout.FindViewById<LinearLayout> (Resource.Id.linearLayout1);

			var id = Xamarin.Forms.Forms.Context.Resources.GetIdentifier ("alertborder", "drawable", Xamarin.Forms.Forms.Context.PackageName);
			Android.Graphics.Drawables.GradientDrawable drawable = 
				Xamarin.Forms.Forms.Context.Resources.GetDrawable (id).JavaCast<Android.Graphics.Drawables.GradientDrawable>();


			var text = submain.FindViewById<TextView> (Resource.Id.textView1);
			text.SetTextColor (alert.TextColor.ToAndroid ());
			text.Text = alert.Text;

			if (alert.TextSize > 0) {
				text.TextSize = alert.TextSize;
			}

			drawable.SetColor (alert.BorderColor.ToAndroid ());
			drawable.SetCornerRadius (alert.BorderWidth);
			main.SetBackground (drawable);

			//activity.ActionBar.Hide ();

			var actionBarHeight = activity.ActionBar.Height;

			var intent = alert.Intent;

			var p = new WindowManagerLayoutParams (
				windowManager.DefaultDisplay.Width - intent * 2,
				(alert.AlertHeight < 0 ? 200 : (int)alert.AlertHeight),
				WindowManagerTypes.SystemAlert,
				0 | WindowManagerFlags.NotFocusable,
				Android.Graphics.Format.Translucent);

			var yOffset = alert.TopOffset;
			p.Gravity = GravityFlags.Top | GravityFlags.Left;
			p.X = intent;
			p.Y = alert.TopOffset + yOffset + (activity.ActionBar.IsShowing ? actionBarHeight : 0);
			p.Height = (alert.AlertHeight < 0 ? 200 : (int)alert.AlertHeight);
			windowManager.AddView (_Layout, p);

			this._Layout.Touch += LayoutTouched;

			Task.Run (async() => {

				await Task.Delay(alert.Duration, this._Token.Token);

				if (this._Token != null && this._Token.IsCancellationRequested == false)
				{
					if(alert.FadeOut)
					{
						Xamarin.Forms.Device.BeginInvokeOnMainThread( () => {
							// this works
							this._fadeOut = ObjectAnimator.OfFloat(_Layout, "alpha", 1f, 0f);
							this._fadeOut.SetDuration(1000);
							this._fadeOut.AnimationEnd += _fadeOut_AnimationEnd;
							this._Set = new AnimatorSet();
							this._Set.Play(_fadeOut);
							this._Set.Start();
						});
					}
					else
					{
						Stop();
					}
				}
			});
		}
        private void StartDrag(int childPosition, int y)
        {
            var item = GetChildAt(childPosition);

            if (null == item) return;

            var id = GetItemIdAtPosition(_startPosition);
            if (null != _dragNDropListener)
                _dragNDropListener.OnItemDrag(this, item, _startPosition, id);

            ((IDragNDropAdapter)Adapter).OnItemDrag(this, item, _startPosition, id);

            if (null != ItemDrag)
                ItemDrag(new DragNDropListViewDragEventArgs{Id = id, ListView = this, View = item, Position = _startPosition});

            item.DrawingCacheEnabled = true;

            using (var bitmap = Bitmap.CreateBitmap(item.DrawingCache))
            {
                var windowParams = new WindowManagerLayoutParams
                    {
                        Gravity = GravityFlags.Top,
                        X = 0,
                        Y = y - _dragPointOffset,
                        Height = ViewGroup.LayoutParams.WrapContent,
                        Width = ViewGroup.LayoutParams.WrapContent,
                        Flags = WindowManagerFlags.NotFocusable
                                | WindowManagerFlags.NotTouchable
                                | WindowManagerFlags.KeepScreenOn
                                | WindowManagerFlags.LayoutInScreen
                                | WindowManagerFlags.LayoutNoLimits,
                        Format = Format.Translucent,
                        WindowAnimations = 0
                    };

                var v = new ImageView(Context);
                v.SetImageBitmap(bitmap);

                var windowManager = Context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>();
                windowManager.AddView(v, windowParams);
                DragView = v;

                item.Visibility = ViewStates.Invisible;
                item.Invalidate();
            }
        }
        private void CreateBallView()
        {
            this.FV = new FrameLayout(this);
            var shape = new OvalShape();
            var dr = new ShapeDrawable(shape);
            dr.Paint.Color = Color.WhiteSmoke;
            dr.Paint.Alpha = 100;
            this.FV.Background = dr;

            //������βü��
            //this.FV.SetClipChildren(true);
            //this.FV.SetClipToPadding(true);

            this.FV.SetOnTouchListener(this);
            this.FV.SetOnClickListener(this);

            var img = new ImageView(this);
            img.SetImageResource(Resource.Drawable.Icon);
            this.Img = img;//������ FreameLayout ��������

            this.FV.AddView(img);
            var param = new WindowManagerLayoutParams();
            param.Width = WindowManagerLayoutParams.WrapContent;
            param.Height = WindowManagerLayoutParams.WrapContent;

            //������������Ӧ���� ԭ�㣬 ������ó�����ֵ�� �϶���ʱ��λ�û��д��
            param.Gravity = GravityFlags.Top | GravityFlags.Left;
            param.Flags = WindowManagerFlags.NotFocusable;

            //�������ã� ��Ȼ���� WindowManager.AddView ��ʱ�򱨴��
            param.Type = WindowManagerTypes.Phone;
            param.Format = Android.Graphics.Format.Transparent;

            this.WindowManager.AddView(this.FV, param);
        }