Skip to content

Commit

Permalink
Merge pull request #1595 from DroidPlanner/feature_takeoff_for_planes
Browse files Browse the repository at this point in the history
Improved takeoff mission item support for planes.
  • Loading branch information
m4gr3d committed Sep 14, 2015
2 parents f8863ba + 42bca94 commit 5183fd3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
14 changes: 14 additions & 0 deletions Android/res/layout/fragment_editor_detail_takeoff.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
android:layout_marginTop="5dp"
android:layout_height="54dp"
android:layout_toRightOf="@id/WaypointIndex"
android:layout_toEndOf="@id/WaypointIndex"
android:layout_alignParentTop="true"
android:background="@drawable/wp_title_div"/>

<RelativeLayout
android:id="@+id/title_content"
android:layout_toRightOf="@id/title_div"
android:layout_toEndOf="@id/title_div"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
Expand All @@ -50,6 +52,7 @@
android:id="@+id/WaypointType"
style="@style/missionHeaderTitle"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/waypointType_TakeOff"/>
Expand All @@ -58,6 +61,7 @@
android:id="@+id/DistanceLabel"
style="@style/missionHeaderlabel"
android:layout_alignLeft="@id/WaypointType"
android:layout_alignStart="@id/WaypointType"
android:layout_below="@id/WaypointType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -71,6 +75,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@id/title_rect"
android:src="@drawable/ic_menu_hint"
android:layout_margin="10dp"
Expand Down Expand Up @@ -101,6 +106,15 @@
android:text="@string/altitude_label"
/>

<org.droidplanner.android.view.spinnerWheel.CardWheelHorizontalView
android:id="@+id/pitchPicker"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/missionItemDetailCard"
android:text="@string/label_pitch"
/>

</LinearLayout>

</RelativeLayout>
1 change: 1 addition & 0 deletions Android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
<string name="telemetry_default_value">0.0</string>
<string name="climb_rate_label">Climb Rate</string>
<string name="altitude_label">Altitude</string>
<string name="label_pitch">Pitch</string>
<string name="roi_height_label">ROI Height</string>
<string name="speed_label">Speed</string>
<string name="length_label">Length</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void onApiConnected() {
YawCondition item = (YawCondition) getMissionItems().get(0);

final NumericWheelAdapter adapter = new NumericWheelAdapter(getContext(),
R.layout.wheel_text_centered, 0, 359, "%d deg");
R.layout.wheel_text_centered, 0, 359, "%d°");
final CardWheelHorizontalView<Integer> cardAltitudePicker = (CardWheelHorizontalView<Integer>) view
.findViewById(R.id.picker1);
cardAltitudePicker.setViewAdapter(adapter);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.droidplanner.android.proxy.mission.item.fragments;

import android.content.Context;
import android.view.View;

import com.o3dr.services.android.lib.drone.mission.MissionItemType;
import com.o3dr.services.android.lib.drone.mission.item.MissionItem;
import com.o3dr.services.android.lib.drone.mission.item.command.Takeoff;
Expand All @@ -9,9 +12,10 @@
import org.droidplanner.android.utils.unit.providers.length.LengthUnitProvider;
import org.droidplanner.android.view.spinnerWheel.CardWheelHorizontalView;
import org.droidplanner.android.view.spinnerWheel.adapters.LengthWheelAdapter;
import org.droidplanner.android.view.spinnerWheel.adapters.NumericWheelAdapter;

public class MissionTakeoffFragment extends MissionDetailFragment implements
CardWheelHorizontalView.OnCardWheelScrollListener<LengthUnit> {
CardWheelHorizontalView.OnCardWheelScrollListener {

@Override
protected int getResource() {
Expand All @@ -22,41 +26,59 @@ protected int getResource() {
public void onApiConnected() {
super.onApiConnected();

final View view = getView();
final Context context = getContext();

typeSpinner.setSelection(commandAdapter.getPosition(MissionItemType.TAKEOFF));

final LengthUnitProvider lengthUP = getLengthUnitProvider();
final LengthWheelAdapter altitudeAdapter = new LengthWheelAdapter(getContext(), R.layout.wheel_text_centered,
final LengthWheelAdapter altitudeAdapter = new LengthWheelAdapter(context, R.layout.wheel_text_centered,
lengthUP.boxBaseValueToTarget(MIN_ALTITUDE), lengthUP.boxBaseValueToTarget(MAX_ALTITUDE));
CardWheelHorizontalView<LengthUnit> cardAltitudePicker = (CardWheelHorizontalView) getView()
CardWheelHorizontalView<LengthUnit> cardAltitudePicker = (CardWheelHorizontalView) view
.findViewById(R.id.altitudePicker);
cardAltitudePicker.setViewAdapter(altitudeAdapter);
cardAltitudePicker.addScrollListener(this);

final NumericWheelAdapter pitchAdapter = new NumericWheelAdapter(context, R.layout.wheel_text_centered, 0, 90, "%d°");
final CardWheelHorizontalView<Integer> pitchPicker = (CardWheelHorizontalView) view.findViewById(R.id.pitchPicker);
pitchPicker.setViewAdapter(pitchAdapter);
pitchPicker.addScrollListener(this);

Takeoff item = (Takeoff) getMissionItems().get(0);
cardAltitudePicker.setCurrentValue(lengthUP.boxBaseValueToTarget(item.getTakeoffAltitude()));
pitchPicker.setCurrentValue((int) item.getTakeoffPitch());
}

@Override
public void onScrollingStarted(CardWheelHorizontalView cardWheel, LengthUnit startValue) {
public void onScrollingStarted(CardWheelHorizontalView cardWheel, Object startValue) {

}

@Override
public void onScrollingUpdate(CardWheelHorizontalView cardWheel, LengthUnit oldValue, LengthUnit newValue) {
public void onScrollingUpdate(CardWheelHorizontalView cardWheel, Object oldValue, Object newValue) {

}

@Override
public void onScrollingEnded(CardWheelHorizontalView wheel, LengthUnit startValue, LengthUnit endValue) {
public void onScrollingEnded(CardWheelHorizontalView wheel, Object startValue, Object endValue) {
switch (wheel.getId()) {
case R.id.altitudePicker:
final double baseValue = endValue.toBase().getValue();
final double baseValue = ((LengthUnit) endValue).toBase().getValue();
for (MissionItem missionItem : getMissionItems()) {
Takeoff item = (Takeoff) missionItem;
item.setTakeoffAltitude(baseValue);
}
getMissionProxy().notifyMissionUpdate();
break;

case R.id.pitchPicker:
final int pitch = (Integer) endValue;
for(MissionItem missionItem : getMissionItems()){
((Takeoff) missionItem).setTakeoffPitch(pitch);
}

getMissionProxy().notifyMissionUpdate();
break;
}
}
}

0 comments on commit 5183fd3

Please sign in to comment.