Date: Thu, 29 Jun 2017 00:35:55 +0200
Subject: [PATCH 15/36] Much cleaner code. Known bugs seem to be fixed. Added
extra progressDialog for posts downloading.
---
.../tagram/CameraFragment.java | 117 +++++-------------
.../myhyvesbookplus/tagram/LoginActivity.java | 4 +-
.../myhyvesbookplus/tagram/MainActivity.java | 14 +--
.../tagram/ProfileAdapter.java | 2 +-
.../tagram/ProfileFragment.java | 55 +++++---
.../tagram/TimelineFragment.java | 51 +++++---
.../app/src/main/res/values-nl/strings.xml | 8 +-
.../app/src/main/res/values/strings.xml | 8 +-
8 files changed, 120 insertions(+), 139 deletions(-)
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/CameraFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/CameraFragment.java
index 818fa47..ab95c27 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/CameraFragment.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/CameraFragment.java
@@ -24,27 +24,8 @@ import android.widget.RelativeLayout;
import nl.myhyvesbookplus.tagram.controller.PostUploader;
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{
- // TODO: Rename parameter arguments, choose names that match
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 CameraPreview mPreview;
private Bitmap mPhoto;
@@ -54,33 +35,6 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
// 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
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -98,11 +52,12 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
mCameraLayout.addView(mPreview);
- // Draw buttons over preview
+ // Draw initial buttons over preview
view.findViewById(R.id.picture_button).bringToFront();
view.findViewById(R.id.switch_camera_button).bringToFront();
filterButtons.bringToFront();
+ /* Upon pressing the switch camera facing button: */
(view.findViewById(R.id.switch_camera_button)).setOnClickListener(new View.OnClickListener() {
@Override
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() {
@Override
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() {
@Override
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() {
@Override
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() {
@Override
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() {
@Override
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() {
@Override
public void onClick(View v) {
@@ -256,30 +217,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
}
- // TODO: Rename method, update argument and hook method into UI event
- 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;
- }
-
+ //TODO Niet helemaal zeker wat dit doet.
@Override
public void 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);
}
+ /**
+ * 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) {
Camera c = null;
try {
@@ -301,13 +244,27 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
return c;
}
+
+ /**
+ * Switch between front facing camera and the back camera.
+ */
public void switchFacing() {
if (facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
facing = Camera.CameraInfo.CAMERA_FACING_BACK;
else
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) {
FloatingActionButton upload = (FloatingActionButton) view.findViewById(R.id.upload_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
public void onPause() {
super.onPause();
@@ -346,20 +305,4 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
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.
- *
- * See the Android Training lesson Communicating with Other Fragments 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/LoginActivity.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/LoginActivity.java
index 46befe8..438db9f 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/LoginActivity.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/LoginActivity.java
@@ -181,7 +181,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
* @param passwordString the entered password
*/
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)
.addOnCompleteListener(this, new OnCompleteListener() {
@@ -211,7 +211,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
* @param password the entered 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)
.addOnCompleteListener(this, new OnCompleteListener() {
@Override
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 a6a67e2..28b3a6d 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
@@ -20,9 +20,10 @@ import nl.myhyvesbookplus.tagram.controller.PostUploader;
import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
public class MainActivity extends AppCompatActivity implements
- CameraFragment.OnFragmentInteractionListener,
ProfilePictureUploader.ProfilePictureUpdatedListener,
- DownloadClass.PostDownloadListener, PostUploader.PostUploadListener {
+ DownloadClass.PostDownloadListener,
+ PostUploader.PostUploadListener {
+
final static private String TAG = "MainScreen";
FirebaseAuth mAuth;
@@ -89,11 +90,6 @@ public class MainActivity extends AppCompatActivity implements
finish();
}
- @Override
- public void onFragmentInteraction(Uri uri) {
-
- }
-
public void logOutOnClick(View view) {
FirebaseAuth.getInstance().signOut();
goToLogin();
@@ -107,7 +103,6 @@ public class MainActivity extends AppCompatActivity implements
@Override
public void ProfilePictureUpdated(Boolean success) {
- Log.d(TAG, "ProfilePictureUpdated: Ja ik luister naar je!");
FragmentManager man = getFragmentManager();
ProfileFragment frag = (ProfileFragment) man.findFragmentById(R.id.content);
FragmentTransaction transaction = man.beginTransaction();
@@ -123,9 +118,12 @@ public class MainActivity extends AppCompatActivity implements
FragmentManager fragmentManager = getFragmentManager();
Fragment frag = fragmentManager.findFragmentById(R.id.content);
+
+
if (frag instanceof ProfileFragment) {
((ProfileFragment) frag).startList();
} else if (frag instanceof TimelineFragment) {
+ ((TimelineFragment) frag).progressDialog.dismiss();
((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 357876a..3bff416 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
@@ -70,7 +70,7 @@ public class ProfileAdapter extends BaseAdapter {
return newRowView;
}
- protected View findViews(View rowView) {
+ private 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 b6cfce8..6f1c334 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
@@ -37,8 +37,9 @@ import static android.app.Activity.RESULT_OK;
public class ProfileFragment extends Fragment implements View.OnClickListener {
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 ImageButton profilePicButton;
protected StorageReference httpsReference;
@@ -46,17 +47,19 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
protected ImageView profilePicture;
protected FirebaseUser user;
protected File photoFile;
+
private ListView listView;
private DownloadClass downloadClass;
private View headerInflater;
private View timeLineInflater;
- ProgressDialog progressDialog;
-
- /// Required empty public constructor ///
-
+ /* Required empty public constructor */
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
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -75,6 +78,9 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
bindOnClick();
}
+ /**
+ * Assign the ListView and add the header to it.
+ */
protected void findTimelineViews() {
listView = (ListView) timeLineInflater.findViewById(R.id.list);
listView.addHeaderView(headerInflater);
@@ -88,8 +94,15 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
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
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -123,11 +136,11 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
/**
* Called when a view has been clicked.
*
- * @param v The view that was clicked.
+ * @param view The view that was clicked.
*/
@Override
- public void onClick(View v) {
- switch (v.getId()) {
+ public void onClick(View view) {
+ switch (view.getId()) {
case R.id.profile_pic_button:
profilePicOnClick();
break;
@@ -142,13 +155,13 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
*/
private void profilePicOnClick() {
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) {
- /* 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).show();
+ Toast.makeText(getActivity(), getString(R.string.image_save_error),
+ Toast.LENGTH_LONG).show();
}
if (photoFile != null) {
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() {
ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getOwnPosts());
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.
+ *
* @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 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 {
- // Create an image file name
String imageFileName = "JPEG_" + user.getUid();
File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
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.
*/
@@ -209,8 +228,6 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
Toast.LENGTH_SHORT).show();
}
});
- } else {
- // TODO Add code here for when there is no currently active user.
}
}
}
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 7d41818..c25cc55 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
@@ -1,6 +1,7 @@
package nl.myhyvesbookplus.tagram;
import android.app.Fragment;
+import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
@@ -9,27 +10,48 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListView;
-
-
+import android.widget.Toast;
import nl.myhyvesbookplus.tagram.controller.DownloadClass;
public class TimelineFragment extends Fragment {
+ /* Some protected and private inits */
private ListView listView;
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
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.list);
- final SwipeRefreshLayout swipeView = (SwipeRefreshLayout) view.findViewById(R.id.swipe);
+ View timeLineInflater = inflater.inflate(R.layout.fragment_timeline, container, false);
+ listView = (ListView) timeLineInflater.findViewById(R.id.list);
+ final SwipeRefreshLayout swipeView = (SwipeRefreshLayout) timeLineInflater.findViewById(R.id.swipe);
swipeView.setEnabled(false);
downloadClass = new DownloadClass(getActivity());
@@ -38,15 +60,16 @@ public class TimelineFragment extends Fragment {
swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
- downloadClass = new DownloadClass(getActivity());
downloadClass.getPostsFromServer();
+ Toast.makeText(getActivity(), R.string.refreshing,
+ Toast.LENGTH_LONG).show();
swipeView.setRefreshing(true);
( new Handler()).postDelayed(new Runnable() {
@Override
public void run() {
swipeView.setRefreshing(false);
}
- }, 3000);
+ }, 1000);
}
});
@@ -57,15 +80,15 @@ public class TimelineFragment extends Fragment {
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- if (firstVisibleItem == 0)
- swipeView.setEnabled(true);
- else
- swipeView.setEnabled(false);
+ swipeView.setEnabled(firstVisibleItem == 0);
}
});
- return view;
+ return timeLineInflater;
}
+ /**
+ * Start display of the list; uses an adapter and listener in the main activity.
+ */
public void startList() {
TimeLineAdapter adapter = new TimeLineAdapter(getActivity(), downloadClass.getmList());
listView.setAdapter(adapter);
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 f02108c..f14844b 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
@@ -11,15 +11,12 @@
Tijdlijn
Profiel
Gebruikersnaam
- bevestig wachtwoord
MyHyvesBookPlusTagram logo
Uitloggen
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.
@@ -30,9 +27,12 @@
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…
- An e-mail was sent, please follow its instructions.
Niet Slecht.
Bijschrift:
Annuleer
Hallo Ik ben een comment!
+ Verversen…
+ Posts worden gedownload…
+ Aan het inloggen
+ Aan het registreren
\ 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 afa90b1..3e4425c 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
@@ -6,7 +6,6 @@
Username
Password
Confirm Password
- confirm password
Login
Register
back to Login
@@ -14,8 +13,6 @@
Please fill in email and password
Passwords do not match
Please fill in all the fields
- Hello blank fragment
- Hello Camera
MyHyvesBookPlusTagram logo
Logout
Change Profile Picture
@@ -33,5 +30,8 @@
Comment:
Cancel
Hello, I am a comment!
- Er is een e-mail verzonden. Volg a.u.b. de instructies.
+ Refreshing…
+ Downloading posts…
+ Registering
+ Logging in
--
2.49.1
From 4eed601b7d4e43bdd174c6515dc06f2bd8d7cad8 Mon Sep 17 00:00:00 2001
From: Niels Zwemmer
Date: Thu, 29 Jun 2017 12:50:29 +0200
Subject: [PATCH 16/36] WIP: for Felix
---
.../tagram/CameraFragment.java | 15 ++++-----
.../myhyvesbookplus/tagram/MainActivity.java | 2 +-
.../tagram/ProfileFragment.java | 2 ++
.../tagram/TimelineFragment.java | 13 +++++++-
.../src/main/res/layout/fragment_timeline.xml | 31 +++++++++++++------
5 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/CameraFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/CameraFragment.java
index ab95c27..575b956 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/CameraFragment.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/CameraFragment.java
@@ -39,11 +39,11 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
- ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
- getActivity().findViewById(R.id.content).setPadding(0,0,0,0);
-
final View view = inflater.inflate(R.layout.fragment_camera, container, false);
+ // Hide the action bar
+ ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
+
mCamera = getCameraInstance(facing);
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
@@ -217,16 +217,13 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
}
- //TODO Niet helemaal zeker wat dit doet.
+ /**
+ * Restores the action bar when exiting the fragment.
+ */
@Override
public void onDestroyView() {
super.onDestroyView();
-
- int padding = 16;
- float scale = getResources().getDisplayMetrics().density;
- int dp = (int) (padding * scale + 0.5f);
((AppCompatActivity)getActivity()).getSupportActionBar().show();
- getActivity().findViewById(R.id.content).setPadding(dp,dp,dp,dp);
}
/**
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 28b3a6d..993d195 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
@@ -123,7 +123,7 @@ public class MainActivity extends AppCompatActivity implements
if (frag instanceof ProfileFragment) {
((ProfileFragment) frag).startList();
} else if (frag instanceof TimelineFragment) {
- ((TimelineFragment) frag).progressDialog.dismiss();
+// ((TimelineFragment) frag).progressDialog.dismiss();
((TimelineFragment) frag).startList();
}
}
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 6f1c334..0b88e92 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
@@ -16,6 +16,7 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
+import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
@@ -38,6 +39,7 @@ import static android.app.Activity.RESULT_OK;
public class ProfileFragment extends Fragment implements View.OnClickListener {
static final int REQUEST_TAKE_PHOTO = 1;
ProgressDialog progressDialog;
+ ProgressBar progressBar;
/* Views, buttons and other protected and private inits */
protected Button changePwdButton;
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 c25cc55..f545bd4 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
@@ -5,11 +5,13 @@ import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListView;
+import android.widget.ProgressBar;
import android.widget.Toast;
import nl.myhyvesbookplus.tagram.controller.DownloadClass;
@@ -21,6 +23,7 @@ public class TimelineFragment extends Fragment {
private ListView listView;
private DownloadClass downloadClass;
ProgressDialog progressDialog;
+ ProgressBar progressBar;
/* Required empty public constructor */
public TimelineFragment() {}
@@ -32,7 +35,7 @@ public class TimelineFragment extends Fragment {
@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);
+// progressDialog = ProgressDialog.show(getActivity(), getString(R.string.please_wait), getString(R.string.downloading_posts), false, false);
}
/**
@@ -50,6 +53,13 @@ public class TimelineFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View timeLineInflater = inflater.inflate(R.layout.fragment_timeline, container, false);
+
+// progressBar = new ProgressBar(getActivity());
+ Log.d("TIMELINEFRAGMENT", "onCreateView: PROGRESSBAR");
+ progressBar = (ProgressBar) timeLineInflater.findViewById(R.id.progressbar_timeline);
+ progressBar.setVisibility(View.VISIBLE);
+ progressBar.bringToFront();
+
listView = (ListView) timeLineInflater.findViewById(R.id.list);
final SwipeRefreshLayout swipeView = (SwipeRefreshLayout) timeLineInflater.findViewById(R.id.swipe);
@@ -83,6 +93,7 @@ public class TimelineFragment extends Fragment {
swipeView.setEnabled(firstVisibleItem == 0);
}
});
+ progressBar.setVisibility(View.GONE);
return timeLineInflater;
}
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_timeline.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_timeline.xml
index 4c91e9e..68e3085 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_timeline.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_timeline.xml
@@ -5,19 +5,32 @@
android:orientation="vertical"
tools:context="nl.myhyvesbookplus.tagram.TimelineFragment">
-
+ android:layout_height="match_parent">
-
+
+
-