task) {
Toast.makeText(getActivity(), task.isSuccessful()
- ? "An e-mail was sent, please follow its instructions."
- : "An error occurred, please check internet connection.",
+ ? "An e-mail was sent, please follow its instructions."
+ : "An error occurred, please check internet connection.",
Toast.LENGTH_SHORT).show();
}
});
@@ -219,43 +192,4 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
// TODO Add code here for when there is no currently active user.
}
}
-
- /**
- * Obligatory onAttach function included in fragments.
- * @param context provided context for the function to operate on.
- */
- @Override
- public void onAttach(Context context) {
- super.onAttach(context);
- if (context instanceof OnFragmentInteractionListener) {
- mListener = (OnFragmentInteractionListener) context;
- } else {
- throw new RuntimeException(context.toString()
- + " must implement OnFragmentInteractionListener");
- }
- }
-
- /**
- * Obligatory onDetach function included in fragments.
- */
- @Override
- public void onDetach() {
- super.onDetach();
- mListener = null;
- }
-
- /**
- * This interface must be implemented by activities that contain this
- * fragment to allow an interaction in this fragment to be communicated
- * to the activity and potentially other fragments contained in that
- * activity.
- * See the Android Training lesson http://developer.android.com/training/basics/fragments/communicating.html
- * for more information.
- */
- public interface OnFragmentInteractionListener {
- // TODO: Update argument type and name
- void onFragmentInteraction(Uri uri);
- }
-
-
}
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimeLineAdapter.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimeLineAdapter.java
index 5cf22f4..c5fde32 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimeLineAdapter.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimeLineAdapter.java
@@ -5,7 +5,9 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
import android.widget.BaseAdapter;
+import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
@@ -22,7 +24,7 @@ import nl.myhyvesbookplus.tagram.model.UriPost;
* Created by marijnjansen on 26/06/2017.
*/
-public class TimeLineAdapter extends BaseAdapter {
+public class TimeLineAdapter extends BaseAdapter implements AdapterView.OnItemClickListener {
private static final String TAG = "TimeLineAdapter";
private LayoutInflater mInflater;
private Context mContext;
@@ -55,12 +57,20 @@ public class TimeLineAdapter extends BaseAdapter {
View rowView = mInflater.inflate(R.layout.list_item_timeline, parent, false);
TextView comment = (TextView) rowView.findViewById(R.id.comment_timeline);
- TextView nietslechts = (TextView) rowView.findViewById(R.id.niet_slecht_count);
+ TextView nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count);
ImageView photo = (ImageView) rowView.findViewById(R.id.timeline_image);
+ ImageButton nietSlechtButton = (ImageButton) rowView.findViewById(R.id.niet_slecht_button);
+
+ nietSlechtButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ }
+ });
UriPost post = (UriPost) getItem(position);
- nietslechts.setText(Integer.toString(post.getNietSlechts()));
+ nietSlechts.setText(Integer.toString(post.getNietSlechts()));
comment.setText(post.getComment());
StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri());
@@ -72,4 +82,23 @@ public class TimeLineAdapter extends BaseAdapter {
return rowView;
}
+
+
+ /**
+ * Callback method to be invoked when an item in this AdapterView has
+ * been clicked.
+ *
+ * Implementers can call getItemAtPosition(position) if they need
+ * to access the data associated with the selected item.
+ *
+ * @param parent The AdapterView where the click happened.
+ * @param view The view within the AdapterView that was clicked (this
+ * will be a view provided by the adapter)
+ * @param position The position of the view in the adapter.
+ * @param id The row id of the item that was clicked.
+ */
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ Log.d(TAG, "onItemClick: rowNumber! "+ position);
+ }
}
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java
index 44f568d..b2ca6d4 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java
@@ -10,13 +10,7 @@ import android.widget.ListView;
import nl.myhyvesbookplus.tagram.controller.DownloadClass;
-/**
- * A simple {@link Fragment} subclass.
- * Use the {@link TimelineFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
public class TimelineFragment extends Fragment {
- final private static String TAG = "TimelineFragment";
private ListView listView;
private DownloadClass downloadClass;
@@ -25,29 +19,15 @@ public class TimelineFragment extends Fragment {
// Required empty public constructor
}
- /**
- * Use this factory method to create a new instance of
- * this fragment using the provided parameters.
- * @return A new instance of fragment TimelineFragment.
- */
- // TODO: Rename and change types and number of parameters
- public static TimelineFragment newInstance() {
- TimelineFragment fragment = new TimelineFragment();
- Bundle args = new Bundle();
- fragment.setArguments(args);
- return fragment;
- }
-
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_timeline, container, false);
-
listView = (ListView) view.findViewById(R.id.listview);
+
downloadClass = new DownloadClass(getActivity());
downloadClass.getPostsFromServer();
- // Inflate the layout for this fragment
return view;
}
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/ProfilePictureUploader.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/ProfilePictureUploader.java
index 1137d5d..3264976 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/ProfilePictureUploader.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/ProfilePictureUploader.java
@@ -5,6 +5,7 @@ import android.graphics.Bitmap;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.Log;
+import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
@@ -12,9 +13,12 @@ import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.UserProfileChangeRequest;
import com.google.firebase.storage.FirebaseStorage;
+import com.google.firebase.storage.StorageMetadata;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
+import java.io.File;
+
import static java.lang.System.currentTimeMillis;
/**
@@ -39,10 +43,13 @@ public class ProfilePictureUploader extends UploadClass {
}
}
- public void uploadProfilePicture(Bitmap picture) {
- byte[] uploadPhoto = bitmapToBytes(picture);
+ public void uploadProfilePicture(File picture) {
oldPicture = mUser.getPhotoUrl();
- UploadTask photoUpload = mStorageRef.child("profile").child(getUserUid() + "_" + currentTimeMillis()).putBytes(uploadPhoto);
+ StorageMetadata metadata = new StorageMetadata.Builder()
+ .setContentType("image/jpg")
+ .build();
+
+ UploadTask photoUpload = mStorageRef.child("profile").child(getUserUid() + "_" + currentTimeMillis()).putFile(Uri.fromFile(picture), metadata);
photoUpload.addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
@@ -80,9 +87,9 @@ public class ProfilePictureUploader extends UploadClass {
@Override
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()) {
- Log.d(TAG, "onComplete: Delete successfull");
+ Log.v(TAG, "onComplete: Delete successful");
} else {
- Log.d(TAG, "onComplete: " + task.getException().getLocalizedMessage());
+ Log.v(TAG, "onComplete: " + task.getException().getLocalizedMessage());
}
}
});
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline.xml
index 5a0d59e..9e1bba4 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline.xml
@@ -2,6 +2,7 @@
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 03b3f3f..79c3196 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
@@ -17,6 +17,19 @@
Wijzig Profiel Foto
profiel foto
Wachtwoord wijzigen
+ Momentje
+ Hallo leeg fragment
+ Hallo Camera fragment
+ Voer alstublieft email en wachtwoord in
+ Er is een fout opgetreden. Controleer internetverbinding.
+ Er is een e-mail verzonden. Volg a.u.b. de instructies.
+ Wachtwoorden komen niet overeen
+ Vul alstublieft alle velden in
+ Opslaan
+ Uploaden
+ Foto opslaan mislukt. Zorg a.u.b. dat er genoeg ruimte op uw telefoon beschikbaar is.
+ Het updaten van de profielfoto is mislukt. Controleer uw internetverbinding.
+ Profielfoto aan het uploaden...
Wacht a.u.b.
\"Niet slecht.\"s
\ 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 8a5ea78..3ba5068 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
@@ -3,7 +3,6 @@
Timeline
Camera
Profile
-
Username
Password
Confirm Password
@@ -15,11 +14,10 @@
Please fill in email and password
Passwords do not match
Please fill in all the fields
-
Hello blank fragment
Hello Camera
MyHyvesBookPlusTagram logo
- LogOut
+ Logout
Change Profile Picture
profile picture
Change Password
@@ -28,4 +26,9 @@
Upload
Save
+ An e-mail was sent. Please follow its instructions.
+ 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...
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/xml/file_paths.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/xml/file_paths.xml
new file mode 100644
index 0000000..c87d3ee
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/xml/file_paths.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file