Exemple #1
0
		/// <summary>Construct an empty Toast object.</summary>
		/// <remarks>
		/// Construct an empty Toast object.  You must call
		/// <see cref="setView(android.view.View)">setView(android.view.View)</see>
		/// before you
		/// can call
		/// <see cref="show()">show()</see>
		/// .
		/// </remarks>
		/// <param name="context">
		/// The context to use.  Usually your
		/// <see cref="android.app.Application">android.app.Application</see>
		/// or
		/// <see cref="android.app.Activity">android.app.Activity</see>
		/// object.
		/// </param>
		public Toast(android.content.Context context)
		{
			mContext = context;
			mTN = new android.widget.Toast.TN();
			mTN.mY = context.getResources().getDimensionPixelSize([email protected]_y_offset
				);
		}
Exemple #2
0
		/// <summary>
		/// Loads an
		/// <see cref="Animation">Animation</see>
		/// object from a resource
		/// </summary>
		/// <param name="context">Application context used to access resources</param>
		/// <param name="id">The resource id of the animation to load</param>
		/// <returns>The animation object reference by the specified id</returns>
		/// <exception cref="android.content.res.Resources.NotFoundException">when the animation cannot be loaded
		/// 	</exception>
		public static android.view.animation.Animation loadAnimation(android.content.Context
			 context, int id)
		{
			android.content.res.XmlResourceParser parser = null;
			try
			{
				parser = context.getResources().getAnimation(id);
				return createAnimationFromXml(context, parser);
			}
			catch (org.xmlpull.v1.XmlPullParserException ex)
			{
				android.content.res.Resources.NotFoundException rnf = new android.content.res.Resources
					.NotFoundException("Can't load animation resource ID #0x" + Sharpen.Util.IntToHexString
					(id));
				rnf.InnerException = ex;
				throw rnf;
			}
			catch (System.IO.IOException ex)
			{
				android.content.res.Resources.NotFoundException rnf = new android.content.res.Resources
					.NotFoundException("Can't load animation resource ID #0x" + Sharpen.Util.IntToHexString
					(id));
				rnf.InnerException = ex;
				throw rnf;
			}
			finally
			{
				if (parser != null)
				{
					parser.close();
				}
			}
		}
		/// <summary>Creates a new configuration for the specified context.</summary>
		/// <remarks>
		/// Creates a new configuration for the specified context. The configuration depends on
		/// various parameters of the context, like the dimension of the display or the density
		/// of the display.
		/// </remarks>
		/// <param name="context">The application context used to initialize this view configuration.
		/// 	</param>
		/// <seealso cref="get(android.content.Context)"></seealso>
		/// <seealso cref="android.util.DisplayMetrics">android.util.DisplayMetrics</seealso>
		private ViewConfiguration (android.content.Context context)
		{
			android.content.res.Resources res = context.getResources ();
			android.util.DisplayMetrics metrics = res.getDisplayMetrics ();
			android.content.res.Configuration config = res.getConfiguration ();
			float density = metrics.density;
			float sizeAndDensity;
			if (config.isLayoutSizeAtLeast (android.content.res.Configuration.SCREENLAYOUT_SIZE_XLARGE))
				sizeAndDensity = density * 1.5f;
			else
				sizeAndDensity = density;
			mEdgeSlop = (int)(sizeAndDensity * EDGE_SLOP + 0.5f);
			mFadingEdgeLength = (int)(sizeAndDensity * FADING_EDGE_LENGTH + 0.5f);
			mMinimumFlingVelocity = (int)(density * MINIMUM_FLING_VELOCITY + 0.5f);
			mMaximumFlingVelocity = (int)(density * MAXIMUM_FLING_VELOCITY + 0.5f);
			mScrollbarSize = (int)(density * SCROLL_BAR_SIZE + 0.5f);
			mTouchSlop = (int)(sizeAndDensity * TOUCH_SLOP + 0.5f);
			mPagingTouchSlop = (int)(sizeAndDensity * PAGING_TOUCH_SLOP + 0.5f);
			mDoubleTapSlop = (int)(sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
			mScaledTouchExplorationTapSlop = (int)(density * TOUCH_EXPLORATION_TAP_SLOP + 0.5f
				);
			mWindowTouchSlop = (int)(sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
			// Size of the screen in bytes, in ARGB_8888 format
			mMaximumDrawingCacheSize = 4 * metrics.widthPixels * metrics.heightPixels;
			mOverscrollDistance = (int)(sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
			mOverflingDistance = (int)(sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
			mFadingMarqueeEnabled = false;
		}
		private void init(android.content.Context context)
		{
			android.content.res.Resources res = context.getResources();
			mShiftIcon = res.getDrawable([email protected]_keyboard_shift);
			mShiftLockIcon = res.getDrawable([email protected]_keyboard_shift_locked
				);
			sSpacebarVerticalCorrection = res.getDimensionPixelOffset([email protected]
				.password_keyboard_spacebar_vertical_correction);
		}
		public ActionMenuItemView(android.content.Context context, android.util.AttributeSet
			 attrs, int defStyle) : base(context, attrs, defStyle)
		{
			android.content.res.Resources res = context.getResources();
			mAllowTextWithIcon = res.getBoolean([email protected][email protected]_allowActionMenuItemTextWithIcon
				);
			mShowTextAllCaps = res.getBoolean([email protected][email protected]_actionMenuItemAllCaps
				);
		}
Exemple #6
0
		public ActionMenuView(android.content.Context context, android.util.AttributeSet 
			attrs) : base(context, attrs)
		{
			// dips
			// dips
			setBaselineAligned(false);
			float density = context.getResources().getDisplayMetrics().density;
			mMinCellSize = (int)(MIN_CELL_SIZE * density);
			mGeneratedItemPadding = (int)(GENERATED_ITEM_PADDING * density);
		}
Exemple #7
0
		public MenuPopupHelper(android.content.Context context, [email protected]
			 menu, android.view.View anchorView, bool overflowOnly)
		{
			mContext = context;
			mInflater = android.view.LayoutInflater.from(context);
			mMenu = menu;
			mOverflowOnly = overflowOnly;
			android.content.res.Resources res = context.getResources();
			mPopupMaxWidth = System.Math.Max(res.getDisplayMetrics().widthPixels / 2, res.getDimensionPixelSize
				([email protected]_prefDialogWidth));
			mAnchorView = anchorView;
			menu.addMenuPresenter(this);
		}
		// Size of the screen in bytes, in ARGB_8888 format
		/// <summary>Returns a configuration for the specified context.</summary>
		/// <remarks>
		/// Returns a configuration for the specified context. The configuration depends on
		/// various parameters of the context, like the dimension of the display or the
		/// density of the display.
		/// </remarks>
		/// <param name="context">The application context used to initialize the view configuration.
		/// 	</param>
		public static android.view.ViewConfiguration get(android.content.Context context)
		{
			android.util.DisplayMetrics metrics = context.getResources().getDisplayMetrics();
			int density = (int)(100.0f * metrics.density);
			android.view.ViewConfiguration configuration = sConfigurations.get(density);
			if (configuration == null)
			{
				configuration = new android.view.ViewConfiguration(context);
				sConfigurations.put(density, configuration);
			}
			return configuration;
		}
Exemple #9
0
		private AppWidgetManager(android.content.Context context)
		{
			mContext = context;
			mDisplayMetrics = context.getResources().getDisplayMetrics();
		}
Exemple #10
0
			internal static void initFromContext(android.content.Context context)
			{
				float ppi = context.getResources().getDisplayMetrics().density * 160.0f;
				PHYSICAL_COEF = android.hardware.SensorManager.GRAVITY_EARTH * 39.37f * ppi * 0.84f;
			}
Exemple #11
0
		internal static bool isLandscapeMode(android.content.Context context)
		{
			return context.getResources().getConfiguration().orientation == android.content.res.Configuration
				.ORIENTATION_LANDSCAPE;
		}
Exemple #12
0
		public MenuBuilder(android.content.Context context)
		{
			mContext = context;
			mResources = context.getResources();
			mItems = new java.util.ArrayList<*****@*****.**>();
			mVisibleItems = new java.util.ArrayList<*****@*****.**>
				();
			mIsVisibleItemsStale = true;
			mActionItems = new java.util.ArrayList<*****@*****.**>(
				);
			mNonActionItems = new java.util.ArrayList<*****@*****.**
				>();
			mIsActionItemsStale = true;
			setShortcutsVisibleInner(true);
		}
Exemple #13
0
		/// <summary>Create a Scroller with the specified interpolator.</summary>
		/// <remarks>
		/// Create a Scroller with the specified interpolator. If the interpolator is
		/// null, the default (viscous) interpolator will be used. Specify whether or
		/// not to support progressive "flywheel" behavior in flinging.
		/// </remarks>
		public Scroller(android.content.Context context, android.view.animation.Interpolator
			 interpolator, bool flywheel)
		{
			mFinished = true;
			mInterpolator = interpolator;
			mPpi = context.getResources().getDisplayMetrics().density * 160.0f;
			mDeceleration = computeDeceleration(android.view.ViewConfiguration.getScrollFriction
				());
			mFlywheel = flywheel;
		}
Exemple #14
0
			internal HolographicHelper(android.content.Context context)
			{
				mDensity = context.getResources().getDisplayMetrics().density;
				mHolographicPaint.setFilterBitmap(true);
				mHolographicPaint.setMaskFilter(android.graphics.TableMaskFilter.CreateClipTable(
					0, 30));
				mErasePaint.setXfermode(new android.graphics.PorterDuffXfermode(android.graphics.PorterDuff.Mode
					.DST_OUT));
				mErasePaint.setFilterBitmap(true);
				mSmallBlurMaskFilter = new android.graphics.BlurMaskFilter(2 * mDensity, android.graphics.BlurMaskFilter.Blur
					.NORMAL);
				mLargeBlurMaskFilter = new android.graphics.BlurMaskFilter(4 * mDensity, android.graphics.BlurMaskFilter.Blur
					.NORMAL);
			}
Exemple #15
0
		private void init(android.content.Context context)
		{
			// Get both the scrollbar states drawables
			android.content.res.TypedArray ta = context.getTheme().obtainStyledAttributes(ATTRS
				);
			useThumbDrawable(context, ta.getDrawable(THUMB_DRAWABLE));
			mTrackDrawable = ta.getDrawable(TRACK_DRAWABLE);
			mOverlayDrawableLeft = ta.getDrawable(PREVIEW_BACKGROUND_LEFT);
			mOverlayDrawableRight = ta.getDrawable(PREVIEW_BACKGROUND_RIGHT);
			mOverlayPosition = ta.getInt(OVERLAY_POSITION, OVERLAY_FLOATING);
			mScrollCompleted = true;
			getSectionsFromIndexer();
			mOverlaySize = context.getResources().getDimensionPixelSize([email protected]
				.fastscroll_overlay_size);
			mOverlayPos = new android.graphics.RectF();
			mScrollFade = new android.widget.FastScroller.ScrollFade(this);
			mPaint = new android.graphics.Paint();
			mPaint.setAntiAlias(true);
			mPaint.setTextAlign(android.graphics.Paint.Align.CENTER);
			mPaint.setTextSize(mOverlaySize / 2);
			android.content.res.ColorStateList textColor = ta.getColorStateList(TEXT_COLOR);
			int textColorNormal = textColor.getDefaultColor();
			mPaint.setColor(textColorNormal);
			mPaint.setStyle(android.graphics.Paint.Style.FILL_AND_STROKE);
			// to show mOverlayDrawable properly
			if (mList.getWidth() > 0 && mList.getHeight() > 0)
			{
				onSizeChanged(mList.getWidth(), mList.getHeight(), 0, 0);
			}
			mState = STATE_NONE;
			refreshDrawableState();
			ta.recycle();
			mScaledTouchSlop = android.view.ViewConfiguration.get(context).getScaledTouchSlop
				();
			mMatchDragPosition = context.getApplicationInfo().targetSdkVersion >= android.os.Build
				.VERSION_CODES.HONEYCOMB;
			setScrollbarPosition(mList.getVerticalScrollbarPosition());
		}
Exemple #16
0
		private void useThumbDrawable(android.content.Context context, android.graphics.drawable.Drawable
			 drawable)
		{
			mThumbDrawable = drawable;
			if (drawable is android.graphics.drawable.NinePatchDrawable)
			{
				mThumbW = context.getResources().getDimensionPixelSize([email protected].
					fastscroll_thumb_width);
				mThumbH = context.getResources().getDimensionPixelSize([email protected].
					fastscroll_thumb_height);
			}
			else
			{
				mThumbW = drawable.getIntrinsicWidth();
				mThumbH = drawable.getIntrinsicHeight();
			}
			mChangedBounds = true;
		}
Exemple #17
0
		public LoadedApk(android.app.ActivityThread activityThread, string name, android.content.Context
			 systemContext, android.content.pm.ApplicationInfo info, android.content.res.CompatibilityInfo
			 compatInfo)
		{
			mActivityThread = activityThread;
			mApplicationInfo = info != null ? info : new android.content.pm.ApplicationInfo();
			mApplicationInfo.packageName = name;
			mPackageName = name;
			mAppDir = null;
			mResDir = null;
			mSharedLibraries = null;
			mDataDir = null;
			mDataDirFile = null;
			mLibDir = null;
			mBaseClassLoader = null;
			mSecurityViolation = false;
			mIncludeCode = true;
			mClassLoader = systemContext.getClassLoader();
			mResources = systemContext.getResources();
			mCompatibilityInfo.set(compatInfo);
		}
Exemple #18
0
		/// <summary>Make a standard toast that just contains a text view with the text from a resource.
		/// 	</summary>
		/// <remarks>Make a standard toast that just contains a text view with the text from a resource.
		/// 	</remarks>
		/// <param name="context">
		/// The context to use.  Usually your
		/// <see cref="android.app.Application">android.app.Application</see>
		/// or
		/// <see cref="android.app.Activity">android.app.Activity</see>
		/// object.
		/// </param>
		/// <param name="resId">The resource id of the string resource to use.  Can be formatted text.
		/// 	</param>
		/// <param name="duration">
		/// How long to display the message.  Either
		/// <see cref="LENGTH_SHORT">LENGTH_SHORT</see>
		/// or
		/// <see cref="LENGTH_LONG">LENGTH_LONG</see>
		/// </param>
		/// <exception cref="android.content.res.Resources.NotFoundException">if the resource can't be found.
		/// 	</exception>
		public static android.widget.Toast makeText(android.content.Context context, int 
			resId, int duration)
		{
			return makeText(context, context.getResources().getText(resId), duration);
		}
		/// <summary>Create a new instance.</summary>
		/// <remarks>Create a new instance.</remarks>
		/// <param name="context">The application environment.</param>
		/// <param name="attrs">A collection of attributes.</param>
		/// <param name="defStyle">The default style to apply to this view.</param>
		public ActivityChooserView(android.content.Context context, android.util.AttributeSet
			 attrs, int defStyle) : base(context, attrs, defStyle)
		{
			mModelDataSetOberver = new _DataSetObserver_118(this);
			mOnGlobalLayoutListener = new _OnGlobalLayoutListener_132(this);
			android.content.res.TypedArray attributesArray = context.obtainStyledAttributes(attrs
				, [email protected], defStyle, 0);
			mInitialActivityCount = attributesArray.getInt([email protected]_initialActivityCount
				, android.widget.ActivityChooserView.ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT
				);
			android.graphics.drawable.Drawable expandActivityOverflowButtonDrawable = attributesArray
				.getDrawable([email protected]_expandActivityOverflowButtonDrawable
				);
			attributesArray.recycle();
			android.view.LayoutInflater inflater = android.view.LayoutInflater.from(mContext);
			inflater.inflate([email protected]_chooser_view, this, true);
			mCallbacks = new android.widget.ActivityChooserView.Callbacks(this);
			mActivityChooserContent = (android.widget.LinearLayout)findViewById([email protected]
				.id.activity_chooser_view_content);
			mActivityChooserContentBackground = mActivityChooserContent.getBackground();
			mDefaultActivityButton = (android.widget.FrameLayout)findViewById([email protected]
				.id.default_activity_button);
			mDefaultActivityButton.setOnClickListener(mCallbacks);
			mDefaultActivityButton.setOnLongClickListener(mCallbacks);
			mDefaultActivityButtonImage = (android.widget.ImageView)mDefaultActivityButton.findViewById
				([email protected]);
			mExpandActivityOverflowButton = (android.widget.FrameLayout)findViewById([email protected]
				.id.expand_activities_button);
			mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
			mExpandActivityOverflowButtonImage = (android.widget.ImageView)mExpandActivityOverflowButton
				.findViewById([email protected]);
			mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable
				);
			mAdapter = new android.widget.ActivityChooserView.ActivityChooserViewAdapter(this
				);
			mAdapter.registerDataSetObserver(new _DataSetObserver_239(this));
			android.content.res.Resources resources = context.getResources();
			mListPopupMaxWidth = System.Math.Max(resources.getDisplayMetrics().widthPixels / 
				2, resources.getDimensionPixelSize([email protected]_prefDialogWidth
				));
		}
Exemple #20
0
		/// <summary>Constructor used when a ScaleAnimation is loaded from a resource.</summary>
		/// <remarks>Constructor used when a ScaleAnimation is loaded from a resource.</remarks>
		/// <param name="context">Application context to use</param>
		/// <param name="attrs">Attribute set from which to read values</param>
		public ScaleAnimation(android.content.Context context, android.util.AttributeSet 
			attrs) : base(context, attrs)
		{
			mResources = context.getResources();
			android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
				.styleable.ScaleAnimation);
			android.util.TypedValue tv = a.peekValue([email protected]_fromXScale
				);
			mFromX = 0.0f;
			if (tv != null)
			{
				if (tv.type == android.util.TypedValue.TYPE_FLOAT)
				{
					// This is a scaling factor.
					mFromX = tv.getFloat();
				}
				else
				{
					mFromXType = tv.type;
					mFromXData = tv.data;
				}
			}
			tv = a.peekValue([email protected]_toXScale);
			mToX = 0.0f;
			if (tv != null)
			{
				if (tv.type == android.util.TypedValue.TYPE_FLOAT)
				{
					// This is a scaling factor.
					mToX = tv.getFloat();
				}
				else
				{
					mToXType = tv.type;
					mToXData = tv.data;
				}
			}
			tv = a.peekValue([email protected]_fromYScale);
			mFromY = 0.0f;
			if (tv != null)
			{
				if (tv.type == android.util.TypedValue.TYPE_FLOAT)
				{
					// This is a scaling factor.
					mFromY = tv.getFloat();
				}
				else
				{
					mFromYType = tv.type;
					mFromYData = tv.data;
				}
			}
			tv = a.peekValue([email protected]_toYScale);
			mToY = 0.0f;
			if (tv != null)
			{
				if (tv.type == android.util.TypedValue.TYPE_FLOAT)
				{
					// This is a scaling factor.
					mToY = tv.getFloat();
				}
				else
				{
					mToYType = tv.type;
					mToYData = tv.data;
				}
			}
			android.view.animation.Animation.Description d = android.view.animation.Animation
				.Description.parseValue(a.peekValue([email protected]_pivotX
				));
			mPivotXType = d.type;
			mPivotXValue = d.value;
			d = android.view.animation.Animation.Description.parseValue(a.peekValue([email protected]
				.styleable.ScaleAnimation_pivotY));
			mPivotYType = d.type;
			mPivotYValue = d.value;
			a.recycle();
		}