use of android.view.WindowManager in project UltimateAndroid by cymcsg.
the class PullDoorView method setupView.
@SuppressLint("NewApi")
private void setupView() {
Interpolator polator = new BounceInterpolator();
mScroller = new Scroller(mContext, polator);
WindowManager wm = (WindowManager) (mContext.getSystemService(Context.WINDOW_SERVICE));
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
mScreenHeigh = dm.heightPixels;
mScreenWidth = dm.widthPixels;
this.setBackgroundColor(Color.argb(0, 0, 0, 0));
mImgView = new ImageView(mContext);
mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
mImgView.setScaleType(ImageView.ScaleType.FIT_XY);
mImgView.setImageResource(R.drawable.circle_button_ic_action_tick);
addView(mImgView);
}
use of android.view.WindowManager in project android-app by eoecn.
the class CameraConfigurationManager method initFromCameraParameters.
/**
* Reads, one time, values from the camera that are needed by the app.
*/
void initFromCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
previewFormat = parameters.getPreviewFormat();
previewFormatString = parameters.get("preview-format");
Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
screenResolution = new Point(display.getWidth(), display.getHeight());
Log.d(TAG, "Screen resolution: " + screenResolution);
/** modify here **/
Point screenResolutionForCamera = new Point();
screenResolutionForCamera.x = screenResolution.x;
screenResolutionForCamera.y = screenResolution.y;
// preview size is always something like 480*320, other 320*480
if (screenResolution.x < screenResolution.y) {
screenResolutionForCamera.x = screenResolution.y;
screenResolutionForCamera.y = screenResolution.x;
}
/** end **/
cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);
Log.d(TAG, "Camera resolution: " + screenResolutionForCamera);
/*
* cameraResolution = getCameraResolution(parameters, screenResolution);
* Log.d(TAG, "Camera resolution: " + screenResolution);
*/
/** end **/
}
use of android.view.WindowManager in project android-app by eoecn.
the class PopupWindowUtil method showActionWindow.
public void showActionWindow(View parent, Context context, List<T> tabs) {
// final RingtoneclipModel currentData = model;
// final int res_id = currentData.getId();
int[] location = new int[2];
int popWidth = context.getResources().getDimensionPixelOffset(R.dimen.popupWindow_width);
parent.getLocationOnScreen(location);
View view = getView(context, tabs);
popupWindow = new PopupWindow(view, popWidth, // new
LayoutParams.WRAP_CONTENT);
// PopupWindow(view,
// popWidth,
// LayoutParams.WRAP_CONTENT);
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// 显示的位置为:屏幕的最右端
int xPos = (int) (windowManager.getDefaultDisplay().getWidth() - popupWindow.getWidth() - context.getResources().getDimension(R.dimen.popupWindow_margin));
// popupWindow.showAsDropDown(parent, -10,0);
popupWindow.showAtLocation(parent, Gravity.NO_GRAVITY, xPos, location[1] + parent.getHeight() - 20);
}
use of android.view.WindowManager in project Onboarding by eoinfogarty.
the class ViewHelper method getDisplaySize.
public static Point getDisplaySize(@NonNull Context context) {
Point point = new Point();
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
manager.getDefaultDisplay().getSize(point);
return point;
}
use of android.view.WindowManager in project android_frameworks_base by ParanoidAndroid.
the class Activity method attach.
final void attach(Context context, ActivityThread aThread, Instrumentation instr, IBinder token, int ident, Application application, Intent intent, ActivityInfo info, CharSequence title, Activity parent, String id, NonConfigurationInstances lastNonConfigurationInstances, Configuration config) {
attachBaseContext(context);
mFragments.attachActivity(this, mContainer, null);
boolean floating = (intent.getFlags() & Intent.FLAG_FLOATING_WINDOW) == Intent.FLAG_FLOATING_WINDOW;
boolean history = (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY;
if (intent != null && floating && !history) {
TypedArray styleArray = context.obtainStyledAttributes(info.theme, com.android.internal.R.styleable.Window);
TypedValue backgroundValue = styleArray.peekValue(com.android.internal.R.styleable.Window_windowBackground);
// Apps that have no title don't need no title bar
TypedValue outValue = new TypedValue();
boolean result = styleArray.getValue(com.android.internal.R.styleable.Window_windowNoTitle, outValue);
if (backgroundValue != null && backgroundValue.toString().contains("light")) {
context.getTheme().applyStyle(com.android.internal.R.style.Theme_DeviceDefault_FloatingWindowLight, true);
} else {
context.getTheme().applyStyle(com.android.internal.R.style.Theme_DeviceDefault_FloatingWindow, true);
}
parent = null;
// Create our new window
mWindow = PolicyManager.makeNewWindow(this);
mWindow.mIsFloatingWindow = true;
mWindow.setCloseOnTouchOutsideIfNotSet(true);
mWindow.setGravity(Gravity.CENTER);
if (this instanceof LayerActivity || android.os.Process.myUid() == android.os.Process.SYSTEM_UID) {
mWindow.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams params = mWindow.getAttributes();
params.alpha = 1f;
params.dimAmount = 0.25f;
mWindow.setAttributes((android.view.WindowManager.LayoutParams) params);
}
// Scale it
scaleFloatingWindow(context);
} else {
mWindow = PolicyManager.makeNewWindow(this);
}
mWindow.setCallback(this);
mWindow.getLayoutInflater().setPrivateFactory(this);
if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
mWindow.setSoftInputMode(info.softInputMode);
}
if (info.uiOptions != 0) {
mWindow.setUiOptions(info.uiOptions);
}
mUiThread = Thread.currentThread();
mMainThread = aThread;
mInstrumentation = instr;
mToken = token;
mIdent = ident;
mApplication = application;
mIntent = intent;
mComponent = intent.getComponent();
mActivityInfo = info;
mTitle = title;
mParent = parent;
mEmbeddedID = id;
mLastNonConfigurationInstances = lastNonConfigurationInstances;
mWindow.setWindowManager((WindowManager) context.getSystemService(Context.WINDOW_SERVICE), mToken, mComponent.flattenToString(), (info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
if (mParent != null) {
mWindow.setContainer(mParent.getWindow());
}
mWindowManager = mWindow.getWindowManager();
mCurrentConfig = config;
}
Aggregations