Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile 'com.google.android.gms:play-services:8.1.0'
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="softeng.eventplanning">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/API/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

public class API {
//public static String serverIP = "http://128.205.44.21:1033";//PROD
public static String serverIP = "http://10.0.2.2:5000";//DEV
public static String serverIP = "http://128.205.44.21:1034";//PROD
//public static String serverIP = "http://10.0.2.2:5000";//DEV

}
14 changes: 10 additions & 4 deletions app/src/main/java/API/CreateEventAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;

import softeng.eventplanning.LoggedInUser;
import softeng.eventplanning.MainActivity;
Expand All @@ -28,6 +29,8 @@
public class CreateEventAPI extends AsyncTask<String,String,String> {
private String[] marray;
private Activity activity;
private int pubint;
private double[] latlong;
@Override
protected void onPreExecute() {
super.onPreExecute();
Expand All @@ -39,15 +42,18 @@ public void setsomething(String[] array){

public void signupActivity(Activity a){activity = a;}

public void setpub(int i) {pubint = i;}

public void getlat(double[] ret) {latlong = ret;}
@Override
protected String doInBackground(String ... params) {
String urlstring = new String(API.serverIP+"/create-event/");
String urlstring = new String(API.serverIP+"/create-event");
DataOutputStream printout;
JSONObject jsonobj = new JSONObject();


try{
Log.d("myTag", Arrays.toString(latlong));

jsonobj.put("date",marray[0]);
jsonobj.put("time",marray[1]);
Expand All @@ -59,9 +65,9 @@ protected String doInBackground(String ... params) {
jsonobj.put("owner",marray[7]);
jsonobj.put("arrivalNot",marray[8]);

jsonobj.put("LAT", marray[10]);
jsonobj.put("LONG", marray[11]);
jsonobj.put("public", marray[12]);
jsonobj.put("LAT", latlong[0]);
jsonobj.put("LONG", latlong[1]);
jsonobj.put("public", pubint);
String urlparam;
urlparam = jsonobj.toString();

Expand Down
108 changes: 80 additions & 28 deletions app/src/main/java/softeng/eventplanning/createEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,43 @@
import android.icu.text.SimpleDateFormat;

import android.location.Location;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Base64;
import android.util.Log;
import android.view.View;


import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.DatePicker;

import android.widget.EditText;
import android.widget.ImageButton;

import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;

import android.widget.ImageView;

import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;


import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;

import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStates;
import com.google.android.gms.location.LocationSettingsStatusCodes;

import java.io.ByteArrayOutputStream;
import java.io.File;
Expand Down Expand Up @@ -87,15 +84,18 @@ public class createEvent extends AppCompatActivity {
private String Edesc;
private String locS;
private String event_name;
private String pub;
private String listOfParts = "";

private int pub;
private static int RESULT_LOAD_IMG=0;
private static int REQUEST_READ;
private byte[] imgByte = null;
private byte[] bytes = null;
String _encoded;
private static String[] PERMISSIONS_STORAGE = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
private static final int MY_PERMISSION_ACCESS_FINE_LOCATION = 11;


@Override
Expand All @@ -104,20 +104,30 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.create_event_new);

final String[] create_event = new String[13];
Log.d("myTag", Arrays.toString(create_event));
final EditText description = (EditText) findViewById(R.id.Desc);
final EditText eventTitle = (EditText) findViewById(R.id.eventT);
final TextView date_v = (TextView) findViewById(R.id.date_view);
final TextView time_v = (TextView) findViewById(R.id.time_view);
final EditText location = (EditText) findViewById(R.id.loc);
final EditText locat = (EditText) findViewById(R.id.loc);
final String user = LoggedInUser.username;

Edesc = description.getText().toString();
event_name = eventTitle.getText().toString();
locS = location.getText().toString();
locS = locat.getText().toString();

final CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox);


for(int i=0;i<LoggedInUser.friendsList.size();i++){
CheckBox rbtn = new CheckBox(this);
rbtn.setId(i);
rbtn.setText(LoggedInUser.friendsList.get(i));
((ViewGroup)findViewById(R.id.checkBoxGroup)).addView(rbtn);

}

final CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox);


final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
Expand Down Expand Up @@ -170,32 +180,39 @@ public void onClick(View v) {
updateDate(date_v);
Log.d("date", date1);
Log.d("time", time);


if (checkBox.isChecked()) {
pub = "1";
pub = 1;
} else {
pub = "0";
pub = 0;
}
Edesc = description.getText().toString();
event_name = eventTitle.getText().toString();
locS = location.getText().toString();
locS = locat.getText().toString();
LinearLayout layout = (LinearLayout)findViewById(R.id.checkBoxGroup);
formIsValid(layout);
if (CheckFields() == true) {
create_event[0] = date1;
create_event[1] = time;
create_event[2] = locS;
create_event[3] = event_name;
create_event[4] = Edesc;
create_event[5] = "friends";
create_event[5] = listOfParts;
create_event[6] = _encoded;
create_event[7] = user;
create_event[10] = "42.0";
create_event[11] = "15.63";
create_event[12] = pub;
create_event[8] = "yes";

double[] ret = getLatLong();

final CreateEventAPI asyncT = createAsyncTask();
asyncT.getlat(ret);
asyncT.setpub(pub);
asyncT.setsomething(create_event);

asyncT.execute();
}

}
});
}
Expand All @@ -206,6 +223,30 @@ public void selectImage(View v){
startActivityForResult(galleryIntent, RESULT_LOAD_IMG);
}

public double[] getLatLong(){
if ( ContextCompat.checkSelfPermission( this, android.Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED ) { ActivityCompat.requestPermissions( this, new String[] { android.Manifest.permission.ACCESS_FINE_LOCATION },
MY_PERMISSION_ACCESS_FINE_LOCATION );
}

LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double[] ret = new double[2];
if (location != null) {

ret[0] = location.getLongitude();
ret[1] = location.getLatitude();

}
else{

ret[0] = 43.0;
ret[1] = 78.789;

}
Log.d("myTag", Arrays.toString(ret));

return ret;
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
Expand Down Expand Up @@ -248,8 +289,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data){
// imgMap.compress(Bitmap.CompressFormat.JPEG,100,ba);
// byte[] bArray = ba.toByteArray();



ImageView imgView = (ImageView) findViewById(R.id.imageView6);
// Set the Image in ImageView after decoding the String
imgView.setImageBitmap(imgMap);
Expand Down Expand Up @@ -282,6 +321,19 @@ private CreateEventAPI createAsyncTask(){
api.signupActivity(this);
return api;
}
public void formIsValid(LinearLayout layout) {
for (int i = 0; i < layout.getChildCount(); i++) {
CheckBox v = (CheckBox) layout.getChildAt(i);
if (v.isChecked()) {
if (listOfParts.equals("")) {
listOfParts = listOfParts + v.getText().toString();
} else {
listOfParts = listOfParts + " " + v.getText().toString();
}

}
}
}

private boolean CheckFields(){
if(checkTitle() == false){
Expand Down
26 changes: 24 additions & 2 deletions app/src/main/res/layout/create_event_new.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:weightSum="1">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="386dp"
android:layout_weight="1.08">

<TextView
android:text="Create Event"
Expand Down Expand Up @@ -83,6 +85,25 @@
android:layout_marginBottom="23dp"
android:id="@+id/create" />


<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_below="@+id/loc"
android:layout_above="@+id/create">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/checkBoxGroup">


</LinearLayout>
</ScrollView>


<TextView
android:text="Add Image"
android:layout_width="wrap_content"
Expand All @@ -108,6 +129,7 @@
android:id="@+id/checkBox"
android:layout_alignTop="@+id/time_view"
android:layout_toEndOf="@+id/create" />
>>>>>>> eventNew

</RelativeLayout>
</LinearLayout>