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 custom video stream provider #1647

Merged
merged 6 commits into from
Oct 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions Android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ dependencies {
compile 'com.android.support:design:23.0.1'

//DroneKit-Android client library.
compile 'com.o3dr.android:dronekit-android:2.6.6'
compile 'com.o3dr.android:dronekit-android:2.6.8-beta'

compile 'me.grantland:autofittextview:0.2.1'
compile(name:'shimmer-android-release', ext:'aar')

compile files('libs/droneapi-java-0.3-SNAPSHOT.jar')
compile files('libs/j2xx.jar')
compile files('libs/protobuf-java-2.5.0.jar')
compile files('libs/jeromq-0.3.4.jar')
compile files('libs/sius-0.3.0-SNAPSHOT.jar')
Expand Down
Binary file removed Android/libs/j2xx.jar
Binary file not shown.
57 changes: 57 additions & 0 deletions Android/res/layout/fragment_widget_video_preferences.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:id="@+id/video_widget_pref"
android:orientation="vertical">

<RadioButton
android:id="@+id/solo_video_stream_check"
android:layout_width="match_parent"
android:background="?android:attr/selectableItemBackground"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:text="@string/label_solo_video_stream"/>

<View
android:layout_height="1px"
android:layout_width="match_parent"
android:layout_margin="5dp"
android:background="@android:color/darker_gray"/>

<RadioButton
android:id="@+id/custom_video_stream_check"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:minHeight="48dp"
android:text="@string/label_custom_video_stream"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_udp_port"
android:layout_margin="10dp"
android:textStyle="bold"/>

<EditText
android:id="@+id/custom_video_provider_udp_port"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:gravity="center"
android:enabled="false"
android:inputType="number"
android:imeOptions="actionDone"
android:hint="@string/hint_custom_video_stream_udp_port"/>

</LinearLayout>

</RadioGroup>
25 changes: 25 additions & 0 deletions Android/res/layout/fragment_widgets_list_pref.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="15dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:gravity="center"
android:text="@string/label_widgets_list"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />

<ListView
android:id="@+id/widgets_list_pref"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@android:color/darker_gray"
android:dividerHeight="1px" />

</LinearLayout>
60 changes: 60 additions & 0 deletions Android/res/layout/list_widgets_list_pref_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:minHeight="56dp"
android:gravity="center">

<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_action_gear"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="?android:attr/selectableItemBackground"
android:scaleType="center"
android:id="@+id/widget_pref_icon"/>

<LinearLayout
android:id="@+id/widget_pref_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:padding="5dp"
android:layout_toEndOf="@+id/widget_pref_icon"
android:layout_toRightOf="@+id/widget_pref_icon"
android:layout_toStartOf="@+id/widget_check"
android:layout_toLeftOf="@+id/widget_check">

<TextView
android:id="@+id/widget_pref_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Flight Timer"
android:textStyle="bold"
android:layout_marginBottom="3dp"
/>

<TextView
android:id="@+id/widget_pref_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Displays the vehicle flight time"/>

</LinearLayout>

<CheckBox
android:id="@+id/widget_check"
android:layout_width="48dp"
android:background="?android:attr/selectableItemBackground"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>

</RelativeLayout>
5 changes: 5 additions & 0 deletions Android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,5 +521,10 @@
<string name="warning_vehicle_home_updated">Vehicle home updated</string>
<string name="label_photo">Photo</string>
<string name="label_record">Record</string>
<string name="label_widgets_list">Widgets List</string>
<string name="label_solo_video_stream">Solo video stream</string>
<string name="label_custom_video_stream">Custom video stream</string>
<string name="hint_custom_video_stream_udp_port">0000</string>
<string name="label_udp_port">UDP Port:</string>

</resources>
6 changes: 2 additions & 4 deletions Android/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@
android:title="@string/pref_ui">

<PreferenceCategory android:title="@string/pref_tower_widgets_category">
<PreferenceScreen
<Preference
android:key="pref_tower_widgets"
android:title="@string/pref_tower_widgets_title">
<PreferenceCategory android:title="@string/pref_widgets_list_category" />
</PreferenceScreen>
android:title="@string/pref_tower_widgets_title"/>
</PreferenceCategory>

<PreferenceCategory android:title="@string/pref_title_local">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package org.droidplanner.android.activities;

import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;

import com.geeksville.apiproxy.LoginFailedException;

import org.droidplanner.android.R;
import org.droidplanner.android.activities.interfaces.AccountLoginListener;
import org.droidplanner.android.fragments.account.DroneshareAccountFragment;
import org.droidplanner.android.fragments.account.DroneshareLoginFragment;
import org.droidplanner.android.utils.connection.DroneshareClient;

/**
* Created by Fredia Huya-Kouadio on 1/22/15.
Expand All @@ -28,7 +22,7 @@ public void onCreate(Bundle savedInstanceState) {

if (savedInstanceState == null) {
Fragment droneShare;
if(mAppPrefs.isDroneshareEnabled())
if (mAppPrefs.isDroneshareEnabled())
droneShare = new DroneshareAccountFragment();
else
droneShare = new DroneshareLoginFragment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.MAVLink.common.msg_global_position_int;
import com.o3dr.android.client.data.tlog.TLogPicker;
import com.o3dr.android.client.utils.data.tlog.TLogPicker;
import com.o3dr.services.android.lib.coordinate.LatLong;
import com.o3dr.services.android.lib.data.ServiceDataContract;
import com.o3dr.services.android.lib.util.MathUtils;
Expand Down Expand Up @@ -73,7 +72,7 @@ public void onCreate(Bundle savedInstanceState) {
FragmentManager fragmentManager = getSupportFragmentManager();

locatorMapFragment = ((LocatorMapFragment) fragmentManager.findFragmentById(R.id.locator_map_fragment));
if(locatorMapFragment == null){
if (locatorMapFragment == null) {
locatorMapFragment = new LocatorMapFragment();
fragmentManager.beginTransaction().add(R.id.locator_map_fragment, locatorMapFragment).commit();
}
Expand Down Expand Up @@ -192,7 +191,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent returnInten
//Get the file's absolute path from the incoming intent
final String tlogAbsolutePath = returnIntent.getStringExtra(ServiceDataContract.EXTRA_TLOG_ABSOLUTE_PATH);

if(tlogOpener != null)
if (tlogOpener != null)
tlogOpener.cancel(true);

tlogOpener = new OpenTLogFileAsyncTask(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.droidplanner.android.fragments.FlightDataFragment
import org.droidplanner.android.fragments.FlightMapFragment
import org.droidplanner.android.fragments.widget.TowerWidget
import org.droidplanner.android.fragments.widget.TowerWidgets
import org.droidplanner.android.fragments.widget.FullWidgetSoloLinkVideo
import org.droidplanner.android.fragments.widget.video.FullWidgetSoloLinkVideo
import org.droidplanner.android.utils.prefs.AutoPanMode
import kotlin.properties.Delegates

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.droidplanner.android.activities.helpers.MapPreferencesActivity;
import org.droidplanner.android.dialogs.ClearBTDialogPreference;
import org.droidplanner.android.fragments.widget.TowerWidgets;
import org.droidplanner.android.fragments.widget.WidgetsListPrefFragment;
import org.droidplanner.android.maps.providers.DPMapProvider;
import org.droidplanner.android.utils.Utils;
import org.droidplanner.android.utils.analytics.GAUtils;
Expand Down Expand Up @@ -221,9 +222,9 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}

private void setupWidgetsPreferences(){
final PreferenceScreen widgetsPref = (PreferenceScreen) findPreference(DroidPlannerPrefs.PREF_TOWER_WIDGETS);
final Preference widgetsPref = findPreference(DroidPlannerPrefs.PREF_TOWER_WIDGETS);
if(widgetsPref != null){
final Activity activity = getActivity();
/*final Activity activity = getActivity();
final Preference.OnPreferenceChangeListener widgetPrefChangeListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Expand All @@ -245,7 +246,15 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
widgetPref.setOnPreferenceChangeListener(widgetPrefChangeListener);

widgetsPref.addPreference(widgetPref);
}
}*/

widgetsPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new WidgetsListPrefFragment().show(getFragmentManager(), "Widgets List Preferences");
return true;
}
});
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.droidplanner.android.fragments.widget

import android.app.DialogFragment
import android.app.Fragment
import android.support.annotation.IdRes
import android.support.annotation.StringRes
import org.droidplanner.android.R
Expand All @@ -8,6 +10,9 @@ import org.droidplanner.android.fragments.widget.diagnostics.MiniWidgetDiagnosti
import org.droidplanner.android.fragments.widget.telemetry.MiniWidgetFlightTimer
import org.droidplanner.android.fragments.widget.telemetry.MiniWidgetGeoInfo
import org.droidplanner.android.fragments.widget.telemetry.MiniWidgetAttitudeSpeedInfo
import org.droidplanner.android.fragments.widget.video.FullWidgetSoloLinkVideo
import org.droidplanner.android.fragments.widget.video.MiniWidgetSoloLinkVideo
import org.droidplanner.android.fragments.widget.video.WidgetVideoPreferences

/**
* Created by Fredia Huya-Kouadio on 8/25/15.
Expand Down Expand Up @@ -37,6 +42,10 @@ public enum class TowerWidgets(@IdRes val idRes: Int, @StringRes val labelResId:
override fun getMinimizedFragment() = MiniWidgetSoloLinkVideo()

override fun getMaximizedFragment() = FullWidgetSoloLinkVideo()

override fun hasPreferences() = true

override fun getPrefFragment() = WidgetVideoPreferences()
},

ATTITUDE_SPEED_INFO(R.id.tower_widget_attitude_speed_info, R.string.label_widget_attitude_speed_info, R.string.description_widget_attitude_speed_info, "pref_widget_attitude_speed_info") {
Expand All @@ -59,6 +68,10 @@ public enum class TowerWidgets(@IdRes val idRes: Int, @StringRes val labelResId:

open fun getMaximizedFragment(): TowerWidget? = null

open fun hasPreferences() = false

open fun getPrefFragment(): DialogFragment? = null

companion object {
@JvmStatic fun getWidgetById(@IdRes id: Int): TowerWidgets? {
return when (id) {
Expand Down
Loading