From 6851009e4bbf740919fadd05f0d6669a1b4ca962 Mon Sep 17 00:00:00 2001
From: Paul Lagerweij
Date: Tue, 27 Jun 2017 13:13:43 +0200
Subject: [PATCH 1/7] Added new files for profile fragment new file:
fragment_profile_header.xml new file: fragment_profile_timeline.xml new
file: list_item_timeline_profile.xml
---
.../res/layout/fragment_profile_header.xml | 69 +++++++++++++++++++
.../res/layout/fragment_profile_timeline.xml | 14 ++++
.../res/layout/list_item_timeline_profile.xml | 18 +++++
3 files changed, 101 insertions(+)
create mode 100644 app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml
create mode 100644 app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_timeline.xml
create mode 100644 app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml
new file mode 100644
index 0000000..f1f70a9
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_timeline.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_timeline.xml
new file mode 100644
index 0000000..fd06e94
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_timeline.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
new file mode 100644
index 0000000..11dde06
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
\ No newline at end of file
From 1d3537cdde8caa2ec50a0de670c455c5fcdecd7b Mon Sep 17 00:00:00 2001
From: Niels Zwemmer
Date: Tue, 27 Jun 2017 13:15:55 +0200
Subject: [PATCH 2/7] First attempt at ProfileAdapter. Not in working state.
---
.../tagram/ProfileAdapter.java | 78 +++++++++++++++++++
.../tagram/ProfileFragment.java | 18 +++++
2 files changed, 96 insertions(+)
create mode 100644 app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java
new file mode 100644
index 0000000..faa15ea
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java
@@ -0,0 +1,78 @@
+package nl.myhyvesbookplus.tagram;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.bumptech.glide.Glide;
+import com.firebase.ui.storage.images.FirebaseImageLoader;
+import com.google.firebase.storage.FirebaseStorage;
+import com.google.firebase.storage.StorageReference;
+
+import java.util.ArrayList;
+
+import nl.myhyvesbookplus.tagram.model.UriPost;
+
+/**
+ * Created by niels on 27-6-17.
+ */
+
+public class ProfileAdapter extends BaseAdapter {
+
+ private static final String TAG = "ProfileAdapter";
+ private LayoutInflater mInflater;
+ private Context mContext;
+ private ArrayList mData;
+ protected TextView comment;
+ protected TextView nietSlechts;
+ protected ImageView photo;
+
+ ProfileAdapter(Context context, ArrayList data) {
+ mContext = context;
+ mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mData = data;
+ }
+
+ @Override
+ public int getCount() {
+ return mData.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mData.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View rowView = mInflater.inflate(R.layout.list_item_timeline_profile, parent, false);
+ View newRowView = findViews(rowView);
+ UriPost post = (UriPost) getItem(position);
+ comment.setText(post.getComment());
+ StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri());
+ Glide.with(mContext)
+ .using(new FirebaseImageLoader())
+ .load(ref)
+ .into(photo);
+
+ return newRowView;
+ }
+
+ protected View findViews(View rowView) {
+ comment = (TextView) rowView.findViewById(R.id.comment_timeline_profile);
+ nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count_profile);
+ photo = (ImageView) rowView.findViewById(R.id.timeline_image_profile);
+ }
+}
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
index eb40f3d..056b8b2 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
@@ -15,6 +15,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
+import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
@@ -29,6 +30,7 @@ import com.google.firebase.storage.StorageReference;
import java.io.File;
import java.io.IOException;
+import nl.myhyvesbookplus.tagram.controller.DownloadClass;
import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
import static android.app.Activity.RESULT_OK;
@@ -44,6 +46,8 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
protected ImageView profilePicture;
protected FirebaseUser user;
protected File photoFile = null;
+ private ListView listView;
+ private DownloadClass downloadClass;
ProgressDialog progressDialog;
@@ -55,6 +59,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
user = FirebaseAuth.getInstance().getCurrentUser();
+ loadPersonalPosts();
}
/**
@@ -65,6 +70,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
profilePicture = (ImageView) view.findViewById(R.id.imageView_profile_picture);
profileName = (TextView) view.findViewById(R.id.profile_name);
changePwdButton = (Button) view.findViewById(R.id.change_psw_button);
+ listView = (ListView) view.findViewById(R.id.listview);
bindOnClick();
}
@@ -99,6 +105,8 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
}
profilePicture.invalidate();
+ downloadClass = new DownloadClass(getActivity());
+ downloadClass.getPostsFromServer();
return view;
}
@@ -143,6 +151,12 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
}
}
+ public void startList() {
+ ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getmList());
+ listView.setAdapter(adapter);
+ listView.addHeaderView(adapter);
+ }
+
/**
* Grabs the image just taken by the built-in camera and pushes this image to the user account.
* @param requestCode The code which corresponds to REQUEST_TAKE_PHOTO. Used as indicator.
@@ -158,6 +172,10 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
}
}
+ public void loadPersonalPosts() {
+
+ }
+
private File createImageFile() throws IOException {
// Create an image file name
From b11cc9500024a034a003e77ea176daa199f0fafc Mon Sep 17 00:00:00 2001
From: Paul Lagerweij
Date: Tue, 27 Jun 2017 13:19:25 +0200
Subject: [PATCH 3/7] put back 'niet slecht count profile'
---
.../res/layout/list_item_timeline_profile.xml | 21 ++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
index 11dde06..2c765fc 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
@@ -4,15 +4,30 @@
android:orientation="vertical">
-
\ No newline at end of file
+
+
+
+
+
+
+
From 0c3ed94bb7f63f58b2ca4d253507c4a3551e4b2b Mon Sep 17 00:00:00 2001
From: Paul Lagerweij
Date: Tue, 27 Jun 2017 13:21:30 +0200
Subject: [PATCH 4/7] put back profile naming
---
.../app/src/main/res/layout/list_item_timeline_profile.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
index 2c765fc..f8020e8 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
@@ -4,13 +4,13 @@
android:orientation="vertical">
From 16c3b727fc2c6f9a30e380d382b7eaa3cea1b784 Mon Sep 17 00:00:00 2001
From: Niels Zwemmer
Date: Tue, 27 Jun 2017 16:12:42 +0200
Subject: [PATCH 5/7] Working profile page with Adapter. Need Marijn to fix the
downloadclass to show user-only content instead of entire timeline.
---
.../myhyvesbookplus/tagram/MainActivity.java | 5 +-
.../tagram/ProfileAdapter.java | 7 +-
.../tagram/ProfileFragment.java | 24 ++++--
.../tagram/controller/DownloadClass.java | 4 +-
.../src/main/res/layout/fragment_profile.xml | 81 -------------------
.../res/layout/fragment_profile_header.xml | 7 ++
6 files changed, 36 insertions(+), 92 deletions(-)
delete mode 100644 app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/MainActivity.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/MainActivity.java
index aa8ec14..8772d76 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/MainActivity.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/MainActivity.java
@@ -122,8 +122,11 @@ public class MainActivity extends AppCompatActivity implements
public void PostDownloaded() {
FragmentManager fragmentManager = getFragmentManager();
Fragment frag = fragmentManager.findFragmentById(R.id.content);
+ Log.d(TAG, "PostDownloaded: " + R.id.content);
- if (frag instanceof TimelineFragment) {
+ if (frag instanceof ProfileFragment) {
+ ((ProfileFragment) frag).startList();
+ } else if (frag instanceof TimelineFragment) {
((TimelineFragment) frag).startList();
}
}
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java
index faa15ea..357876a 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java
@@ -30,9 +30,9 @@ public class ProfileAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Context mContext;
private ArrayList mData;
- protected TextView comment;
- protected TextView nietSlechts;
- protected ImageView photo;
+ private TextView comment;
+ private TextView nietSlechts;
+ private ImageView photo;
ProfileAdapter(Context context, ArrayList data) {
mContext = context;
@@ -74,5 +74,6 @@ public class ProfileAdapter extends BaseAdapter {
comment = (TextView) rowView.findViewById(R.id.comment_timeline_profile);
nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count_profile);
photo = (ImageView) rowView.findViewById(R.id.timeline_image_profile);
+ return rowView;
}
}
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
index 056b8b2..73c0388 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
@@ -9,6 +9,7 @@ import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.content.FileProvider;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -70,7 +71,6 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
profilePicture = (ImageView) view.findViewById(R.id.imageView_profile_picture);
profileName = (TextView) view.findViewById(R.id.profile_name);
changePwdButton = (Button) view.findViewById(R.id.change_psw_button);
- listView = (ListView) view.findViewById(R.id.listview);
bindOnClick();
}
@@ -87,8 +87,14 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_profile, container, false);
- findViews(view);
+ View viewTimeline = inflater.inflate(R.layout.fragment_profile_timeline, container, false);
+
+
+
+ listView = (ListView) viewTimeline.findViewById(R.id.listview_profile);
+ View viewHeader = inflater.inflate(R.layout.fragment_profile_header, listView, false);
+ findViews(viewHeader);
+ listView.addHeaderView(viewHeader);
if (user != null) {
if(user.getPhotoUrl() != null) {
@@ -105,10 +111,11 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
}
profilePicture.invalidate();
+
downloadClass = new DownloadClass(getActivity());
downloadClass.getPostsFromServer();
- return view;
+ return viewTimeline;
}
/**
@@ -153,8 +160,13 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
public void startList() {
ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getmList());
- listView.setAdapter(adapter);
- listView.addHeaderView(adapter);
+ if (listView != null) {
+ listView.setAdapter(adapter);
+ } else {
+ Log.d("Jemoeder", "startList: Halloooooooo");
+ }
+
+// listView.addHeaderView(adapter);
}
/**
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/DownloadClass.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/DownloadClass.java
index a32a97c..d589360 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/DownloadClass.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/DownloadClass.java
@@ -40,8 +40,10 @@ public class DownloadClass {
mDataRef.child("posts").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
+
for (DataSnapshot data : dataSnapshot.getChildren()) {
- mList.add(data.getValue(UriPost.class));
+
+ mList.add(data.getValue(UriPost.class));
}
Collections.reverse(mList);
mListener.PostDownloaded();
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml
deleted file mode 100644
index 8e04ad4..0000000
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml
index f1f70a9..562849d 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml
@@ -65,5 +65,12 @@
android:text="@string/logout_button"
android:textColor="@android:color/white"
android:textSize="16sp" />
+
+
+
\ No newline at end of file
From 3aab4631433c15d9a0e558cc19d836cc176ee60f Mon Sep 17 00:00:00 2001
From: Niels Zwemmer
Date: Wed, 28 Jun 2017 11:13:39 +0200
Subject: [PATCH 6/7] Added error message-shows and mail_successful/mail_failed
to the error messages.
---
.../java/nl/myhyvesbookplus/tagram/ProfileFragment.java | 6 +++---
.../app/src/main/res/values-nl/strings.xml | 1 +
.../app/src/main/res/values/strings.xml | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
index 73c0388..16378c1 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
@@ -146,7 +146,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
try {
photoFile = createImageFile();
} catch (IOException ex) {
- Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_LONG);
+ Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_LONG).show();
}
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(getActivity(),
@@ -213,8 +213,8 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
@Override
public void onComplete(@NonNull Task task) {
Toast.makeText(getActivity(), task.isSuccessful()
- ? "An e-mail was sent, please follow its instructions."
- : "An error occurred, please check internet connection.",
+ ? getString(R.string.mail_successful)
+ : getString(R.string.mail_failed),
Toast.LENGTH_SHORT).show();
}
});
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
index 57fc504..ff4209c 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
@@ -31,4 +31,5 @@
Het updaten van de profielfoto is mislukt. Controleer uw internetverbinding.
Profielfoto aan het uploaden…
"\"Niet slecht.\"s "
+ An e-mail was sent, please follow its instructions.
\ No newline at end of file
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
index 7f065d9..39d347b 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
@@ -29,5 +29,5 @@
An error occurred. Please check internet connection.
Saving image to storage failed. Please make sure there is space available on the device.
Updating the profile picture failed. Please check network connection.
- Uploading profile picture...
+ Uploading profile picture…
From 017b5890c2473ee19f92a5ef1cf78acffce555c5 Mon Sep 17 00:00:00 2001
From: Niels Zwemmer
Date: Wed, 28 Jun 2017 13:11:30 +0200
Subject: [PATCH 7/7] Neated up the code.
---
.../app/src/main/AndroidManifest.xml | 5 ++--
.../tagram/ProfileFragment.java | 30 ++++++-------------
2 files changed, 11 insertions(+), 24 deletions(-)
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml b/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml
index 63bdf6e..2284c0c 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml
@@ -3,9 +3,8 @@
package="nl.myhyvesbookplus.tagram">
-
-
+
+