Esempio n. 1
0
  private void setDefaultLocation() {
    wmParams.x = defaultOffsetX;
    wmParams.y = defaultOffsetY;

    wmParams.width = defaultWidth;
    wmParams.height = defaultHeight;
  }
  @Override
  protected void onPrepareDialog(int id, Dialog dialog) {
    super.onPrepareDialog(id, dialog);

    if (Log.DEBUG) Log.v("onPrepareDialog()");
    // User interacted so remove all locks and cancel reminders
    ClearAllReceiver.removeCancel(getApplicationContext());
    ClearAllReceiver.clearAll(false);
    ReminderReceiver.cancelReminder(getApplicationContext());

    switch (id) {
      case DIALOG_QUICKREPLY:
        showSoftKeyboard(qrEditText);

        // Set width of dialog to fill_parent
        LayoutParams mLP = dialog.getWindow().getAttributes();

        // TODO: this should be limited in case the screen is large
        mLP.width = LayoutParams.FILL_PARENT;
        dialog.getWindow().setAttributes(mLP);
        break;

      case DIALOG_PRESET_MSG:
        break;
    }
  }
 public void onEvent(EventsModel eventsModel) {
   if (eventsModel != null && eventsModel.getEventType() == EventType.SETTINGS_CHANGE) {
     setupParams();
     setupFloatingImage(true);
     animateHidden();
     EventTrackerHelper.sendEvent(
         "onEvent", "onLoadCompleteListener", "EventType.SETTINGS_CHANGE");
   } else if (eventsModel != null && eventsModel.getEventType() == EventType.PREVIEW) {
     mParams.height = AppHelper.toPx(context, eventsModel.getPreviewSize());
     mParams.width = AppHelper.toPx(context, eventsModel.getPreviewSize());
     try {
       EventTrackerHelper.sendEvent("onEvent", "onLoadCompleteListener", "EventType.PREVIEW");
       if (windowManager != null) {
         windowManager.updateViewLayout(FloatingHorizontalLayout.this.view, mParams);
         new Handler()
             .postDelayed(
                 new Runnable() {
                   @Override
                   public void run() {
                     setupParams();
                     setupFloatingImage(true);
                   }
                 },
                 1500);
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   } else if (eventsModel != null && eventsModel.getEventType() == EventType.FA_BACKGROUND) {
     setupBackground();
   } else if (eventsModel != null && eventsModel.getEventType() == EventType.ICON_ALPHA) {
     animateHidden();
   }
 }
Esempio n. 4
0
  @Override
  protected void initUI() {
    super.initUI();
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.WRAP_CONTENT;
    params.height = LayoutParams.WRAP_CONTENT;
    params.dimAmount = 0.5f;

    CloudGlobalDialogPage page =
        (CloudGlobalDialogPage)
            ProxyFactory.getFactory(ProxyFactory.TYPE_CLOUD_GLOBAL)
                .createDetailPage(this, CloudGlobalDialogFactory.NORMAL_GLOBAL_TYPE);

    CloudGlobalDialogPage.Builder builder = new Builder(page);

    if (!TextUtils.isEmpty(title)) builder.setTitle(title);
    if (!TextUtils.isEmpty(content)) builder.setContent(content);
    builder.setOnPositiveButton(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (mOnGlobalClickListener != null) {
              mOnGlobalClickListener.onClick();
            }
            finish();
          }
        });
    setContentView(page.getView());
  }
 private void hideRenderView() {
   if (this.tabAddedToWindow.booleanValue()) {
     LayoutParams params = (LayoutParams) this.swipeRenderView.getLayoutParams();
     params.x = 100000;
     getWindowManager().updateViewLayout(this.swipeRenderView, params);
   }
 }
Esempio n. 6
0
  public static void addButton(
      final Fragment fragment,
      ViewGroup layout,
      final String title,
      final String onClick,
      final Class<?>[] parameters,
      final Object[] objects) {
    Button button = new Button(fragment.getActivity());
    LayoutParams params = new LayoutParams();
    params.width = 200 * getDensity(fragment.getActivity());
    params.height = 100;
    button.setLayoutParams(params);
    button.setText(title);
    button.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (parameters == null) {
              invoke(fragment, onClick);
            } else {
              invoke(fragment, onClick, parameters, objects);
            }
          }
        });
    layout.addView(button);
  }
 public LayoutParams getClingWindowLayoutParams() {
   LayoutParams lp = new LayoutParams(-1, -1, 2005, 16777480, -3);
   lp.privateFlags |= 16;
   lp.setTitle(TAG);
   lp.windowAnimations = 16974566;
   lp.gravity = 119;
   return lp;
 }
Esempio n. 8
0
 private void checkBoundaries(LayoutParams params) {
   if (params.y < this.BOTTOM_BORDER_PX) {
     params.y = this.BOTTOM_BORDER_PX;
   }
   if (params.y > this.windowSize.y - this.TOP_BORDER_PX) {
     params.y = this.windowSize.y - this.TOP_BORDER_PX;
   }
   this.windowManager.updateViewLayout(this.rootView, params);
 }
Esempio n. 9
0
 private void updateLayoutParamsForPosiion(View anchor, LayoutParams p, int yOffset) {
   this.measureFloater();
   int measuredHeight = this.mPopupView.getMeasuredHeight();
   int paddingBottom = this.mPopupView.mMarker.getPaddingBottom();
   anchor.getLocationInWindow(this.mDrawingLocation);
   p.x = 0;
   p.y = this.mDrawingLocation[1] - measuredHeight + yOffset + paddingBottom;
   p.width = this.screenSize.x;
   p.height = measuredHeight;
 }
Esempio n. 10
0
  public void setAsPOPLeftWindow() {
    wmParams.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;

    wmParams.x = 0;
    wmParams.y = 0;

    int w = mScreenWidth / 2;
    int h = (int) ((float) mScreenHeight / mScreenWidth * mScreenWidth / 2);
    setWindowSize(w, h);

    setTVLocation(new float[] {0, mScreenHeight / 2 - h / 2});
  }
Esempio n. 11
0
 private void showAsPopup(Activity activity) {
   activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);
   activity
       .getWindow()
       .setFlags(
           WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND);
   LayoutParams params = activity.getWindow().getAttributes();
   params.height = LayoutParams.MATCH_PARENT;
   params.width = 850; // fixed width
   params.alpha = 1.0f;
   params.dimAmount = 0.5f;
   activity.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
 }
Esempio n. 12
0
 private LayoutParams createPopupLayout(IBinder token) {
   LayoutParams p = new LayoutParams();
   p.gravity = 8388659;
   p.width = -1;
   p.height = -1;
   p.format = -3;
   p.flags = this.computeFlags(p.flags);
   p.type = 1000;
   p.token = token;
   p.softInputMode = 3;
   p.setTitle("DiscreteSeekBar Indicator:" + Integer.toHexString(this.hashCode()));
   return p;
 }
 private void showRecycler() {
   int iconSize = AppHelper.getFinalSize(context);
   if (paramsF != null) {
     rParams.x = paramsF.x;
     if (paramsF.y + iconSize / 2 > szWindow.y / 2) {
       rParams.y = paramsF.y - iconSize;
     } else if (paramsF.y + iconSize / 2 <= szWindow.y / 2) {
       rParams.y = paramsF.y + iconSize;
     }
     windowManager.updateViewLayout(view, rParams);
   }
   view.setVisibility(View.VISIBLE);
 }
  private void setWindow() {
    WindowManager m = getWindowManager();
    Display d = m.getDefaultDisplay(); // Ϊ��ȡ��Ļ�?��
    Point outsize = new Point();
    LayoutParams p = getWindow().getAttributes(); // ��ȡ�Ի���ǰ�IJ���ֵ
    d.getSize(outsize);
    p.height = (int) (outsize.y * 0.8); // �߶�����Ϊ��Ļ��0.8
    p.width = (int) (outsize.x * 0.8); // �������Ϊ��Ļ��0.8
    p.alpha = 1.0f; // ���ñ���͸����
    p.dimAmount = 0.0f; // ���úڰ���

    getWindow().setAttributes(p); // ������Ч
    getWindow().setGravity(Gravity.CENTER); // ���ÿ��Ҷ���
  }
  public UserInfoDialog(Context context) {
    super(context, R.style.Dialog);
    setContentView(R.layout.user_center_content);

    // 设置点击对话框之外能消失
    setCanceledOnTouchOutside(true);
    // 设置window属性
    lp = getWindow().getAttributes();
    lp.gravity = Gravity.TOP;
    lp.dimAmount = 0; // 去背景遮盖
    lp.alpha = 1.0f;
    lp.y = 55;
    getWindow().setAttributes(lp);
  }
  @Override
  protected void displayAD() {
    if (null == mWindowManager) {
      mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    }
    lpWindow = new LayoutParams();
    lpWindow.type = LayoutParams.TYPE_SYSTEM_ALERT;
    lpWindow.flags = LayoutParams.FLAG_NOT_FOCUSABLE;
    lpWindow.gravity = Gravity.TOP;
    Point point = new Point();
    mWindowManager.getDefaultDisplay().getRealSize(point);
    lpWindow.x = 0;
    lpWindow.y = 0;

    lpWindow.width = point.x;
    lpWindow.height =
        CommonUtils.dip2px(
            mContext, mContext.getResources().getDimension(R.dimen.advanced_float_window_height));
    lpWindow.format = PixelFormat.RGBA_8888;

    if (null == mRootView) {
      if (null == mInflater) {
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
      mRootView = mInflater.inflate(R.layout.advanced_banner_window, null);
    }
    initViews();
    initDatas();
  }
Esempio n. 17
0
 public void setMenuItem(int x, int y, int resId) {
   ImageView item = new ImageView(ctx);
   item.setImageResource(resId);
   item.setVisibility(View.GONE);
   menuItems[y * xGrids + x] = item;
   mWindowManager.getDefaultDisplay().getMetrics(mDisplayMetrics);
   int xGrid = mDisplayMetrics.widthPixels / xGrids;
   int yGrid = mDisplayMetrics.heightPixels / yGrids;
   float xOffset = ((float) xGrids - 1) / 2;
   float yOffset = ((float) yGrids - 1) / 2;
   itemLayoutParams.x = (int) ((x - xOffset) * xGrid);
   itemLayoutParams.y = (int) ((y - yOffset) * yGrid);
   mWindowManager.addView(item, itemLayoutParams);
 }
Esempio n. 18
0
 public void showIndicator(View parent, Rect touchBounds) {
   if (this.isShowing()) {
     this.mPopupView.mMarker.animateOpen();
   } else {
     IBinder windowToken = parent.getWindowToken();
     if (windowToken != null) {
       LayoutParams p = this.createPopupLayout(windowToken);
       p.gravity = 8388659;
       this.updateLayoutParamsForPosiion(parent, p, touchBounds.bottom);
       this.mShowing = true;
       this.translateViewIntoPosition(touchBounds.centerX());
       this.invokePopup(p);
     }
   }
 }
Esempio n. 19
0
  public LoadingDialog(Context context) {
    super(context, R.style.Dialog);

    this.mContext = context;

    inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.loadingdialog, null);
    setContentView(layout);

    // 璁剧疆window灞炴�
    lp = getWindow().getAttributes();
    lp.gravity = Gravity.CENTER;
    lp.dimAmount = 0; // 鍘昏儗鏅伄鐩�
    lp.alpha = 1.0f;
    getWindow().setAttributes(lp);
  }
Esempio n. 20
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dialog_address);

    mListView = (ListView) findViewById(R.id.dialog_listview);
    // 设置adapter
    setAdapter(mAdapter);
    setOnItemClickListener(mListener);

    // 改变样式-->window的样式
    Window window = getWindow();
    LayoutParams params = window.getAttributes();
    params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; // 设置弹出位置
    window.setAttributes(params);
  }
 private void LightShow() {
   // preview brightness changes at this window
   // get the current window attributes
   LayoutParams layoutpars = getWindow().getAttributes();
   // set the brightness of this window
   int light = 100;
   try {
     light = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
     layoutpars.screenBrightness =
         SettingUtils.getSetting(ComicImageViewActivity.this, "light", light) / (float) 255;
     // apply attribute changes to this window
     getWindow().setAttributes(layoutpars);
   } catch (SettingNotFoundException e) {
     e.printStackTrace();
   }
 }
Esempio n. 22
0
  public void setFullScreen() {
    wmParams.gravity = Gravity.LEFT | Gravity.TOP;

    setWindowSize(mScreenWidth, mScreenHeight); // debugging -100
    this.setWindowPadding(0, 100);

    setTVLocation(new float[] {0, 0});
  }
 private void initWindows() {
   windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   windowManager.getDefaultDisplay().getSize(szWindow);
   mParams =
       new LayoutParams(
           TYPE_PRIORITY_PHONE /* to appear on top of keyboard */,
           FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL,
           PixelFormat.TRANSLUCENT);
   rParams =
       new LayoutParams(
           TYPE_PRIORITY_PHONE /* to appear on top of keyboard */,
           FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL,
           PixelFormat.TRANSLUCENT);
   setupParams();
   mParams.gravity = Gravity.LEFT | Gravity.TOP;
   rParams.gravity = Gravity.LEFT | Gravity.TOP;
   initView();
 }
Esempio n. 24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.hookup_tutorial);
    sInstance = this;

    LayoutParams params = getWindow().getAttributes();
    params.height = LayoutParams.MATCH_PARENT;
    params.width = LayoutParams.MATCH_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    setDuration(LONG_ANIM_DURATION);
    mTutorialLayout = (RelativeLayout) findViewById(R.id.rlTutorial);
    mTutorialText = (TextView) findViewById(R.id.tvTutorialText);
    mTutorialText.setText(getIntent().getStringExtra(TEXT));
    setTranslateAnimations();
    startTranslateAnimations();
  }
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   paramsF = mParams;
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       initialX = paramsF.x;
       initialY = paramsF.y;
       initialTouchX = event.getRawX();
       initialTouchY = event.getRawY();
       animateShowing();
       break;
     case MotionEvent.ACTION_UP:
       if (AppHelper.isEdged(context)) {
         moveToEdge();
       } else {
         if (AppHelper.isSavePositionEnabled(context)) {
           AppHelper.savePosition(context, paramsF.y, paramsF.x);
         }
       }
       animateHidden();
       break;
     case MotionEvent.ACTION_MOVE:
       if (paramsF.y < 0) {
         paramsF.y = 0;
       }
       if (paramsF.y >= 0 || paramsF.y <= (szWindow.y - AppHelper.getFinalSize(context))) {
         paramsF.x = initialX + (int) (event.getRawX() - initialTouchX);
         paramsF.y = initialY + (int) (event.getRawY() - initialTouchY);
         try {
           windowManager.updateViewLayout(FloatingHorizontalLayout.this.floatingImage, paramsF);
           if (view.isShown()) {
             showRecycler();
           }
         } catch (Exception e) {
           e.printStackTrace();
         }
         animateShowing();
       } else if (paramsF.y > (szWindow.y - AppHelper.getFinalSize(context))) {
         paramsF.y = (szWindow.y - AppHelper.getFinalSize(context));
       }
       break;
   }
   return false;
 }
Esempio n. 26
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.thumb_dialog);
   final ListView view = (ListView) findViewById(R.id.thumbListView);
   view.setAdapter(new ThumbAdapter(movie.getThumb(), width, height, context));
   LayoutParams params = getWindow().getAttributes();
   params.width = width;
   params.height = LayoutParams.WRAP_CONTENT;
   getWindow().setAttributes((LayoutParams) params);
   view.setOnItemClickListener(
       new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
           Thumb thumb = (Thumb) view.getItemAtPosition(position);
           movie.setActiveThumb(thumb.getValue());
           new HelperFactory(context).saveOrUpdate(movie);
         }
       });
 }
Esempio n. 27
0
  @Override
  protected void displayAD() {
    if (null == mWindowManager) {
      mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    }
    LayoutParams lpWindow = new LayoutParams();
    lpWindow.type = LayoutParams.TYPE_SYSTEM_ALERT;
    lpWindow.flags = LayoutParams.FLAG_DIM_BEHIND;
    lpWindow.dimAmount = 0.8f;
    lpWindow.gravity = Gravity.CENTER;
    Point point = new Point();
    mWindowManager.getDefaultDisplay().getRealSize(point);
    lpWindow.x = 0;
    lpWindow.y = 0;

    lpWindow.width =
        CommonUtils.dip2px(
            mContext, mContext.getResources().getDimension(R.dimen.simple_window_width));
    lpWindow.height =
        CommonUtils.dip2px(
            mContext, mContext.getResources().getDimension(R.dimen.simple_window_height));
    lpWindow.format = PixelFormat.RGBA_8888;

    if (null == mRootView) {
      if (null == mInflater) {
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
      mRootView = mInflater.inflate(R.layout.simple_window, null);
    }
    mWindowManager.addView(mRootView, lpWindow);
    initViews();
    initDatas();
    super.displayAD();

    SharedPreferences sp = mContext.getSharedPreferences(AMConstants.SP_NAME, Context.MODE_PRIVATE);
    sp.edit().putLong(AMConstants.SP_LAST_AD_STAMP, System.currentTimeMillis()).commit();

    AdDisplayUploadRequest request = new AdDisplayUploadRequest(null);
    request.start(mAD.getDisplayPager());
  }
Esempio n. 28
0
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       mOldX = event.getRawX();
       mOldY = event.getRawY();
       mIsDrag = false;
       mFloatView.getBackground().setAlpha(255);
       return false;
     case MotionEvent.ACTION_MOVE:
       int px = (int) (mOldX - event.getRawX());
       int py = (int) (mOldY - event.getRawY());
       if (Math.abs(px) >= 5 && Math.abs(py) >= 5) {
         mIsDrag = true;
       }
       if (mIsDrag) {
         wmParams.x = wmParams.x - px;
         wmParams.y = wmParams.y - py;
         if (wmParams.x > FaceApp.winWidth / 2) {
           wmParams.x = FaceApp.winWidth / 2;
         }
         if (wmParams.x < -FaceApp.winWidth / 2) {
           wmParams.x = -FaceApp.winWidth / 2;
         }
         mWindowManager.updateViewLayout(mFloatView, wmParams);
         mOldX = event.getRawX();
         mOldY = event.getRawY();
       }
       return false;
     case MotionEvent.ACTION_UP:
       PreSetting.getInstance().setFloatViewX(wmParams.x);
       PreSetting.getInstance().setFloatViewY(wmParams.y);
       return mIsDrag;
     default:
       return false;
   }
 }
Esempio n. 29
0
 private void initFloatView() {
   wmParams = new LayoutParams();
   wmParams.format = PixelFormat.RGBA_8888;
   wmParams.x = PreSetting.getInstance().getFloatViewX();
   wmParams.y = PreSetting.getInstance().getFloatViewY();
   wmParams.width = LayoutParams.WRAP_CONTENT;
   wmParams.height = LayoutParams.WRAP_CONTENT;
   wmParams.flags = LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_NOT_FOCUSABLE;
   wmParams.type = LayoutParams.TYPE_PHONE;
   wmParams.windowAnimations = android.R.style.Animation_Translucent;
   LayoutInflater inflater = LayoutInflater.from(getApplication());
   mFloatView = inflater.inflate(R.layout.layout_floatbutton, null);
   mFloatView.setOnTouchListener(onTouchListener);
   mFloatView.setOnClickListener(onClickListener);
   ((ButtonFloatSmall) mFloatView).setRippleColor(Color.TRANSPARENT);
   //		((ButtonFloatSmall)mFloatView).getBackground().setAlpha(50);
 }
Esempio n. 30
0
 private void addTabViewToWindow(View view, int x, int y, int w, int h, Boolean touchable) {
   int flags = 16843544;
   if (!touchable.booleanValue()) {
     flags = 16843544 | 16;
   }
   LayoutParams params = new LayoutParams(-2, -2, 2007, flags, -3);
   params.gravity = 51;
   params.width = w;
   params.height = h;
   params.x = x;
   params.y = y;
   try {
     Field privateFlags = params.getClass().getDeclaredField("privateFlags");
     privateFlags.setInt(params, privateFlags.getInt(params) | 64);
   } catch (NoSuchFieldException ex) {
     ex.printStackTrace();
   } catch (IllegalAccessException ex2) {
     ex2.printStackTrace();
   }
   getWindowManager().addView(view, params);
 }