Much cleaner code. Known bugs seem to be fixed. Added extra progressDialog for posts downloading.
This commit is contained in:
@@ -24,27 +24,8 @@ import android.widget.RelativeLayout;
|
|||||||
import nl.myhyvesbookplus.tagram.controller.PostUploader;
|
import nl.myhyvesbookplus.tagram.controller.PostUploader;
|
||||||
import nl.myhyvesbookplus.tagram.model.BitmapPost;
|
import nl.myhyvesbookplus.tagram.model.BitmapPost;
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple {@link Fragment} subclass.
|
|
||||||
* Activities that contain this fragment must implement the
|
|
||||||
* {@link CameraFragment.OnFragmentInteractionListener} interface
|
|
||||||
* to handle interaction events.
|
|
||||||
* Use the {@link CameraFragment#newInstance} factory method to
|
|
||||||
* create an instance of this fragment.
|
|
||||||
*/
|
|
||||||
public class CameraFragment extends Fragment implements PostUploader.PostUploadListener{
|
public class CameraFragment extends Fragment implements PostUploader.PostUploadListener{
|
||||||
// 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
|
|
||||||
private static final String ARG_PARAM1 = "param1";
|
|
||||||
private static final String ARG_PARAM2 = "param2";
|
|
||||||
|
|
||||||
// TODO: Rename and change types of parameters
|
|
||||||
private String mParam1;
|
|
||||||
private String mParam2;
|
|
||||||
|
|
||||||
private OnFragmentInteractionListener mListener;
|
|
||||||
|
|
||||||
private Camera mCamera;
|
private Camera mCamera;
|
||||||
private CameraPreview mPreview;
|
private CameraPreview mPreview;
|
||||||
private Bitmap mPhoto;
|
private Bitmap mPhoto;
|
||||||
@@ -54,33 +35,6 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 CameraFragment.
|
|
||||||
*/
|
|
||||||
// TODO: Rename and change types and number of parameters
|
|
||||||
public static CameraFragment newInstance(String param1, String param2) {
|
|
||||||
CameraFragment fragment = new CameraFragment();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(ARG_PARAM1, param1);
|
|
||||||
args.putString(ARG_PARAM2, param2);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
if (getArguments() != null) {
|
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@@ -98,11 +52,12 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
|
|
||||||
mCameraLayout.addView(mPreview);
|
mCameraLayout.addView(mPreview);
|
||||||
|
|
||||||
// Draw buttons over preview
|
// Draw initial buttons over preview
|
||||||
view.findViewById(R.id.picture_button).bringToFront();
|
view.findViewById(R.id.picture_button).bringToFront();
|
||||||
view.findViewById(R.id.switch_camera_button).bringToFront();
|
view.findViewById(R.id.switch_camera_button).bringToFront();
|
||||||
filterButtons.bringToFront();
|
filterButtons.bringToFront();
|
||||||
|
|
||||||
|
/* Upon pressing the switch camera facing button: */
|
||||||
(view.findViewById(R.id.switch_camera_button)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.switch_camera_button)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -119,6 +74,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Upon pressing the take photo button: */
|
||||||
(view.findViewById(R.id.picture_button)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.picture_button)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -141,6 +97,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Upon pressing the upload button: */
|
||||||
(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) {
|
||||||
@@ -153,6 +110,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Upon pressing the enter button on the virtual keyboard: */
|
||||||
(view.findViewById(R.id.comment_submit)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.comment_submit)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -184,6 +142,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Upon pressing the cancel button: */
|
||||||
(view.findViewById(R.id.comment_cancel)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.comment_cancel)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -209,6 +168,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Upon pressing the left arrow filter change button: */
|
||||||
(view.findViewById(R.id.filter_left)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.filter_left)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -227,6 +187,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Upon pressing the right arrow filter change button: */
|
||||||
(view.findViewById(R.id.filter_right)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.filter_right)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -256,30 +217,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
|
.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Rename method, update argument and hook method into UI event
|
//TODO Niet helemaal zeker wat dit doet.
|
||||||
public void onButtonPressed(Uri uri) {
|
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onFragmentInteraction(uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDetach() {
|
|
||||||
super.onDetach();
|
|
||||||
mListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
@@ -291,6 +229,11 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
getActivity().findViewById(R.id.content).setPadding(dp,dp,dp,dp);
|
getActivity().findViewById(R.id.content).setPadding(dp,dp,dp,dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the camera.
|
||||||
|
* @param facing The direction in which the camera should be initialized (back by default).
|
||||||
|
* @return the result of the opened camera, if successful.
|
||||||
|
*/
|
||||||
public static Camera getCameraInstance(int facing) {
|
public static Camera getCameraInstance(int facing) {
|
||||||
Camera c = null;
|
Camera c = null;
|
||||||
try {
|
try {
|
||||||
@@ -301,13 +244,27 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch between front facing camera and the back camera.
|
||||||
|
*/
|
||||||
public void switchFacing() {
|
public void switchFacing() {
|
||||||
if (facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
|
if (facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
|
||||||
facing = Camera.CameraInfo.CAMERA_FACING_BACK;
|
facing = Camera.CameraInfo.CAMERA_FACING_BACK;
|
||||||
else
|
else
|
||||||
facing = Camera.CameraInfo.CAMERA_FACING_FRONT;
|
facing = Camera.CameraInfo.CAMERA_FACING_FRONT;
|
||||||
|
// TODO
|
||||||
|
// facing =
|
||||||
|
// facing == Camera.CameraInfo.CAMERA_FACING_FRONT ?
|
||||||
|
// Camera.CameraInfo.CAMERA_FACING_BACK :
|
||||||
|
// Camera.CameraInfo.CAMERA_FACING_FRONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change which buttons are visible during the different stages on the camera fragment.
|
||||||
|
*
|
||||||
|
* @param view The current view upon which the buttons need to be placed or removed.
|
||||||
|
*/
|
||||||
public void switchButtons(View view) {
|
public void switchButtons(View view) {
|
||||||
FloatingActionButton upload = (FloatingActionButton) view.findViewById(R.id.upload_button);
|
FloatingActionButton upload = (FloatingActionButton) view.findViewById(R.id.upload_button);
|
||||||
ImageButton picButton = (ImageButton) view.findViewById(R.id.picture_button);
|
ImageButton picButton = (ImageButton) view.findViewById(R.id.picture_button);
|
||||||
@@ -332,6 +289,8 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: Kan dit weg? super aanroepen enzo.
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
@@ -346,20 +305,4 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
public void PostUploadComplete(Boolean success) {
|
public void PostUploadComplete(Boolean success) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
* <p>
|
|
||||||
* See the Android Training lesson <a href=
|
|
||||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
|
||||||
* >Communicating with Other Fragments</a> for more information.
|
|
||||||
*/
|
|
||||||
public interface OnFragmentInteractionListener {
|
|
||||||
// TODO: Update argument type and name
|
|
||||||
void onFragmentInteraction(Uri uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
* @param passwordString the entered password
|
* @param passwordString the entered password
|
||||||
*/
|
*/
|
||||||
protected void logIn(String emailString, String passwordString) {
|
protected void logIn(String emailString, String passwordString) {
|
||||||
progressDialog = ProgressDialog.show(LoginActivity.this, getString(R.string.please_wait), "Logging in", true, false);
|
progressDialog = ProgressDialog.show(LoginActivity.this, getString(R.string.please_wait), getString(R.string.logging_in), true, false);
|
||||||
|
|
||||||
mAuth.signInWithEmailAndPassword(emailString, passwordString)
|
mAuth.signInWithEmailAndPassword(emailString, passwordString)
|
||||||
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
|
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
|
||||||
@@ -211,7 +211,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
* @param password the entered password
|
* @param password the entered password
|
||||||
*/
|
*/
|
||||||
protected void registerUser(String email, String password) {
|
protected void registerUser(String email, String password) {
|
||||||
this.progressDialog = ProgressDialog.show(LoginActivity.this, getString(R.string.please_wait), "Registering", true, false);
|
this.progressDialog = ProgressDialog.show(LoginActivity.this, getString(R.string.please_wait), getString(R.string.registering), true, false);
|
||||||
mAuth.createUserWithEmailAndPassword(email, password)
|
mAuth.createUserWithEmailAndPassword(email, password)
|
||||||
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
|
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,9 +20,10 @@ import nl.myhyvesbookplus.tagram.controller.PostUploader;
|
|||||||
import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
|
import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements
|
public class MainActivity extends AppCompatActivity implements
|
||||||
CameraFragment.OnFragmentInteractionListener,
|
|
||||||
ProfilePictureUploader.ProfilePictureUpdatedListener,
|
ProfilePictureUploader.ProfilePictureUpdatedListener,
|
||||||
DownloadClass.PostDownloadListener, PostUploader.PostUploadListener {
|
DownloadClass.PostDownloadListener,
|
||||||
|
PostUploader.PostUploadListener {
|
||||||
|
|
||||||
final static private String TAG = "MainScreen";
|
final static private String TAG = "MainScreen";
|
||||||
|
|
||||||
FirebaseAuth mAuth;
|
FirebaseAuth mAuth;
|
||||||
@@ -89,11 +90,6 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFragmentInteraction(Uri uri) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logOutOnClick(View view) {
|
public void logOutOnClick(View view) {
|
||||||
FirebaseAuth.getInstance().signOut();
|
FirebaseAuth.getInstance().signOut();
|
||||||
goToLogin();
|
goToLogin();
|
||||||
@@ -107,7 +103,6 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ProfilePictureUpdated(Boolean success) {
|
public void ProfilePictureUpdated(Boolean success) {
|
||||||
Log.d(TAG, "ProfilePictureUpdated: Ja ik luister naar je!");
|
|
||||||
FragmentManager man = getFragmentManager();
|
FragmentManager man = getFragmentManager();
|
||||||
ProfileFragment frag = (ProfileFragment) man.findFragmentById(R.id.content);
|
ProfileFragment frag = (ProfileFragment) man.findFragmentById(R.id.content);
|
||||||
FragmentTransaction transaction = man.beginTransaction();
|
FragmentTransaction transaction = man.beginTransaction();
|
||||||
@@ -123,9 +118,12 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
FragmentManager fragmentManager = getFragmentManager();
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
Fragment frag = fragmentManager.findFragmentById(R.id.content);
|
Fragment frag = fragmentManager.findFragmentById(R.id.content);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (frag instanceof ProfileFragment) {
|
if (frag instanceof ProfileFragment) {
|
||||||
((ProfileFragment) frag).startList();
|
((ProfileFragment) frag).startList();
|
||||||
} else if (frag instanceof TimelineFragment) {
|
} else if (frag instanceof TimelineFragment) {
|
||||||
|
((TimelineFragment) frag).progressDialog.dismiss();
|
||||||
((TimelineFragment) frag).startList();
|
((TimelineFragment) frag).startList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class ProfileAdapter extends BaseAdapter {
|
|||||||
return newRowView;
|
return newRowView;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected View findViews(View rowView) {
|
private View findViews(View rowView) {
|
||||||
comment = (TextView) rowView.findViewById(R.id.comment_timeline_profile);
|
comment = (TextView) rowView.findViewById(R.id.comment_timeline_profile);
|
||||||
nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count_profile);
|
nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count_profile);
|
||||||
photo = (ImageView) rowView.findViewById(R.id.timeline_image_profile);
|
photo = (ImageView) rowView.findViewById(R.id.timeline_image_profile);
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ import static android.app.Activity.RESULT_OK;
|
|||||||
|
|
||||||
public class ProfileFragment extends Fragment implements View.OnClickListener {
|
public class ProfileFragment extends Fragment implements View.OnClickListener {
|
||||||
static final int REQUEST_TAKE_PHOTO = 1;
|
static final int REQUEST_TAKE_PHOTO = 1;
|
||||||
|
ProgressDialog progressDialog;
|
||||||
|
|
||||||
/// Views, buttons and other protected declarations ///
|
/* Views, buttons and other protected and private inits */
|
||||||
protected Button changePwdButton;
|
protected Button changePwdButton;
|
||||||
protected ImageButton profilePicButton;
|
protected ImageButton profilePicButton;
|
||||||
protected StorageReference httpsReference;
|
protected StorageReference httpsReference;
|
||||||
@@ -46,17 +47,19 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
protected ImageView profilePicture;
|
protected ImageView profilePicture;
|
||||||
protected FirebaseUser user;
|
protected FirebaseUser user;
|
||||||
protected File photoFile;
|
protected File photoFile;
|
||||||
|
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private DownloadClass downloadClass;
|
private DownloadClass downloadClass;
|
||||||
private View headerInflater;
|
private View headerInflater;
|
||||||
private View timeLineInflater;
|
private View timeLineInflater;
|
||||||
|
|
||||||
ProgressDialog progressDialog;
|
/* Required empty public constructor */
|
||||||
|
|
||||||
/// Required empty public constructor ///
|
|
||||||
|
|
||||||
public ProfileFragment() {}
|
public ProfileFragment() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden onCreate which initializes a user and sets the default photoFile to null.
|
||||||
|
* @param savedInstanceState The standard return of the onCreate method.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -75,6 +78,9 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
bindOnClick();
|
bindOnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign the ListView and add the header to it.
|
||||||
|
*/
|
||||||
protected void findTimelineViews() {
|
protected void findTimelineViews() {
|
||||||
listView = (ListView) timeLineInflater.findViewById(R.id.list);
|
listView = (ListView) timeLineInflater.findViewById(R.id.list);
|
||||||
listView.addHeaderView(headerInflater);
|
listView.addHeaderView(headerInflater);
|
||||||
@@ -88,8 +94,15 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
changePwdButton.setOnClickListener(this);
|
changePwdButton.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Page setup ///
|
/**
|
||||||
|
* Overridden onCreateView which serves as a fragment content creator.
|
||||||
|
* Checks for user data to be displayed.
|
||||||
|
*
|
||||||
|
* @param inflater The inflater used for the fragment.
|
||||||
|
* @param container The container which holds this fragment.
|
||||||
|
* @param savedInstanceState The state which was provided by onCreate.
|
||||||
|
* @return the timeLineInflater View which is required for the ListView to be updated.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@@ -123,11 +136,11 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
/**
|
/**
|
||||||
* Called when a view has been clicked.
|
* Called when a view has been clicked.
|
||||||
*
|
*
|
||||||
* @param v The view that was clicked.
|
* @param view The view that was clicked.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View view) {
|
||||||
switch (v.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.profile_pic_button:
|
case R.id.profile_pic_button:
|
||||||
profilePicOnClick();
|
profilePicOnClick();
|
||||||
break;
|
break;
|
||||||
@@ -142,13 +155,13 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
*/
|
*/
|
||||||
private void profilePicOnClick() {
|
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) {
|
||||||
/* Create the File where the photo should go */
|
|
||||||
try {
|
try {
|
||||||
photoFile = createImageFile();
|
photoFile = createImageFile();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), getString(R.string.image_save_error),
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
if (photoFile != null) {
|
if (photoFile != null) {
|
||||||
Uri photoURI = FileProvider.getUriForFile(getActivity(),
|
Uri photoURI = FileProvider.getUriForFile(getActivity(),
|
||||||
@@ -160,6 +173,9 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start display of the list; uses an adapter and listener in the main activity.
|
||||||
|
*/
|
||||||
public void startList() {
|
public void startList() {
|
||||||
ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getOwnPosts());
|
ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getOwnPosts());
|
||||||
listView.setAdapter(adapter);
|
listView.setAdapter(adapter);
|
||||||
@@ -167,6 +183,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 The code which corresponds to REQUEST_TAKE_PHOTO. Used as indicator.
|
* @param requestCode The code which corresponds to REQUEST_TAKE_PHOTO. Used as indicator.
|
||||||
* @param resultCode Code should be RESULT_OK to allow camera to proceed.
|
* @param resultCode Code should be RESULT_OK to allow camera to proceed.
|
||||||
* @param data The image data from the camera.
|
* @param data The image data from the camera.
|
||||||
@@ -180,8 +197,13 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the file which the camera requires to save a proper quality picture to.
|
||||||
|
*
|
||||||
|
* @return The new file.
|
||||||
|
* @throws IOException when insufficient permission or storage available.
|
||||||
|
*/
|
||||||
private File createImageFile() throws IOException {
|
private File createImageFile() throws IOException {
|
||||||
// Create an image file name
|
|
||||||
String imageFileName = "JPEG_" + user.getUid();
|
String imageFileName = "JPEG_" + user.getUid();
|
||||||
File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||||
return File.createTempFile(
|
return File.createTempFile(
|
||||||
@@ -191,9 +213,6 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO Make this function into its own class for modularity.
|
|
||||||
/**
|
/**
|
||||||
* Performs password reset action.
|
* Performs password reset action.
|
||||||
*/
|
*/
|
||||||
@@ -209,8 +228,6 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
// TODO Add code here for when there is no currently active user.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package nl.myhyvesbookplus.tagram;
|
package nl.myhyvesbookplus.tagram;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
@@ -9,27 +10,48 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
import nl.myhyvesbookplus.tagram.controller.DownloadClass;
|
import nl.myhyvesbookplus.tagram.controller.DownloadClass;
|
||||||
|
|
||||||
|
|
||||||
public class TimelineFragment extends Fragment {
|
public class TimelineFragment extends Fragment {
|
||||||
|
|
||||||
|
/* Some protected and private inits */
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private DownloadClass downloadClass;
|
private DownloadClass downloadClass;
|
||||||
|
ProgressDialog progressDialog;
|
||||||
|
|
||||||
public TimelineFragment() {
|
/* Required empty public constructor */
|
||||||
// Required empty public constructor
|
public TimelineFragment() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden onCreate which also starts a progress dialog for the posts being downloaded.
|
||||||
|
* @param savedInstanceState The standard return of the onCreate method.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
progressDialog = ProgressDialog.show(getActivity(), getString(R.string.please_wait), getString(R.string.downloading_posts), false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden onCreateView method which creates the ListView and contains a possible refresh
|
||||||
|
* functionality (swipe down page for result).
|
||||||
|
*
|
||||||
|
* https://www.survivingwithandroid.com/2014/05/android-swiperefreshlayout-tutorial-2.html
|
||||||
|
* Above reference was largely copied from.
|
||||||
|
* @param inflater The inflater used for the fragment.
|
||||||
|
* @param container The container which holds this fragment.
|
||||||
|
* @param savedInstanceState The state which was provided by onCreate.
|
||||||
|
* @return the timeLineInflater View which is required for the ListView to be updated.
|
||||||
|
*/
|
||||||
@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 timeLineInflater = inflater.inflate(R.layout.fragment_timeline, container, false);
|
||||||
listView = (ListView) view.findViewById(R.id.list);
|
listView = (ListView) timeLineInflater.findViewById(R.id.list);
|
||||||
final SwipeRefreshLayout swipeView = (SwipeRefreshLayout) view.findViewById(R.id.swipe);
|
final SwipeRefreshLayout swipeView = (SwipeRefreshLayout) timeLineInflater.findViewById(R.id.swipe);
|
||||||
|
|
||||||
swipeView.setEnabled(false);
|
swipeView.setEnabled(false);
|
||||||
downloadClass = new DownloadClass(getActivity());
|
downloadClass = new DownloadClass(getActivity());
|
||||||
@@ -38,15 +60,16 @@ public class TimelineFragment extends Fragment {
|
|||||||
swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
downloadClass = new DownloadClass(getActivity());
|
|
||||||
downloadClass.getPostsFromServer();
|
downloadClass.getPostsFromServer();
|
||||||
|
Toast.makeText(getActivity(), R.string.refreshing,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
swipeView.setRefreshing(true);
|
swipeView.setRefreshing(true);
|
||||||
( new Handler()).postDelayed(new Runnable() {
|
( new Handler()).postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
swipeView.setRefreshing(false);
|
swipeView.setRefreshing(false);
|
||||||
}
|
}
|
||||||
}, 3000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -57,15 +80,15 @@ public class TimelineFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||||
if (firstVisibleItem == 0)
|
swipeView.setEnabled(firstVisibleItem == 0);
|
||||||
swipeView.setEnabled(true);
|
|
||||||
else
|
|
||||||
swipeView.setEnabled(false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return view;
|
return timeLineInflater;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start display of the list; uses an adapter and listener in the main activity.
|
||||||
|
*/
|
||||||
public void startList() {
|
public void startList() {
|
||||||
TimeLineAdapter adapter = new TimeLineAdapter(getActivity(), downloadClass.getmList());
|
TimeLineAdapter adapter = new TimeLineAdapter(getActivity(), downloadClass.getmList());
|
||||||
listView.setAdapter(adapter);
|
listView.setAdapter(adapter);
|
||||||
|
|||||||
@@ -11,15 +11,12 @@
|
|||||||
<string name="title_home">Tijdlijn</string>
|
<string name="title_home">Tijdlijn</string>
|
||||||
<string name="title_notifications">Profiel</string>
|
<string name="title_notifications">Profiel</string>
|
||||||
<string name="username">Gebruikersnaam</string>
|
<string name="username">Gebruikersnaam</string>
|
||||||
<string name="confirm_password_hint">bevestig wachtwoord</string>
|
|
||||||
<string name="logo_text">MyHyvesBookPlusTagram logo</string>
|
<string name="logo_text">MyHyvesBookPlusTagram logo</string>
|
||||||
<string name="logout_button">Uitloggen</string>
|
<string name="logout_button">Uitloggen</string>
|
||||||
<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="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="login_error">Voer alstublieft email en wachtwoord in</string>
|
||||||
<string name="mail_failed">Er is een fout opgetreden. Controleer internetverbinding.</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="mail_successful">Er is een e-mail verzonden. Volg a.u.b. de instructies.</string>
|
||||||
@@ -30,9 +27,12 @@
|
|||||||
<string name="image_save_error">Foto opslaan mislukt. Zorg a.u.b. dat er genoeg ruimte op uw telefoon beschikbaar is.</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="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="upload_profile_pic">Profielfoto aan het uploaden…</string>
|
||||||
<string name="mail_success">An e-mail was sent, please follow its instructions.</string>
|
|
||||||
<string name="niet_slecht">Niet Slecht.</string>
|
<string name="niet_slecht">Niet Slecht.</string>
|
||||||
<string name="comment">Bijschrift:</string>
|
<string name="comment">Bijschrift:</string>
|
||||||
<string name="cancel">Annuleer</string>
|
<string name="cancel">Annuleer</string>
|
||||||
<string name="comment_placeholder">Hallo Ik ben een comment!</string>
|
<string name="comment_placeholder">Hallo Ik ben een comment!</string>
|
||||||
|
<string name="refreshing">Verversen…</string>
|
||||||
|
<string name="downloading_posts">Posts worden gedownload…</string>
|
||||||
|
<string name="logging_in">Aan het inloggen</string>
|
||||||
|
<string name="registering">Aan het registreren</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
<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>
|
||||||
<string name="confirm_password_hint">confirm password</string>
|
|
||||||
<string name="login_button">Login</string>
|
<string name="login_button">Login</string>
|
||||||
<string name="register">Register</string>
|
<string name="register">Register</string>
|
||||||
<string name="back_to_login">back to Login</string>
|
<string name="back_to_login">back to Login</string>
|
||||||
@@ -14,8 +13,6 @@
|
|||||||
<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_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>
|
||||||
@@ -33,5 +30,8 @@
|
|||||||
<string name="comment">Comment:</string>
|
<string name="comment">Comment:</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="comment_placeholder">Hello, I am a comment!</string>
|
<string name="comment_placeholder">Hello, I am a comment!</string>
|
||||||
<string name="mail_success">Er is een e-mail verzonden. Volg a.u.b. de instructies.</string>
|
<string name="refreshing">Refreshing…</string>
|
||||||
|
<string name="downloading_posts">Downloading posts…</string>
|
||||||
|
<string name="registering">Registering</string>
|
||||||
|
<string name="logging_in">Logging in</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user