Example #1
0
  @Override
  public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    updateMapLocationButtons(mAppPrefs.getAutoPanMode());

    final View telemetryView = telemetryFragment.getView();
    if (telemetryView != null) {
      final int slidingDrawerWidth = telemetryView.getWidth();
      updateLocationButtonsMargin(isActionDrawerOpened(), slidingDrawerWidth);
    }
  }
Example #2
0
  @Override
  public void onDrawerClosed() {
    super.onDrawerClosed();

    if (actionDrawerToggle != null) actionDrawerToggle.setActivated(false);

    if (telemetryFragment == null) return;
    final View telemetryView = telemetryFragment.getView();
    if (telemetryView != null) {
      final int slidingDrawerWidth = telemetryView.getWidth();
      final boolean isSlidingDrawerOpened = isActionDrawerOpened();
      updateLocationButtonsMargin(isSlidingDrawerOpened, slidingDrawerWidth);
    }
  }
  @Override
  public void onDroneEvent(DroneEventsType event, Drone drone) {
    super.onDroneEvent(event, drone);
    switch (event) {
      case AUTOPILOT_WARNING:
        onWarningChanged(drone);
        break;

      case ARMING:
      case CONNECTED:
      case DISCONNECTED:
      case STATE:
        enableSlidingUpPanel(drone);
        break;

      default:
        break;
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {

    this.requestWindowFeature(Window.FEATURE_NO_TITLE); // 去掉标题栏

    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN); // 去掉信息栏

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // 横屏
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_configuration);

    if (savedInstanceState != null) {
      mConfigScreenId = savedInstanceState.getInt(EXTRA_CONFIG_SCREEN_ID, mConfigScreenId);
    }

    handleIntent(getIntent());
  }
Example #5
0
 @Override
 public void onStart() {
   super.onStart();
   setupMapFragment();
 }
Example #6
0
 @Override
 public void onApiDisconnected() {
   super.onApiDisconnected();
   enableSlidingUpPanel(dpApp.getDrone());
   getBroadcastManager().unregisterReceiver(eventReceiver);
 }
Example #7
0
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putBoolean(EXTRA_IS_ACTION_DRAWER_OPENED, isActionDrawerOpened());
 }
Example #8
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flight);

    fragmentManager = getSupportFragmentManager();

    mSlidingPanel = (SlidingUpPanelLayout) findViewById(R.id.slidingPanelContainer);
    warningView = (TextView) findViewById(R.id.failsafeTextView);

    setupMapFragment();

    mLocationButtonsContainer = findViewById(R.id.location_button_container);
    mGoToMyLocation = (ImageButton) findViewById(R.id.my_location_button);
    mGoToDroneLocation = (ImageButton) findViewById(R.id.drone_location_button);
    actionDrawerToggle = (ImageButton) findViewById(R.id.toggle_action_drawer);
    actionDrawerToggle.setVisibility(View.VISIBLE);

    actionDrawerToggle.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (isActionDrawerOpened()) closeActionDrawer();
            else openActionDrawer();
          }
        });

    mGoToMyLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mapFragment != null) {
              mapFragment.goToMyLocation();
              updateMapLocationButtons(AutoPanMode.DISABLED);
            }
          }
        });
    mGoToMyLocation.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            if (mapFragment != null) {
              mapFragment.goToMyLocation();
              updateMapLocationButtons(AutoPanMode.USER);
              return true;
            }
            return false;
          }
        });

    mGoToDroneLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mapFragment != null) {
              mapFragment.goToDroneLocation();
              updateMapLocationButtons(AutoPanMode.DISABLED);
            }
          }
        });
    mGoToDroneLocation.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            if (mapFragment != null) {
              mapFragment.goToDroneLocation();
              updateMapLocationButtons(AutoPanMode.DRONE);
              return true;
            }
            return false;
          }
        });

    flightActions =
        (FlightControlManagerFragment) fragmentManager.findFragmentById(R.id.flightActionsFragment);
    if (flightActions == null) {
      flightActions = new FlightControlManagerFragment();
      fragmentManager.beginTransaction().add(R.id.flightActionsFragment, flightActions).commit();
    }

    mFlightActionsView = findViewById(R.id.flightActionsFragment);
    mFlightActionsView
        .getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
              @Override
              public void onGlobalLayout() {
                if (!mSlidingPanelCollapsing.get()) {
                  mSlidingPanel.setPanelHeight(mFlightActionsView.getHeight());
                }
              }
            });

    // Add the telemetry fragment
    final int actionDrawerId = getActionDrawerId();
    telemetryFragment = (TelemetryFragment) fragmentManager.findFragmentById(actionDrawerId);
    if (telemetryFragment == null) {
      telemetryFragment = new TelemetryFragment();
      fragmentManager.beginTransaction().add(actionDrawerId, telemetryFragment).commit();
    }

    // Add the mode info panel fragment
    FlightModePanel flightModePanel =
        (FlightModePanel) fragmentManager.findFragmentById(R.id.sliding_drawer_content);
    if (flightModePanel == null) {
      flightModePanel = new FlightModePanel();
      fragmentManager.beginTransaction().add(R.id.sliding_drawer_content, flightModePanel).commit();
    }

    boolean isActionDrawerOpened = DEFAULT_IS_ACTION_DRAWER_OPENED;
    if (savedInstanceState != null) {
      isActionDrawerOpened =
          savedInstanceState.getBoolean(EXTRA_IS_ACTION_DRAWER_OPENED, isActionDrawerOpened);
    }

    if (isActionDrawerOpened) openActionDrawer();
  }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putInt(EXTRA_CONFIG_SCREEN_ID, mConfigScreenId);
 }
 @Override
 public void onNewIntent(Intent intent) {
   super.onNewIntent(intent);
   setIntent(intent);
   handleIntent(intent);
 }
 @Override
 public void onApiConnected() {
   super.onApiConnected();
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flight);

    fragmentManager = getSupportFragmentManager();

    mSlidingPanel = (SlidingUpPanelLayout) findViewById(R.id.slidingPanelContainer);
    enableSlidingUpPanel(this.drone);

    warningView = (TextView) findViewById(R.id.failsafeTextView);

    final SlidingDrawer slidingDrawer = (SlidingDrawer) findViewById(R.id.slidingDrawerRight);
    // Only the phone layout has the sliding drawer
    if (slidingDrawer != null) {
      slidingDrawer.setOnDrawerCloseListener(
          new SlidingDrawer.OnDrawerCloseListener() {
            @Override
            public void onDrawerClosed() {
              final int slidingDrawerWidth = slidingDrawer.getContent().getWidth();
              final boolean isSlidingDrawerOpened = slidingDrawer.isOpened();
              updateLocationButtonsMargin(isSlidingDrawerOpened, slidingDrawerWidth);
            }
          });

      slidingDrawer.setOnDrawerOpenListener(
          new SlidingDrawer.OnDrawerOpenListener() {
            @Override
            public void onDrawerOpened() {
              final int slidingDrawerWidth = slidingDrawer.getContent().getWidth();
              final boolean isSlidingDrawerOpened = slidingDrawer.isOpened();
              updateLocationButtonsMargin(isSlidingDrawerOpened, slidingDrawerWidth);
            }
          });
    }

    setupMapFragment();

    mLocationButtonsContainer = findViewById(R.id.location_button_container);
    mGoToMyLocation = (ImageButton) findViewById(R.id.my_location_button);
    mGoToDroneLocation = (ImageButton) findViewById(R.id.drone_location_button);

    final ImageButton resetMapBearing = (ImageButton) findViewById(R.id.map_orientation_button);
    resetMapBearing.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mapFragment != null) {
              mapFragment.updateMapBearing(0);
            }
          }
        });

    mGoToMyLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mapFragment != null) {
              mapFragment.goToMyLocation();
              updateMapLocationButtons(AutoPanMode.DISABLED);
            }
          }
        });
    mGoToMyLocation.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            if (mapFragment != null) {
              mapFragment.goToMyLocation();
              updateMapLocationButtons(AutoPanMode.USER);
              return true;
            }
            return false;
          }
        });

    mGoToDroneLocation.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mapFragment != null) {
              mapFragment.goToDroneLocation();
              updateMapLocationButtons(AutoPanMode.DISABLED);
            }
          }
        });
    mGoToDroneLocation.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            if (mapFragment != null) {
              mapFragment.goToDroneLocation();
              updateMapLocationButtons(AutoPanMode.DRONE);
              return true;
            }
            return false;
          }
        });

    Fragment flightActions = fragmentManager.findFragmentById(R.id.flightActionsFragment);
    if (flightActions == null) {
      flightActions = new FlightActionsFragment();
      fragmentManager.beginTransaction().add(R.id.flightActionsFragment, flightActions).commit();
    }

    mFlightActionsView = findViewById(R.id.flightActionsFragment);
    mFlightActionsView
        .getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
              @Override
              public void onGlobalLayout() {
                if (!mSlidingPanelCollapsing.get()) {
                  mSlidingPanel.setPanelHeight(mFlightActionsView.getHeight());
                }
              }
            });

    // Add the telemetry fragment
    Fragment telemetryFragment = fragmentManager.findFragmentById(R.id.telemetryFragment);
    if (telemetryFragment == null) {
      telemetryFragment = new TelemetryFragment();
      fragmentManager.beginTransaction().add(R.id.telemetryFragment, telemetryFragment).commit();
    }

    // Add the mode info panel fragment
    Fragment flightModePanel = fragmentManager.findFragmentById(R.id.sliding_drawer_content);
    if (flightModePanel == null) {
      flightModePanel = new FlightModePanel();
      fragmentManager.beginTransaction().add(R.id.sliding_drawer_content, flightModePanel).commit();
    }

    DroneshareDialog.perhapsShow(this);
  }
 @Override
 public void onWindowFocusChanged(boolean hasFocus) {
   super.onWindowFocusChanged(hasFocus);
   updateMapLocationButtons(mAppPrefs.getAutoPanMode());
 }