Skip to content

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Feb 6, 2015
1 parent 09ef84b commit fb5b031
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 9 deletions.
Binary file modified ClientLib/mobile/libs/AidlLib.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions ServiceApp/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>

<receiver
android:name=".utils.apps.AppsUpdateReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
</application>

</manifest>
2 changes: 1 addition & 1 deletion ServiceApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android {
applicationId 'org.droidplanner.services.android'
minSdkVersion 14
targetSdkVersion 21
versionCode 10201
versionCode 10202
versionName getGitVersion()
}

Expand Down
2 changes: 2 additions & 0 deletions ServiceApp/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@
<string name="label_learn_more">Learn more</string>
<string name="label_action_button_install">Install</string>
<string name="label_action_button_open">Open</string>
<string name="label_view_category_active">Active</string>
<string name="label_view_category_recommended">Recommended</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public IDroneApi registerDroneApi(IApiListener listener, String appId) throws Re

@Override
public Bundle[] getConnectedApps(String requesterId) throws RemoteException {
Log.d(TAG, "List connected apps request from " + requesterId);
Log.d(TAG, "List of connected apps request from " + requesterId);

List<Bundle> appsInfo = new ArrayList<>();
for(DroneApi droneApi : getService().droneApiStore){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

Expand Down Expand Up @@ -47,7 +48,6 @@ public class DroidPlannerService extends Service {
public static final String ACTION_DRONE_DESTROYED = Utils.PACKAGE_NAME + ".ACTION_DRONE_DESTROYED";
public static final String ACTION_KICK_START_DRONESHARE_UPLOADS = Utils.PACKAGE_NAME + ".ACTION_KICK_START_DRONESHARE_UPLOADS";

private final Handler handler = new Handler();
private LocalBroadcastManager lbm;

final ConcurrentLinkedQueue<DroneApi> droneApiStore = new ConcurrentLinkedQueue<DroneApi>();
Expand All @@ -65,7 +65,7 @@ DroneApi registerDroneApi(IApiListener listener, String appId) {
if (listener == null)
return null;

DroneApi droneApi = new DroneApi(this, handler, mavlinkApi, listener, appId);
DroneApi droneApi = new DroneApi(this, new Handler(Looper.getMainLooper()), mavlinkApi, listener, appId);
droneApiStore.add(droneApi);
lbm.sendBroadcast(new Intent(ACTION_DRONE_CREATED));
return droneApi;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.droidplanner.services.android.ui.fragment;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
Expand All @@ -11,12 +15,32 @@

import org.droidplanner.services.android.R;
import org.droidplanner.services.android.ui.adapter.RecommendedAppsAdapter;
import org.droidplanner.services.android.utils.Utils;

/**
* Provide a view of recommended apps that are compatible with 3DR Services.
*/
public class RecommendedAppsFragment extends Fragment {

public static final String ACTION_REFRESH_RECOMMENDED_APPS = Utils.PACKAGE_NAME + ".action" +
".REFRESH_RECOMMENDED_APPS";

private static final IntentFilter intentFilter = new IntentFilter(ACTION_REFRESH_RECOMMENDED_APPS);

private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
switch(intent.getAction()){
case ACTION_REFRESH_RECOMMENDED_APPS:
if(recommendedAppsAdapter != null)
recommendedAppsAdapter.notifyDataSetChanged();
break;
}
}
};
private RecommendedAppsAdapter recommendedAppsAdapter;
private LocalBroadcastManager lbm;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
return inflater.inflate(R.layout.fragment_recommended_apps, container, false);
Expand All @@ -28,6 +52,7 @@ public void onViewCreated(View view, Bundle savedInstanceState){

final Context context = getActivity().getApplicationContext();

lbm = LocalBroadcastManager.getInstance(context);
final RecyclerView recommendedList = (RecyclerView) view.findViewById(R.id.recommended_apps_list);

//Use this setting to improve performance if you know that changes in content do not change the layout side
Expand All @@ -39,6 +64,20 @@ public void onViewCreated(View view, Bundle savedInstanceState){
final RecyclerView.LayoutManager gridLayoutMgr = new GridLayoutManager(context, colCount);
recommendedList.setLayoutManager(gridLayoutMgr);

recommendedList.setAdapter(new RecommendedAppsAdapter(context));
recommendedAppsAdapter = new RecommendedAppsAdapter(context);
recommendedList.setAdapter(recommendedAppsAdapter);
}

@Override
public void onStart(){
super.onStart();
recommendedAppsAdapter.notifyDataSetChanged();
lbm.registerReceiver(broadcastReceiver, intentFilter);
}

@Override
public void onStop(){
super.onStop();
lbm.unregisterReceiver(broadcastReceiver);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.droidplanner.services.android.ui.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
Expand Down Expand Up @@ -30,7 +31,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle saved
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewPager = (ViewPager) view.findViewById(R.id.connections_view_pager);
viewPager.setAdapter(new ConnectionCategoryAdapter(getChildFragmentManager()));
viewPager.setAdapter(new ConnectionCategoryAdapter(getActivity().getApplicationContext(),
getChildFragmentManager()));

int categoryIndex = 1;
if (savedInstanceState != null) {
Expand All @@ -51,8 +53,11 @@ public void onSaveInstanceState(Bundle outState) {

private static class ConnectionCategoryAdapter extends FragmentPagerAdapter {

public ConnectionCategoryAdapter(FragmentManager fm) {
private final Context context;

public ConnectionCategoryAdapter(Context context, FragmentManager fm) {
super(fm);
this.context = context;
}

@Override
Expand All @@ -76,11 +81,11 @@ public int getCount() {
public CharSequence getPageTitle(int position){
switch(position){
case 0:
return "Active";
return context.getString(R.string.label_view_category_active);

case 1:
default:
return "Recommended";
return context.getString(R.string.label_view_category_recommended);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.droidplanner.services.android.utils.apps;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;

import org.droidplanner.services.android.ui.fragment.RecommendedAppsFragment;

/**
* Created by Fredia Huya-Kouadio on 2/5/15.
*/
public class AppsUpdateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(RecommendedAppsFragment
.ACTION_REFRESH_RECOMMENDED_APPS));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void onHeartbeat(msg_heartbeat msg) {
switch (heartbeatState) {
case FIRST_HEARTBEAT:
notifyConnected();
System.out.println("Received first heartbeat.");
myDrone.notifyDroneEvent(DroneEventsType.HEARTBEAT_FIRST);
break;

Expand Down Expand Up @@ -100,6 +101,7 @@ public void onDroneEvent(DroneEventsType event, Drone drone) {
break;

case CONNECTING:
System.out.println("Received connecting event.");
gcsHeartbeat.setActive(true);
notifyConnecting();
break;
Expand Down Expand Up @@ -137,6 +139,7 @@ private void onHeartbeatTimeout() {
break;

case FIRST_HEARTBEAT:
System.out.println("First heartbeat timeout.");
myDrone.notifyDroneEvent(DroneEventsType.CONNECTION_FAILED);
break;

Expand Down

0 comments on commit fb5b031

Please sign in to comment.