Example #1
1
  @Override
  public void onCreate() {

    super.onCreate();

    sp = getSharedPreferences("date", 0);
    sp_setting = PreferenceManager.getDefaultSharedPreferences(this);
    sp_userinfo = getSharedPreferences("userinfo", 0);
    C.FRAME = Integer.parseInt(sp_setting.getString("Frame", "60"));
    Wm = (WindowManager) getApplication().getSystemService(Context.WINDOW_SERVICE);
    wmParams = new WindowManager.LayoutParams();
    wmParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
    // 设置悬浮窗为全屏
    wmParams.flags = 1280;
    wmParams.format = PixelFormat.RGBA_8888;
    wmParams.alpha = 0.8f;
    wmParams.gravity = Gravity.LEFT | Gravity.BOTTOM;
    wmParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    wmParams.height = ViewGroup.LayoutParams.MATCH_PARENT;

    Wm_control = (WindowManager) getApplication().getSystemService(Context.WINDOW_SERVICE);
    wmParams_control = new WindowManager.LayoutParams();
    wmParams_control.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    wmParams_control.format = PixelFormat.RGB_888;
    wmParams_control.flags =
        WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
            | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
    wmParams_control.alpha = 0;
    wmParams_control.width = 0;
    wmParams_control.height = 0;
    win_control = new View(this);
    Wm_control.addView(win_control, wmParams_control);

    // 注册系统广播
    sr = new ScreenReceiver();
    sr.registerScreenActionReceiver(MSSService.this);
    registerBattery();

    // 注册自己程序的广播
    IntentFilter inf = new IntentFilter();
    inf.addAction("com.jiusg.mainscreenshow");
    mssr = new MSSReceiver();
    registerReceiver(mssr, inf);

    sa_IsEvent = new SparseBooleanArray();
    sa_Animation = new SparseArray<Integer>();
    animManage = new AnimationManage(Wm, wmParams, getApplicationContext());

    isView = false;

    mHandler = new MssHandler();

    imageCache = new ImageCache(getApplicationContext());

    AVAnalytics.onEvent(MSSService.this, "Server Create", TAG);

    startService(new Intent(this, MSSLiveWallpaper.class));
  }
  /**
   * Positions the popup window on screen. When the popup window is too tall to fit under the
   * anchor, a parent scroll view is seeked and scrolled up to reclaim space. If scrolling is not
   * possible or not enough, the popup window gets moved on top of the anchor.
   *
   * <p>The height must have been set on the layout parameters prior to calling this method.
   *
   * @param anchor the view on which the popup window must be anchored
   * @param p the layout parameters used to display the drop down
   * @return true if the popup is translated upwards to fit on screen
   */
  private boolean findDropDownPosition(
      View anchor, WindowManager.LayoutParams p, int xoff, int yoff) {
    anchor.getLocationInWindow(mDrawingLocation);
    p.x = mDrawingLocation[0] + xoff;
    p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;

    boolean onTop = false;

    p.gravity = Gravity.LEFT | Gravity.TOP;

    anchor.getLocationOnScreen(mScreenLocation);
    final Rect displayFrame = new Rect();
    anchor.getWindowVisibleDisplayFrame(displayFrame);

    final View root = anchor.getRootView();
    if (mScreenLocation[1] + anchor.getMeasuredHeight() + yoff + mPopupHeight > displayFrame.bottom
        || p.x + mPopupWidth - root.getWidth() > 0) {
      // if the drop down disappears at the bottom of the screen. we try to
      // scroll a parent scrollview or move the drop down back up on top of
      // the edit box
      int scrollX = anchor.getScrollX();
      int scrollY = anchor.getScrollY();
      Rect r =
          new Rect(
              scrollX,
              scrollY,
              scrollX + mPopupWidth,
              scrollY + mPopupHeight + anchor.getMeasuredHeight());
      anchor.requestRectangleOnScreen(r, true);

      // now we re-evaluate the space available, and decide from that
      // whether the pop-up will go above or below the anchor.
      anchor.getLocationInWindow(mDrawingLocation);
      p.x = mDrawingLocation[0] + xoff;
      p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;

      // determine whether there is more space above or below the anchor
      anchor.getLocationOnScreen(mScreenLocation);

      onTop =
          (displayFrame.bottom - mScreenLocation[1] - anchor.getMeasuredHeight() - yoff)
              < (mScreenLocation[1] - yoff - displayFrame.top);
      if (onTop) {
        p.gravity = Gravity.LEFT | Gravity.BOTTOM;
        p.y = root.getHeight() - mDrawingLocation[1] - yoff;
      } else {
        p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;
      }
    }

    p.gravity |= Gravity.DISPLAY_CLIP_VERTICAL;

    return onTop;
  }
  /**
   * Show the controller on screen. It will go away automatically after 'timeout' milliseconds of
   * inactivity.
   *
   * @param timeout The timeout in milliseconds. Use 0 to show the controller until hide() is
   *     called.
   */
  public void show(int timeout) {

    if (!mShowing && mAnchor != null) {
      setProgress();

      int[] anchorpos = new int[2];
      mAnchor.getLocationOnScreen(anchorpos);

      WindowManager.LayoutParams p = new WindowManager.LayoutParams();
      p.gravity = Gravity.TOP;
      p.width = mAnchor.getWidth();
      p.height = LayoutParams.WRAP_CONTENT;
      p.x = 0;
      p.y = anchorpos[1] + mAnchor.getHeight() - p.height;
      p.format = PixelFormat.TRANSLUCENT;
      p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
      p.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
      p.token = null;
      p.windowAnimations = 0; // android.R.style.DropDownAnimationDown;
      mWindowManager.addView(mDecor, p);
      mShowing = true;
    }
    updatePausePlay();

    // cause the progress bar to be updated even if mShowing
    // was already true.  This happens, for example, if we're
    // paused with the progress bar showing the user hits play.
    mHandler.sendEmptyMessage(SHOW_PROGRESS);

    Message msg = mHandler.obtainMessage(FADE_OUT);
    if (timeout != 0) {
      mHandler.removeMessages(FADE_OUT);
      mHandler.sendMessageDelayed(msg, timeout);
    }
  }
  // 夜间模式
  @Override
  protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

    Myapp = (MyApplication) getApplication();
    if (nightView != null) {
      mWindowManager.removeView(nightView);
      nightView = null;
    }
    if (Myapp.getlunaMode()) {
      WindowManager.LayoutParams params =
          new WindowManager.LayoutParams(
              LayoutParams.MATCH_PARENT,
              LayoutParams.MATCH_PARENT,
              android.view.WindowManager.LayoutParams.TYPE_APPLICATION,
              WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                  | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
              PixelFormat.TRANSLUCENT);
      params.gravity = Gravity.BOTTOM;

      if (nightView == null) {
        nightView = new TextView(this);
        nightView.setBackgroundColor(0xa0000000);
        mWindowManager.addView(nightView, params);
      }

    } else {
      if (nightView != null) {
        mWindowManager.removeView(nightView);
      }
    }
  }
  private void initView() {
    mWM = (WindowManager) mContext.getSystemService(WINDOW_SERVICE);
    mTextView =
        new TextView(mContext) {
          @Override
          protected void onDraw(android.graphics.Canvas canvas) {
            int t = getTop();
            int l = getLeft();
            int b = getBottom();
            int r = getRight();
            mRect.top = t;
            mRect.left = t;
            mRect.right = r;
            mRect.bottom = b;
            canvas.drawRect(mRect, mPaint);
            super.onDraw(canvas);
          };
        };

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.type = 2002;
    // wmParams.format=1;
    lp.flags |= 8;

    lp.gravity = Gravity.LEFT | Gravity.TOP; // 调整悬浮窗口至左上角
    // 以屏幕左上角为原点,设置x、y初始值
    lp.x = 0;
    lp.y = 0;

    // 设置悬浮窗口长宽数据
    lp.width = 300;
    lp.height = 25;
    mTextView.setText("");
    mWM.addView(mTextView, lp);
  }
Example #6
0
  private void startDragging(Bitmap bm, int y) {
    stopDragging();

    mWindowParams = new WindowManager.LayoutParams();
    mWindowParams.gravity = Gravity.TOP;
    mWindowParams.x = 0;
    mWindowParams.y = y - mDragPoint + mCoordOffset;

    mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    mWindowParams.format = PixelFormat.TRANSLUCENT;
    mWindowParams.windowAnimations = 0;

    ImageView v = new ImageView(getContext());
    //        int backGroundColor =
    // getContext().getResources().getColor(R.color.dragndrop_background);
    v.setBackgroundColor(dragndropBackgroundColor);
    v.setImageBitmap(bm);
    mDragBitmap = bm;

    mWindowManager = (WindowManager) getContext().getSystemService("window");
    mWindowManager.addView(v, mWindowParams);
    mDragView = v;
  }
 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);
 }
Example #8
0
  @Override
  public void onCreate() {
    super.onCreate();
    executorService = Executors.newSingleThreadExecutor();

    handlerThread = new HandlerThread("TabQueueHandlerThread");
    handlerThread.start();
    tabQueueHandler = new Handler(handlerThread.getLooper());

    windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

    LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    toastLayout = layoutInflater.inflate(R.layout.tab_queue_toast, null);

    final Resources resources = getResources();

    TextView messageView = (TextView) toastLayout.findViewById(R.id.toast_message);
    messageView.setText(resources.getText(R.string.tab_queue_toast_message));

    openNowButton = (Button) toastLayout.findViewById(R.id.toast_button);
    openNowButton.setText(resources.getText(R.string.tab_queue_toast_action));

    toastLayoutParams =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);

    toastLayoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
  }
Example #9
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 #10
0
  @Override
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {

    super.initialize(cordova, webView);

    WindowManager manager =
        ((WindowManager)
            cordova.getActivity().getApplicationContext().getSystemService(Context.WINDOW_SERVICE));

    WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
    localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    localLayoutParams.gravity = Gravity.TOP;
    localLayoutParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            |

            // this is to enable the notification to recieve touch events
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
            |

            // Draws over status bar
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

    localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    localLayoutParams.height =
        (int) (30 * cordova.getActivity().getResources().getDisplayMetrics().scaledDensity);
    localLayoutParams.format = PixelFormat.TRANSPARENT;

    CustomViewGroup view = new CustomViewGroup(cordova.getActivity().getApplicationContext());

    manager.addView(view, localLayoutParams);
  }
 @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);
 }
  private void startDragging(Bitmap bm, int x, int y) {
    stopDragging();

    mWindowParams = new WindowManager.LayoutParams();
    mWindowParams.gravity = Gravity.TOP | Gravity.LEFT;
    mWindowParams.x = x - mDragPointX + mXOffset;
    mWindowParams.y = y - mDragPointY + mYOffset;

    mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
    mWindowParams.format = PixelFormat.TRANSLUCENT;
    mWindowParams.windowAnimations = 0;

    Context context = getContext();
    ImageView v = new ImageView(context);
    // int backGroundColor = context.getResources().getColor(R.color.dragndrop_background);

    v.setBackgroundColor(0x882211); // !!toa
    // v.setBackgroundResource(R.drawable.playlist_tile_drag);
    v.setPadding(0, 0, 0, 0);
    v.setImageBitmap(bm);
    mDragBitmap = bm;

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    mWindowManager.addView(v, mWindowParams);
    mDragView = v;
  }
  /**
   * Adds the status bar view to the window manager.
   *
   * @param statusBarView The view to add.
   * @param barHeight The height of the status bar in collapsed state.
   */
  public void add(View statusBarView, int barHeight) {

    // Now that the status bar window encompasses the sliding panel and its
    // translucent backdrop, the entire thing is made TRANSLUCENT and is
    // hardware-accelerated.
    mLp =
        new WindowManager.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            barHeight,
            WindowManager.LayoutParams.TYPE_STATUS_BAR,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING
                | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
            PixelFormat.TRANSLUCENT);
    mLp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
    mLp.gravity = Gravity.TOP;
    mLp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
    mLp.setTitle("StatusBar");
    mLp.packageName = mContext.getPackageName();
    mStatusBarView = statusBarView;
    mBarHeight = barHeight;
    mWindowManager.addView(mStatusBarView, mLp);
    mLpChanged = new WindowManager.LayoutParams();
    mLpChanged.copyFrom(mLp);
  }
Example #14
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);
  }
  void displayEula() {
    AlertDialog.Builder adb = new SimpleEula(this).show();
    if (adb != null) {
      Dialog dialog = adb.create();

      Display display = getWindowManager().getDefaultDisplay();
      int mwidth = display.getWidth();
      int mheight = display.getHeight();

      dialog.show();

      int apiLevel = getApiLevel();
      if (apiLevel >= 11) {

        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();

        lp.copyFrom(dialog.getWindow().getAttributes());
        lp.width = mwidth;
        lp.height = mheight;
        lp.gravity = Gravity.CENTER_VERTICAL;
        lp.dimAmount = 0.7f;

        dialog.getWindow().setAttributes(lp);
        dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
      }
    }
  }
  private void startDragging(Bitmap bm, int x, int y) {
    stopDragging();

    mWindowParams = new WindowManager.LayoutParams();
    mWindowParams.gravity = Gravity.TOP | Gravity.LEFT;
    mWindowParams.x = x;
    mWindowParams.y = y - mDragPoint + mCoordOffset;

    mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
    mWindowParams.format = PixelFormat.TRANSLUCENT;
    mWindowParams.windowAnimations = 0;

    Context context = getContext();
    ImageView v = new ImageView(context);
    int backGroundColor = context.getResources().getColor(android.R.color.holo_blue_dark);
    v.setAlpha((float) 0.7);
    v.setBackgroundColor(backGroundColor);
    v.setImageBitmap(bm);
    mDragBitmap = bm;

    mWindowManager = (WindowManager) context.getSystemService("window");
    mWindowManager.addView(v, mWindowParams);
    mDragView = v;
  }
Example #17
0
 public void handleShow() {
   if (localLOGV)
     Log.v(TAG, "HANDLE SHOW: " + this + " mView=" + mView + " mNextView=" + mNextView);
   if (mView != mNextView) {
     // remove the old view if necessary
     handleHide();
     mView = mNextView;
     mWM = WindowManagerImpl.getDefault();
     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;
     if (mView.getParent() != null) {
       if (localLOGV) Log.v(TAG, "REMOVE! " + mView + " in " + this);
       mWM.removeView(mView);
     }
     if (localLOGV) Log.v(TAG, "ADD! " + mView + " in " + this);
     mWM.addView(mView, mParams);
     trySendAccessibilityEvent();
   }
 }
Example #18
0
  /**
   * Creates a system overlay that allows the user to touch the corner of the screen to push to
   * talk.
   */
  public void createPTTOverlay() {
    WindowManager.LayoutParams pttParams =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT);
    String hotCorner = settings.getHotCorner();
    if (hotCorner.equals(Settings.ARRAY_HOT_CORNER_TOP_LEFT)) {
      pttParams.gravity = Gravity.LEFT | Gravity.TOP;
    } else if (hotCorner.equals(Settings.ARRAY_HOT_CORNER_BOTTOM_LEFT)) {
      pttParams.gravity = Gravity.LEFT | Gravity.BOTTOM;
    } else if (hotCorner.equals(Settings.ARRAY_HOT_CORNER_TOP_RIGHT)) {
      pttParams.gravity = Gravity.RIGHT | Gravity.TOP;
    } else if (hotCorner.equals(Settings.ARRAY_HOT_CORNER_BOTTOM_RIGHT)) {
      pttParams.gravity = Gravity.RIGHT | Gravity.BOTTOM;
    }
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    overlayView = inflater.inflate(R.layout.overlay, null);
    final Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    overlayView.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
              setPushToTalk(true);
              // Vibrate to provide haptic feedback
              vibrator.vibrate(10);
              overlayView.setBackgroundColor(0xAA33b5e5);
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
              setPushToTalk(false);
              overlayView.setBackgroundColor(0);
            }
            return false;
          }
        });

    // Add layout to window manager
    wm.addView(overlayView, pttParams);
  }
  public void showChecked() {
    if (showing == (emojiKeyboardView != null)) {
      return;
    }
    emojiKeyboardView = createView();
    WindowManager.LayoutParams params =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            (keyboardHeight),
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);

    params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    windowManager.addView(emojiKeyboardView, params);
    //        emojiKeyboardView.post(new Runnable() {
    //            @Override
    //            public void run() {
    //                AlphaAnimation animation = new AlphaAnimation(0, 1);
    //                animation.setDuration(400);
    //                animation.setInterpolator(new MaterialInterpolator());
    //                animation.setStartOffset(0);
    //                animation.setAnimationListener(new Animation.AnimationListener() {
    //                    @Override
    //                    public void onAnimationStart(Animation animation) {
    //                        Log.d(TAG, "onAnimationStart");
    //                    }
    //
    //                    @Override
    //                    public void onAnimationEnd(Animation animation) {
    //                        Log.d(TAG, "onAnimationEnd");
    //                    }
    //
    //                    @Override
    //                    public void onAnimationRepeat(Animation animation) {
    //                        Log.d(TAG, "onAnimationReset");
    //                    }
    //                });
    //            }
    //        });

    //        emojiKeyboardView.setTranslationY(140);
    //        emojiKeyboardView
    //                .animate()
    //                .y(0)
    //                .setDuration(200)
    //                .setStartDelay(0)
    //                .setInterpolator(new DecelerateInterpolator(1.4f))
    //                .start();

    if (keyboardStatusListener != null) keyboardStatusListener.onShow();
    onShow();
  }
Example #20
0
  /**
   * Create a ShareOverlay for given title/url combination and add it to the screen.
   *
   * @return A reference to the created ShareOverlay.
   */
  private ShareOverlay getShareOverlay(String title, String url) {
    final WindowManager.LayoutParams params = getOverlayLayoutParams();

    params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;

    final ShareOverlay shareOverlay = new ShareOverlay(context, url);
    shareOverlay.setTitle(title);

    windowManager.addView(shareOverlay, params);

    return shareOverlay;
  }
Example #21
0
 private android.view.WindowManager.LayoutParams createPopupLayout(IBinder token) {
   android.view.WindowManager.LayoutParams p = new android.view.WindowManager.LayoutParams();
   p.gravity = 51;
   p.width = mWidth;
   p.height = mHeight;
   p.format = -3;
   p.flags = 16;
   if (!mFocusable) p.flags |= 8;
   p.type = 1000;
   p.token = token;
   p.animation = 0x102002c;
   return p;
 }
Example #22
0
 public OverlayDialog(Activity activity) {
   super(activity, R.style.OverlayDialog);
   WindowManager.LayoutParams params = getWindow().getAttributes();
   params.type = TYPE_SYSTEM_ALERT;
   params.dimAmount = 0.0F; // transparent
   params.width = 0;
   params.height = 0;
   params.gravity = Gravity.BOTTOM;
   getWindow().setAttributes(params);
   getWindow().setFlags(FLAG_SHOW_WHEN_LOCKED | FLAG_NOT_TOUCH_MODAL, 0xffffff);
   setOwnerActivity(activity);
   setCancelable(false);
 }
Example #23
0
  /**
   * @param context Context.
   * @param title The title of this AlertDialog can be null .
   * @param items button name list.
   * @param alertDo methods call Id:Button + cancel_Button.
   * @param exit Name can be null.It will be Red Color
   * @return A AlertDialog
   */
  public static Dialog showAlert(
      final Context context,
      final String title,
      final String[] items,
      String exit,
      final OnAlertSelectId alertDo,
      OnCancelListener cancelListener) {
    String cancel = context.getString(R.string.app_cancel);
    final Dialog dlg = new Dialog(context, R.style.MMTheme_DataSheet);
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.alert_dialog_menu_layout, null);
    final int cFullFillWidth = 10000;
    layout.setMinimumWidth(cFullFillWidth);
    final ListView list = (ListView) layout.findViewById(R.id.content_list);
    AlertAdapter adapter = new AlertAdapter(context, title, items, exit, cancel);
    list.setAdapter(adapter);
    list.setDividerHeight(0);

    list.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!(title == null || title.equals("")) && position - 1 >= 0) {
              alertDo.onClick(position - 1);
              dlg.dismiss();
              list.requestFocus();
            } else {
              alertDo.onClick(position);
              dlg.dismiss();
              list.requestFocus();
            }
          }
        });
    // set a large value put it in bottom
    Window w = dlg.getWindow();
    WindowManager.LayoutParams lp = w.getAttributes();
    lp.x = 0;
    final int cMakeBottom = -1000;
    lp.y = cMakeBottom;
    lp.gravity = Gravity.BOTTOM;
    dlg.onWindowAttributesChanged(lp);
    dlg.setCanceledOnTouchOutside(true);
    if (cancelListener != null) {
      dlg.setOnCancelListener(cancelListener);
    }
    dlg.setContentView(layout);
    dlg.show();
    return dlg;
  }
  private WindowManager.LayoutParams createPopupLayout(IBinder token) {
    WindowManager.LayoutParams p = new WindowManager.LayoutParams();
    p.gravity = Gravity.START | Gravity.TOP;
    p.width = ViewGroup.LayoutParams.MATCH_PARENT;
    p.height = ViewGroup.LayoutParams.MATCH_PARENT;
    p.format = PixelFormat.TRANSLUCENT;
    p.flags = computeFlags(p.flags);
    p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
    p.token = token;
    p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
    p.setTitle("DiscreteSeekBar Indicator:" + Integer.toHexString(hashCode()));

    return p;
  }
Example #25
0
 private void initDragWindowParams() {
   mWindowParams = new WindowManager.LayoutParams();
   mWindowParams.gravity = Gravity.TOP | Gravity.LEFT;
   mWindowParams.alpha = 1.0f;
   mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
   mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
   mWindowParams.flags =
       WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
           | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
           | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
           | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
   mWindowParams.format = PixelFormat.TRANSLUCENT;
   mWindowParams.windowAnimations = 0;
 }
Example #26
0
  public void showDialog(View view) {
    setContentView(view);
    Window window = getWindow(); // 得到对话框
    if (isAnimation) window.setWindowAnimations(animationStyle);

    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.MATCH_PARENT;
    params.height = LayoutParams.WRAP_CONTENT;
    params.gravity = Gravity.BOTTOM;
    params.dimAmount = 0f;
    getWindow().setAttributes(params);
    // getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    show();
  }
Example #27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    A.v(MainActivity.class, "onCreate");
    //
    //	//测试FLAG_ACTIVITY_FORWARD_RESULT的使用:MainActivity---startActivityForResult(SecondActivity---startActivity(ThirdActivity
    //		startActivityForResult(new Intent(this, SecondActivity.class), 0x10);

    // 测试添加系统窗口
    Button btn = new Button(getApplicationContext());
    btn.setText("Hello window");
    btn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            A.i("clicked...");
          }
        });
    WindowManager.LayoutParams lp =
        new WindowManager.LayoutParams(
            150,
            100,
            WindowManager.LayoutParams.TYPE_PRIORITY_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING,
            PixelFormat.RGB_888);
    lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
    lp.setTitle("title");
    lp.token = new Binder();
    WindowManager wm = (WindowManager) getApplicationContext().getSystemService("window");
    btn.setTag("123");
    wm.addView(btn, lp);

    super.onCreate(savedInstanceState);

    // 测试ContentObserver
    Uri uri = Uri.parse("test://haha");
    getContentResolver().registerContentObserver(uri, true, new OneContentObserver());
    // 调用notifyChange后,会通知到OneContentObserver
    getContentResolver().notifyChange(uri, null);

    // 测试文件系统更改的通知

    SharedPreferences sp = getSharedPreferences("ad_sp", Context.MODE_PRIVATE);

    sp.registerOnSharedPreferenceChangeListener(new OneSharedPreferenceChangeListener());

    sp.edit().putInt("testkey", 100).commit();
  }
  /**
   * Actual internal method to show this dialog. Called only by {@link #considerShowing()} when all
   * data requirements have been met.
   */
  private void showInternal() {
    mDecor = mWindow.getDecorView();
    mDecor.getViewTreeObserver().addOnGlobalLayoutListener(this);
    WindowManager.LayoutParams l = mWindow.getAttributes();

    l.width = mScreenWidth + mShadowHoriz + mShadowHoriz;
    l.height = WindowManager.LayoutParams.WRAP_CONTENT;

    // Force layout measuring pass so we have baseline numbers
    mDecor.measure(l.width, l.height);
    final int blockHeight = mDecor.getMeasuredHeight();

    l.gravity = Gravity.TOP | Gravity.LEFT;
    l.x = -mShadowHoriz;

    if (mAnchor.top > blockHeight) {
      // Show downwards callout when enough room, aligning bottom block
      // edge with top of anchor area, and adjusting to inset arrow.
      showArrow(R.id.arrow_down, mAnchor.centerX());
      l.y = mAnchor.top - blockHeight + mShadowVert;
      l.windowAnimations = R.style.QuickContactAboveAnimation;

    } else {
      // Otherwise show upwards callout, aligning block top with bottom of
      // anchor area, and adjusting to inset arrow.
      showArrow(R.id.arrow_up, mAnchor.centerX());
      l.y = mAnchor.bottom - mShadowVert;
      l.windowAnimations = R.style.QuickContactBelowAnimation;
    }

    l.flags =
        WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;

    mRequestedY = l.y;
    mWindowManager.addView(mDecor, l);
    mShowing = true;
    mQuerying = false;
    mDismissed = false;

    mTrack.startAnimation(mTrackAnim);

    if (TRACE_LAUNCH) {
      android.os.Debug.stopMethodTracing();
      Log.d(
          TAG,
          "Window recycled " + mWindowRecycled + " times, chiclets " + mActionRecycled + " times");
    }
  }
  private void update() {
    if (emojiKeyboardView != null) {
      WindowManager.LayoutParams params =
          new WindowManager.LayoutParams(
              WindowManager.LayoutParams.MATCH_PARENT,
              (keyboardHeight),
              WindowManager.LayoutParams.TYPE_PHONE,
              WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
              PixelFormat.TRANSLUCENT);
      params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
      windowManager.updateViewLayout(emojiKeyboardView, params);
    } else {

    }
  }
Example #30
0
 // Allocate and initialize the static parts of mDecorLayoutParams. Must
 // also call updateFloatingWindowLayout() to fill in the dynamic parts
 // (y and width) before mDecorLayoutParams can be used.
 private void initFloatingWindowLayout() {
   mDecorLayoutParams = new WindowManager.LayoutParams();
   WindowManager.LayoutParams p = mDecorLayoutParams;
   p.gravity = Gravity.TOP | Gravity.LEFT;
   p.height = LayoutParams.WRAP_CONTENT;
   p.x = 0;
   p.format = PixelFormat.TRANSLUCENT;
   p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
   p.flags |=
       WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
           | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
           | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
   p.token = null;
   p.windowAnimations = 0; // android.R.style.DropDownAnimationDown;
 }