Skip to content

Commit

Permalink
feat: Added launcher icon, share feature, map options and bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanmeade committed Dec 10, 2019
1 parent aa8e57c commit 31cf8b1
Show file tree
Hide file tree
Showing 25 changed files with 235 additions and 56 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.camp.campingtripplanner"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionCode 4
versionName "1.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -20,6 +20,7 @@ android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField("String", "googlemapskey", google_maps_key)
resValue("string", "google_maps_key", google_maps_key)
buildConfigField("String", "openweatherkey", openweather_key)
Expand Down
Binary file added app/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.Calendar;
import java.util.Random;
Expand Down Expand Up @@ -220,27 +222,33 @@ public void onClick(View v) {
}

public void saveTrip(View view) {
value = rand.nextInt(500);
getCurrentTripValues();
final Trip trip = new Trip();
trip.tid = value;
trip.name = name;
trip.location = location;
trip.arrival = arrival;
trip.departure = departure;
trip.tent = tent;
trip.bag = bag;
trip.eggs = eggs;
trip.bacon = bacon;
AppExecutors.getInstance().diskIO().execute(new Runnable() {
@Override
public void run() {
db.tripDao().insertAll(trip);
Intent intent = new Intent(context, ViewTripActivity.class);
intent.putExtra("tid", value);
startActivity(intent);
}
});
if (validateInput()){
value = rand.nextInt(500);
final Trip trip = new Trip();
trip.tid = value;
trip.name = name;
trip.location = location;
trip.arrival = arrival;
trip.departure = departure;
trip.tent = tent;
trip.bag = bag;
trip.eggs = eggs;
trip.bacon = bacon;
AppExecutors.getInstance().diskIO().execute(new Runnable() {
@Override
public void run() {
db.tripDao().insertAll(trip);
Intent intent = new Intent(context, ViewTripActivity.class);
intent.putExtra("tid", value);
startActivity(intent);
}
});
}
else {
Toast.makeText(this, "Make sure all fields have been filled.", Toast.LENGTH_LONG).show();
}


}

Expand Down Expand Up @@ -279,6 +287,36 @@ public void initializeViews(){
baconIncrementImageView = findViewById(R.id.baconIncrementButton);
}

private boolean validateInput(){
/* if (name.equals("")){
return false;
}
if (location.equals("")){
return false;
}
if (arrival.equals("")){
return false;
}
if (departure.equals("")){
return false;
}*/

if (name == null){
return false;
}
if (location.equals("(None)")){
return false;
}
if (arrival.equals("(None)")){
return false;
}
if (departure.equals("(None)")){
return false;
}

return true;
}

public void getCurrentTripValues(){
name = nameEditText.getText().toString();
location = locationTextView.getText().toString();
Expand Down
50 changes: 46 additions & 4 deletions app/src/main/java/com/camp/campingtripplanner/MapActivity.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.camp.campingtripplanner;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.FragmentActivity;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

Expand All @@ -14,7 +22,7 @@
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapActivity extends FragmentActivity implements OnMapReadyCallback {
public class MapActivity extends AppCompatActivity implements OnMapReadyCallback {
private Button cancelButton;
private Button saveButton;
private String location;
Expand All @@ -24,10 +32,13 @@ public class MapActivity extends FragmentActivity implements OnMapReadyCallback
private GoogleMap mMap;
private LatLng latLngToSave;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
receivedIntent = getIntent();
receivedBundle = receivedIntent.getExtras();
cancelButton = findViewById(R.id.cancel_button);
Expand Down Expand Up @@ -57,9 +68,39 @@ public void onClick(View v) {
mapFragment.getMapAsync(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.hybrid:
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
return true;
case R.id.normal:
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
return true;
case R.id.satellite:
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
return true;
case R.id.terrain:
mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
return true;
default:
return super.onOptionsItemSelected(item);
}
}

@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;

mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {

@Override
Expand All @@ -73,9 +114,10 @@ public void onMapClick(LatLng latLng) {
mMap.addMarker(markerOptions);
}
});
LatLng clemson = new LatLng(34.686440, -82.823330);
mMap.addMarker(new MarkerOptions().position(clemson).title(getString(R.string.original_marker_title)));
mMap.moveCamera(CameraUpdateFactory.newLatLng(clemson));
LatLng mtMitchell = new LatLng(35.764904, -82.265171);
latLngToSave = mtMitchell;
mMap.addMarker(new MarkerOptions().position(mtMitchell).title(getString(R.string.original_marker_title)));
mMap.moveCamera(CameraUpdateFactory.newLatLng(mtMitchell));
}

public void putTripIntentExtras(Intent intent){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public class ViewTripActivity extends AppCompatActivity {
TextView eggsTextView;
TextView baconTextView;

String name;
String location;
String dateRange;
String tent;
String bag;
String eggs;
String bacon;

ImageView viewLocationButton;

TextView weatherTextView;
Expand Down Expand Up @@ -88,7 +96,7 @@ public void setLocationButton(final Trip mTrip){
viewLocationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri gmmIntentUri = Uri.parse("geo:" + mTrip.location);
Uri gmmIntentUri = Uri.parse("geo:" + mTrip.location + "?q=" + mTrip.location + "(Campsite)");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage(getString(R.string.google_maps_package));
startActivity(mapIntent);
Expand Down Expand Up @@ -138,6 +146,22 @@ public void setTextViews(Trip trip){
baconTextView.setText(trip.bacon + getString(R.string.bacon_quantity));
}

private void setShareableString(){
name = nameTextView.getText().toString();
location = locationTextView.getText().toString();
dateRange = dateRangeTextView.getText().toString();
tent = tentTextView.getText().toString();
bag = bagTextView.getText().toString();
eggs = eggsTextView.getText().toString();
bacon = baconTextView.getText().toString();
}

private String getShareableString(){
setShareableString();
String shareableString = "Camping trip:\n\n" + name + "\nhttp://maps.google.com/?q=" + location + "\n" + dateRange + "\n" + tent + "\n" + bag + "\n" + eggs + "\n" + bacon;
return shareableString;
}

public void editTrip(View view) {
Bundle bundle = new Bundle();
bundle.putString(getString(R.string.name_lowercase), trip.name);
Expand Down Expand Up @@ -165,4 +189,15 @@ public void run() {
});

}

public void shareTrip(View view) {
String tripDetails;
/*tripDetails = */
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Camping Trip:");
intent.putExtra(Intent.EXTRA_TEXT, getShareableString());
startActivity(intent);
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="41.37931"
android:viewportHeight="41.37931"
android:tint="#FFFD00">
<group android:translateX="8.689655"
android:translateY="8.689655">
<path
android:fillColor="#FF000000"
android:pathData="M13.5,0.67s0.74,2.65 0.74,4.8c0,2.06 -1.35,3.73 -3.41,3.73 -2.07,0 -3.63,-1.67 -3.63,-3.73l0.03,-0.36C5.21,7.51 4,10.62 4,14c0,4.42 3.58,8 8,8s8,-3.58 8,-8C20,8.61 17.41,3.8 13.5,0.67zM11.71,19c-1.78,0 -3.22,-1.4 -3.22,-3.14 0,-1.62 1.05,-2.76 2.81,-3.12 1.77,-0.36 3.6,-1.21 4.62,-2.58 0.39,1.29 0.59,2.65 0.59,4.04 0,2.65 -2.15,4.8 -4.8,4.8z"/>
</group>
</vector>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_create_trip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
app:layout_constraintBottom_toBottomOf="@+id/nameTextView"
app:layout_constraintStart_toEndOf="@+id/nameTextView"
app:layout_constraintTop_toTopOf="@+id/nameTextView"
android:layout_marginStart="16dp" />
android:layout_marginStart="16dp"
android:singleLine="true" />

<TextView
android:id="@+id/locationTextView"
Expand Down
50 changes: 30 additions & 20 deletions app/src/main/res/layout/activity_map.xml
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MapActivity"
android:background="@color/colorPrimaryDark">
android:background="@color/colorPrimaryDark"
tools:context=".MapActivity">

<TextView
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_height="?actionBarSize"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:id="@+id/toolbar"
app:title="@string/select_location"
app:titleTextColor="@color/colorAccent"
app:popupTheme="@style/MyDarkToolbarStyle"/>

<!-- <TextView
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center"
android:text="@string/mapInstruction"
android:textColor="@color/colorAccent"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />-->

<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:layout_marginBottom="?attr/actionBarSize"/>
android:layout_marginBottom="?attr/actionBarSize" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/map"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
app:layout_constraintTop_toBottomOf="@+id/map">

<Button
android:id="@+id/select_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select"
android:background="@color/colorAccent"
android:textColor="@color/colorPrimaryDark"/>
android:text="@string/select"
android:textColor="@color/colorPrimaryDark" />

<Button
android:id="@+id/cancel_button"
android:layout_marginLeft="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:background="@color/colorAccent"
android:textColor="@color/colorPrimaryDark"
android:layout_marginStart="32dp" />
android:text="@string/cancel"
android:textColor="@color/colorPrimaryDark" />

</LinearLayout>

Expand Down
Loading

0 comments on commit 31cf8b1

Please sign in to comment.