Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Apr 23, 2018
1 parent 84aa31d commit 0ccb970
Show file tree
Hide file tree
Showing 31 changed files with 333 additions and 19 deletions.
Binary file modified .gradle/4.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/4.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/4.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/4.4/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified .gradle/4.4/javaCompile/jarAnalysis.bin
Binary file not shown.
Binary file modified .gradle/4.4/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified .gradle/4.4/javaCompile/taskHistory.bin
Binary file not shown.
Binary file modified .gradle/4.4/javaCompile/taskJars.bin
Binary file not shown.
Binary file modified .gradle/4.4/taskHistory/taskHistory.bin
Binary file not shown.
Binary file modified .gradle/4.4/taskHistory/taskHistory.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
12 changes: 12 additions & 0 deletions .idea/libraries/Gradle__com_android_support_design_27_1_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/libraries/Gradle__com_android_support_transition_27_1_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: com.google.firebase:firebase-common-15.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.firebase:firebase-storage-15.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-basement-15.0.0" level="project" />
Expand All @@ -128,23 +129,24 @@
<orderEntry type="library" name="Gradle: com.google.firebase:firebase-database-15.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:recyclerview-v7-27.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.squareup:javawriter:2.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v4-26.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.firebase:firebase-iid-15.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:rules-1.0.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains:annotations-java5:15.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-fragment-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-1.1.0" level="project" />
<orderEntry type="library" name="Gradle: android.arch.core:runtime-1.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:design-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.google.firebase:firebase-database-collection-15.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-tasks-15.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.firebase:firebase-analytics-15.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: net.sf.kxml:kxml2:2.3.0@jar" level="project" />
<orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime-1.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner-1.0.1" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:transition-27.1.1" level="project" />
<orderEntry type="library" name="Gradle: com.google.firebase:firebase-invites-15.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-27.1.1" level="project" />
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
}

apply plugin: 'com.google.gms.google-services'
80 changes: 80 additions & 0 deletions app/src/main/java/com/project/wanderlust/JourneyLsitAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.project.wanderlust;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class JourneyLsitAdapter extends ArrayAdapter<JourneyMini> {
private ArrayList<JourneyMini> items;
private Bitmap userPic;
private String userName;
private LayoutInflater inflater;

public JourneyLsitAdapter(Context context, ArrayList<JourneyMini> items, Bitmap userPic, String userName) {
super(context, 0, items);
this.items = items;
this.userPic = userPic;
this.userName = userName;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Nullable
@Override
public JourneyMini getItem(int position) {
return super.getItem(position);
}

@Override
public int getCount() {
return super.getCount();
}

@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
if(position == 1)
convertView = convertView;
if(convertView == null)
convertView = inflater.inflate(R.layout.journey_cell, null);
JourneyMini item = getItem(position);
((ImageView) convertView.findViewById(R.id.photo)).setImageBitmap(userPic);
((TextView) convertView.findViewById(R.id.userName)).setText(userName);
((TextView) convertView.findViewById(R.id.location)).setText(item.getLocation());
((TextView) convertView.findViewById(R.id.locationBroader)).setText(item.getBroaderLocation());
((TextView) convertView.findViewById(R.id.date)).setText(SharedFunctions.months[item.getDate().getMonth() - 1] + " " + item.getDate().getDate());
((TextView) convertView.findViewById(R.id.title)).setText(item.getTitle());
if(item.getBitmap() != null) {
ImageView imageView = convertView.findViewById(R.id.journeyPic);
imageView.setImageURI(item.getBitmap());
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
imageView.setLayoutParams(layoutParams);
}

convertView.setTag(item);
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
JourneyMini journey = (JourneyMini) v.getTag();
if(journey != null) {
Intent intent = new Intent(getContext(), ShowJourney.class);
intent.putExtra("timestamp", new SimpleDateFormat(CreateJourneyActivity.DATE_FORMAT).format(journey.getDate()));
getContext().startActivity(intent);
}
}
});
return convertView;
}
}
31 changes: 31 additions & 0 deletions app/src/main/java/com/project/wanderlust/JourneyMini.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.project.wanderlust;

import android.net.Uri;

import java.util.Date;

public class JourneyMini {
private String title;
private Date date;
private String location;
private String broaderLoocation;
private Uri bitmap;

public JourneyMini(String title, Date date, String location, String broaderLocation, Uri bitmap) {
this.title = title;
this.date = date;
this.location = location;
this.broaderLoocation = broaderLocation;
this.bitmap = bitmap;
}

public String getTitle() { return title; }

public Date getDate() { return date; }

public Uri getBitmap() { return bitmap; }

public String getLocation() { return location; }

public String getBroaderLocation() { return broaderLoocation; }
}
62 changes: 62 additions & 0 deletions app/src/main/java/com/project/wanderlust/JourneysLsitActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,75 @@
package com.project.wanderlust;

import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

import java.io.File;
import java.lang.reflect.Array;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import de.hdodenhof.circleimageview.CircleImageView;

public class JourneysLsitActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journeys_lsit);

ContextWrapper wrapper = new ContextWrapper(getApplicationContext());
File file = wrapper.getDir("profilePictures",MODE_PRIVATE);
file = new File(file, FirebaseAuth.getInstance().getCurrentUser().getPhoneNumber() + ".jpg");
final Bitmap bitmap = SharedFunctions.decodeBitmapFromFile(file, 100, 100);
//((CircleImageView) findViewById(R.id.userPhoto)).setImageBitmap(bitmap);
final Context context = this;

FirebaseDatabase.getInstance().getReference("Journeys").child(FirebaseAuth.getInstance().getCurrentUser().getPhoneNumber())
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
ContextWrapper wrapper = new ContextWrapper(getApplicationContext());
ArrayList<JourneyMini> journeys = new ArrayList<>();
SimpleDateFormat format = new SimpleDateFormat(CreateJourneyActivity.DATE_FORMAT);
for(DataSnapshot ds : dataSnapshot.getChildren()) {
try {
Date date = format.parse(ds.getKey());
String title = ds.child(CreateJourneyActivity.TITLE).getValue(String.class);
File file = wrapper.getDir(ds.getKey(), MODE_PRIVATE);
Uri photo = null;
if (file.isDirectory()) {
String[] images = file.list();
if(images.length > 0)
photo = Uri.parse(new File(file, images[0]).getAbsolutePath());
}
journeys.add(new JourneyMini(title, date, "Faisal Town", "Lahore", photo));
} catch (ParseException e) {}
}
JourneyLsitAdapter adapter = new JourneyLsitAdapter(context, journeys, bitmap, "Farhan");
ListView view = findViewById(R.id.journeysList);
view.setAdapter(adapter);
}

@Override public void onCancelled(DatabaseError databaseError) { }
});
}

public void createJourney(View view) {
startActivity(new Intent(this, CreateJourneyActivity.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ protected void onCreate(Bundle savedInstanceState) {
try {
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseDatabase.getInstance().getReference("users").keepSynced(true);
FirebaseDatabase.getInstance().getReference("Journeys").keepSynced(true);
FirebaseDatabase.getInstance().getReference("inviteLink").keepSynced(true);
}
catch (Exception ex) {}
Expand Down Expand Up @@ -61,7 +62,7 @@ private void doAfterPermissions() {
//checking if user already signed in
mAuth = FirebaseAuth.getInstance();
if(mAuth.getCurrentUser() != null) {
startActivity(new Intent(this, CreateJourneyActivity.class));
startActivity(new Intent(this, JourneysLsitActivity.class));
finish();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
reference1.child("name").setValue(null);
reference1.child("status").setValue(null);
mDatabase.child("users").child(phone).setValue(map);
startActivity(new Intent(SetProfileData.this, CreateJourneyActivity.class));
startActivity(new Intent(SetProfileData.this, JourneysLsitActivity.class));
finish();
}
});
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/project/wanderlust/SharedFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.io.File;

public class SharedFunctions {
public static String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

@Contract(pure = true)
public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
final int height = options.outHeight;
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/project/wanderlust/ShowJourney.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ protected void onCreate(Bundle savedInstanceState) {

Intent intent = getIntent();
String timestamp = (String) intent.getSerializableExtra("timestamp");
timestamp = "2018-04-22 11:18:44";

final TextView titleView = findViewById(R.id.title);
final TextView descriptionView = findViewById(R.id.description);
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/plus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- drawable/plus.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#FFFFFF" android:pathData="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" />
</vector>
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_create_journey.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="getCameraPicture"
android:layout_marginEnd="5dp"
android:text="@string/camera" />

<Button
android:id="@+id/gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="getGalleryPictures"
android:layout_marginStart="5dp"
android:text="@string/gallery"
tools:layout_editor_absoluteY="111dp" />
</LinearLayout>
Expand Down
Loading

0 comments on commit 0ccb970

Please sign in to comment.