Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature return to me #1611

Merged
merged 17 commits into from
Sep 26, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Android/build.gradle
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ dependencies {
compile 'com.android.support:design:22.2.1'

//DroneKit-Android client library.
compile 'com.o3dr.android:dronekit-android:2.6.2'
compile 'com.o3dr.android:dronekit-android:2.6.4'

compile 'me.grantland:autofittextview:0.2.1'
compile(name:'shimmer-android-release', ext:'aar')
2 changes: 2 additions & 0 deletions Android/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -517,5 +517,7 @@
<string name="label_primary">Primary</string>
<string name="label_clipping">Clipping</string>
<string name="unset_timer">--:--</string>
<string name="pref_enable_return_to_me_title">Enable Return To Me</string>
<string name="pref_enable_return_to_me_summary">Vehicle will return to the last known user location on RTL</string>

</resources>
6 changes: 6 additions & 0 deletions Android/res/xml/preferences.xml
Original file line number Diff line number Diff line change
@@ -316,6 +316,12 @@
android:summary="@string/pref_enable_kill_switch_summary"
android:title="@string/pref_enable_kill_switch_title"/>

<CheckBoxPreference
android:defaultValue="false"
android:key="pref_enable_return_to_me"
android:summary="@string/pref_enable_return_to_me_summary"
android:title="@string/pref_enable_return_to_me_title"/>

</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.HitBuilders;
import com.o3dr.android.client.Drone;
import com.o3dr.android.client.apis.VehicleApi;
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent;
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.connection.ConnectionType;
@@ -297,6 +298,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}
});
}

final CheckBoxPreference killSwitch = (CheckBoxPreference) findPreference(DroidPlannerPrefs.PREF_ENABLE_KILL_SWITCH);
if(killSwitch != null) {
killSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@@ -307,6 +309,21 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}
});
}

final CheckBoxPreference returnToMe = (CheckBoxPreference) findPreference(DroidPlannerPrefs.PREF_RETURN_TO_ME);
if(returnToMe != null){
returnToMe.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final Drone drone = dpApp.getDrone();
if(drone.isConnected()) {
final boolean isEnabled = (Boolean) newValue;
VehicleApi.getApi(drone).enableReturnToMe(isEnabled, null);
}
return true;
}
});
}
}

private void setupUnitSystemPreferences(){
@@ -723,7 +740,6 @@ public void onPause() {
@Override
public void onApiConnected() {
Drone drone = dpApp.getDrone();
State droneState = drone.getAttribute(AttributeType.STATE);
Type droneType = drone.getAttribute(AttributeType.TYPE);

updateFirmwareVersionPreference(droneType);
Original file line number Diff line number Diff line change
@@ -156,6 +156,9 @@ public class DroidPlannerPrefs {

public static final String PREF_TOWER_WIDGETS = "pref_tower_widgets";

public static final String PREF_RETURN_TO_ME = "pref_enable_return_to_me";
public static final boolean DEFAULT_RETURN_TO_ME = false;

// Public for legacy usage
public SharedPreferences prefs;

@@ -476,4 +479,8 @@ public boolean isTtsEnabled() {
public boolean isWidgetEnabled(TowerWidgets widget){
return prefs.getBoolean(widget.getPrefKey(), widget.isEnabledByDefault());
}

public boolean isReturnToMeEnabled(){
return prefs.getBoolean(PREF_RETURN_TO_ME, DEFAULT_RETURN_TO_ME);
}
}