Skip to content

Commit

Permalink
Merge branch 'master' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurbenemann committed Oct 2, 2014
2 parents a7729b7 + c224f55 commit bf373b9
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 151 deletions.
2 changes: 1 addition & 1 deletion Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.droidplanner"
android:versionCode="101"
android:versionCode="102"
android:versionName="please run version.sh to get the version name">

<uses-sdk
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
12 changes: 9 additions & 3 deletions Android/res/layout/fragment_mission_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
android:drawableTop="@drawable/ic_takeoff"
android:text="@string/mission_control_takeoff"
/>

<Button
android:id="@+id/mc_TakeoffInAutoBtn"
style="@style/flightControlButton.Row"
android:drawableTop="@drawable/ic_auto"
android:text="@string/mission_control_auto"/>

</LinearLayout>

Expand Down Expand Up @@ -110,12 +116,12 @@
tools:ignore="ContentDescription"/>

<Button
android:id="@+id/mc_loiter"
android:id="@+id/mc_pause"
style="@style/flightControlButton.Row"
android:layout_width="75dp"
android:layout_height="match_parent"
android:drawableTop="@drawable/ic_loiter"
android:text="@string/mission_control_loiter"
android:drawableTop="@drawable/ic_pause"
android:text="@string/mission_control_pause"
android:layout_weight="1"
tools:ignore="ContentDescription"/>

Expand Down
1 change: 0 additions & 1 deletion Android/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@
<string name="mission_control_home">Start</string>
<string name="mission_control_land">Landen</string>
<string name="mission_control_takeoff">Abheben</string>
<string name="mission_control_loiter">Loiter</string>
<string name="mission_control_follow">Folgen</string>

<!-- Bluetooth device selection strings -->
Expand Down
1 change: 0 additions & 1 deletion Android/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@
<string name="mission_control_home">回家</string>
<string name="mission_control_land">降落</string>
<string name="mission_control_takeoff">起飞</string>
<string name="mission_control_loiter">悬停</string>
<string name="mission_control_follow">跟随</string>
<string name="telemetry_label">遥测</string>
<string name="flight_modes_label">飞行模式</string>
Expand Down
95 changes: 55 additions & 40 deletions Android/res/values-zh-rTW/strings.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
<string name="mission_control_disarm">Disarm</string>
<string name="mission_control_land">Land</string>
<string name="mission_control_takeoff">Takeoff</string>
<string name="mission_control_loiter">Loiter</string>
<string name="mission_control_pause">Pause</string>
<string name="mission_control_auto">Auto</string>
<string name="mission_control_follow">Follow</string>
<string name="mission_control_dronie">Dronie</string>
Expand Down
220 changes: 117 additions & 103 deletions Android/src/org/droidplanner/android/fragments/FlightActionsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

public class FlightActionsFragment extends Fragment implements OnClickListener, OnDroneListener {

private static final double TAKEOFF_ALTITUDE = 10.0;

public interface OnMissionControlInteraction {
public void onJoystickSelected();
}
Expand All @@ -36,16 +38,16 @@ public interface OnMissionControlInteraction {

private Follow followMe;

private View mDisconnectedButtons;
private View mDisarmedButtons;
private View mArmedButtons;
private View mInFlightButtons;
private View mDisconnectedButtons;
private View mDisarmedButtons;
private View mArmedButtons;
private View mInFlightButtons;

private Button followBtn;
private Button homeBtn;
private Button landBtn;
private Button loiterBtn;
private Button autoBtn;
private Button followBtn;
private Button homeBtn;
private Button landBtn;
private Button pauseBtn;
private Button autoBtn;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand All @@ -61,42 +63,45 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

mDisconnectedButtons = view.findViewById(R.id.mc_disconnected_buttons);
mDisarmedButtons = view.findViewById(R.id.mc_disarmed_buttons);
mArmedButtons = view.findViewById(R.id.mc_armed_buttons);
mInFlightButtons = view.findViewById(R.id.mc_in_flight_buttons);
mDisconnectedButtons = view.findViewById(R.id.mc_disconnected_buttons);
mDisarmedButtons = view.findViewById(R.id.mc_disarmed_buttons);
mArmedButtons = view.findViewById(R.id.mc_armed_buttons);
mInFlightButtons = view.findViewById(R.id.mc_in_flight_buttons);

final Button joystickBtn = (Button) view.findViewById(R.id.mc_joystickBtn);
joystickBtn.setOnClickListener(this);

final Button connectBtn = (Button) view.findViewById(R.id.mc_connectBtn);
final Button connectBtn = (Button) view.findViewById(R.id.mc_connectBtn);
connectBtn.setOnClickListener(this);

homeBtn = (Button) view.findViewById(R.id.mc_homeBtn);
homeBtn = (Button) view.findViewById(R.id.mc_homeBtn);
homeBtn.setOnClickListener(this);

final Button armBtn = (Button) view.findViewById(R.id.mc_armBtn);
final Button armBtn = (Button) view.findViewById(R.id.mc_armBtn);
armBtn.setOnClickListener(this);

final Button disarmBtn = (Button) view.findViewById(R.id.mc_disarmBtn);
final Button disarmBtn = (Button) view.findViewById(R.id.mc_disarmBtn);
disarmBtn.setOnClickListener(this);

landBtn = (Button) view.findViewById(R.id.mc_land);
landBtn = (Button) view.findViewById(R.id.mc_land);
landBtn.setOnClickListener(this);

final Button takeoffBtn = (Button) view.findViewById(R.id.mc_takeoff);
final Button takeoffBtn = (Button) view.findViewById(R.id.mc_takeoff);
takeoffBtn.setOnClickListener(this);

loiterBtn = (Button) view.findViewById(R.id.mc_loiter);
loiterBtn.setOnClickListener(this);
pauseBtn = (Button) view.findViewById(R.id.mc_pause);
pauseBtn.setOnClickListener(this);

autoBtn = (Button) view.findViewById(R.id.mc_autoBtn);
autoBtn = (Button) view.findViewById(R.id.mc_autoBtn);
autoBtn.setOnClickListener(this);

final Button takeoffInAuto = (Button) view.findViewById(R.id.mc_TakeoffInAutoBtn);
takeoffInAuto.setOnClickListener(this);

followBtn = (Button) view.findViewById(R.id.mc_follow);
followBtn = (Button) view.findViewById(R.id.mc_follow);
followBtn.setOnClickListener(this);

final Button dronieBtn = (Button) view.findViewById(R.id.mc_dronieBtn);
final Button dronieBtn = (Button) view.findViewById(R.id.mc_dronieBtn);
dronieBtn.setOnClickListener(this);

drone.addDroneListener(this);
Expand Down Expand Up @@ -126,8 +131,8 @@ public void onClick(View v) {
break;

case R.id.mc_armBtn:
getArmingConfirmation();
eventBuilder.setAction("Changed flight mode").setLabel("Arm");
getArmingConfirmation();
eventBuilder.setAction("Changed flight mode").setLabel("Arm");
break;

case R.id.mc_disarmBtn:
Expand All @@ -141,7 +146,7 @@ public void onClick(View v) {
break;

case R.id.mc_takeoff:
drone.getState().doTakeoff(new Altitude(10.0));
drone.getState().doTakeoff(new Altitude(TAKEOFF_ALTITUDE));
eventBuilder.setAction("Changed flight mode").setLabel("Takeoff");
break;

Expand All @@ -150,15 +155,21 @@ public void onClick(View v) {
eventBuilder.setAction("Changed flight mode").setLabel(ApmModes.ROTOR_RTL.getName());
break;

case R.id.mc_loiter:
drone.getState().changeFlightMode(ApmModes.ROTOR_LOITER);
eventBuilder.setAction("Changed flight mode").setLabel(ApmModes.ROTOR_LOITER.getName());
case R.id.mc_pause:
drone.getGuidedPoint().pauseAtCurrentLocation();
eventBuilder.setAction("Changed flight mode").setLabel("Pause");
break;

case R.id.mc_autoBtn:
drone.getState().changeFlightMode(ApmModes.ROTOR_AUTO);
eventBuilder.setAction("Changed flight mode").setLabel(ApmModes.ROTOR_AUTO.getName());
break;

case R.id.mc_TakeoffInAutoBtn:
drone.getState().doTakeoff(new Altitude(TAKEOFF_ALTITUDE));
drone.getState().changeFlightMode(ApmModes.ROTOR_AUTO);
eventBuilder.setAction("Changed flight mode").setLabel(ApmModes.ROTOR_AUTO.getName());
break;

case R.id.mc_follow:
final int result = followMe.toggleFollowMeState();
Expand Down Expand Up @@ -190,7 +201,7 @@ public void onClick(View v) {
Toast.makeText(getActivity(), eventLabel, Toast.LENGTH_SHORT).show();
}
break;

case R.id.mc_dronieBtn:
drone.getMission().makeAndUploadDronie();
eventBuilder.setAction("Dronie").setLabel("Dronie");
Expand All @@ -206,24 +217,23 @@ public void onClick(View v) {

}

private void getArmingConfirmation() {
YesNoDialog ynd = YesNoDialog.newInstance(getString(R.string.dialog_confirm_arming_title),
getString(R.string.dialog_confirm_arming_msg),
new YesNoDialog.Listener() {
@Override
public void onYes() {
MavLinkArm.sendArmMessage(drone, true);
}
private void getArmingConfirmation() {
YesNoDialog ynd = YesNoDialog.newInstance(getString(R.string.dialog_confirm_arming_title),
getString(R.string.dialog_confirm_arming_msg), new YesNoDialog.Listener() {
@Override
public void onYes() {
MavLinkArm.sendArmMessage(drone, true);
}

@Override
public void onNo() {
}
});
@Override
public void onNo() {
}
});

ynd.show(getChildFragmentManager(), "Confirm arming");
}
ynd.show(getChildFragmentManager(), "Confirm arming");
}

@Override
@Override
public void onDroneEvent(DroneEventsType event, Drone drone) {
switch (event) {
case ARMING:
Expand All @@ -233,62 +243,66 @@ public void onDroneEvent(DroneEventsType event, Drone drone) {
setupButtonsByFlightState();
break;

case MODE:
updateFlightModeButtons();
break;
case MODE:
updateFlightModeButtons();
break;

case FOLLOW_START:
case FOLLOW_STOP:
updateFollowButton();
break;
case FOLLOW_START:
case FOLLOW_STOP:
updateFollowButton();
break;

default:
break;
}
}

private void updateFlightModeButtons() {
resetFlightModeButtons();

final ApmModes flightMode = drone.getState().getMode();
switch(flightMode){
case ROTOR_AUTO:
autoBtn.setActivated(true);
break;

case ROTOR_LOITER:
loiterBtn.setActivated(true);
break;

case ROTOR_RTL:
homeBtn.setActivated(true);
break;

case ROTOR_LAND:
landBtn.setActivated(true);
break;
}
}

private void resetFlightModeButtons() {
homeBtn.setActivated(false);
landBtn.setActivated(false);
loiterBtn.setActivated(false);
autoBtn.setActivated(false);
}

private void updateFollowButton() {
followBtn.setActivated(followMe.isEnabled());
}

private void resetButtonsContainerVisibility(){
mDisconnectedButtons.setVisibility(View.GONE);
mDisarmedButtons.setVisibility(View.GONE);
mArmedButtons.setVisibility(View.GONE);
mInFlightButtons.setVisibility(View.GONE);
}

private void setupButtonsByFlightState() {
private void updateFlightModeButtons() {
resetFlightModeButtons();

final ApmModes flightMode = drone.getState().getMode();
switch (flightMode) {
case ROTOR_AUTO:
autoBtn.setActivated(true);
break;

case ROTOR_GUIDED:
if (drone.getGuidedPoint().isIdle()) {
pauseBtn.setActivated(true);
}
break;

case ROTOR_RTL:
homeBtn.setActivated(true);
break;

case ROTOR_LAND:
landBtn.setActivated(true);
break;
default:
break;
}
}

private void resetFlightModeButtons() {
homeBtn.setActivated(false);
landBtn.setActivated(false);
pauseBtn.setActivated(false);
autoBtn.setActivated(false);
}

private void updateFollowButton() {
followBtn.setActivated(followMe.isEnabled());
}

private void resetButtonsContainerVisibility() {
mDisconnectedButtons.setVisibility(View.GONE);
mDisarmedButtons.setVisibility(View.GONE);
mArmedButtons.setVisibility(View.GONE);
mInFlightButtons.setVisibility(View.GONE);
}

private void setupButtonsByFlightState() {
if (drone.getMavClient().isConnected()) {
if (drone.getState().isArmed()) {
if (drone.getState().isFlying()) {
Expand All @@ -305,23 +319,23 @@ private void setupButtonsByFlightState() {
}

private void setupButtonsForDisconnected() {
resetButtonsContainerVisibility();
mDisconnectedButtons.setVisibility(View.VISIBLE);
resetButtonsContainerVisibility();
mDisconnectedButtons.setVisibility(View.VISIBLE);
}

private void setupButtonsForDisarmed() {
resetButtonsContainerVisibility();
mDisarmedButtons.setVisibility(View.VISIBLE);
resetButtonsContainerVisibility();
mDisarmedButtons.setVisibility(View.VISIBLE);
}

private void setupButtonsForArmed() {
resetButtonsContainerVisibility();
mArmedButtons.setVisibility(View.VISIBLE);
resetButtonsContainerVisibility();
mArmedButtons.setVisibility(View.VISIBLE);
}

private void setupButtonsForFlying() {
resetButtonsContainerVisibility();
mInFlightButtons.setVisibility(View.VISIBLE);
resetButtonsContainerVisibility();
mInFlightButtons.setVisibility(View.VISIBLE);
}

}
Loading

0 comments on commit bf373b9

Please sign in to comment.