compileSdkVersion updated and tabbed interface - yay
This commit is contained in:
parent
c9e1f1c750
commit
4905e4258d
7 changed files with 103 additions and 114 deletions
|
@ -1,15 +1,15 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 24
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion "24.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.y20k.trackbook"
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 24
|
||||
versionCode 6
|
||||
versionName "0.9.5 (The Great Gig in the Sky)"
|
||||
targetSdkVersion 25
|
||||
versionCode 7
|
||||
versionName "1.0.0 (Astronomy Domine )"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
buildTypes {
|
||||
|
@ -23,8 +23,8 @@ android {
|
|||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:24.2.1'
|
||||
compile 'com.android.support:design:24.2.1'
|
||||
compile 'org.osmdroid:osmdroid-android:5.4.1:release@aar'
|
||||
compile 'com.android.support:appcompat-v7:25.0.0'
|
||||
compile 'com.android.support:design:25.0.0'
|
||||
compile 'org.osmdroid:osmdroid-android:5.5:release@aar'
|
||||
compile 'com.google.code.gson:gson:2.7'
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -71,6 +72,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
private List<String> mMissingPermissions;
|
||||
private FloatingActionButton mFloatingActionButton;
|
||||
private MainActivityMapFragment mMainActivityMapFragment;
|
||||
private MainActivityTrackFragment mMainActivityTrackFragment;
|
||||
private BroadcastReceiver mTrackingStoppedReceiver;
|
||||
private int mSelectedTab;
|
||||
|
||||
|
@ -101,7 +103,39 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
|
||||
// set up main layout
|
||||
setupLayout();
|
||||
// setupTestLayout();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
// add listeners to button
|
||||
if (mFloatingActionButton != null) {
|
||||
mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// onClick: start / stop tracking
|
||||
handleFloatingActionButtonClick(view);
|
||||
}
|
||||
});
|
||||
mFloatingActionButton.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
// onLongClick: clear map
|
||||
if (mTrackerServiceRunning || mMainActivityMapFragment == null) {
|
||||
return false;
|
||||
} else {
|
||||
// show clear dialog
|
||||
DialogFragment dialog = new DialogClearFragment();
|
||||
dialog.show(getFragmentManager(), "DialogClearFragment");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// register broadcast receiver for stopped tracking
|
||||
mTrackingStoppedReceiver = createTrackingStoppedReceiver();
|
||||
|
@ -216,6 +250,9 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
// clear the map
|
||||
mMainActivityMapFragment.clearMap();
|
||||
|
||||
// reset current track
|
||||
mMainActivityTrackFragment.refreshTrackView();
|
||||
|
||||
// dismiss notification
|
||||
NotificationHelper.stop();
|
||||
}
|
||||
|
@ -230,66 +267,6 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
|
||||
/* Set up main layout */
|
||||
private void setupLayout() {
|
||||
if (mPermissionsGranted) {
|
||||
// point to the main map layout
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// show action bar
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
// get reference to fragment
|
||||
mMainActivityMapFragment = (MainActivityMapFragment)getSupportFragmentManager().findFragmentById(R.id.content_main);
|
||||
|
||||
// show the record button and attach listener
|
||||
mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
|
||||
mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// onClick: start / stop tracking
|
||||
handleFloatingActionButtonClick(view);
|
||||
}
|
||||
});
|
||||
mFloatingActionButton.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
// onLongClick: clear map
|
||||
if (mTrackerServiceRunning || mMainActivityMapFragment == null) {
|
||||
return false;
|
||||
} else {
|
||||
// show clear dialog
|
||||
DialogFragment dialog = new DialogClearFragment();
|
||||
dialog.show(getFragmentManager(), "DialogClearFragment");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
// point to the on main onboarding layout
|
||||
setContentView(R.layout.activity_main_onboarding);
|
||||
|
||||
// show the okay button and attach listener
|
||||
Button okButton = (Button) findViewById(R.id.button_okay);
|
||||
okButton.setOnClickListener(new View.OnClickListener() {
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mMissingPermissions != null && !mMissingPermissions.isEmpty()) {
|
||||
// request permissions
|
||||
String[] params = mMissingPermissions.toArray(new String[mMissingPermissions.size()]);
|
||||
requestPermissions(params, REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* TEST: Set up main layout */
|
||||
private void setupTestLayout() {
|
||||
if (mPermissionsGranted) {
|
||||
// point to the main map layout
|
||||
setContentView(R.layout.activity_main_test);
|
||||
|
@ -298,9 +275,7 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
/* BEGIN NEW STUFF */
|
||||
// Create the adapter that will return a fragment for each of the three
|
||||
// primary sections of the activity.
|
||||
// create adapter that returns fragments for the maim map and the last track display
|
||||
SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
|
||||
// Set up the ViewPager with the sections adapter.
|
||||
|
@ -314,10 +289,10 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
switch (tab.getPosition()) {
|
||||
case 0:
|
||||
case FRAGMENT_ID_MAP:
|
||||
mFloatingActionButton.show();
|
||||
break;
|
||||
case 1:
|
||||
case FRAGMENT_ID_TRACK:
|
||||
mFloatingActionButton.hide();
|
||||
break;
|
||||
default:
|
||||
|
@ -336,31 +311,9 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
|
||||
}
|
||||
});
|
||||
/* END NEW STUFF */
|
||||
|
||||
// get reference to fragment
|
||||
mMainActivityMapFragment = (MainActivityMapFragment)getSupportFragmentManager().findFragmentById(R.id.content_main);
|
||||
|
||||
// show the record button and attach listener
|
||||
mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
|
||||
mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// onClick: start / stop tracking
|
||||
handleFloatingActionButtonClick(view);
|
||||
}
|
||||
});
|
||||
mFloatingActionButton.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
// onLongClick: clear map
|
||||
if (mTrackerServiceRunning || mMainActivityMapFragment == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
// point to the on main onboarding layout
|
||||
|
@ -385,8 +338,6 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Handles tap on the record button */
|
||||
private void handleFloatingActionButtonClick(View view) {
|
||||
if (mTrackerServiceRunning) {
|
||||
|
@ -523,17 +474,9 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
public Fragment getItem(int position) {
|
||||
// getItem is called to instantiate the fragment for the given page.
|
||||
switch (position) {
|
||||
case 0:
|
||||
// if (mMainActivityMapFragment == null) {
|
||||
// mMainActivityMapFragment = new MainActivityMapFragment();
|
||||
// }
|
||||
// return mMainActivityMapFragment;
|
||||
case FRAGMENT_ID_MAP:
|
||||
return new MainActivityMapFragment();
|
||||
case 1:
|
||||
// if (mMainActivityMapFragment == null) {
|
||||
// mMainActivityMapFragment = new MainActivityMapFragment();
|
||||
// }
|
||||
// return mMainActivityMapFragment;
|
||||
case FRAGMENT_ID_TRACK:
|
||||
return new MainActivityTrackFragment();
|
||||
}
|
||||
return null;
|
||||
|
@ -548,14 +491,28 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys, Di
|
|||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
case FRAGMENT_ID_MAP:
|
||||
return getString(R.string.tab_map);
|
||||
case 1:
|
||||
case FRAGMENT_ID_TRACK:
|
||||
return getString(R.string.tab_last_track);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
Fragment createdFragment = (Fragment) super.instantiateItem(container, position);
|
||||
// save references to created Fragments
|
||||
switch (position) {
|
||||
case FRAGMENT_ID_MAP:
|
||||
mMainActivityMapFragment = (MainActivityMapFragment)createdFragment;
|
||||
break;
|
||||
case FRAGMENT_ID_TRACK:
|
||||
mMainActivityTrackFragment = (MainActivityTrackFragment)createdFragment;
|
||||
break;
|
||||
}
|
||||
return createdFragment;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* End of inner class
|
||||
|
|
|
@ -390,6 +390,8 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
|||
/* Removes track crumbs from map */
|
||||
public void clearMap() {
|
||||
|
||||
LogHelper.v(LOG_TAG, "!!! Ding clear.");
|
||||
|
||||
// clear map
|
||||
if (mTrackOverlay != null) {
|
||||
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_clear_map), Toast.LENGTH_LONG).show();
|
||||
|
|
|
@ -133,7 +133,7 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
|||
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
||||
loadTrackAsyncHelper.execute();
|
||||
} else {
|
||||
// display map and statistics
|
||||
// just display map and statistics
|
||||
displayTrack();
|
||||
}
|
||||
|
||||
|
@ -179,6 +179,20 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
|||
}
|
||||
|
||||
|
||||
/* Removes current track display */
|
||||
public void refreshTrackView() {
|
||||
|
||||
// remove previous track
|
||||
if (mMapView != null && mTrackOverlay != null) {
|
||||
mMapView.getOverlays().remove(mTrackOverlay);
|
||||
}
|
||||
|
||||
// load track and display map and statistics
|
||||
LoadTrackAsyncHelper loadTrackAsyncHelper = new LoadTrackAsyncHelper();
|
||||
loadTrackAsyncHelper.execute();
|
||||
}
|
||||
|
||||
|
||||
/* Displays map and statistics for track */
|
||||
private void displayTrack() {
|
||||
GeoPoint position;
|
||||
|
@ -239,8 +253,6 @@ public class MainActivityTrackFragment extends Fragment implements TrackbookKeys
|
|||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
// clear track object
|
||||
// LogHelper.v(LOG_TAG, "!!! TRACK:" + mTrack.getWayPoints().get(0).getLocation().getExtras());
|
||||
LogHelper.v(LOG_TAG, "Display map and statistics of track.");
|
||||
displayTrack();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.y20k.trackbook.core;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
|
@ -29,12 +30,23 @@ public class WayPoint implements Parcelable {
|
|||
private Location mLocation;
|
||||
private boolean mIsStopOver;
|
||||
private float mDistanceToStartingPoint;
|
||||
private int mNumberSatellites;
|
||||
|
||||
/* Constructor */
|
||||
public WayPoint(Location location, boolean isStopOver, float distanceToStartingPoint) {
|
||||
mLocation = location;
|
||||
mIsStopOver = isStopOver;
|
||||
mDistanceToStartingPoint = distanceToStartingPoint;
|
||||
|
||||
// save number of satellites
|
||||
Bundle extras = location.getExtras();
|
||||
if (extras != null && extras.containsKey("satellites")) {
|
||||
mNumberSatellites = extras.getInt("satellites", 0);
|
||||
mLocation.setExtras(null); // necessary because Location Extras cause cannot be serialized properly by GSON
|
||||
} else {
|
||||
mNumberSatellites = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Constructor used by CREATOR */
|
||||
|
@ -43,6 +55,7 @@ public class WayPoint implements Parcelable {
|
|||
mLocation = Location.CREATOR.createFromParcel(in);
|
||||
mIsStopOver = in.readByte() != 0;
|
||||
mDistanceToStartingPoint = in.readFloat();
|
||||
mNumberSatellites = in.readInt();
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,9 +117,10 @@ public class WayPoint implements Parcelable {
|
|||
@Override
|
||||
public void writeToParcel(Parcel parcel, int flags) {
|
||||
// parcel.writeParcelable(mLocation, flags);
|
||||
mLocation.setExtras(null); // necessary because: Location Extras cause cannot be serialized properly by GSON
|
||||
mLocation.setExtras(null); // necessary because Location Extras cause cannot be serialized properly by GSON
|
||||
mLocation.writeToParcel(parcel, flags);
|
||||
parcel.writeByte((byte) (mIsStopOver ? 1 : 0));
|
||||
parcel.writeFloat(mDistanceToStartingPoint);
|
||||
parcel.writeInt(mNumberSatellites);
|
||||
}
|
||||
}
|
|
@ -69,6 +69,10 @@ public interface TrackbookKeys {
|
|||
String INSTANCE_ZOOM_LEVEL_TRACK_MAP = "zoomLevelTrackMap";
|
||||
String INSTANCE_CURRENT_LOCATION = "currentLocation";
|
||||
|
||||
/* FRAGMENT IDS */
|
||||
int FRAGMENT_ID_MAP = 0;
|
||||
int FRAGMENT_ID_TRACK = 1;
|
||||
|
||||
/* RESULTS */
|
||||
|
||||
/* CONSTANTS */
|
||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.0'
|
||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
Loading…
Reference in a new issue