Пример #1
0
 public void HandleSoftKeyboardShwon(bool shown, int newHeight)
 {
     if (shown)
     {
         _toolbarLayout.Visibility = Android.Views.ViewStates.Visible;
         int widthSpec  = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
         int heightSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
         _toolbarLayout.Measure(widthSpec, heightSpec);
         int toolbarHeight    = _toolbarLayout.MeasuredHeight == 0 ? (int)(ToolbarFixHeight * Resources.DisplayMetrics.Density) : _toolbarLayout.MeasuredHeight;
         int topToolbarHeight = _topToolBar.MeasuredHeight == 0 ? (int)(ToolbarFixHeight * Resources.DisplayMetrics.Density) : _topToolBar.MeasuredHeight;
         int editorHeight     = newHeight - toolbarHeight - topToolbarHeight;
         _editorWebView.LayoutParameters.Height = editorHeight;
         _editorWebView.LayoutParameters.Width  = LinearLayout.LayoutParams.MatchParent;
         _editorWebView.RequestLayout();
     }
     else
     {
         if (newHeight != 0)
         {
             _toolbarLayout.Visibility       = Android.Views.ViewStates.Invisible;
             _editorWebView.LayoutParameters = new LinearLayout.LayoutParams(-1, -1);
             ;
         }
     }
 }
Пример #2
0
        void CollepseAnimation(LinearLayout content)
        {
            if (content.Visibility.Equals(ViewStates.Gone))
            {
                content.Visibility = ViewStates.Visible;

                int widthSpec  = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                int heightSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                content.Measure(widthSpec, heightSpec);

                ValueAnimator mAnimator = slideAnimator(0, content.MeasuredHeight, content);
                mAnimator.Start();
            }
            else
            {
                int finalHeight = content.Height;

                ValueAnimator mAnimator = slideAnimator(finalHeight, 0, content);
                mAnimator.Start();
                mAnimator.AnimationEnd += (object IntentSender, EventArgs arg) =>
                {
                    content.Visibility = ViewStates.Gone;
                };
            }
        }
Пример #3
0
        /**
         * Creates an icon with the current content and style.
         * <p/>
         * This method is useful if a custom view has previously been set, or if text content is not
         * applicable.
         */

        public Bitmap MakeIcon()
        {
            int measureSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);

            mContainer.Measure(measureSpec, measureSpec);

            int measuredWidth  = mContainer.MeasuredWidth;
            int measuredHeight = mContainer.MeasuredHeight;

            mContainer.Layout(0, 0, measuredWidth, measuredHeight);

            Bitmap r = Bitmap.CreateBitmap(measuredWidth, measuredHeight, Bitmap.Config.Argb8888);

            r.EraseColor(Color.Transparent);

            Canvas canvas = new Canvas(r);

            canvas.DrawColor(Color.White, PorterDuff.Mode.SrcIn);
            Drawable drawable = mContainer.Background;

            if (drawable != null)
            {
                drawable.Draw(canvas);
            }
            mContainer.Draw(canvas);
            return(r);
        }
Пример #4
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);
            var msw = Android.Views.View.MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
            var msh = Android.Views.View.MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

            layout.Measure(msw, msh);
            layout.Layout(0, 0, r - l, b - t);
        }
Пример #5
0
 /// <summary>
 /// Called when this view should assign a size and position to all of its children.
 /// <para> A Caveat of this is that always measure this based on the root most of the layout. in this case, linearlayout.
 /// For example, in the parent class, we did the measure on viewpager itself since it is the rootmost of the class</para>
 /// </summary>
 /// <param name="changed">if set to <c>true</c> This will be the new size or position for this view.</param>
 /// <param name="l">Left position, relative to parent.</param>
 /// <param name="t">Top position, relative to parent.</param>
 /// <param name="r">Right position, relative to parent.</param>
 /// <param name="b">Bottom position, relative to parent.</param>
 protected override void OnLayout(bool changed, int l, int t, int r, int b)
 {
     base.OnLayout(changed, l, t, r, b);
     if (linearLayout == null)
     {
         return;
     }
     linearLayout.Measure(MakeMeasureSpec(r - l, MeasureSpecMode.Exactly), MakeMeasureSpec(b - t, MeasureSpecMode.Exactly));
     linearLayout.Layout(0, 0, r - l, b - t);
 }
        void InitView()
        {
            NotchLayout = new LinearLayout(Container.Context);
            NotchLayout.LayoutParameters = new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.MatchParent);


            var button = new Android.Widget.Button(Container.Context);

            button.Text = "Notch";

            var page = Element as Page;

            if (NotchInfo.Model == PhoneModels.Custom)
            {
                Device = NotchInfo.CustomDevice;
            }
            else
            {
                Device = Devices[NotchInfo.Model];
            }


            var notch = new NotchView(Container.Context)
            {
                Device = Device
            };

            NotchLayout.AddView(notch);
            Container.AddView(NotchLayout);

            NotchLayout.Parent.BringChildToFront(NotchLayout);


            Container.LayoutChange += (sender, e) =>
            {
                if (NotchLayout != null)
                {
                    var msw = MeasureSpec.MakeMeasureSpec(e.Right, MeasureSpecMode.Exactly);
                    var msh = MeasureSpec.MakeMeasureSpec(e.Bottom, MeasureSpecMode.Exactly);

                    NotchLayout.Measure(msw, msh);
                    NotchLayout.Layout(0, 0, e.Right, e.Bottom);

                    NotchLayout.Parent.BringChildToFront(NotchLayout);
                }
            };
        }
Пример #7
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            if (_androidLinearLayout != null)
            {
                var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
                var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

                _androidLinearLayout.Measure(msw, msh);
                _androidLinearLayout.Layout(0, 0, r - l, b - t);
                if (webView != null)
                {
                    webView.Measure(msw, msh);
                    webView.Layout(0, (int)toolbarHeight, r - l, b - t);
                }
            }
        }
Пример #8
0
        public PackageRow(Context context)
            : base(context)
        {
            SetBackgroundColor(Color.Rgb(240, 240, 240));

            Orientation = Orientation.Horizontal;

            textContainer = new LinearLayout(context);
            textContainer.Orientation = Orientation.Vertical;

            AddView(textContainer);

            buttonContainer = new LinearLayout(context);
            AddView(buttonContainer);

            int height = context.Resources.DisplayMetrics.HeightPixels / 10;
            LayoutParameters = new AbsListView.LayoutParams(LayoutParams.MatchParent, height);

            textContainer.LayoutParameters = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 7);
            buttonContainer.LayoutParameters = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 3);

            nameLabel = new TextView(context);
            nameLabel.SetTextColor(Color.Black);
            nameLabel.Gravity = Android.Views.GravityFlags.CenterVertical;
            nameLabel.Typeface = Typeface.Create("Helvetica Neue", TypefaceStyle.Normal);
            nameLabel.SetTextSize(Android.Util.ComplexUnitType.Dip, 16);
            textContainer.AddView(nameLabel);

            statusLabel = new TextView(context);
            statusLabel.SetTextColor(Color.DarkGray);
            statusLabel.Gravity = Android.Views.GravityFlags.Top;
            statusLabel.Typeface = Typeface.Create("Helvetica Neue", TypefaceStyle.Normal);

            textContainer.AddView(statusLabel);

            Button = new PMButton(context);
            buttonContainer.AddView(Button);

            buttonContainer.Measure(0, 0);

            padding = buttonContainer.MeasuredHeight / 3;

            Button.LayoutParameters = GetButtonParams(padding);
        }
Пример #9
0
        public PackageRow(Context context) : base(context)
        {
            SetBackgroundColor(Color.Rgb(240, 240, 240));

            Orientation = Orientation.Horizontal;

            textContainer             = new LinearLayout(context);
            textContainer.Orientation = Orientation.Vertical;

            AddView(textContainer);

            buttonContainer = new LinearLayout(context);
            AddView(buttonContainer);

            int height = context.Resources.DisplayMetrics.HeightPixels / 10;

            LayoutParameters = new AbsListView.LayoutParams(LayoutParams.MatchParent, height);

            textContainer.LayoutParameters   = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 7);
            buttonContainer.LayoutParameters = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 3);

            nameLabel = new TextView(context);
            nameLabel.SetTextColor(Color.Black);
            nameLabel.Gravity  = Android.Views.GravityFlags.CenterVertical;
            nameLabel.Typeface = Typeface.Create("Helvetica Neue", TypefaceStyle.Normal);
            nameLabel.SetTextSize(Android.Util.ComplexUnitType.Dip, 16);
            textContainer.AddView(nameLabel);

            statusLabel = new TextView(context);
            statusLabel.SetTextColor(Color.DarkGray);
            statusLabel.Gravity  = Android.Views.GravityFlags.Top;
            statusLabel.Typeface = Typeface.Create("Helvetica Neue", TypefaceStyle.Normal);

            textContainer.AddView(statusLabel);

            Button = new PMButton(context);
            buttonContainer.AddView(Button);

            buttonContainer.Measure(0, 0);

            padding = buttonContainer.MeasuredHeight / 3;

            Button.LayoutParameters = GetButtonParams(padding);
        }
Пример #10
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            Context context = Context;
            int     width   = r - l;
            int     height  = b - t;

            rootView.Measure(AppCompat.MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.AtMost), AppCompat.MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.AtMost));

            if (width > 0 && height > 0)
            {
                if (Element.HasSearchBar)
                {
                    PageController.ContainerArea = new Rectangle(0, 0, context.FromPixels(width), context.FromPixels(height - searchContainer.MeasuredHeight));
                }
                else
                {
                    PageController.ContainerArea = new Rectangle(0, 0, context.FromPixels(width), context.FromPixels(height));
                }
                rootView.Layout(0, 0, width, b);
            }

            base.OnLayout(changed, l, t, r, b);
        }
Пример #11
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            int width  = r - l;
            int height = b - t;

            if (width > 0 && height > 0)
            {
                var context = Context;
                _rootLayout.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.AtMost), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.AtMost));
                _rootLayout.Layout(0, 0, _rootLayout.MeasuredWidth, _rootLayout.MeasuredHeight);

                _bottomBar.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.AtMost));
                int tabsHeight = BottomBarHeight.HasValue ? (int)Context.ToPixels(BottomBarHeight.Value) : Math.Min(height, Math.Max(_bottomBar.MeasuredHeight, _bottomBar.MinimumHeight));

                _frameLayout.Layout(0, 0, width, height - tabsHeight);

                _pageController.ContainerArea = new Rectangle(0, 0, context.FromPixels(width), context.FromPixels(_frameLayout.Height));

                _bottomBar.Layout(0, height - tabsHeight, width, height);
            }

            base.OnLayout(changed, l, t, r, b);
        }
Пример #12
0
        private void OverlayPromptToAutofill(AccessibilityNodeInfo root, AccessibilityEvent e)
        {
            if (!AccessibilityHelpers.OverlayPermitted())
            {
                System.Diagnostics.Debug.WriteLine(">>> Overlay Permission not granted");
                Toast.MakeText(this, AppResources.AccessibilityOverlayPermissionAlert, ToastLength.Long).Show();
                return;
            }

            if (_overlayView != null || _anchorNode != null || _overlayAnchorObserverRunning)
            {
                CancelOverlayPrompt();
            }

            if (Java.Lang.JavaSystem.CurrentTimeMillis() - _lastAutoFillTime < 1000)
            {
                return;
            }

            var uri = AccessibilityHelpers.GetUri(root);

            if (string.IsNullOrWhiteSpace(uri))
            {
                return;
            }

            var intent = new Intent(this, typeof(AccessibilityActivity));

            intent.PutExtra("uri", uri);
            intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop | ActivityFlags.ClearTop);

            _overlayView = AccessibilityHelpers.GetOverlayView(this);
            _overlayView.Measure(View.MeasureSpec.MakeMeasureSpec(0, 0),
                                 View.MeasureSpec.MakeMeasureSpec(0, 0));
            _overlayViewHeight  = _overlayView.MeasuredHeight;
            _overlayView.Click += (sender, eventArgs) =>
            {
                CancelOverlayPrompt();
                StartActivity(intent);
            };

            var layoutParams   = AccessibilityHelpers.GetOverlayLayoutParams();
            var anchorPosition = AccessibilityHelpers.GetOverlayAnchorPosition(e.Source, _overlayViewHeight,
                                                                               _isOverlayAboveAnchor);

            layoutParams.X = anchorPosition.X;
            layoutParams.Y = anchorPosition.Y;

            if (_windowManager == null)
            {
                _windowManager = GetSystemService(WindowService).JavaCast <IWindowManager>();
            }

            _anchorNode  = e.Source;
            _lastAnchorX = anchorPosition.X;
            _lastAnchorY = anchorPosition.Y;

            _windowManager.AddView(_overlayView, layoutParams);

            System.Diagnostics.Debug.WriteLine(">>> Accessibility Overlay View Added at X:{0} Y:{1}",
                                               layoutParams.X, layoutParams.Y);

            StartOverlayAnchorObserver();
        }
        private void OverlayPromptToAutofill(AccessibilityNodeInfo root, AccessibilityEvent e)
        {
            if (Java.Lang.JavaSystem.CurrentTimeMillis() - _lastAutoFillTime < 1000 ||
                AccessibilityHelpers.IsAutofillServicePromptVisible(Windows))
            {
                return;
            }

            if (!AccessibilityHelpers.OverlayPermitted())
            {
                if (!AccessibilityHelpers.IsAutofillTileAdded)
                {
                    // The user has the option of only using the autofill tile and leaving the overlay permission
                    // disabled, so only show this toast if they're using accessibility without overlay permission and
                    // have _not_ added the autofill tile
                    System.Diagnostics.Debug.WriteLine(">>> Overlay Permission not granted");
                    Toast.MakeText(this, AppResources.AccessibilityOverlayPermissionAlert, ToastLength.Long).Show();
                }
                return;
            }

            if (_overlayView != null || _anchorNode != null || _overlayAnchorObserverRunning)
            {
                CancelOverlayPrompt();
            }

            var uri      = AccessibilityHelpers.GetUri(root);
            var fillable = !string.IsNullOrWhiteSpace(uri);

            if (fillable)
            {
                if (_blacklistedUris != null && _blacklistedUris.Any())
                {
                    if (Uri.TryCreate(uri, UriKind.Absolute, out var parsedUri) && parsedUri.Scheme.StartsWith("http"))
                    {
                        fillable = !_blacklistedUris.Contains(
                            string.Format("{0}://{1}", parsedUri.Scheme, parsedUri.Host));
                    }
                    else
                    {
                        fillable = !_blacklistedUris.Contains(uri);
                    }
                }
            }
            if (!fillable)
            {
                return;
            }

            var intent = new Intent(this, typeof(AccessibilityActivity));

            intent.PutExtra("uri", uri);
            intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop | ActivityFlags.ClearTop);

            _overlayView = AccessibilityHelpers.GetOverlayView(this);
            _overlayView.Measure(View.MeasureSpec.MakeMeasureSpec(0, 0),
                                 View.MeasureSpec.MakeMeasureSpec(0, 0));
            _overlayViewHeight  = _overlayView.MeasuredHeight;
            _overlayView.Click += (sender, eventArgs) =>
            {
                CancelOverlayPrompt();
                StartActivity(intent);
            };

            var layoutParams   = AccessibilityHelpers.GetOverlayLayoutParams();
            var anchorPosition = AccessibilityHelpers.GetOverlayAnchorPosition(this, e.Source,
                                                                               _overlayViewHeight, _isOverlayAboveAnchor);

            layoutParams.X = anchorPosition.X;
            layoutParams.Y = anchorPosition.Y;

            if (_windowManager == null)
            {
                _windowManager = GetSystemService(WindowService).JavaCast <IWindowManager>();
            }

            _anchorNode  = e.Source;
            _lastAnchorX = anchorPosition.X;
            _lastAnchorY = anchorPosition.Y;

            _windowManager.AddView(_overlayView, layoutParams);

            System.Diagnostics.Debug.WriteLine(">>> Accessibility Overlay View Added at X:{0} Y:{1}",
                                               layoutParams.X, layoutParams.Y);

            StartOverlayAnchorObserver();
        }
        public virtual void show(View anchor, List <object> line, int wordNum, int showX, bool redraw)
        {
            try
            {
                this.showX = showX;

                if (redraw)
                {
                    this.dismiss();
                }

                if (line != null)
                {
                    this.line                 = line;
                    this.wordIndex            = wordNum;
                    this.entry                = (int)line[wordNum];
                    splitButton.Visibility    = ViewStates.Visible;
                    bookmarkButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    this.entry                = wordNum;
                    splitButton.Visibility    = ViewStates.Gone;
                    bookmarkButton.Visibility = ViewStates.Gone;
                }

                string sTrad = Dict.GetCh(entry, "traditional");
                string sSimp = Dict.GetCh(entry, "simplified");

                SpannableStringBuilder text = new SpannableStringBuilder();

                if (sSimp.Length > 1)
                {
                    List <object> subWords = BreakWord(sSimp);
                    foreach (object word in subWords)
                    {
                        if (word is int)
                        { //was found
                            string ch = Dict.GetCh((int)word, "simplified");
                            text.Append(ch).Append(new Java.Lang.String(" "));
                            WordSpan clickable = new WordSpan(this);
                            clickable.link = ch;
                            text.SetSpan(clickable, text.Length() - ch.Length - 1, text.Length() - 1, SpanTypes.User);
                        }
                        else
                        {
                            text.Append((string)word).Append(new Java.Lang.String(" "));
                        }
                    }
                }
                else
                {
                    text.Append(sSimp).Append(new Java.Lang.String(" "));
                    text.SetSpan(new AbsoluteSizeSpan(24, true), text.Length() - sSimp.Length - 1, text.Length() - 1, SpanTypes.User);
                    splitButton.Visibility = ViewStates.Gone;
                }

                if (!sTrad.Equals(sSimp))
                {
                    text.Append(sTrad);
                }

                mChars.SetText(text, TextView.BufferType.Spannable);

                text.Clear();
                string pinyin = Dict.PinyinToTones(Dict.GetPinyin(entry));
                text.Append("[ ").Append(new Java.Lang.String(pinyin)).Append(new Java.Lang.String(" ]  "));

                appendInlineButtons(text, pinyin);

                text.Append("\n");

                string[] parts = Regex.Split(Regex.Replace(Dict.GetEnglish(entry), @"/", "\n• "), @"\\$");

                int i = 0;
                foreach (string s in parts)
                {
                    if (i++ % 2 == 1)
                    {
                        pinyin = Dict.PinyinToTones(s);
                        text.Append("\n\n[ ").Append(new Java.Lang.String(pinyin)).Append(new Java.Lang.String(" ]  "));
                        appendInlineButtons(text, pinyin);
                        text.Append("\n");
                    }
                    else
                    {
                        text.Append("• ");

                        int beforeAppended = text.Length();

                        int bracketIndex, bracketEnd = 0;
                        while ((bracketIndex = s.IndexOf("[", bracketEnd, StringComparison.Ordinal)) > -1)
                        {
                            text.Append(s, bracketEnd, bracketIndex);
                            bracketEnd = s.IndexOf("]", bracketIndex);
                            text.Append(Dict.PinyinToTones(s.SubstringSpecial(bracketIndex, bracketEnd)));
                        }

                        text.Append(s, bracketEnd, s.Length);

                        int afterAppended = text.Length();

                        for (int m = beforeAppended; m < afterAppended; m++)
                        {
                            if (text.CharAt(m) >= '\u25CB' && text.CharAt(m) <= '\u9FA5')
                            {
                                int n = m + 1;
                                while (n < text.Length() && text.CharAt(n) >= '\u25CB' && text.CharAt(n) <= '\u9FA5')
                                {
                                    n++;
                                }

                                WordSpan clickable = new WordSpan(this);
                                clickable.link = text.SubSequence(m, n - m).ToString();
                                text.SetSpan(clickable, m, n, SpanTypes.User);
                            }
                        }
                    }
                }

                mContent.SetText(text, TextView.BufferType.Spannable);

                LinearLayout bookmarkTitleLayout = (LinearLayout)mRootView.FindViewById(Resource.Id.bookmark);
                if (mContext.annoMode != AnnotationActivity.ANNOTATE_FILE)
                {
                    bookmarkButton.Visibility      = ViewStates.Gone;
                    bookmarkTitleLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    int  lineNum      = mContext.lines.IndexOf(line);
                    long bookmarkPos  = mContext.GetPosition(mContext.lines, lineNum + 1, wordIndex, true);
                    int  bookmarksPos = Bookmark.SearchClosest(bookmarkPos, mContext.mBookmarks);
                    bool isBookmarked = mContext.mBookmarks.Count > bookmarksPos && mContext.mBookmarks[bookmarksPos].mPosition == bookmarkPos;

                    ToggleBookmark(bookmarkButton, isBookmarked);

                    if (isBookmarked)
                    {
                        bookmarkTitleLayout.Visibility = ViewStates.Visible;
                        ((TextView)mRootView.FindViewById(Resource.Id.bookmarkTitle)).Text = mContext.mBookmarks[bookmarksPos].mTitle;
                    }
                    else
                    {
                        bookmarkTitleLayout.Visibility = ViewStates.Gone;
                    }
                }

                ToggleStar(null, AnnotationActivity.sharedPrefs.GetString("stars", "").StartsWith(Dict.GetCh(entry, "simplified") + "\n") || AnnotationActivity.sharedPrefs.GetString("stars", "").Contains("\n" + Dict.GetCh(entry, "simplified") + "\n"));

                this.parent = anchor;

                float xPos = 0, yPos = 0, arrowPos;

                int[] location = new int[2];

                anchor.GetLocationOnScreen(location);

                Rect anchorRect = new Rect(location[0], location[1], location[0] + anchor.Width, location[1] + anchor.Height);

                if (redraw)
                {
                    mWindow.ShowAtLocation(anchor, GravityFlags.NoGravity, 0, 0);
                }
                mBubble.Measure(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

                float rootHeight = mBubble.MeasuredHeight;
                float rootWidth  = mBubble.MeasuredWidth;

                xPos = showX - (rootWidth / 2);

                if ((xPos + rootWidth) > screenX)
                {
                    xPos = screenX - rootWidth;
                }
                else if (xPos < 0)
                {
                    xPos = 0;
                }

                arrowPos = showX - xPos;

                float dyTop    = anchorRect.Top - 60 * scale;
                float dyBottom = screenY - anchorRect.Bottom - 20 * scale;

                bool onTop = dyBottom <rootHeight && dyTop> dyBottom;

                if (onTop)
                {
                    if (rootHeight + 20 * scale > dyTop)
                    {
                        yPos       = 60 * scale;
                        rootHeight = anchorRect.Top - yPos - 20 * scale;
                    }
                    else
                    {
                        yPos = anchorRect.Top - rootHeight - 20 * scale;
                    }
                }
                else
                {
                    yPos = anchorRect.Bottom;

                    if (rootHeight > dyBottom)
                    {
                        rootHeight = dyBottom;
                    }
                }

                showArrow((onTop ? Resource.Id.arrow_down : Resource.Id.arrow_up), arrowPos, rootWidth);

                mWindow.Update((int)Math.Round(xPos), (int)Math.Round(yPos), (int)Math.Round(rootWidth), (int)Math.Round(rootHeight + 21 * scale));
                mScroll.FullScroll(FocusSearchDirection.Up);
            }
            catch (Exception e)
            {
                Toast.MakeText(mContext, "Error: " + e.Message, ToastLength.Long).Show();
            }
        }
Пример #15
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.detalle, container, false);

            Button btnRegistroDatos = view.FindViewById <Button>(Resource.Id.btnRegistrarDatos);

            expandable = view.FindViewById <LinearLayout>(Resource.Id.linearLayoutFillData);

            //Definicion de los diferentes espacios de texto a mostrar
            mExpediente            = view.FindViewById <TextView>(Resource.Id.txtExpediente);
            mSector                = view.FindViewById <TextView>(Resource.Id.txtSector);
            mFormaNotificacion     = view.FindViewById <TextView>(Resource.Id.txtFormaNotificacion);
            mProvincia             = view.FindViewById <TextView>(Resource.Id.txtProvincia);
            mCanton                = view.FindViewById <TextView>(Resource.Id.txtCanton);
            mDistrito              = view.FindViewById <TextView>(Resource.Id.textDistrito);
            mDireccion             = view.FindViewById <TextView>(Resource.Id.txtDireccion);
            mCopias                = view.FindViewById <TextView>(Resource.Id.txtCopias);
            mOficial               = view.FindViewById <TextView>(Resource.Id.txtOficialNombreDatos);
            mFechaNotificacion     = view.FindViewById <TextView>(Resource.Id.txtFechaNotificacion);
            mresultadoNotificacion = view.FindViewById <TextView>(Resource.Id.txtResultadoNotificacion);
            mFechaResolucion       = view.FindViewById <TextView>(Resource.Id.txtFechaResolucion);
            mDespacho              = view.FindViewById <TextView>(Resource.Id.txtDespacho);
            mNotificando           = view.FindViewById <TextView>(Resource.Id.txtNotificandoNombre);
            mUrgente               = view.FindViewById <TextView>(Resource.Id.txtUrgente);
            mHorario               = view.FindViewById <TextView>(Resource.Id.txtHorario);

            Switch mSwitch = view.FindViewById <Switch>(Resource.Id.monitored_switch);

            mSwitch.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e)
            {
                mSwitch.Text = "Resultado " + (e.IsChecked ? "Positivo" : "Negativo");
            };
            expandable.Visibility   = ViewStates.Gone;
            btnRegistroDatos.Click += (s, e) =>
            {
                if (expandable.Visibility.Equals(ViewStates.Gone))
                {
                    expandable.Visibility = ViewStates.Visible;
                    int widthSpec  = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                    int heightSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);
                    expandable.Measure(widthSpec, heightSpec);
                    ValueAnimator mAnimator = slideAnimator(0, expandable.MeasuredHeight);
                    mAnimator.Start();
                }
                else
                {
                    int           finalHeight = expandable.Height;
                    ValueAnimator mAnimator   = slideAnimator(finalHeight, 0);
                    mAnimator.Start();
                    mAnimator.AnimationEnd += (object IntentSender, EventArgs arg) => {
                        expandable.Visibility = ViewStates.Gone;
                    };
                }
            };
            //
            if (!string.IsNullOrEmpty(codNotificacion))
            {
                string query = "SELECT * FROM Notificaciones WHERE CodigoNotificacion=" + codNotificacion + "";
                ManejoBaseDatos.Abrir();
                ICursor mCursor = ManejoBaseDatos.Seleccionar(query);
                if (mCursor.MoveToFirst())
                {
                    do
                    {
                        mExpediente.Text        = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Expediente"))) ? mCursor.GetString(mCursor.GetColumnIndex("Expediente")) : "");
                        mSector.Text            = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Sector"))) ? mCursor.GetString(mCursor.GetColumnIndex("Sector")) : "");
                        mProvincia.Text         = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Provincia"))) ? mCursor.GetString(mCursor.GetColumnIndex("Provincia")) : "");
                        mCanton.Text            = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Canton"))) ? mCursor.GetString(mCursor.GetColumnIndex("Canton")) : "");
                        mDireccion.Text         = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Direccion"))) ? mCursor.GetString(mCursor.GetColumnIndex("Direccion")) : "");
                        mSector.Text            = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Sector"))) ? "S-" + mCursor.GetString(mCursor.GetColumnIndex("Sector")) : "");
                        mDistrito.Text          = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Distrito"))) ? mCursor.GetString(mCursor.GetColumnIndex("Distrito")) : "");
                        mFechaResolucion.Text   = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("FechaDocumento"))) ? mCursor.GetString(mCursor.GetColumnIndex("FechaDocumento")) : "");
                        mDespacho.Text          = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("DespachoDescripcion"))) ? mCursor.GetString(mCursor.GetColumnIndex("DespachoDescripcion")) : "");
                        mNotificando.Text       = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Notificando"))) ? mCursor.GetString(mCursor.GetColumnIndex("Notificando")) : "");
                        mFormaNotificacion.Text = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Medio"))) ? mCursor.GetString(mCursor.GetColumnIndex("Medio")) : "");
                        mUrgente.Text           = (mCursor.GetString(mCursor.GetColumnIndex("Urgente")).Equals("True") || (mCursor.GetString(mCursor.GetColumnIndex("Urgente")).Equals("true")) ? "Sí" : "No");
                        mHorario.Text           = (!string.IsNullOrEmpty(mCursor.GetString(mCursor.GetColumnIndex("Medio"))) ? "Sí" : "No");
                    } while (mCursor.MoveToNext());
                }
                mCursor.Close();
                ManejoBaseDatos.Cerrar();
            }
            else
            {
                AlertDialog.Builder alerta = new AlertDialog.Builder(this.Context);
                alerta.SetTitle("Mensaje de alerta");
                alerta.SetIcon(Resource.Drawable.alertaNuevo);
                alerta.SetMessage("El usuario tiene una jornada abierta.");
                alerta.SetPositiveButton("Regresar", HandleButtonClick);
                //alerta.SetNegativeButton("Continuar", HandleButonContinuar);
                alerta.SetCancelable(false);
                alerta.Create();
                alerta.Show();
            }
            return(view);
        }
Пример #16
0
        /// <summary>
        /// Element Changed
        /// </summary>
        /// <param name="e"></param>
        protected override void OnElementChanged(ElementChangedEventArgs <ActionButton> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || this.Element == null)
            {
                return;
            }

            if (e.OldElement != null)
            {
                e.OldElement.PropertyChanged -= HandlePropertyChanged;
            }

            if (this.Element != null)
            {
                this.Element.PropertyChanged += HandlePropertyChanged;
            }

            Element.Show   = Show;
            Element.Hide   = Hide;
            Element.Margin = MARGIN;

            if (Element.Color != Color.Transparent)
            {
                Element.Content.Color = Element.Color;
            }

            SetFabSize(Element.Size);

            fab.BackgroundTintList = ColorStateList.ValueOf(Element.ButtonColor.ToAndroid());
            fab.RippleColor        = Element.ColorRipple.ToAndroid();
            fab.Click += Fab_Click;

            var frameLayout = new FrameLayout(Context);

            frameLayout.RemoveAllViews();
            var layout = new LinearLayout(Context);

            layout.Orientation = Android.Widget.Orientation.Horizontal;
            if (!string.IsNullOrWhiteSpace(Element.Tooltip))
            {
                var view = new TextView(Context);
                view.Text = Element.Tooltip;
                view.SetTextColor(Color.White.ToAndroid());
                view.SetBackgroundColor(Color.Black.MultiplyAlpha(0.5).ToAndroid());
                view.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent)
                {
                    Gravity = GravityFlags.CenterVertical | GravityFlags.CenterHorizontal,
                };
                view.SetPadding(10, 5, 10, 5);
                layout.AddView(view);
            }
            layout.AddView(fab);
            layout.Measure(AT_MOST, AT_MOST);
            frameLayout.AddView(layout);

            if (Element.Content != null)
            {
                var content = Platform.CreateRendererWithContext(Element.Content, Context).View;

                if (content is IConvertable bitmapContent)
                {
                    bitmapContent.SetSize(Element.Size);
                    var bmp      = bitmapContent.ToBitmap((int)Element.Width);
                    var drawable = new Android.Graphics.Drawables.BitmapDrawable(Resources, bmp);
                    fab.SetImageDrawable(drawable);
                }
            }
            SetNativeControl(frameLayout);
            //SetBackgroundColor(Color.Fuchsia.MultiplyAlpha(0.2).ToAndroid());
            //Layout(0, 0, fab.MeasuredWidth + MARGIN * 2, fab.MeasuredHeight + MARGIN * 2);
            Layout(0, 0, layout.MeasuredWidth, layout.MeasuredHeight);
        }