Skip to content

Commit

Permalink
Merge pull request #1489 from DroidPlanner/feature_custom_alt_prefere…
Browse files Browse the repository at this point in the history
…nces

Feature custom altitude preferences
  • Loading branch information
m4gr3d committed May 26, 2015
2 parents c1ba3c1 + f2849e5 commit 91e3c5a
Show file tree
Hide file tree
Showing 44 changed files with 1,563 additions and 532 deletions.
15 changes: 9 additions & 6 deletions Android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
apply plugin: 'com.android.application'

dependencies {
compile 'com.google.android.gms:play-services-maps:7.0.0'
compile 'com.google.android.gms:play-services-location:7.0.0'
compile 'com.google.android.gms:play-services-analytics:7.0.0'
compile 'com.google.android.gms:play-services-maps:7.3.0'
compile 'com.google.android.gms:play-services-location:7.3.0'
compile 'com.google.android.gms:play-services-analytics:7.3.0'

compile 'com.sothree.slidinguppanel:library:2.0.2'

compile 'com.android.support:support-v4:22.1.0'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:cardview-v7:22.1.0'
compile 'com.android.support:recyclerview-v7:22.1.0'

compile 'com.o3dr.android:dronekit-android:2.3.11'
compile 'com.o3dr.android:dronekit-android:2.3.25'

compile 'me.grantland:autofittextview:0.2.1'
compile(name:'shimmer-android-release', ext:'aar')
Expand All @@ -22,6 +22,9 @@ dependencies {
compile files('libs/protobuf-java-2.5.0.jar')
compile files('libs/jeromq-0.3.4.jar')
compile files('libs/sius-0.3.2-SNAPSHOT.jar')

compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.3.0'
}

android {
Expand Down
4 changes: 4 additions & 0 deletions Android/res/values/preferences_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ This file is used to store the preferences keys so that it's accessible and modi
<string name="pref_udp_ping_receiver_ip_key" translatable="false">pref_udp_ping_receiver_ip</string>
<string name="pref_udp_ping_receiver_port_key" translatable="false">pref_udp_ping_receiver_port</string>

<string name="pref_alt_max_value_key" translatable="false">pref_alt_max_value</string>
<string name="pref_alt_min_value_key" translatable="false">pref_alt_min_value</string>
<string name="pref_alt_default_value_key" translatable="false">pref_alt_default_value</string>

</resources>
7 changes: 7 additions & 0 deletions Android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -549,5 +549,12 @@
<string name="pref_udp_server_ping_summary">Enable to allow the app to periodically ping the udp server.</string>
<string name="pref_udp_ping_receiver_ip_title">UDP ping receiver ip</string>
<string name="pref_udp_ping_receiver_port_title">UDP ping receiver port</string>
<string name="invalid_location_settings_warning">Unable to get accurate location. Please update your location settings!</string>

<!-- Altitude preferences -->
<string name="pref_alt_title">Altitude Preferences</string>
<string name="pref_max_alt_title">Max altitude value</string>
<string name="pref_min_alt_title">Min altitude value</string>
<string name="pref_default_alt_title">Default altitude value</string>

</resources>
27 changes: 27 additions & 0 deletions Android/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,33 @@
android:title="@string/pref_ui_gps_hdop_title" />
</PreferenceCategory>

<PreferenceCategory
android:title="@string/pref_alt_title">

<EditTextPreference
android:gravity="center"
android:inputType="numberSigned"
android:key="@string/pref_alt_max_value_key"
android:title="@string/pref_max_alt_title"
android:persistent="false"
/>

<EditTextPreference
android:gravity="center"
android:inputType="numberSigned"
android:key="@string/pref_alt_min_value_key"
android:title="@string/pref_min_alt_title"
android:persistent="false"/>

<EditTextPreference
android:gravity="center"
android:inputType="numberSigned"
android:key="@string/pref_alt_default_value_key"
android:title="@string/pref_default_alt_title"
android:persistent="false"/>

</PreferenceCategory>

<!-- Disabling kill switch until arducopter v3.3 is out.
<PreferenceCategory
android:title="@string/pref_advance_menu_title">
Expand Down
9 changes: 8 additions & 1 deletion Android/src/org/droidplanner/android/DroidPlannerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.o3dr.services.android.lib.drone.connection.DroneSharePrefs;

import org.droidplanner.android.activities.helpers.BluetoothDevicesActivity;
import org.droidplanner.android.maps.providers.mapbox.offline.MapDownloader;
import org.droidplanner.android.notifications.NotificationHandler;
import org.droidplanner.android.proxy.mission.MissionProxy;
import org.droidplanner.android.utils.Utils;
Expand Down Expand Up @@ -127,6 +128,7 @@ public void run() {
private DroidPlannerPrefs dpPrefs;
private LocalBroadcastManager lbm;
private NotificationHandler notificationHandler;
private MapDownloader mapDownloader;

@Override
public void onCreate() {
Expand All @@ -135,9 +137,10 @@ public void onCreate() {

dpPrefs = new DroidPlannerPrefs(context);
lbm = LocalBroadcastManager.getInstance(context);
mapDownloader = new MapDownloader(context);

controlTower = new ControlTower(context);
drone = new Drone();
drone = new Drone(context);
missionProxy = new MissionProxy(context, this.drone);

final Thread.UncaughtExceptionHandler dpExceptionHandler = new Thread.UncaughtExceptionHandler() {
Expand All @@ -160,6 +163,10 @@ public void uncaughtException(Thread thread, Throwable ex) {
registerReceiver(broadcastReceiver, intentFilter);
}

public MapDownloader getMapDownloader() {
return mapDownloader;
}

public void addApiListener(ApiListener listener) {
if (listener == null)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
import android.widget.FrameLayout;
import android.widget.TextView;

import com.google.android.gms.maps.GoogleMap;

import org.droidplanner.android.R;
import org.droidplanner.android.activities.helpers.SuperUI;
import org.droidplanner.android.fragments.SettingsFragment;
import org.droidplanner.android.fragments.actionbar.ActionBarTelemFragment;
import org.droidplanner.android.maps.providers.google_map.GoogleMapFragment;
import org.droidplanner.android.fragments.control.BaseFlightControlFragment;
import org.droidplanner.android.widgets.SlidingDrawer;

/**
Expand Down Expand Up @@ -100,7 +98,7 @@ protected View getActionDrawer() {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
switch(requestCode) {
case GoogleMapFragment.REQUEST_CHECK_SETTINGS:
case BaseFlightControlFragment.FOLLOW_SETTINGS_UPDATE:
LocalBroadcastManager.getInstance(getApplicationContext())
.sendBroadcast(new Intent(SettingsFragment.ACTION_LOCATION_SETTINGS_UPDATED)
.putExtra(SettingsFragment.EXTRA_RESULT_CODE, resultCode));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ public class EditorActivity extends DrawerNavigationUI implements OnPathFinished
static {
eventFilter.addAction(MissionProxy.ACTION_MISSION_PROXY_UPDATE);
eventFilter.addAction(AttributeEvent.MISSION_RECEIVED);
eventFilter.addAction(AttributeEvent.PARAMETERS_REFRESH_ENDED);
eventFilter.addAction(AttributeEvent.PARAMETERS_REFRESH_COMPLETED);
}

private final BroadcastReceiver eventReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
switch (action) {
case AttributeEvent.PARAMETERS_REFRESH_ENDED:
case AttributeEvent.PARAMETERS_REFRESH_COMPLETED:
case MissionProxy.ACTION_MISSION_PROXY_UPDATE:
updateMissionLength();
break;
Expand Down
40 changes: 40 additions & 0 deletions Android/src/org/droidplanner/android/data/DatabaseState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.droidplanner.android.data;

import android.content.Context;
import android.text.TextUtils;

import org.droidplanner.android.maps.providers.mapbox.offline.OfflineDatabaseHandler;

import java.util.Locale;
import java.util.concurrent.ConcurrentHashMap;

/**
* Created by Fredia Huya-Kouadio on 5/13/15.
*/
public class DatabaseState {

private static final ConcurrentHashMap<String, OfflineDatabaseHandler> databaseHandlers = new ConcurrentHashMap<>();

public static OfflineDatabaseHandler getOfflineDatabaseHandlerForMapId(Context context, String dbName) {
final String lowerMapId = dbName.toLowerCase(Locale.US);
if (databaseHandlers.containsKey(lowerMapId)) {
return databaseHandlers.get(dbName);
}

OfflineDatabaseHandler dbh = new OfflineDatabaseHandler(context, lowerMapId);
databaseHandlers.put(lowerMapId, dbh);
return dbh;
}

public static void deleteDatabase(Context context, String dbName){
if(context == null || TextUtils.isEmpty(dbName))
return;

final String lowerMapId = dbName.toLowerCase(Locale.US);
OfflineDatabaseHandler dbHandler = databaseHandlers.remove(lowerMapId);
if(dbHandler != null)
dbHandler.close();

context.deleteDatabase(lowerMapId);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.droidplanner.android.dialogs;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
Expand Down
5 changes: 2 additions & 3 deletions Android/src/org/droidplanner/android/dialogs/YesNoDialog.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.droidplanner.android.dialogs;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.TextView;

Expand Down Expand Up @@ -69,8 +69,7 @@ public void onClick(DialogInterface dialog, int which) {
}

protected View generateContentView(Bundle savedInstanceState){
final View contentView = getActivity().getLayoutInflater().inflate(R.layout
.dialog_yes_no_content, null);
final View contentView = getActivity().getLayoutInflater().inflate(R.layout.dialog_yes_no_content, null);

if(contentView == null){
return contentView;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.droidplanner.android.dialogs;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;
Expand Down
2 changes: 2 additions & 0 deletions Android/src/org/droidplanner/android/fragments/DroneMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public abstract class DroneMap extends ApiListenerFragment {
eventFilter.addAction(AttributeEvent.STATE_DISCONNECTED);
eventFilter.addAction(AttributeEvent.CAMERA_FOOTPRINTS_UPDATED);
eventFilter.addAction(AttributeEvent.ATTITUDE_UPDATED);
eventFilter.addAction(AttributeEvent.HOME_UPDATED);
eventFilter.addAction(ACTION_UPDATE_MAP);
}

Expand All @@ -70,6 +71,7 @@ public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
switch (action) {
case ACTION_UPDATE_MAP:
case AttributeEvent.HOME_UPDATED:
case MissionProxy.ACTION_MISSION_PROXY_UPDATE:
postUpdate();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public class ParamsFragment extends ApiListenerListFragment {

static {
intentFilter.addAction(AttributeEvent.PARAMETERS_REFRESH_STARTED);
intentFilter.addAction(AttributeEvent.PARAMETERS_REFRESH_ENDED);
intentFilter.addAction(AttributeEvent.PARAMETERS_RECEIVED);
intentFilter.addAction(AttributeEvent.PARAMETERS_REFRESH_COMPLETED);
intentFilter.addAction(AttributeEvent.PARAMETER_RECEIVED);
intentFilter.addAction(AttributeEvent.STATE_CONNECTED);
intentFilter.addAction(AttributeEvent.TYPE_UPDATED);
}
Expand All @@ -78,7 +78,7 @@ public void onReceive(Context context, Intent intent) {
startProgress();
break;

case AttributeEvent.PARAMETERS_REFRESH_ENDED:
case AttributeEvent.PARAMETERS_REFRESH_COMPLETED:
stopProgress();
/*** FALL - THROUGH ***/
case AttributeEvent.STATE_CONNECTED:
Expand All @@ -90,7 +90,7 @@ public void onReceive(Context context, Intent intent) {
}
break;

case AttributeEvent.PARAMETERS_RECEIVED:
case AttributeEvent.PARAMETER_RECEIVED:
final int defaultValue = -1;
int index = intent.getIntExtra(AttributeEventExtra.EXTRA_PARAMETER_INDEX, defaultValue);
int count = intent.getIntExtra(AttributeEventExtra.EXTRA_PARAMETERS_COUNT, defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import org.droidplanner.android.R;
import org.droidplanner.android.fragments.calibration.imu.FragmentSetupIMU;
import org.droidplanner.android.fragments.calibration.mag.FragmentSetupMAG;
import org.droidplanner.android.widgets.viewPager.TabPageIndicator;

/**
Expand Down Expand Up @@ -54,15 +53,11 @@ public Fragment getItem(int i) {
case 0:
default:
return new FragmentSetupIMU();
case 1:
return new FragmentSetupMAG();
}
}

@Override
public int getCount() {
//Enable mag calibration when it's fully working.
// return 2;
return 1;
}

Expand All @@ -72,8 +67,6 @@ public CharSequence getPageTitle(int position) {
case 0:
default:
return FragmentSetupIMU.getTitle(context);
case 1:
return FragmentSetupMAG.getTitle(context);
}
}
}
Expand Down
Loading

0 comments on commit 91e3c5a

Please sign in to comment.