Merge remote-tracking branch 'origin/master' into marijn-appje
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
package="nl.myhyvesbookplus.tagram">
|
package="nl.myhyvesbookplus.tagram">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
|
android:maxSdkVersion="18"/>
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -11,6 +14,18 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="android.support.v4.content.FileProvider"
|
||||||
|
android:authorities="nl.myhyvesbookplus.tagram.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths"/>
|
||||||
|
</provider>
|
||||||
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import nl.myhyvesbookplus.tagram.controller.UploadClass;
|
import nl.myhyvesbookplus.tagram.controller.PostUploader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
@@ -26,7 +26,7 @@ import nl.myhyvesbookplus.tagram.controller.UploadClass;
|
|||||||
* Use the {@link CameraFragment#newInstance} factory method to
|
* Use the {@link CameraFragment#newInstance} factory method to
|
||||||
* create an instance of this fragment.
|
* create an instance of this fragment.
|
||||||
*/
|
*/
|
||||||
public class CameraFragment extends Fragment {
|
public class CameraFragment extends Fragment implements PostUploader.PostUploadListener{
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
// TODO: Rename parameter arguments, choose names that match
|
||||||
private static final String TAG = "CameraFragment";
|
private static final String TAG = "CameraFragment";
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||||
@@ -144,8 +144,6 @@ public class CameraFragment extends Fragment {
|
|||||||
(view.findViewById(R.id.upload_button)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.upload_button)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
UploadClass upload = new UploadClass();
|
|
||||||
upload.uploadPicture(mPhoto);
|
|
||||||
|
|
||||||
mPhoto.recycle();
|
mPhoto.recycle();
|
||||||
mPhoto = null;
|
mPhoto = null;
|
||||||
@@ -291,6 +289,11 @@ public class CameraFragment extends Fragment {
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void PostUploadComplete(Boolean success) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface must be implemented by activities that contain this
|
* This interface must be implemented by activities that contain this
|
||||||
* fragment to allow an interaction in this fragment to be communicated
|
* fragment to allow an interaction in this fragment to be communicated
|
||||||
@@ -305,4 +308,5 @@ public class CameraFragment extends Fragment {
|
|||||||
// TODO: Update argument type and name
|
// TODO: Update argument type and name
|
||||||
void onFragmentInteraction(Uri uri);
|
void onFragmentInteraction(Uri uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
|
|||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements
|
public class MainActivity extends AppCompatActivity implements
|
||||||
CameraFragment.OnFragmentInteractionListener,
|
CameraFragment.OnFragmentInteractionListener,
|
||||||
ProfileFragment.OnFragmentInteractionListener,
|
|
||||||
ProfilePictureUploader.ProfilePictureUpdatedListener,
|
ProfilePictureUploader.ProfilePictureUpdatedListener,
|
||||||
DownloadClass.PostDownloadListener {
|
DownloadClass.PostDownloadListener {
|
||||||
final static private String TAG = "MainScreen";
|
final static private String TAG = "MainScreen";
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package nl.myhyvesbookplus.tagram;
|
|||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.content.FileProvider;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -17,7 +17,6 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.firebase.ui.storage.images.FirebaseImageLoader;
|
import com.firebase.ui.storage.images.FirebaseImageLoader;
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
import com.google.android.gms.tasks.OnCompleteListener;
|
||||||
@@ -27,76 +26,39 @@ import com.google.firebase.auth.FirebaseUser;
|
|||||||
import com.google.firebase.storage.FirebaseStorage;
|
import com.google.firebase.storage.FirebaseStorage;
|
||||||
import com.google.firebase.storage.StorageReference;
|
import com.google.firebase.storage.StorageReference;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
|
import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
|
||||||
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple {@link Fragment} subclass.
|
|
||||||
* Activities that contain this fragment must implement the
|
|
||||||
* {@link ProfileFragment.OnFragmentInteractionListener} interface
|
|
||||||
* to handle interaction events.
|
|
||||||
* Use the {@link ProfileFragment#newInstance} factory method to
|
|
||||||
* create an instance of this fragment.
|
|
||||||
*/
|
|
||||||
public class ProfileFragment extends Fragment implements View.OnClickListener {
|
public class ProfileFragment extends Fragment implements View.OnClickListener {
|
||||||
static final int REQUEST_IMAGE_CAPTURE = 1;
|
static final int REQUEST_TAKE_PHOTO = 1;
|
||||||
final static private String TAG = "ProfileFragment";
|
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
/// Views, buttons and other protected declarations ///
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
|
||||||
private static final String ARG_PARAM1 = "param1";
|
|
||||||
private static final String ARG_PARAM2 = "param2";
|
|
||||||
private static Uri downloadUrl;
|
|
||||||
protected Button changePwdButton;
|
protected Button changePwdButton;
|
||||||
protected ImageButton profilePicButton;
|
protected ImageButton profilePicButton;
|
||||||
|
|
||||||
/// Views ///
|
|
||||||
protected StorageReference httpsReference;
|
protected StorageReference httpsReference;
|
||||||
protected TextView profileName;
|
protected TextView profileName;
|
||||||
protected ImageView profilePicture;
|
protected ImageView profilePicture;
|
||||||
protected FirebaseUser user;
|
protected FirebaseUser user;
|
||||||
|
protected File photoFile = null;
|
||||||
|
|
||||||
ProgressDialog progressDialog;
|
ProgressDialog progressDialog;
|
||||||
// TODO: Rename and change types of parameters
|
|
||||||
private String mParam1;
|
|
||||||
private String mParam2;
|
|
||||||
private OnFragmentInteractionListener mListener;
|
|
||||||
|
|
||||||
/// Required empty public constructor ///
|
/// Required empty public constructor ///
|
||||||
|
|
||||||
public ProfileFragment() {}
|
public ProfileFragment() {}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this factory method to create a new instance of
|
|
||||||
* this fragment using the provided parameters.
|
|
||||||
*
|
|
||||||
* @param param1 Parameter 1.
|
|
||||||
* @param param2 Parameter 2.
|
|
||||||
* @return A new instance of fragment ProfileFragment.
|
|
||||||
*/
|
|
||||||
// TODO: Rename and change types and number of parameters
|
|
||||||
public static ProfileFragment newInstance(String param1, String param2) {
|
|
||||||
ProfileFragment fragment = new ProfileFragment();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(ARG_PARAM1, param1);
|
|
||||||
args.putString(ARG_PARAM2, param2);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (getArguments() != null) {
|
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
||||||
}
|
|
||||||
|
|
||||||
user = FirebaseAuth.getInstance().getCurrentUser();
|
user = FirebaseAuth.getInstance().getCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns all views.
|
* Assigns all views and buttons.
|
||||||
*/
|
*/
|
||||||
protected void findViews(View view) {
|
protected void findViews(View view) {
|
||||||
profilePicButton = (ImageButton) view.findViewById(R.id.profile_pic_button);
|
profilePicButton = (ImageButton) view.findViewById(R.id.profile_pic_button);
|
||||||
@@ -106,22 +68,30 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
bindOnClick();
|
bindOnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind the buttons to their listeners.
|
||||||
|
*/
|
||||||
protected void bindOnClick() {
|
protected void bindOnClick() {
|
||||||
profilePicButton.setOnClickListener(this);
|
profilePicButton.setOnClickListener(this);
|
||||||
changePwdButton.setOnClickListener(this);
|
changePwdButton.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Setup ///
|
/// Page setup ///
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
// Inflate the layout for this fragment
|
|
||||||
View view = inflater.inflate(R.layout.fragment_profile, container, false);
|
View view = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||||
findViews(view);
|
findViews(view);
|
||||||
|
|
||||||
if (user != null && user.getPhotoUrl() != null) {
|
if (user != null) {
|
||||||
httpsReference = FirebaseStorage.getInstance().getReferenceFromUrl(user.getPhotoUrl().toString());
|
if(user.getPhotoUrl() != null) {
|
||||||
|
httpsReference = FirebaseStorage.getInstance().getReferenceFromUrl(user.getPhotoUrl().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.getDisplayName() != null) {
|
||||||
|
profileName.setText(user.getDisplayName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpsReference != null) {
|
if (httpsReference != null) {
|
||||||
@@ -130,20 +100,9 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
|
|
||||||
profilePicture.invalidate();
|
profilePicture.invalidate();
|
||||||
|
|
||||||
if (user != null && user.getDisplayName() != null) {
|
|
||||||
profileName.setText(user.getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Rename method, update argument and hook method into UI event
|
|
||||||
public void onButtonPressed(Uri uri) {
|
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onFragmentInteraction(uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a view has been clicked.
|
* Called when a view has been clicked.
|
||||||
*
|
*
|
||||||
@@ -161,43 +120,57 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Make the function actually do something.
|
|
||||||
/**
|
|
||||||
* Performs profile picture change action.
|
|
||||||
*/
|
|
||||||
public void profilePicOnClick() {
|
|
||||||
// Log.d(TAG, "profilePicOnClick: JE KAN NOG GEEN FOTO UPLOADEN");
|
|
||||||
dispatchTakePictureIntent();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts new intent for access to the built-in camera of device.
|
* Starts new intent for access to the built-in camera of device.
|
||||||
*/
|
*/
|
||||||
private void dispatchTakePictureIntent() {
|
private void profilePicOnClick() {
|
||||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
/* Ensure that there's a camera activity to handle the intent */
|
||||||
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
|
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
|
||||||
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
|
/* Create the File where the photo should go */
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_LONG);
|
||||||
|
}
|
||||||
|
if (photoFile != null) {
|
||||||
|
Uri photoURI = FileProvider.getUriForFile(getActivity(),
|
||||||
|
"nl.myhyvesbookplus.tagram.fileprovider",
|
||||||
|
photoFile);
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
|
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs the image just taken by the built-in camera and pushes this image to the user account.
|
* Grabs the image just taken by the built-in camera and pushes this image to the user account.
|
||||||
* @param requestCode
|
* @param requestCode The code which corresponds to REQUEST_TAKE_PHOTO. Used as indicator.
|
||||||
* @param resultCode
|
* @param resultCode Code should be RESULT_OK to allow camera to proceed.
|
||||||
* @param data
|
* @param data The image data from the camera.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
|
if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) {
|
||||||
Bundle extras = data.getExtras();
|
progressDialog = ProgressDialog.show(getActivity(), getString(R.string.please_wait), getString(R.string.upload_profile_pic), false, false);
|
||||||
Bitmap imageBitmap = (Bitmap) extras.get("data");
|
|
||||||
progressDialog = ProgressDialog.show(getActivity(), getString(R.string.please_wait), "bezig met uploaden", false, false);
|
|
||||||
ProfilePictureUploader profilePictureUploader = new ProfilePictureUploader(getActivity());
|
ProfilePictureUploader profilePictureUploader = new ProfilePictureUploader(getActivity());
|
||||||
profilePictureUploader.uploadProfilePicture(imageBitmap);
|
profilePictureUploader.uploadProfilePicture(photoFile.getAbsoluteFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private File createImageFile() throws IOException {
|
||||||
|
// Create an image file name
|
||||||
|
String imageFileName = "JPEG_" + user.getUid();
|
||||||
|
File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||||
|
return File.createTempFile(
|
||||||
|
imageFileName, /* prefix */
|
||||||
|
".jpg", /* suffix */
|
||||||
|
storageDir /* directory */
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO Make this function into its own class for modularity.
|
// TODO Make this function into its own class for modularity.
|
||||||
/**
|
/**
|
||||||
@@ -210,8 +183,8 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
Toast.makeText(getActivity(), task.isSuccessful()
|
Toast.makeText(getActivity(), task.isSuccessful()
|
||||||
? "An e-mail was sent, please follow its instructions."
|
? "An e-mail was sent, please follow its instructions."
|
||||||
: "An error occurred, please check internet connection.",
|
: "An error occurred, please check internet connection.",
|
||||||
Toast.LENGTH_SHORT).show();
|
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.
|
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import android.util.Log;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -22,7 +24,7 @@ import nl.myhyvesbookplus.tagram.model.UriPost;
|
|||||||
* Created by marijnjansen on 26/06/2017.
|
* 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 static final String TAG = "TimeLineAdapter";
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -55,12 +57,20 @@ public class TimeLineAdapter extends BaseAdapter {
|
|||||||
View rowView = mInflater.inflate(R.layout.list_item_timeline, parent, false);
|
View rowView = mInflater.inflate(R.layout.list_item_timeline, parent, false);
|
||||||
|
|
||||||
TextView comment = (TextView) rowView.findViewById(R.id.comment_timeline);
|
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);
|
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);
|
UriPost post = (UriPost) getItem(position);
|
||||||
|
|
||||||
nietslechts.setText(Integer.toString(post.getNietSlechts()));
|
nietSlechts.setText(Integer.toString(post.getNietSlechts()));
|
||||||
comment.setText(post.getComment());
|
comment.setText(post.getComment());
|
||||||
|
|
||||||
StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri());
|
StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri());
|
||||||
@@ -72,4 +82,23 @@ public class TimeLineAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
return rowView;
|
return rowView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback method to be invoked when an item in this AdapterView has
|
||||||
|
* been clicked.
|
||||||
|
* <p>
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,7 @@ import android.widget.ListView;
|
|||||||
import nl.myhyvesbookplus.tagram.controller.DownloadClass;
|
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 {
|
public class TimelineFragment extends Fragment {
|
||||||
final private static String TAG = "TimelineFragment";
|
|
||||||
|
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private DownloadClass downloadClass;
|
private DownloadClass downloadClass;
|
||||||
@@ -25,29 +19,15 @@ public class TimelineFragment extends Fragment {
|
|||||||
// Required empty public constructor
|
// 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
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_timeline, container, false);
|
View view = inflater.inflate(R.layout.fragment_timeline, container, false);
|
||||||
|
|
||||||
listView = (ListView) view.findViewById(R.id.listview);
|
listView = (ListView) view.findViewById(R.id.listview);
|
||||||
|
|
||||||
downloadClass = new DownloadClass(getActivity());
|
downloadClass = new DownloadClass(getActivity());
|
||||||
downloadClass.getPostsFromServer();
|
downloadClass.getPostsFromServer();
|
||||||
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
import com.google.android.gms.tasks.OnCompleteListener;
|
||||||
import com.google.android.gms.tasks.OnFailureListener;
|
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.android.gms.tasks.Task;
|
||||||
import com.google.firebase.auth.UserProfileChangeRequest;
|
import com.google.firebase.auth.UserProfileChangeRequest;
|
||||||
import com.google.firebase.storage.FirebaseStorage;
|
import com.google.firebase.storage.FirebaseStorage;
|
||||||
|
import com.google.firebase.storage.StorageMetadata;
|
||||||
import com.google.firebase.storage.StorageReference;
|
import com.google.firebase.storage.StorageReference;
|
||||||
import com.google.firebase.storage.UploadTask;
|
import com.google.firebase.storage.UploadTask;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import static java.lang.System.currentTimeMillis;
|
import static java.lang.System.currentTimeMillis;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,10 +43,13 @@ public class ProfilePictureUploader extends UploadClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uploadProfilePicture(Bitmap picture) {
|
public void uploadProfilePicture(File picture) {
|
||||||
byte[] uploadPhoto = bitmapToBytes(picture);
|
|
||||||
oldPicture = mUser.getPhotoUrl();
|
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<UploadTask.TaskSnapshot>() {
|
photoUpload.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
|
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
|
||||||
@@ -80,9 +87,9 @@ public class ProfilePictureUploader extends UploadClass {
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<Void> task) {
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
Log.d(TAG, "onComplete: Delete successfull");
|
Log.v(TAG, "onComplete: Delete successful");
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "onComplete: " + task.getException().getLocalizedMessage());
|
Log.v(TAG, "onComplete: " + task.getException().getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
android:layout_height="40dp">
|
android:layout_height="40dp">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
|
android:id="@+id/niet_slecht_button"
|
||||||
android:layout_width="200dp"
|
android:layout_width="200dp"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,19 @@
|
|||||||
<string name="profile_picture_button">Wijzig Profiel Foto</string>
|
<string name="profile_picture_button">Wijzig Profiel Foto</string>
|
||||||
<string name="profile_picture_description">profiel foto</string>
|
<string name="profile_picture_description">profiel foto</string>
|
||||||
<string name="change_psw_button">Wachtwoord wijzigen</string>
|
<string name="change_psw_button">Wachtwoord wijzigen</string>
|
||||||
|
<string name="please_wait">Momentje</string>
|
||||||
|
<string name="hello_blank_fragment">Hallo leeg fragment</string>
|
||||||
|
<string name="hello_camera">Hallo Camera fragment</string>
|
||||||
|
<string name="login_error">Voer alstublieft email en wachtwoord in</string>
|
||||||
|
<string name="mail_failed">Er is een fout opgetreden. Controleer internetverbinding.</string>
|
||||||
|
<string name="mail_successful">Er is een e-mail verzonden. Volg a.u.b. de instructies.</string>
|
||||||
|
<string name="password_match_error">Wachtwoorden komen niet overeen</string>
|
||||||
|
<string name="register_error">Vul alstublieft alle velden in</string>
|
||||||
|
<string name="save">Opslaan</string>
|
||||||
|
<string name="upload">Uploaden</string>
|
||||||
|
<string name="image_save_error">Foto opslaan mislukt. Zorg a.u.b. dat er genoeg ruimte op uw telefoon beschikbaar is.</string>
|
||||||
|
<string name="update_profile_pic_error">Het updaten van de profielfoto is mislukt. Controleer uw internetverbinding.</string>
|
||||||
|
<string name="upload_profile_pic">Profielfoto aan het uploaden...</string>
|
||||||
<string name="please_wait">Wacht a.u.b.</string>
|
<string name="please_wait">Wacht a.u.b.</string>
|
||||||
<string name="niet_slecht">\"Niet slecht.\"s</string>
|
<string name="niet_slecht">\"Niet slecht.\"s</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
<string name="title_home">Timeline</string>
|
<string name="title_home">Timeline</string>
|
||||||
<string name="title_dashboard">Camera</string>
|
<string name="title_dashboard">Camera</string>
|
||||||
<string name="title_notifications">Profile</string>
|
<string name="title_notifications">Profile</string>
|
||||||
|
|
||||||
<string name="username">Username</string>
|
<string name="username">Username</string>
|
||||||
<string name="password">Password</string>
|
<string name="password">Password</string>
|
||||||
<string name="confirm_password">Confirm Password</string>
|
<string name="confirm_password">Confirm Password</string>
|
||||||
@@ -15,11 +14,10 @@
|
|||||||
<string name="login_error">Please fill in email and password</string>
|
<string name="login_error">Please fill in email and password</string>
|
||||||
<string name="password_match_error">Passwords do not match</string>
|
<string name="password_match_error">Passwords do not match</string>
|
||||||
<string name="register_error">Please fill in all the fields</string>
|
<string name="register_error">Please fill in all the fields</string>
|
||||||
|
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
<string name="hello_camera">Hello Camera</string>
|
<string name="hello_camera">Hello Camera</string>
|
||||||
<string name="logo_text">MyHyvesBookPlusTagram logo</string>
|
<string name="logo_text">MyHyvesBookPlusTagram logo</string>
|
||||||
<string name="logout_button">LogOut</string>
|
<string name="logout_button">Logout</string>
|
||||||
<string name="profile_picture_button">Change Profile Picture</string>
|
<string name="profile_picture_button">Change Profile Picture</string>
|
||||||
<string name="profile_picture_description">profile picture</string>
|
<string name="profile_picture_description">profile picture</string>
|
||||||
<string name="change_psw_button">Change Password</string>
|
<string name="change_psw_button">Change Password</string>
|
||||||
@@ -28,4 +26,9 @@
|
|||||||
|
|
||||||
<string name="upload">Upload</string>
|
<string name="upload">Upload</string>
|
||||||
<string name="save">Save</string>
|
<string name="save">Save</string>
|
||||||
|
<string name="mail_successful">An e-mail was sent. Please follow its instructions.</string>
|
||||||
|
<string name="mail_failed">An error occurred. Please check internet connection.</string>
|
||||||
|
<string name="image_save_error">Saving image to storage failed. Please make sure there is space available on the device.</string>
|
||||||
|
<string name="update_profile_pic_error">Updating the profile picture failed. Please check network connection.</string>
|
||||||
|
<string name="upload_profile_pic">Uploading profile picture...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<external-files-path name="profile_pic_URI" path="Pictures/" />
|
||||||
|
</paths>
|
||||||
|
</resources>
|
||||||
Reference in New Issue
Block a user