DroidPlanner / Tower

Ground Control Station for Android Devices
https://play.google.com/store/apps/details?id=org.droidplanner.android
Other
619 stars 554 forks source link

Code donation: Save mission flow #1770

Closed snorkel123 closed 8 years ago

snorkel123 commented 8 years ago

Hi everyone,

First I would like to thank you for great efforts put in Tower project. I can say it is a role model in GCS development. I am really glad to see that Tower project grows and develops!

I would like to make small donation: new save/load mission flow. It provides ability to save/load mission as well delete and rename them. It is also moved to separate Activity (providing cleaner UX), so that in future additional cool features could be added.

Currently it uses simplified Mission and saves it to txt file in JSON, but I think this is not a great obstacle.

I would have done PR myself, but I am a bit filled with work and do not know when I am about to free.

I hope you will like it. Feel free to ask me if my code is not clear.

screenshot_2016-07-19-18-26-11

Codebase.zip

Dependencies:

compile 'com.yqritc:recyclerview-flexibledivider:1.4.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.android.gms:play-services-maps:9.2.1'

Usage. Call side (fragment) :

 Intent intent = new Intent(getActivity(), MissionManagerActivity.class);
 intent.putParcelableArrayListExtra(MissionManagerFragment.CURRENT_MISSION_WP_KEY,
                        (ArrayList<LatLng>) waypoints);
 intent.putExtra(MissionManagerFragment.CURRENT_MISSION_ENDING_KEY, missionEnd);
 startActivityForResult(intent, LOAD_MISSION_REQUEST_CODE);

Usage. Receive side (fragment):

 boolean requiresZoomAfterMissionLoad = false;
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == LOAD_MISSION_REQUEST_CODE && resultCode == Activity.RESULT_OK) {

            List<LatLng> waypoints = data.getParcelableArrayListExtra(MissionManagerFragment.CURRENT_MISSION_WP_KEY);
            MissionEnd missionEnd = (MissionEnd) data.getSerializableExtra(MissionManagerFragment.CURRENT_MISSION_ENDING_KEY);

            requiresZoomAfterMissionLoad = true;

            constructRoute();
        }
    }
m4gr3d commented 8 years ago

@alextel69 while I appreciate the intent, I'd rather have this provided as a pull request. Github provides the tools to easily and quickly review pull requests which makes the process a lot easier for all developers involved since everybody is also filled with work. And that process also allows to recognize our contributors.