Example #1
0
 private void init(android.view.View decor)
 {
     mContext    = decor.getContext();
     mActionView = ([email protected])decor.findViewById([email protected]
                                                                              .id.action_bar);
     mContextView = ([email protected])decor.findViewById(
         [email protected]_context_bar);
     mContainerView = ([email protected])decor.findViewById(
         [email protected]_bar_container);
     mSplitView = ([email protected])decor.findViewById([email protected]
                                                                                  .id.split_action_bar);
     if (mActionView == null || mContextView == null || mContainerView == null)
     {
         throw new System.InvalidOperationException(GetType().Name + " can only be used "
                                                    + "with a compatible window decor layout");
     }
     mActionView.setContextView(mContextView);
     mContextDisplayMode = mActionView.isSplitActionBar() ? CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL;
     // Older apps get the home button interaction enabled by default.
     // Newer apps need to enable it explicitly.
     setHomeButtonEnabled(mContext.getApplicationInfo().targetSdkVersion < android.os.Build
                          .VERSION_CODES.ICE_CREAM_SANDWICH);
     setHasEmbeddedTabs(mContext.getResources().getBoolean([email protected][email protected]_bar_embed_tabs
                                                           ));
 }
Example #2
0
 /// <summary>Constructor</summary>
 /// <param name="bounds">
 /// Bounds in local coordinates of the containing view that should be mapped to
 /// the delegate view
 /// </param>
 /// <param name="delegateView">The view that should receive motion events</param>
 public TouchDelegate(android.graphics.Rect bounds, android.view.View delegateView
                      )
 {
     mBounds = bounds;
     mSlop   = android.view.ViewConfiguration.get(delegateView.getContext()).getScaledTouchSlop
                   ();
     mSlopBounds = new android.graphics.Rect(bounds);
     mSlopBounds.inset(-mSlop, -mSlop);
     mDelegateView = delegateView;
 }
Example #3
0
 /// <summary>
 /// Constructor for the
 /// <see cref="ZoomButtonsController">ZoomButtonsController</see>
 /// .
 /// </summary>
 /// <param name="ownerView">
 /// The view that is being zoomed by the zoom controls. The
 /// zoom controls will be displayed aligned with this view.
 /// </param>
 public ZoomButtonsController(android.view.View ownerView)
 {
     mConfigurationChangedReceiver = new _BroadcastReceiver_150(this);
     mHandler       = new _Handler_170(this);
     mContext       = ownerView.getContext();
     mWindowManager = (android.view.WindowManager)mContext.getSystemService(android.content.Context
                                                                            .WINDOW_SERVICE);
     mOwnerView            = ownerView;
     mTouchPaddingScaledSq = (int)(ZOOM_CONTROLS_TOUCH_PADDING * mContext.getResources
                                       ().getDisplayMetrics().density);
     mTouchPaddingScaledSq *= mTouchPaddingScaledSq;
     mContainer             = createContainer();
 }
Example #4
0
        private bool showCharacterPicker(android.view.View view, android.text.Editable content
                                         , char c, bool insert, int count)
        {
            string set = PICKER_SETS.get(c);

            if (set == null)
            {
                return(false);
            }
            if (count == 1)
            {
                new android.text.method.CharacterPickerDialog(view.getContext(), view, content, set
                                                              , insert).show();
            }
            return(true);
        }
Example #5
0
 internal void trySendAccessibilityEvent()
 {
     android.view.accessibility.AccessibilityManager accessibilityManager = android.view.accessibility.AccessibilityManager
                                                                            .getInstance(mView.getContext());
     if (!accessibilityManager.isEnabled())
     {
         return;
     }
     // treat toasts as notifications since they are used to
     // announce a transient piece of information to the user
     android.view.accessibility.AccessibilityEvent @event = android.view.accessibility.AccessibilityEvent
                                                            .obtain(android.view.accessibility.AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED
                                                                    );
     @event.setClassName(java.lang.CharSequenceProxy.Wrap(GetType().FullName));
     @event.setPackageName(java.lang.CharSequenceProxy.Wrap(mView.getContext().getPackageName
                                                                ()));
     mView.dispatchPopulateAccessibilityEvent(@event);
     accessibilityManager.sendAccessibilityEvent(@event);
 }
Example #6
0
 internal virtual android.view.View removeViewLocked(int index)
 {
     android.view.ViewRootImpl root = mRoots[index];
     android.view.View         view = root.getView();
     // Don't really remove until we have matched all calls to add().
     root.mAddNesting--;
     if (root.mAddNesting > 0)
     {
         return(view);
     }
     if (view != null)
     {
         android.view.inputmethod.InputMethodManager imm = android.view.inputmethod.InputMethodManager
                                                           .getInstance(view.getContext());
         if (imm != null)
         {
             imm.windowDismissed(mViews[index].getWindowToken());
         }
     }
     root.die(false);
     finishRemoveViewLocked(view, index);
     return(view);
 }
Example #7
0
		/// <summary><p>Change the popup's content.</summary>
		/// <remarks>
		/// <p>Change the popup's content. The content is represented by an instance
		/// of
		/// <see cref="android.view.View">android.view.View</see>
		/// .</p>
		/// <p>This method has no effect if called when the popup is showing.</p>
		/// </remarks>
		/// <param name="contentView">the new content for the popup</param>
		/// <seealso cref="getContentView()">getContentView()</seealso>
		/// <seealso cref="isShowing()">isShowing()</seealso>
		public virtual void setContentView(android.view.View contentView)
		{
			if (isShowing())
			{
				return;
			}
			mContentView = contentView;
			if (mContext == null && mContentView != null)
			{
				mContext = mContentView.getContext();
			}
			if (mWindowManager == null && mContentView != null)
			{
				mWindowManager = (android.view.WindowManager)mContext.getSystemService(android.content.Context
					.WINDOW_SERVICE);
			}
		}
Example #8
0
 private void addView(android.view.View view, android.view.ViewGroup.LayoutParams
                      @params, android.view.CompatibilityInfoHolder cih, bool nest)
 {
     if (false)
     {
         android.util.Log.v("WindowManager", "addView view=" + view);
     }
     if (!(@params is android.view.WindowManagerClass.LayoutParams))
     {
         throw new System.ArgumentException("Params must be WindowManager.LayoutParams");
     }
     android.view.WindowManagerClass.LayoutParams wparams = (android.view.WindowManagerClass
                                                             .LayoutParams)@params;
     android.view.ViewRootImpl root;
     android.view.View         panelParentView = null;
     lock (this)
     {
         // Here's an odd/questionable case: if someone tries to add a
         // view multiple times, then we simply bump up a nesting count
         // and they need to remove the view the corresponding number of
         // times to have it actually removed from the window manager.
         // This is useful specifically for the notification manager,
         // which can continually add/remove the same view as a
         // notification gets updated.
         int index = findViewLocked(view, false);
         if (index >= 0)
         {
             if (!nest)
             {
                 throw new System.InvalidOperationException("View " + view + " has already been added to the window manager."
                                                            );
             }
             root = mRoots[index];
             root.mAddNesting++;
             // Update layout parameters.
             view.setLayoutParams(wparams);
             root.setLayoutParams(wparams, true);
             return;
         }
         // If this is a panel window, then find the window it is being
         // attached to for future reference.
         if (wparams.type >= android.view.WindowManagerClass.LayoutParams.FIRST_SUB_WINDOW &&
             wparams.type <= android.view.WindowManagerClass.LayoutParams.LAST_SUB_WINDOW)
         {
             int count = mViews != null ? mViews.Length : 0;
             {
                 for (int i = 0; i < count; i++)
                 {
                     if (mRoots[i].mWindow.asBinder() == wparams.token)
                     {
                         panelParentView = mViews[i];
                     }
                 }
             }
         }
         root             = new android.view.ViewRootImpl(view.getContext());
         root.mAddNesting = 1;
         if (cih == null)
         {
             root.mCompatibilityInfo = new android.view.CompatibilityInfoHolder();
         }
         else
         {
             root.mCompatibilityInfo = cih;
         }
         view.setLayoutParams(wparams);
         if (mViews == null)
         {
             index   = 1;
             mViews  = new android.view.View[1];
             mRoots  = new android.view.ViewRootImpl[1];
             mParams = new android.view.WindowManagerClass.LayoutParams[1];
         }
         else
         {
             index = mViews.Length + 1;
             object[] old = mViews;
             mViews = new android.view.View[index];
             System.Array.Copy(old, 0, mViews, 0, index - 1);
             old    = mRoots;
             mRoots = new android.view.ViewRootImpl[index];
             System.Array.Copy(old, 0, mRoots, 0, index - 1);
             old     = mParams;
             mParams = new android.view.WindowManagerClass.LayoutParams[index];
             System.Array.Copy(old, 0, mParams, 0, index - 1);
         }
         index--;
         mViews[index]  = view;
         mRoots[index]  = root;
         mParams[index] = wparams;
     }
     // do this last because it fires off messages to start doing things
     root.setView(view, wparams, panelParentView);
 }
Example #9
0
        public override bool onKeyDown(android.view.View view, android.text.Editable content
                                       , int keyCode, android.view.KeyEvent @event)
        {
            int selStart;
            int selEnd;
            int pref = 0;

            if (view != null)
            {
                pref = android.text.method.TextKeyListener.getInstance().getPrefs(view.getContext
                                                                                      ());
            }
            {
                int a = android.text.Selection.getSelectionStart(content);
                int b = android.text.Selection.getSelectionEnd(content);
                selStart = System.Math.Min(a, b);
                selEnd   = System.Math.Max(a, b);
                if (selStart < 0 || selEnd < 0)
                {
                    selStart = selEnd = 0;
                    android.text.Selection.setSelection(content, 0, 0);
                }
            }
            int activeStart = content.getSpanStart(android.text.method.TextKeyListener.ACTIVE
                                                   );
            int activeEnd = content.getSpanEnd(android.text.method.TextKeyListener.ACTIVE);
            // QWERTY keyboard normal case
            int i = @event.getUnicodeChar(@event.getMetaState() | getMetaState(content));

            if (!mFullKeyboard)
            {
                int count = @event.getRepeatCount();
                if (count > 0 && selStart == selEnd && selStart > 0)
                {
                    char c = content[selStart - 1];
                    if (c == i || c == Sharpen.CharHelper.ToUpper(i) && view != null)
                    {
                        if (showCharacterPicker(view, content, c, false, count))
                        {
                            resetMetaState(content);
                            return(true);
                        }
                    }
                }
            }
            if (i == android.view.KeyCharacterMap.PICKER_DIALOG_INPUT)
            {
                if (view != null)
                {
                    showCharacterPicker(view, content, android.view.KeyCharacterMap.PICKER_DIALOG_INPUT
                                        , true, 1);
                }
                resetMetaState(content);
                return(true);
            }
            if (i == android.view.KeyCharacterMap.HEX_INPUT)
            {
                int start;
                if (selStart == selEnd)
                {
                    start = selEnd;
                    while (start > 0 && selEnd - start < 4 && Sharpen.CharHelper.Digit(content[start
                                                                                               - 1], 16) >= 0)
                    {
                        start--;
                    }
                }
                else
                {
                    start = selStart;
                }
                int ch = -1;
                try
                {
                    string hex = android.text.TextUtils.substring(content, start, selEnd);
                    ch = System.Convert.ToInt32(hex, 16);
                }
                catch (System.ArgumentException)
                {
                }
                if (ch >= 0)
                {
                    selStart = start;
                    android.text.Selection.setSelection(content, selStart, selEnd);
                    i = ch;
                }
                else
                {
                    i = 0;
                }
            }
            if (i != 0)
            {
                bool dead = false;
                if ((i & android.view.KeyCharacterMap.COMBINING_ACCENT) != 0)
                {
                    dead = true;
                    i    = i & android.view.KeyCharacterMap.COMBINING_ACCENT_MASK;
                }
                if (activeStart == selStart && activeEnd == selEnd)
                {
                    bool replace = false;
                    if (selEnd - selStart - 1 == 0)
                    {
                        char accent   = content[selStart];
                        int  composed = android.view.KeyEvent.getDeadChar(accent, i);
                        if (composed != 0)
                        {
                            i       = composed;
                            replace = true;
                        }
                    }
                    if (!replace)
                    {
                        android.text.Selection.setSelection(content, selEnd);
                        content.removeSpan(android.text.method.TextKeyListener.ACTIVE);
                        selStart = selEnd;
                    }
                }
                if ((pref & android.text.method.TextKeyListener.AUTO_CAP) != 0 && Sharpen.CharHelper.IsLower
                        (i) && android.text.method.TextKeyListener.shouldCap(mAutoCap, content, selStart
                                                                             ))
                {
                    int where = content.getSpanEnd(android.text.method.TextKeyListener.CAPPED);
                    int flags = content.getSpanFlags(android.text.method.TextKeyListener.CAPPED);
                    if (where == selStart && (((flags >> 16) & unchecked ((int)(0xFFFF))) == i))
                    {
                        content.removeSpan(android.text.method.TextKeyListener.CAPPED);
                    }
                    else
                    {
                        flags = i << 16;
                        i     = Sharpen.CharHelper.ToUpper(i);
                        if (selStart == 0)
                        {
                            content.setSpan(android.text.method.TextKeyListener.CAPPED, 0, 0, android.text.SpannedClass.SPAN_MARK_MARK
                                            | flags);
                        }
                        else
                        {
                            content.setSpan(android.text.method.TextKeyListener.CAPPED, selStart - 1, selStart
                                            , android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE | flags);
                        }
                    }
                }
                if (selStart != selEnd)
                {
                    android.text.Selection.setSelection(content, selEnd);
                }
                content.setSpan(OLD_SEL_START, selStart, selStart, android.text.SpannedClass.SPAN_MARK_MARK
                                );
                content.replace(selStart, selEnd, java.lang.CharSequenceProxy.Wrap(((char)i).ToString
                                                                                       ()));
                int oldStart = content.getSpanStart(OLD_SEL_START);
                selEnd = android.text.Selection.getSelectionEnd(content);
                if (oldStart < selEnd)
                {
                    content.setSpan(android.text.method.TextKeyListener.LAST_TYPED, oldStart, selEnd,
                                    android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE);
                    if (dead)
                    {
                        android.text.Selection.setSelection(content, oldStart, selEnd);
                        content.setSpan(android.text.method.TextKeyListener.ACTIVE, oldStart, selEnd, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE
                                        );
                    }
                }
                adjustMetaAfterKeypress(content);
                // potentially do autotext replacement if the character
                // that was typed was an autotext terminator
                if ((pref & android.text.method.TextKeyListener.AUTO_TEXT) != 0 && mAutoText && (
                        i == ' ' || i == '\t' || i == '\n' || i == ',' || i == '.' || i == '!' || i == '?' ||
                        i == '"' || Sharpen.CharHelper.GetType(i) == Sharpen.CharHelper.END_PUNCTUATION
                        ) && content.getSpanEnd(android.text.method.TextKeyListener.INHIBIT_REPLACEMENT)
                    != oldStart)
                {
                    int x;
                    for (x = oldStart; x > 0; x--)
                    {
                        char c = content[x - 1];
                        if (c != '\'' && !System.Char.IsLetter(c))
                        {
                            break;
                        }
                    }
                    string rep = getReplacement(content, x, oldStart, view);
                    if (rep != null)
                    {
                        android.text.method.QwertyKeyListener.Replaced[] repl = content.getSpans <android.text.method.QwertyKeyListener
                                                                                                  .Replaced>(0, content.Length);
                        {
                            for (int a = 0; a < repl.Length; a++)
                            {
                                content.removeSpan(repl[a]);
                            }
                        }
                        char[] orig = new char[oldStart - x];
                        android.text.TextUtils.getChars(content, x, oldStart, orig, 0);
                        content.setSpan(new android.text.method.QwertyKeyListener.Replaced(orig), x, oldStart
                                        , android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE);
                        content.replace(x, oldStart, java.lang.CharSequenceProxy.Wrap(rep));
                    }
                }
                // Replace two spaces by a period and a space.
                if ((pref & android.text.method.TextKeyListener.AUTO_PERIOD) != 0 && mAutoText)
                {
                    selEnd = android.text.Selection.getSelectionEnd(content);
                    if (selEnd - 3 >= 0)
                    {
                        if (content[selEnd - 1] == ' ' && content[selEnd - 2] == ' ')
                        {
                            char c = content[selEnd - 3];
                            {
                                for (int j = selEnd - 3; j > 0; j--)
                                {
                                    if (c == '"' || Sharpen.CharHelper.GetType(c) == Sharpen.CharHelper.END_PUNCTUATION)
                                    {
                                        c = content[j - 1];
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                            if (System.Char.IsLetter(c) || System.Char.IsDigit(c))
                            {
                                content.replace(selEnd - 2, selEnd - 1, java.lang.CharSequenceProxy.Wrap("."));
                            }
                        }
                    }
                }
                return(true);
            }
            else
            {
                if (keyCode == android.view.KeyEvent.KEYCODE_DEL && (@event.hasNoModifiers() || @event
                                                                     .hasModifiers(android.view.KeyEvent.META_ALT_ON)) && selStart == selEnd)
                {
                    // special backspace case for undoing autotext
                    int consider = 1;
                    // if backspacing over the last typed character,
                    // it undoes the autotext prior to that character
                    // (unless the character typed was newline, in which
                    // case this behavior would be confusing)
                    if (content.getSpanEnd(android.text.method.TextKeyListener.LAST_TYPED) == selStart)
                    {
                        if (content[selStart - 1] != '\n')
                        {
                            consider = 2;
                        }
                    }
                    android.text.method.QwertyKeyListener.Replaced[] repl = content.getSpans <android.text.method.QwertyKeyListener
                                                                                              .Replaced>(selStart - consider, selStart);
                    if (repl.Length > 0)
                    {
                        int    st  = content.getSpanStart(repl[0]);
                        int    en  = content.getSpanEnd(repl[0]);
                        string old = new string(repl[0].mText);
                        content.removeSpan(repl[0]);
                        // only cancel the autocomplete if the cursor is at the end of
                        // the replaced span (or after it, because the user is
                        // backspacing over the space after the word, not the word
                        // itself).
                        if (selStart >= en)
                        {
                            content.setSpan(android.text.method.TextKeyListener.INHIBIT_REPLACEMENT, en, en,
                                            android.text.SpannedClass.SPAN_POINT_POINT);
                            content.replace(st, en, java.lang.CharSequenceProxy.Wrap(old));
                            en = content.getSpanStart(android.text.method.TextKeyListener.INHIBIT_REPLACEMENT
                                                      );
                            if (en - 1 >= 0)
                            {
                                content.setSpan(android.text.method.TextKeyListener.INHIBIT_REPLACEMENT, en - 1,
                                                en, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE);
                            }
                            else
                            {
                                content.removeSpan(android.text.method.TextKeyListener.INHIBIT_REPLACEMENT);
                            }
                            adjustMetaAfterKeypress(content);
                        }
                        else
                        {
                            adjustMetaAfterKeypress(content);
                            return(base.onKeyDown(view, content, keyCode, @event));
                        }
                        return(true);
                    }
                }
            }
            return(base.onKeyDown(view, content, keyCode, @event));
        }