Esempio n. 1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mView = (RelativeLayout) findViewById(R.id.mainview);
    mView.setFocusableInTouchMode(false);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
      mView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    }

    mWPM = WallpaperManager.getInstance(this);
  }
Esempio n. 2
0
  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
      case R.id.btn1:
        // 显示状态栏,Activity不全屏显示(恢复到有状态的正常情况)
        mRLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        break;
      case R.id.btn2:
        // 隐藏状态栏,同时Activity会伸展全屏显示
        mRLayout.setSystemUiVisibility(View.INVISIBLE);
        break;
      case R.id.btn3:
        // Activity全屏显示,且状态栏被隐藏覆盖掉。
        mRLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
        break;
      case R.id.btn4:
        // Activity全屏显示,但状态栏不会被隐藏覆盖,状态栏依然可见,Activity顶端布局部分会被状态遮住
        mRLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        break;

      case R.id.btn5:
        // 同mRLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        mRLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
        break;
      case R.id.btn6:
        // 同mRLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        mRLayout.setSystemUiVisibility(View.SYSTEM_UI_LAYOUT_FLAGS);
        break;
      case R.id.btn7:
        // 隐藏虚拟按键(导航栏)
        mRLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        break;
      case R.id.btn8:
        // 状态栏显示处于低能显示状态(low profile模式),状态栏上一些图标显示会被隐藏。
        mRLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        break;
    }
  }
Esempio n. 3
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      xPos = event.getX();
      yPos = event.getY();
      // kill app if touched in bottom right corner
      if (xPos > mView.getWidth() - 50 && event.getY() > mView.getHeight() - 50) finish();
      else {
        mWPM.sendWallpaperCommand(
            mView.getWindowToken(),
            WallpaperManager.COMMAND_TAP,
            (int) xPos,
            (int) event.getY(),
            0,
            null);
      }
    } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
      xWP = xWP + (xPos - event.getX()) / 500;
      xPos = event.getX();
      if (xWP < 0) xWP = 0;
      if (xWP > 1) xWP = 1;

      yWP = yWP + (yPos - event.getY()) / 500;
      yPos = event.getY();
      if (yWP < 0) yWP = 0;
      if (yWP > 1) yWP = 1;
      mWPM.setWallpaperOffsets(mView.getWindowToken(), xWP, yWP);
    }

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
      mView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
      Log.d("Cleaner", "Lights out");
    }

    return super.onTouchEvent(event);
  }