public override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(com.opentok.android.demo.opentoksamples.R.layout.layout_fragment_sub_control, container, false); mSubContainer = (RelativeLayout)openTokActivity.findViewById(com.opentok.android.demo.opentoksamples.R.id.fragment_sub_container); showSubscriberWidget(mSubscriberWidgetVisible, false); mSubscriberMute = (ImageButton)rootView.findViewById(com.opentok.android.demo.opentoksamples.R.id.muteSubscriber); mSubscriberMute.OnClickListener = this; mSubscriberName = (TextView)rootView.findViewById(com.opentok.android.demo.opentoksamples.R.id.subscriberName); if (openTokActivity.Resources.Configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { RelativeLayout.LayoutParams @params = (RelativeLayout.LayoutParams)container.LayoutParams; DisplayMetrics metrics = new DisplayMetrics(); openTokActivity.WindowManager.DefaultDisplay.getMetrics(metrics); @params.width = metrics.widthPixels - openTokActivity.dpToPx(48); container.LayoutParams = @params; } return(rootView); }
/// <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; }
public virtual void applyToDisplayMetrics(android.util.DisplayMetrics inoutDm) { if (!supportsScreen()) { // This is a larger screen device and the app is not // compatible with large screens, so diddle it. android.content.res.CompatibilityInfo.computeCompatibleScaling(inoutDm, inoutDm); } else { inoutDm.widthPixels = inoutDm.noncompatWidthPixels; inoutDm.heightPixels = inoutDm.noncompatHeightPixels; } if (isScalingRequired()) { float invertedRatio = applicationInvertedScale; inoutDm.density = inoutDm.noncompatDensity * invertedRatio; inoutDm.densityDpi = (int)((inoutDm.density * android.util.DisplayMetrics.DENSITY_DEFAULT ) + .5f); inoutDm.scaledDensity = inoutDm.noncompatScaledDensity * invertedRatio; inoutDm.xdpi = inoutDm.noncompatXdpi * invertedRatio; inoutDm.ydpi = inoutDm.noncompatYdpi * invertedRatio; inoutDm.widthPixels = (int)(inoutDm.widthPixels * invertedRatio + 0.5f); inoutDm.heightPixels = (int)(inoutDm.heightPixels * invertedRatio + 0.5f); } }
/// <summary>Gets display metrics based on the real size of this display.</summary> /// <remarks>Gets display metrics based on the real size of this display.</remarks> /// <hide></hide> public virtual void getRealMetrics(android.util.DisplayMetrics outMetrics) { lock (mTmpPoint) { getRealSize(mTmpPoint); getMetricsWithSize(outMetrics, mTmpPoint.x, mTmpPoint.y); } }
/// <summary>Compute the frame Rect for applications runs under compatibility mode.</summary> /// <remarks>Compute the frame Rect for applications runs under compatibility mode.</remarks> /// <param name="dm">the display metrics used to compute the frame size.</param> /// <param name="orientation">the orientation of the screen.</param> /// <param name="outRect">the output parameter which will contain the result.</param> /// <returns>Returns the scaling factor for the window.</returns> public static float computeCompatibleScaling(android.util.DisplayMetrics dm, android.util.DisplayMetrics outDm) { int width = dm.noncompatWidthPixels; int height = dm.noncompatHeightPixels; int shortSize; int longSize; if (width < height) { shortSize = width; longSize = height; } else { shortSize = height; longSize = width; } int newShortSize = (int)(DEFAULT_NORMAL_SHORT_DIMENSION * dm.density + 0.5f); float aspect = ((float)longSize) / shortSize; if (aspect > MAXIMUM_ASPECT_RATIO) { aspect = MAXIMUM_ASPECT_RATIO; } int newLongSize = (int)(newShortSize * aspect + 0.5f); int newWidth; int newHeight; if (width < height) { newWidth = newShortSize; newHeight = newLongSize; } else { newWidth = newLongSize; newHeight = newShortSize; } float sw = width / (float)newWidth; float sh = height / (float)newHeight; float scale = sw < sh ? sw : sh; if (scale < 1) { scale = 1; } if (outDm != null) { outDm.widthPixels = newWidth; outDm.heightPixels = newHeight; } return(scale); }
public virtual float getDimension(android.util.DisplayMetrics arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(@__env.CallFloatMethod(this.JvmHandle, global::android.util.TypedValue._getDimension8638, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))); } else { return(@__env.CallNonVirtualFloatMethod(this.JvmHandle, global::android.util.TypedValue.staticClass, global::android.util.TypedValue._getDimension8638, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))); } }
public static float complexToDimensionNoisy(int data, android.util.DisplayMetrics metrics) { float res = complexToDimension(data, metrics); java.io.Console.Out.println("Dimension (0x" + ((data >> android.util.TypedValue.COMPLEX_MANTISSA_SHIFT ) & android.util.TypedValue.COMPLEX_MANTISSA_MASK) + "*" + (RADIX_MULTS[(data >> android.util.TypedValue.COMPLEX_RADIX_SHIFT) & android.util.TypedValue.COMPLEX_RADIX_MASK ] / MANTISSA_MULT) + ")" + DIMENSION_UNIT_STRS[(data >> COMPLEX_UNIT_SHIFT) & COMPLEX_UNIT_MASK ] + " = " + res); return(res); }
/// <summary>Gets display metrics based on an explicit assumed display size.</summary> /// <remarks>Gets display metrics based on an explicit assumed display size.</remarks> /// <hide></hide> public virtual void getMetricsWithSize(android.util.DisplayMetrics outMetrics, int width, int height) { outMetrics.densityDpi = (int)((mDensity * android.util.DisplayMetrics.DENSITY_DEFAULT ) + .5f); outMetrics.noncompatWidthPixels = outMetrics.widthPixels = width; outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height; outMetrics.density = outMetrics.noncompatDensity = mDensity; outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density; outMetrics.xdpi = outMetrics.noncompatXdpi = mDpiX; outMetrics.ydpi = outMetrics.noncompatYdpi = mDpiY; }
public virtual void getMetrics(android.util.DisplayMetrics arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.view.Display._getMetrics8723, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.view.Display.staticClass, global::android.view.Display._getMetrics8723, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } }
public virtual void setTargetDensity(android.util.DisplayMetrics arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.graphics.drawable.BitmapDrawable._setTargetDensity3867, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.graphics.drawable.BitmapDrawable.staticClass, global::android.graphics.drawable.BitmapDrawable._setTargetDensity3867, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } }
public int getScaledHeight(android.util.DisplayMetrics arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(@__env.CallIntMethod(this.JvmHandle, global::android.graphics.Bitmap._getScaledHeight3113, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))); } else { return(@__env.CallNonVirtualIntMethod(this.JvmHandle, global::android.graphics.Bitmap.staticClass, global::android.graphics.Bitmap._getScaledHeight3113, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))); } }
/// <summary>Gets display metrics that describe the size and density of this display. /// </summary> /// <remarks> /// Gets display metrics that describe the size and density of this display. /// <p> /// The size is adjusted based on the current rotation of the display. /// </p><p> /// The size returned by this method does not necessarily represent the /// actual raw size (native resolution) of the display. The returned size may /// be adjusted to exclude certain system decor elements that are always visible. /// It may also be scaled to provide compatibility with older applications that /// were originally designed for smaller displays. /// </p> /// </remarks> /// <param name="outMetrics"> /// A /// <see cref="android.util.DisplayMetrics">android.util.DisplayMetrics</see> /// object to receive the metrics. /// </param> public virtual void getMetrics(android.util.DisplayMetrics outMetrics) { lock (mTmpPoint) { getSizeInternal(mTmpPoint, false); getMetricsWithSize(outMetrics, mTmpPoint.x, mTmpPoint.y); } android.content.res.CompatibilityInfo ci = mCompatibilityInfo.getIfNeeded(); if (ci != null) { ci.applyToDisplayMetrics(outMetrics); } }
// 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); }
public virtual void setTo(android.util.DisplayMetrics o) { widthPixels = o.widthPixels; heightPixels = o.heightPixels; density = o.density; densityDpi = o.densityDpi; scaledDensity = o.scaledDensity; xdpi = o.xdpi; ydpi = o.ydpi; noncompatWidthPixels = o.noncompatWidthPixels; noncompatHeightPixels = o.noncompatHeightPixels; noncompatDensity = o.noncompatDensity; noncompatScaledDensity = o.noncompatScaledDensity; noncompatXdpi = o.noncompatXdpi; noncompatYdpi = o.noncompatYdpi; }
protected internal override void onMeasure(int widthMeasureSpec, int heightMeasureSpec ) { android.util.DisplayMetrics metrics = getContext().getResources().getDisplayMetrics (); int screenWidth = metrics.widthPixels; bool isPortrait = screenWidth < metrics.heightPixels; int widthMode = android.view.View.MeasureSpec.getMode(widthMeasureSpec); base.onMeasure(widthMeasureSpec, heightMeasureSpec); int width = getMeasuredWidth(); bool measure_1 = false; widthMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(width, android.view.View .MeasureSpec.EXACTLY); float widthWeightMin = isPortrait ? mMinorWeightMin : mMajorWeightMin; float widthWeightMax = isPortrait ? mMinorWeightMax : mMajorWeightMax; if (widthMode == android.view.View.MeasureSpec.AT_MOST) { int weightedMin = (int)(screenWidth * widthWeightMin); int weightedMax = (int)(screenWidth * widthWeightMin); if (widthWeightMin > 0.0f && width < weightedMin) { widthMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(weightedMin, android.view.View .MeasureSpec.EXACTLY); measure_1 = true; } else { if (widthWeightMax > 0.0f && width > weightedMax) { widthMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(weightedMax, android.view.View .MeasureSpec.EXACTLY); measure_1 = true; } } } // TODO: Support height? if (measure_1) { base.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
/// <summary> /// Returns the available screensize, including status bar and navigation bar </summary> public static Size getScreenSize(Activity context) { Display display = context.WindowManager.DefaultDisplay; int realWidth; int realHeight; if (Build.VERSION.SDK_INT >= 17) { DisplayMetrics realMetrics = new DisplayMetrics(); display.getRealMetrics(realMetrics); realWidth = realMetrics.widthPixels; realHeight = realMetrics.heightPixels; } else if (Build.VERSION.SDK_INT >= 14) { try { Method mGetRawH = typeof(Display).GetMethod("getRawHeight"); Method mGetRawW = typeof(Display).GetMethod("getRawWidth"); realWidth = (int?) mGetRawW.invoke(display); realHeight = (int?) mGetRawH.invoke(display); } catch (Exception e) { //this may not be 100% accurate, but it's all we've got realWidth = display.Width; realHeight = display.Height; Log.e("Display Info", "Couldn't use reflection to get the real display metrics."); } } else { //This should be close, as lower API devices should not have window navigation bars realWidth = display.Width; realHeight = display.Height; } return new Size(realWidth, realHeight); }
public override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.layout_fragment_pub_status, container, false); mPubStatusContainer = (RelativeLayout)openTokActivity.findViewById(R.id.fragment_pub_status_container); archiving = (ImageButton)rootView.findViewById(R.id.archiving); statusText = (TextView)rootView.findViewById(R.id.statusLabel); if (openTokActivity.Resources.Configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { RelativeLayout.LayoutParams @params = (RelativeLayout.LayoutParams)container.LayoutParams; DisplayMetrics metrics = new DisplayMetrics(); openTokActivity.WindowManager.DefaultDisplay.getMetrics(metrics); @params.width = metrics.widthPixels - openTokActivity.dpToPx(48); container.LayoutParams = @params; } return(rootView); }
/// <summary>This method is not intended for general use.</summary> /// <remarks> /// This method is not intended for general use. It was created /// temporarily to improve performance of 3D layers in Launcher /// and should be removed and fixed properly. /// Do not call this method. Ever. /// </remarks> /// <hide></hide> protected internal virtual void hideSurface() { if (mSession != null && mWindow != null) { mSurfaceLock.@lock(); try { android.util.DisplayMetrics metrics = getResources().getDisplayMetrics(); mLayout.x = metrics.widthPixels * 3; mSession.relayout(mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, VISIBLE, false , mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface); } catch (android.os.RemoteException) { } finally { // Ignore mSurfaceLock.unlock(); } } }
/// <summary> /// Converts a complex data value holding a dimension to its final value /// as an integer pixel size. /// </summary> /// <remarks> /// Converts a complex data value holding a dimension to its final value /// as an integer pixel size. This is the same as /// <see cref="complexToDimension(int, DisplayMetrics)">complexToDimension(int, DisplayMetrics) /// </see> /// , except the raw floating point value is /// converted to an integer (pixel) value for use as a size. A size /// conversion involves rounding the base value, and ensuring that a /// non-zero base value is at least one pixel in size. /// The given <var>data</var> must be structured as a /// <see cref="TYPE_DIMENSION">TYPE_DIMENSION</see> /// . /// </remarks> /// <param name="data"> /// A complex data value holding a unit, magnitude, and /// mantissa. /// </param> /// <param name="metrics"> /// Current display metrics to use in the conversion -- /// supplies display density and scaling information. /// </param> /// <returns> /// The number of pixels specified by the data and its desired /// multiplier and units. /// </returns> public static int complexToDimensionPixelSize(int data, android.util.DisplayMetrics metrics) { float value = complexToFloat(data); float f = applyDimension((data >> COMPLEX_UNIT_SHIFT) & COMPLEX_UNIT_MASK, value, metrics); int res = (int)(f + 0.5f); if (res != 0) { return(res); } if (value == 0) { return(0); } if (value > 0) { return(1); } return(-1); }
public override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.layout_fragment_pub_status, container, false); mPubStatusContainer = (RelativeLayout) openTokActivity.findViewById(R.id.fragment_pub_status_container); archiving = (ImageButton) rootView.findViewById(R.id.archiving); statusText = (TextView) rootView.findViewById(R.id.statusLabel); if (openTokActivity.Resources.Configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { RelativeLayout.LayoutParams @params = (RelativeLayout.LayoutParams) container.LayoutParams; DisplayMetrics metrics = new DisplayMetrics(); openTokActivity.WindowManager.DefaultDisplay.getMetrics(metrics); @params.width = metrics.widthPixels - openTokActivity.dpToPx(48); container.LayoutParams = @params; } return rootView; }
/// <summary> /// Converts an unpacked complex data value holding a dimension to its final floating /// point value. /// </summary> /// <remarks> /// Converts an unpacked complex data value holding a dimension to its final floating /// point value. The two parameters <var>unit</var> and <var>value</var> /// are as in /// <see cref="TYPE_DIMENSION">TYPE_DIMENSION</see> /// . /// </remarks> /// <param name="unit">The unit to convert from.</param> /// <param name="value">The value to apply the unit to.</param> /// <param name="metrics"> /// Current display metrics to use in the conversion -- /// supplies display density and scaling information. /// </param> /// <returns> /// The complex floating point value multiplied by the appropriate /// metrics depending on its unit. /// </returns> public static float applyDimension(int unit, float value, android.util.DisplayMetrics metrics) { switch (unit) { case COMPLEX_UNIT_PX: { return(value); } case COMPLEX_UNIT_DIP: { return(value * metrics.density); } case COMPLEX_UNIT_SP: { return(value * metrics.scaledDensity); } case COMPLEX_UNIT_PT: { return(value * metrics.xdpi * (1.0f / 72)); } case COMPLEX_UNIT_IN: { return(value * metrics.xdpi); } case COMPLEX_UNIT_MM: { return(value * metrics.xdpi * (1.0f / 25.4f)); } } return(0); }
public override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(com.opentok.android.demo.opentoksamples.R.layout.layout_fragment_sub_control, container, false); mSubContainer = (RelativeLayout) openTokActivity.findViewById(com.opentok.android.demo.opentoksamples.R.id.fragment_sub_container); showSubscriberWidget(mSubscriberWidgetVisible, false); mSubscriberMute = (ImageButton) rootView.findViewById(com.opentok.android.demo.opentoksamples.R.id.muteSubscriber); mSubscriberMute.OnClickListener = this; mSubscriberName = (TextView) rootView.findViewById(com.opentok.android.demo.opentoksamples.R.id.subscriberName); if (openTokActivity.Resources.Configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { RelativeLayout.LayoutParams @params = (RelativeLayout.LayoutParams) container.LayoutParams; DisplayMetrics metrics = new DisplayMetrics(); openTokActivity.WindowManager.DefaultDisplay.getMetrics(metrics); @params.width = metrics.widthPixels - openTokActivity.dpToPx(48); container.LayoutParams = @params; } return rootView; }
private AppWidgetManager(android.content.Context context) { mContext = context; mDisplayMetrics = context.getResources().getDisplayMetrics(); }
public virtual bool onTouchEvent(android.view.MotionEvent @event) { if (mInputEventConsistencyVerifier != null) { mInputEventConsistencyVerifier.onTouchEvent(@event, 0); } int action = @event.getActionMasked(); if (action == android.view.MotionEvent.ACTION_DOWN) { reset(); } // Start fresh bool handled = true; if (mInvalidGesture) { handled = false; } else { if (!mGestureInProgress) { switch (action) { case android.view.MotionEvent.ACTION_DOWN: { mActiveId0 = @event.getPointerId(0); mActive0MostRecent = true; break; } case android.view.MotionEvent.ACTION_UP: { reset(); break; } case android.view.MotionEvent.ACTION_POINTER_DOWN: { // We have a new multi-finger gesture // as orientation can change, query the metrics in touch down android.util.DisplayMetrics metrics = mContext.getResources().getDisplayMetrics(); mRightSlopEdge = metrics.widthPixels - mEdgeSlop; mBottomSlopEdge = metrics.heightPixels - mEdgeSlop; if (mPrevEvent != null) { mPrevEvent.recycle(); } mPrevEvent = android.view.MotionEvent.obtain(@event); mTimeDelta = 0; int index1 = @event.getActionIndex(); int index0 = @event.findPointerIndex(mActiveId0); mActiveId1 = @event.getPointerId(index1); if (index0 < 0 || index0 == index1) { // Probably someone sending us a broken event stream. index0 = findNewActiveIndex(@event, index0 == index1 ? -1 : mActiveId1, index0); mActiveId0 = @event.getPointerId(index0); } mActive0MostRecent = false; setContext(@event); // Check if we have a sloppy gesture. If so, delay // the beginning of the gesture until we're sure that's // what the user wanted. Sloppy gestures can happen if the // edge of the user's hand is touching the screen, for example. float edgeSlop = mEdgeSlop; float rightSlop = mRightSlopEdge; float bottomSlop = mBottomSlopEdge; float x0 = getRawX(@event, index0); float y0 = getRawY(@event, index0); float x1 = getRawX(@event, index1); float y1 = getRawY(@event, index1); bool p0sloppy = x0 <edgeSlop || y0 <edgeSlop || x0> rightSlop || y0> bottomSlop; bool p1sloppy = x1 <edgeSlop || y1 <edgeSlop || x1> rightSlop || y1> bottomSlop; if (p0sloppy && p1sloppy) { mFocusX = -1; mFocusY = -1; mSloppyGesture = true; } else { if (p0sloppy) { mFocusX = @event.getX(index1); mFocusY = @event.getY(index1); mSloppyGesture = true; } else { if (p1sloppy) { mFocusX = @event.getX(index0); mFocusY = @event.getY(index0); mSloppyGesture = true; } else { mSloppyGesture = false; mGestureInProgress = mListener.onScaleBegin(this); } } } break; } case android.view.MotionEvent.ACTION_MOVE: { if (mSloppyGesture) { // Initiate sloppy gestures if we've moved outside of the slop area. float edgeSlop = mEdgeSlop; float rightSlop = mRightSlopEdge; float bottomSlop = mBottomSlopEdge; int index0 = @event.findPointerIndex(mActiveId0); int index1 = @event.findPointerIndex(mActiveId1); float x0 = getRawX(@event, index0); float y0 = getRawY(@event, index0); float x1 = getRawX(@event, index1); float y1 = getRawY(@event, index1); bool p0sloppy = x0 <edgeSlop || y0 <edgeSlop || x0> rightSlop || y0> bottomSlop; bool p1sloppy = x1 <edgeSlop || y1 <edgeSlop || x1> rightSlop || y1> bottomSlop; if (p0sloppy) { // Do we have a different pointer that isn't sloppy? int index = findNewActiveIndex(@event, mActiveId1, index0); if (index >= 0) { index0 = index; mActiveId0 = @event.getPointerId(index); x0 = getRawX(@event, index); y0 = getRawY(@event, index); p0sloppy = false; } } if (p1sloppy) { // Do we have a different pointer that isn't sloppy? int index = findNewActiveIndex(@event, mActiveId0, index1); if (index >= 0) { index1 = index; mActiveId1 = @event.getPointerId(index); x1 = getRawX(@event, index); y1 = getRawY(@event, index); p1sloppy = false; } } if (p0sloppy && p1sloppy) { mFocusX = -1; mFocusY = -1; } else { if (p0sloppy) { mFocusX = @event.getX(index1); mFocusY = @event.getY(index1); } else { if (p1sloppy) { mFocusX = @event.getX(index0); mFocusY = @event.getY(index0); } else { mSloppyGesture = false; mGestureInProgress = mListener.onScaleBegin(this); } } } } break; } case android.view.MotionEvent.ACTION_POINTER_UP: { if (mSloppyGesture) { int pointerCount = @event.getPointerCount(); int actionIndex = @event.getActionIndex(); int actionId = @event.getPointerId(actionIndex); if (pointerCount > 2) { if (actionId == mActiveId0) { int newIndex = findNewActiveIndex(@event, mActiveId1, actionIndex); if (newIndex >= 0) { mActiveId0 = @event.getPointerId(newIndex); } } else { if (actionId == mActiveId1) { int newIndex = findNewActiveIndex(@event, mActiveId0, actionIndex); if (newIndex >= 0) { mActiveId1 = @event.getPointerId(newIndex); } } } } else { // Set focus point to the remaining finger int index = @event.findPointerIndex(actionId == mActiveId0 ? mActiveId1 : mActiveId0 ); if (index < 0) { mInvalidGesture = true; android.util.Log.e(TAG, "Invalid MotionEvent stream detected.", new System.Exception ()); if (mGestureInProgress) { mListener.onScaleEnd(this); } return(false); } mActiveId0 = @event.getPointerId(index); mActive0MostRecent = true; mActiveId1 = -1; mFocusX = @event.getX(index); mFocusY = @event.getY(index); } } break; } } } else { switch (action) { case android.view.MotionEvent.ACTION_POINTER_DOWN: { // Transform gesture in progress - attempt to handle it // End the old gesture and begin a new one with the most recent two fingers. mListener.onScaleEnd(this); int oldActive0 = mActiveId0; int oldActive1 = mActiveId1; reset(); mPrevEvent = android.view.MotionEvent.obtain(@event); mActiveId0 = mActive0MostRecent ? oldActive0 : oldActive1; mActiveId1 = @event.getPointerId(@event.getActionIndex()); mActive0MostRecent = false; int index0 = @event.findPointerIndex(mActiveId0); if (index0 < 0 || mActiveId0 == mActiveId1) { // Probably someone sending us a broken event stream. android.util.Log.e(TAG, "Got " + android.view.MotionEvent.actionToString(action) + " with bad state while a gesture was in progress. " + "Did you forget to pass an event to " + "ScaleGestureDetector#onTouchEvent?"); index0 = findNewActiveIndex(@event, mActiveId0 == mActiveId1 ? -1 : mActiveId1, index0 ); mActiveId0 = @event.getPointerId(index0); } setContext(@event); mGestureInProgress = mListener.onScaleBegin(this); break; } case android.view.MotionEvent.ACTION_POINTER_UP: { int pointerCount = @event.getPointerCount(); int actionIndex = @event.getActionIndex(); int actionId = @event.getPointerId(actionIndex); bool gestureEnded = false; if (pointerCount > 2) { if (actionId == mActiveId0) { int newIndex = findNewActiveIndex(@event, mActiveId1, actionIndex); if (newIndex >= 0) { mListener.onScaleEnd(this); mActiveId0 = @event.getPointerId(newIndex); mActive0MostRecent = true; mPrevEvent = android.view.MotionEvent.obtain(@event); setContext(@event); mGestureInProgress = mListener.onScaleBegin(this); } else { gestureEnded = true; } } else { if (actionId == mActiveId1) { int newIndex = findNewActiveIndex(@event, mActiveId0, actionIndex); if (newIndex >= 0) { mListener.onScaleEnd(this); mActiveId1 = @event.getPointerId(newIndex); mActive0MostRecent = false; mPrevEvent = android.view.MotionEvent.obtain(@event); setContext(@event); mGestureInProgress = mListener.onScaleBegin(this); } else { gestureEnded = true; } } } mPrevEvent.recycle(); mPrevEvent = android.view.MotionEvent.obtain(@event); setContext(@event); } else { gestureEnded = true; } if (gestureEnded) { // Gesture ended setContext(@event); // Set focus point to the remaining finger int activeId = actionId == mActiveId0 ? mActiveId1 : mActiveId0; int index = @event.findPointerIndex(activeId); mFocusX = @event.getX(index); mFocusY = @event.getY(index); mListener.onScaleEnd(this); reset(); mActiveId0 = activeId; mActive0MostRecent = true; } break; } case android.view.MotionEvent.ACTION_CANCEL: { mListener.onScaleEnd(this); reset(); break; } case android.view.MotionEvent.ACTION_UP: { reset(); break; } case android.view.MotionEvent.ACTION_MOVE: { setContext(@event); // Only accept the event if our relative pressure is within // a certain limit - this can help filter shaky data as a // finger is lifted. if (mCurrPressure / mPrevPressure > PRESSURE_THRESHOLD) { bool updatePrevious = mListener.onScale(this); if (updatePrevious) { mPrevEvent.recycle(); mPrevEvent = android.view.MotionEvent.obtain(@event); } } break; } } } } if (!handled && mInputEventConsistencyVerifier != null) { mInputEventConsistencyVerifier.onUnhandledEvent(@event, 0); } return(handled); }
/// <summary> /// Retrieve overall information about an application package defined /// in a package archive file /// </summary> /// <param name="archiveFilePath">The path to the archive file</param> /// <param name="flags"> /// Additional option flags. Use any combination of /// <see cref="GET_ACTIVITIES">GET_ACTIVITIES</see> /// , /// <see cref="GET_GIDS">GET_GIDS</see> /// , /// <see cref="GET_CONFIGURATIONS">GET_CONFIGURATIONS</see> /// , /// <see cref="GET_INSTRUMENTATION">GET_INSTRUMENTATION</see> /// , /// <see cref="GET_PERMISSIONS">GET_PERMISSIONS</see> /// , /// <see cref="GET_PROVIDERS">GET_PROVIDERS</see> /// , /// <see cref="GET_RECEIVERS">GET_RECEIVERS</see> /// , /// <see cref="GET_SERVICES">GET_SERVICES</see> /// , /// <see cref="GET_SIGNATURES">GET_SIGNATURES</see> /// , to modify the data returned. /// </param> /// <returns> /// Returns the information about the package. Returns /// null if the package could not be successfully parsed. /// </returns> /// <seealso cref="GET_ACTIVITIES">GET_ACTIVITIES</seealso> /// <seealso cref="GET_GIDS">GET_GIDS</seealso> /// <seealso cref="GET_CONFIGURATIONS">GET_CONFIGURATIONS</seealso> /// <seealso cref="GET_INSTRUMENTATION">GET_INSTRUMENTATION</seealso> /// <seealso cref="GET_PERMISSIONS">GET_PERMISSIONS</seealso> /// <seealso cref="GET_PROVIDERS">GET_PROVIDERS</seealso> /// <seealso cref="GET_RECEIVERS">GET_RECEIVERS</seealso> /// <seealso cref="GET_SERVICES">GET_SERVICES</seealso> /// <seealso cref="GET_SIGNATURES">GET_SIGNATURES</seealso> public virtual android.content.pm.PackageInfo getPackageArchiveInfo(string archiveFilePath , int flags) { android.content.pm.PackageParser packageParser = new android.content.pm.PackageParser (archiveFilePath); android.util.DisplayMetrics metrics = new android.util.DisplayMetrics(); metrics.setToDefaults(); java.io.File sourceFile = new java.io.File(archiveFilePath); android.content.pm.PackageParser.Package pkg = packageParser.parsePackage(sourceFile , archiveFilePath, metrics, 0); if (pkg == null) { return null; } if ((flags & GET_SIGNATURES) != 0) { packageParser.collectCertificates(pkg, 0); } return android.content.pm.PackageParser.generatePackageInfo(pkg, null, flags, 0, 0); }
private AppWidgetManager(android.content.Context context) { mContext = context; mDisplayMetrics = context.getResources().getDisplayMetrics(); }
/// <summary>Set the density scale at which this drawable will be rendered.</summary> /// <remarks>Set the density scale at which this drawable will be rendered.</remarks> /// <param name="metrics">The DisplayMetrics indicating the density scale for this drawable. /// </param> /// <seealso cref="android.graphics.Bitmap.setDensity(int)">android.graphics.Bitmap.setDensity(int) /// </seealso> /// <seealso cref="android.graphics.Bitmap.getDensity()">android.graphics.Bitmap.getDensity() /// </seealso> public virtual void setTargetDensity(android.util.DisplayMetrics metrics) { setTargetDensity(metrics.densityDpi); }
internal android.util.DisplayMetrics getDisplayMetricsLocked(android.content.res.CompatibilityInfo ci, bool forceUpdate) { android.util.DisplayMetrics dm = mDisplayMetrics.get(ci); if (dm != null && !forceUpdate) { return dm; } if (dm == null) { dm = new android.util.DisplayMetrics(); mDisplayMetrics.put(ci, dm); } android.view.Display d = android.view.WindowManagerImpl.getDefault(ci).getDefaultDisplay (); d.getMetrics(dm); //Slog.i("foo", "New metrics: w=" + metrics.widthPixels + " h=" // + metrics.heightPixels + " den=" + metrics.density // + " xdpi=" + metrics.xdpi + " ydpi=" + metrics.ydpi); return dm; }
/// <summary> /// Converts a complex data value holding a dimension to its final value /// as an integer pixel offset. /// </summary> /// <remarks> /// Converts a complex data value holding a dimension to its final value /// as an integer pixel offset. This is the same as /// <see cref="complexToDimension(int, DisplayMetrics)">complexToDimension(int, DisplayMetrics) /// </see> /// , except the raw floating point value is /// truncated to an integer (pixel) value. /// The given <var>data</var> must be structured as a /// <see cref="TYPE_DIMENSION">TYPE_DIMENSION</see> /// . /// </remarks> /// <param name="data"> /// A complex data value holding a unit, magnitude, and /// mantissa. /// </param> /// <param name="metrics"> /// Current display metrics to use in the conversion -- /// supplies display density and scaling information. /// </param> /// <returns> /// The number of pixels specified by the data and its desired /// multiplier and units. /// </returns> public static int complexToDimensionPixelOffset(int data, android.util.DisplayMetrics metrics) { return((int)applyDimension((data >> COMPLEX_UNIT_SHIFT) & COMPLEX_UNIT_MASK, complexToFloat (data), metrics)); }
/// <summary>Return the data for this value as a dimension.</summary> /// <remarks> /// Return the data for this value as a dimension. Only use for values /// whose type is /// <see cref="TYPE_DIMENSION">TYPE_DIMENSION</see> /// . /// </remarks> /// <param name="metrics"> /// Current display metrics to use in the conversion -- /// supplies display density and scaling information. /// </param> /// <returns> /// The complex floating point value multiplied by the appropriate /// metrics depending on its unit. /// </returns> public virtual float getDimension(android.util.DisplayMetrics metrics) { return(complexToDimension(data, metrics)); }
public static float complexToDimension(int arg0, android.util.DisplayMetrics arg1) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; return(@__env.CallStaticFloatMethod(android.util.TypedValue.staticClass, global::android.util.TypedValue._complexToDimension8641, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))); }