Skip to content

Commit

Permalink
Merge pull request #1196 from ne0fhyk/fix_issue_1127
Browse files Browse the repository at this point in the history
Fixed issue #1127
  • Loading branch information
m4gr3d committed Oct 22, 2014
2 parents 187ea47 + d89af08 commit 54359de
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions Android/res/values/preferences_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This file is used to store the preferences keys so that it's accessible and modi
<string name="pref_dialogs_key">pref_dialogs</string>
<string name="pref_warn_on_arm_key">pref_warn_on_arm</string>
<string name="pref_auto_insert_mission_takeoff_rtl_land_key">pref_auto_insert_mission_takeoff_rtl_land</string>
<string name="pref_warn_on_takeoff_in_auto_key">pref_warn_on_takeoff_in_auto</string>

<string name="pref_enable_tts_key">pref_enable_tts</string>
<string name="pref_tts_periodic_key">tts_periodic</string>
Expand Down
2 changes: 2 additions & 0 deletions Android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -506,5 +506,7 @@
<string name="pref_dialog_entry_never">Never</string>
<string name="pref_dialog_entry_ask">Ask</string>
<string name="pref_dialog_selection_reset_desc"><![CDATA[Reset selection through: Settings -> User Interface -> Preference Dialogs]]></string>
<string name="dialog_confirm_take_off_in_auto_title">Take off in Auto?</string>
<string name="dialog_confirm_take_off_in_auto_msg">Warning! The drone will now take off and start the mission.</string>

</resources>
7 changes: 7 additions & 0 deletions Android/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@
android:defaultValue="@string/pref_dialog_entry_ask"
android:entryValues="@array/preference_dialog_entry"/>

<ListPreference
android:key="@string/pref_warn_on_takeoff_in_auto_key"
android:title="@string/dialog_confirm_take_off_in_auto_title"
android:entries="@array/preference_dialog_entry"
android:defaultValue="@string/pref_dialog_entry_ask"
android:entryValues="@array/preference_dialog_entry"/>

</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ public void onClick(View v) {
break;

case R.id.mc_TakeoffInAutoBtn:
drone.getState().doTakeoff(new Altitude(TAKEOFF_ALTITUDE));
drone.getState().changeFlightMode(ApmModes.ROTOR_AUTO);
getTakeOffInAutoConfirmation();
eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel(ApmModes.ROTOR_AUTO.getName());
break;

Expand Down Expand Up @@ -224,6 +223,26 @@ public void onClick(View v) {

}

private void getTakeOffInAutoConfirmation() {
YesNoWithPrefsDialog ynd = YesNoWithPrefsDialog.newInstance(getActivity()
.getApplicationContext(), getString(R.string.dialog_confirm_take_off_in_auto_title),
getString(R.string.dialog_confirm_take_off_in_auto_msg), new YesNoDialog.Listener() {
@Override
public void onYes() {
drone.getState().doTakeoff(new Altitude(TAKEOFF_ALTITUDE));
drone.getState().changeFlightMode(ApmModes.ROTOR_AUTO);
}

@Override
public void onNo() {
}
}, getString(R.string.pref_warn_on_takeoff_in_auto_key));

if(ynd != null){
ynd.show(getChildFragmentManager(), "Confirm take off in auto");
}
}

private void getArmingConfirmation() {
YesNoWithPrefsDialog ynd = YesNoWithPrefsDialog.newInstance(getActivity().getApplicationContext(),
getString(R.string.dialog_confirm_arming_title),
Expand Down

0 comments on commit 54359de

Please sign in to comment.