// 设置屏幕亮度[0---255]
 public void setBrightnessValue(Activity activity, int brightnessValue) {
   if (brightnessValue < 0) brightnessValue = 0;
   if (brightnessValue > 255) brightnessValue = 255;
   WindowManager.LayoutParams layoutParams = activity.getWindow().getAttributes();
   layoutParams.screenBrightness = Float.valueOf(brightnessValue * (1f / 255f));
   activity.getWindow().setAttributes(layoutParams);
 }
Example #2
1
  public static void setCurWindowBrightness(Context context, int brightness) {

    // 如果开启自动亮度,则关闭。否则,设置了亮度值也是无效的
    if (IsAutoBrightness(context)) {
      stopAutoBrightness(context);
    }

    // context转换为Activity
    Activity activity = (Activity) context;
    WindowManager.LayoutParams lp = activity.getWindow().getAttributes();

    // 异常处理
    if (brightness < 1) {
      brightness = 1;
    }

    // 异常处理
    if (brightness > 255) {
      brightness = 255;
    }

    lp.screenBrightness = Float.valueOf(brightness) * (1f / 255f);

    activity.getWindow().setAttributes(lp);
  }
 private void updateWindowAttributes() {
   final Window window = getWindow();
   final WindowManager.LayoutParams attributes = window.getAttributes();
   attributes.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
   attributes.y = mSystemWindowsInsets.top;
   window.setAttributes(attributes);
 }
 private void applyModalFlag(State state) {
   if (state.headsUpShowing) {
     mLpChanged.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
   } else {
     mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
   }
 }
Example #5
0
  private void setDimAmount(float alpha, float dimAmount) {
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.alpha = alpha;
    lp.dimAmount = dimAmount;

    getWindow().setAttributes(lp);
  }
Example #6
0
  private void exit_full_screen() {
    final WindowManager.LayoutParams attrs = this.getWindow().getAttributes();

    attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.getWindow().setAttributes(attrs);
    this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
  }
  /**
   * Updates the state of the popup window, if it is currently being displayed, from the currently
   * set state. This include: {@link #setClippingEnabled(boolean)}, {@link #setFocusable(boolean)},
   * {@link #setIgnoreCheekPress()}, {@link #setInputMethodMode(int)}, {@link
   * #setTouchable(boolean)}, and {@link #setAnimationStyle(int)}.
   */
  public void update() {
    if (!isShowing() || mContentView == null) {
      return;
    }

    WindowManager.LayoutParams p = (WindowManager.LayoutParams) mPopupView.getLayoutParams();

    boolean update = false;

    final int newAnim = computeAnimationResource();
    if (newAnim != p.windowAnimations) {
      p.windowAnimations = newAnim;
      update = true;
    }

    final int newFlags = computeFlags(p.flags);
    if (newFlags != p.flags) {
      p.flags = newFlags;
      update = true;
    }

    if (update) {
      mWindowManager.updateViewLayout(mPopupView, p);
    }
  }
  public void removeNote() {
    if (config.notes.size() <= 0) return;

    boolean removing = false;

    int noteCount = 0;
    for (int i = 0; i < config.notes.size(); i++) {
      SteamHUDNote note = config.notes.get(i);
      if (!note.removing) {
        noteCount = config.notes.size() - i - 1;
        note.removing = true;
        break;
      } else if (i == config.notes.size() - 1) {
        return;
      }
    }

    WindowManager.LayoutParams params = (WindowManager.LayoutParams) getLayoutParams();
    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);

    params.height = (int) (74 * noteCount * config.scaleFactor) + 1;

    wm.updateViewLayout(this, params);

    config.hudRender.invalidate();
  }
Example #9
0
  @SuppressWarnings("deprecation")
  private void ErrorDialog(int icon, int title, int content, int makesur) {
    final Builder builder = new AlertDialog.Builder(LoginActivity.this);
    // 设置对话框的图标
    builder.setIcon(icon);
    // 设置对话框的标题
    builder.setTitle(title);
    // 设置对话框的内容
    builder.setMessage(content);
    // 设置对话框的"确定"按钮
    builder.setNegativeButton(
        makesur,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            System.out.println("IRoundU");
          }
        });
    AlertDialog alertDialog = builder.create();
    // 设置Dialog透明
    Window window = alertDialog.getWindow();
    WindowManager.LayoutParams lp = window.getAttributes();
    // 设置透明度为0.3
    lp.alpha = 0.8f;
    window.setAttributes(lp);
    // Dialog后面的内容会变得模糊
    window.setFlags(
        WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
    alertDialog.show();
  }
  public ActionSheetDialog builder() {
    View view = LayoutInflater.from(context).inflate(R.layout.dt_view_actionsheet, null);

    view.setMinimumWidth(display.getWidth());

    sLayout_content = (ScrollView) view.findViewById(R.id.sLayout_content);
    lLayout_content = (LinearLayout) view.findViewById(R.id.lLayout_content);
    txt_title = (TextView) view.findViewById(R.id.txt_title);
    txt_cancel = (TextView) view.findViewById(R.id.txt_cancel);
    txt_cancel.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            dialog.dismiss();
          }
        });

    dialog = new Dialog(context, R.style.ActionSheetDialogStyle);
    dialog.setContentView(view);
    Window dialogWindow = dialog.getWindow();
    dialogWindow.setGravity(Gravity.LEFT | Gravity.BOTTOM);
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    lp.x = 0;
    lp.y = 0;
    dialogWindow.setAttributes(lp);
    return this;
  }
Example #11
0
  protected Dialog onCreateDialog() {
    Dialog dialog = null;
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    builder.setTitle("Chose file");
    loadFileList();
    if (mFileList == null) {
      dialog = builder.create();
      return dialog;
    }
    builder.setItems(
        mFileList,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            // mChosenFile = mFileList[which];
          }
        });
    dialog = builder.create();
    WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();

    wmlp.gravity = Gravity.TOP | Gravity.LEFT;
    wmlp.x = 100;
    wmlp.y = 100;
    dialog = builder.show();
    return dialog;
  }
Example #12
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    context = this;

    // Params for the window.
    // You can easily set the alpha and the dim behind the window from here
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.alpha = 0.8f; // lower than one makes it more transparent
    params.dimAmount = 0f; // set it higher if you want to dim behind the window
    getWindow().setAttributes(params);

    // Gets the display size so that you can set the window to a percent of that
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x; // assign device display width to var width
    int height = size.y; // assign device display height to var height

    // set the width and height of the app window to multiples of the display dimensions
    getWindow().setLayout((int) (width * .95), (int) (height * .5));

    // Make sure to set your content view AFTER you have set up the window or it will crash.
    setContentView(R.layout.activity_main);
  }
Example #13
0
 private synchronized void handleShow() {
   if (mView != mNextView) {
     // remove the old view if necessary
     handleHide();
     mView = mNextView;
     // / M: we set hint center_horizontal and bottom in xml.
     // final int gravity = mGravity;
     // mParams.gravity = gravity;
     // if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK)
     // == Gravity.FILL_HORIZONTAL) {
     // mParams.horizontalWeight = 1.0f;
     // }
     // if ((gravity & Gravity.VERTICAL_GRAVITY_MASK)
     // == Gravity.FILL_VERTICAL) {
     // mParams.verticalWeight = 1.0f;
     // }
     // mParams.x = mX;
     // mParams.y = mY;
     // mParams.verticalMargin = mVerticalMargin;
     // mParams.horizontalMargin = mHorizontalMargin;
     mParams.x = 0;
     mParams.y = 0;
     mParams.height = WindowManager.LayoutParams.MATCH_PARENT;
     mParams.width = WindowManager.LayoutParams.MATCH_PARENT;
     try {
       if (mView.getParent() != null) {
         mWM.removeView(mView);
       }
       mWM.addView(mView, mParams);
     } catch (BadTokenException ex) {
       ex.printStackTrace();
     }
     Util.fadeIn(mView);
   }
 }
  private void initializeViews() {
    WindowManager.LayoutParams lpWindow = new WindowManager.LayoutParams();
    lpWindow.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    lpWindow.dimAmount = 0.8f;
    getWindow().setAttributes(lpWindow);

    setContentView(R.layout.select_box_dialog);

    Button.class.cast(findViewById(R.id.confirm)).setOnClickListener(confirmClickListener);

    RadioGroup select_group = RadioGroup.class.cast(findViewById(R.id.select_group));
    select_group.setOnCheckedChangeListener(radio_group_listener);
    for (Map.Entry<Object, String> elem : select_list.entrySet()) {
      RadioButton radio_button = new RadioButton(this.getContext());
      radio_button.setButtonDrawable(R.drawable.ui_radio_blue);
      radio_button.setText(elem.getValue());
      radio_button.setId(ServerList.ServerInfo.ServerName.class.cast(elem.getKey()).ordinal());
      if (checked_index == ServerList.ServerInfo.ServerName.class.cast(elem.getKey()).ordinal()) {
        radio_button.setChecked(true);
      }
      select_group.addView(radio_button);
    }
    TextView.class.cast(findViewById(R.id.message)).setText(this.message);
    if (this.message.equals("")) {
      TextView.class.cast(findViewById(R.id.message)).setVisibility(View.GONE);
    }
  }
Example #15
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Window window = getWindow();
   // Flashlights should be bright.
   WindowManager.LayoutParams params = window.getAttributes();
   params.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
   // params.buttonBrightness was added in API level 8. The additional brightness is not worth the
   // added code size.
   // The screen will go to max brightness even without the following line, but the API doesn't
   // guarantee it.
   window.setAttributes(params);
   window.addFlags(
       // Use the power button to turn flashlight off and on, even if you have a lock screen.
       WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
           // We won't do anything with touch events. Don't bother sending them to us.
           // Unfortunately, there is a platform bug that still exists in 4.2 (!) that causes ANRs
           // if this
           // flag is set.
           // | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
           // A flashlight that turns itself off isn't a good flashlight.
           | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
           // Turn the screen on if it isn't already on when launching (e.g., from ADB).
           | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
 }
Example #16
0
  /** 学院 */
  private void showCademyDialog() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
        .setTitle("学院")
        .setItems(
            R.array.cademys,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                // user.job = which;
                // action_done();
                curUser.setCademy(getResources().getStringArray(R.array.cademys)[which]);
                aq.id(R.id.et_mineinfo_cademy).text(curUser.getCademy());
              }
            });

    // builder.create().show();
    WindowManager m = getWindowManager();
    Display d = m.getDefaultDisplay();
    AlertDialog dialog = builder.create();
    dialog.show();
    WindowManager.LayoutParams p = dialog.getWindow().getAttributes();
    Point outSize = new Point();
    d.getSize(outSize);
    p.height = (int) (outSize.y * 0.6); // 高度设置为屏幕的0.6
    // p.width = (int) (d.getWidth() * 0.8);
    dialog.getWindow().setAttributes(p);
    dialogTitleLineColor(dialog);
  }
Example #17
0
 /**
  * 打开单选框
  *
  * @param context 上下文
  */
 public static AlertDialog showWaiting(Context context) {
   final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
   alertDialog.show();
   Window window = alertDialog.getWindow();
   WindowManager.LayoutParams layoutParams = window.getAttributes();
   layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
   layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
   window.setGravity(Gravity.CENTER);
   window.setAttributes(layoutParams);
   window.setContentView(R.layout.dialog_waiting);
   ViewGroup background = (ViewGroup) window.findViewById(R.id.waiting_layout_background);
   background.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           // alertDialog.cancel();
         }
       });
   ImageView icon = (ImageView) window.findViewById(R.id.waiting_image_icon);
   final RotateAnimation animation =
       new RotateAnimation(
           0f, 720f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
   animation.setDuration(2000);
   animation.setRepeatCount(Animation.INFINITE);
   icon.startAnimation(animation);
   return alertDialog;
 }
Example #18
0
  protected void showErrorDialog(View view, boolean cancelable) {
    if (getActivity().isFinishing()) return;

    if (mErrorDialog == null) {
      mErrorDialog = new AlertDialog.Builder(mContext, R.style.error_dialog).create();
      mErrorDialog.setCancelable(cancelable);
      mErrorDialog.setCanceledOnTouchOutside(cancelable);
    }
    mErrorDialog.show();
    Window window = mErrorDialog.getWindow();
    window.setGravity(Gravity.CENTER | Gravity.BOTTOM);
    window.setContentView(view);
    window.setWindowAnimations(R.style.animation_error_dialog);
    int width = (int) (ScreenUtils.getScreenW(mContext) * 5 / 6f);
    WindowManager.LayoutParams wmlp = window.getAttributes();
    wmlp.gravity = Gravity.CENTER | Gravity.BOTTOM;
    wmlp.y = 200;
    window.setLayout(width, ViewGroup.LayoutParams.WRAP_CONTENT);

    executor.schedule(
        new Runnable() {
          @Override
          public void run() {
            dismissErrorDialog();
          }
        },
        5,
        TimeUnit.SECONDS);
  }
  /**
   * Prepare the popup by embedding in into a new ViewGroup if the background drawable is not null.
   * If embedding is required, the layout parameters' height is mnodified to take into account the
   * background's padding.
   *
   * @param p the layout parameters of the popup's content view
   */
  private void preparePopup(WindowManager.LayoutParams p) {
    if (mBackground != null) {
      // when a background is available, we embed the content view
      // within another view that owns the background drawable
      PopupViewContainer popupViewContainer = new PopupViewContainer(mContext);
      PopupViewContainer.LayoutParams listParams =
          new PopupViewContainer.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
      popupViewContainer.setBackgroundDrawable(mBackground);
      popupViewContainer.addView(mContentView, listParams);

      if (p.height >= 0) {
        // accomodate the popup's height to take into account the
        // background's padding
        p.height += popupViewContainer.getPaddingTop() + popupViewContainer.getPaddingBottom();
      }
      if (p.width >= 0) {
        // accomodate the popup's width to take into account the
        // background's padding
        p.width += popupViewContainer.getPaddingLeft() + popupViewContainer.getPaddingRight();
      }
      mPopupView = popupViewContainer;
    } else {
      mPopupView = mContentView;
    }
    mPopupWidth = p.width;
    mPopupHeight = p.height;
  }
Example #20
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.v(ac_tag, "onCreate");
    super.onCreate(savedInstanceState);
    Window win = getWindow();
    WindowManager.LayoutParams winParams = win.getAttributes();
    winParams.flags |=
        (WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
            | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_FULLSCREEN);
    // | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    win.setAttributes(winParams);
    setContentView(R.layout.activity_lock);

    this.timeView = (TextView) super.findViewById(R.id.tTime);
    this.dateView = (TextView) super.findViewById(R.id.tDate);
    this.progressView = (TextView) super.findViewById(R.id.tProgress);
    this.mPassView = (EditText) findViewById(R.id.editPass);
    this.pbCircle = (ProgressBar) super.findViewById(R.id.pbCircle);
    this.mPassView.addTextChangedListener(new CheckPassword());

    decimalFormat = new DecimalFormat("00");

    // Initially hide the content view.
    this.mPassView.setVisibility(View.GONE);

    // Retrieve and cache the system's default "short" animation time.
    mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);

    SqlOpenHelper helper = new SqlOpenHelper(getApplicationContext());
    database = helper.getReadableDatabase();
  }
Example #21
0
 /*
  * For some reason, it's very difficult to create a layout that covers exactly the entire screen
  * and doesn't move when an unhandled key is pressed. The configuration we're using seems to
  * result in a layout that starts above the screen. So we split initialization into two
  * pieces, and here we find out where the overlay ended up and move it to be at the top
  * of the screen.
  * TODO(pweaver) Separating the menu and highlighting should be a cleaner way to solve this
  * issue
  */
 private void configureOverlayAfterShow() {
   int[] location = new int[2];
   mRelativeLayout.getLocationOnScreen(location);
   WindowManager.LayoutParams layoutParams = mOverlay.getParams();
   layoutParams.y -= location[1];
   mOverlay.setParams(layoutParams);
 }
Example #22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.detailexplain_store);

    wm = this.getWindow().getAttributes();
    wm.height = 740;
    wm.width = 793;

    initData();

    closeButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            dismiss();
          }
        });

    buyButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // 현재 포인트에서 물건 포인트 빼기 등등 처리 해야함
            dismiss(); // 다이얼로그 종료
          }
        });
  }
 @Override
 protected void onPrepareDialog(int id, Dialog dialog) {
   switch (id) {
     case MARKERCONFIG_DIALOG:
       if (markerConfigDialog != null && longTouchGeoPoint != null) {
         Window window = markerConfigDialog.getWindow();
         WindowManager.LayoutParams lp = window.getAttributes();
         // 设置对话框初始位置为左上角
         lp.gravity = Gravity.LEFT | Gravity.TOP;
         // lp.x与lp.y表示相对于原始位置的偏移
         // (touchX, touchY)为触屏位置坐标,坐标系以屏幕左上角为(0, 0)
         lp.x = touchX;
         lp.y = touchY;
         // 重新设置对话框位置
         window.setAttributes(lp);
         markerConfigDialog.setLongTouchGeoPoint(longTouchGeoPoint);
       }
       break;
     case README_DIALOG:
       ReadmeDialog readmeDialog = (ReadmeDialog) dialog;
       readmeDialog.setReadmeText(getResources().getString(R.string.overlayeventdemo_readme));
       break;
     default:
       break;
   }
   super.onPrepareDialog(id, dialog);
 }
  @AfterViews
  void init() {
    // 设置ErrorHandler
    userApi.setRestErrorHandler(errorHandlerForUserService);
    ExitApplication.getInstance().addActivity(this);
    inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    views =
        inflater.inflate( // 获取自定义布局文件dialog.xml的视图
            R.layout.activity_modifyname, null, false);

    app = (CustomApplication) getApplication();
    userId = app.getUserId();
    intent = getIntent();

    // 获取修改前性别
    this.oldSex = app.getUserSex();
    if (this.oldSex.equals("男")) {
      this.imageViewMan.setImageResource(R.drawable.defalt_head);
    } else {
      this.imageViewWoman.setImageResource(R.drawable.defalt_head);
    }
    // 初始化界面
    Window window = getWindow();
    WindowManager.LayoutParams layoutParams = window.getAttributes();
    // 设置窗口的大小及透明度
    layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    layoutParams.height = layoutParams.WRAP_CONTENT;
    window.setAttributes(layoutParams);
    this.setFinishOnTouchOutside(true);
  }
Example #25
0
 /**
  * 弹出自定义ProgressDialog
  *
  * @param context 上下文
  * @param message 提示
  * @param cancelable 是否按返回键取消
  * @param cancelListener 按下返回键监听
  * @return
  */
 public static CustomProgress show(
     Context context, CharSequence message, boolean cancelable, OnCancelListener cancelListener) {
   CustomProgress dialog = new CustomProgress(context, R.style.Custom_Progress);
   dialog.setTitle("");
   dialog.setContentView(R.layout.progress_custom);
   if (message == null || message.length() == 0) {
     dialog.findViewById(R.id.message).setVisibility(View.GONE);
   } else {
     TextView txt = (TextView) dialog.findViewById(R.id.message);
     txt.setText(message);
   }
   // 按返回键是否取消
   dialog.setCancelable(cancelable);
   // 监听返回键处理
   dialog.setOnCancelListener(cancelListener);
   // 设置居中
   dialog.getWindow().getAttributes().gravity = Gravity.CENTER;
   WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
   // 设置背景层透明度
   lp.dimAmount = 0.2f;
   dialog.getWindow().setAttributes(lp);
   // dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
   dialog.show();
   return dialog;
 }
Example #26
0
 private boolean findDropDownPosition(View anchor, android.view.WindowManager.LayoutParams p) {
   anchor.getLocationOnScreen(mDrawingLocation);
   p.x = mDrawingLocation[0];
   p.y = mDrawingLocation[1] + anchor.getMeasuredHeight();
   boolean onTop = false;
   View root = anchor.getRootView();
   int delta = (p.y + p.height) - root.getWindowTop() - root.getHeight();
   if (delta > 0) {
     if (p.y != anchor.getWindowBottom()) {
       ScrollView scrollView =
           (ScrollView) anchor.findParentViewOfType(android / widget / ScrollView);
       if (scrollView != null) {
         int bottom = anchor.getWindowBottom() + p.height;
         if (bottom > scrollView.getChildAt(scrollView.getChildCount() - 1).getWindowBottom())
           onTop = true;
         else if (bottom > scrollView.getWindowBottom()) {
           boolean enabled = scrollView.isVerticalScrollBarEnabled();
           if (enabled) scrollView.setVerticalScrollBarEnabled(false);
           scrollView.smoothScrollBy(0, delta);
           if (enabled) scrollView.setVerticalScrollBarEnabled(enabled);
           p.y -= delta;
         } else {
           onTop = true;
         }
       } else {
         onTop = true;
       }
     } else {
       onTop = true;
     }
     if (onTop) p.y -= anchor.getMeasuredHeight() + p.height;
   }
   return onTop;
 }
 private void applyBrightness(State state) {
   if (state.forceDozeBrightness) {
     mLpChanged.screenBrightness = mScreenBrightnessDoze;
   } else {
     mLpChanged.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
   }
 }
Example #28
0
 public void update(int x, int y, int width, int height) {
   if (width != -1) setWidth(width);
   if (height != -1) setHeight(height);
   if (!isShowing() || mContentView == null) return;
   android.view.WindowManager.LayoutParams p =
       (android.view.WindowManager.LayoutParams) mContentView.getLayoutParams();
   boolean update = false;
   if (width != -1 && p.width != width) {
     p.width = width;
     update = true;
   }
   if (height != -1 && p.height != height) {
     p.height = height;
     update = true;
   }
   if (p.x != x) {
     p.x = x;
     update = true;
   }
   if (p.y != y) {
     p.y = y;
     update = true;
   }
   if (update) {
     WindowManagerImpl wm = WindowManagerImpl.getDefault();
     wm.updateViewLayout(mContentView, p);
   }
 }
Example #29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_blackout);

    // Hide the status bar.
    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);

    // Sets screen brightness to lowest possible setting
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.screenBrightness = 0;
    getWindow().setAttributes(params);

    // Ensures the device won't lock while the app is running
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // begins listening for audio
    // this will detect the sound from the user
    try {
      bufferSize =
          AudioRecord.getMinBufferSize(
              sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
    } catch (Exception e) {
      android.util.Log.e("TrackingFlow", "Exception", e);
    }
  }
  private void startDragging(Bitmap bitmap, int y) {
    stopDragging();

    if (bitmap.getHeight() > maximumDragViewHeight) {
      bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), maximumDragViewHeight);
    }

    ImageView imageView = getGlowingBorder(bitmap);

    WindowManager.LayoutParams dragViewParameters = createLayoutParameters();
    if (isScrolling) {
      isScrolling = false;

      dragViewParameters.y = getHeight() / 2 - bitmap.getHeight() / 2;
    } else {
      dragViewParameters.y = y - bitmap.getHeight() / 2;
    }
    dragViewParameters.windowAnimations = R.style.brick_new;

    WindowManager windowManager = getWindowManager();

    windowManager.addView(imageView, dragViewParameters);

    dragView = imageView;
  }