diff --git a/app/MyHyvesBookPlusStagram/app/build.gradle b/app/MyHyvesBookPlusStagram/app/build.gradle
index c93b672..1a05b0f 100644
--- a/app/MyHyvesBookPlusStagram/app/build.gradle
+++ b/app/MyHyvesBookPlusStagram/app/build.gradle
@@ -4,7 +4,7 @@ android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
- applicationId "nl.myhyvesbookplus.stagram"
+ applicationId "nl.myhyvesbookplus.tagram"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
@@ -37,4 +37,9 @@ dependencies {
+
+
+
+
+
apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml b/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml
index 14b8e95..86ae044 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml
@@ -10,18 +10,17 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
-
-
-
+
+
\ No newline at end of file
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
new file mode 100644
index 0000000..1d258cc
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/CameraFragment.java
@@ -0,0 +1,108 @@
+package nl.myhyvesbookplus.tagram;
+
+import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+
+/**
+ * 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 {
+ // TODO: Rename parameter arguments, choose names that match
+ // 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;
+
+ public CameraFragment() {
+ // 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) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_camera, container, false);
+ }
+
+ // 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;
+ }
+
+ /**
+ * 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 98b1a9d..1adf687 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
@@ -40,6 +40,14 @@ public class LoginActivity extends AppCompatActivity {
findViews();
}
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ /**
+ * Assigns all views.
+ */
protected void findViews() {
passwordConfirmLabel = (TextView) findViewById(R.id.confirm_password_label);
usernameLabel = (TextView) findViewById(R.id.username_label);
@@ -57,14 +65,22 @@ public class LoginActivity extends AppCompatActivity {
/// OnClick ///
+ /**
+ * Performs the logon action.
+ *
+ * @param view
+ */
public void logInOnClick(View view) {
- mAuth.signOut(); // TODO: Remove this after login check is implemented.
String emailSting = emailField.getText().toString();
String passwordSting = passwordField.getText().toString();
logIn(emailSting, passwordSting);
}
+ /**
+ * Performs the register action.
+ * @param view
+ */
public void registerOnClick(View view) {
Log.d(TAG, "registerOnClick: ");
@@ -80,6 +96,10 @@ public class LoginActivity extends AppCompatActivity {
/// UI-changes ///
+ /**
+ * Changes the Activity for registering.
+ * @param view
+ */
public void goToRegisterOnClick(View view) {
passwordConfirmField.setVisibility(View.VISIBLE);
passwordConfirmLabel.setVisibility(View.VISIBLE);
@@ -92,6 +112,10 @@ public class LoginActivity extends AppCompatActivity {
logInButton.setVisibility(View.GONE);
}
+ /**
+ * Changes the Activity for logging in.
+ * @param view
+ */
public void backToLoginOnClick(View view) {
passwordConfirmField.setVisibility(View.GONE);
passwordConfirmLabel.setVisibility(View.GONE);
@@ -104,13 +128,22 @@ public class LoginActivity extends AppCompatActivity {
logInButton.setVisibility(View.VISIBLE);
}
+ /**
+ * Performs intend to Main screen.
+ */
protected void goToMainScreen() {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
+ this.finish();
}
/// FireBase ///
+ /**
+ * Performs the actual login action.
+ * @param emailSting email address
+ * @param passwordSting the entered password
+ */
protected void logIn(String emailSting, String passwordSting) {
mAuth.signInWithEmailAndPassword(emailSting, passwordSting)
.addOnCompleteListener(this, new OnCompleteListener() {
@@ -133,6 +166,11 @@ public class LoginActivity extends AppCompatActivity {
});
}
+ /**
+ * Performs the actual register action
+ * @param email Users email address
+ * @param password the entered password
+ */
protected void registerUser(String email, String password) {
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener() {
@@ -156,6 +194,10 @@ public class LoginActivity extends AppCompatActivity {
});
}
+ /**
+ * Saves the Username to Firebase
+ * @param user The User object that needs to be updated
+ */
protected void updateUserInfo(final FirebaseUser user) {
UserProfileChangeRequest request = new UserProfileChangeRequest.Builder()
.setDisplayName(usernameField.getText().toString())
@@ -173,6 +215,10 @@ public class LoginActivity extends AppCompatActivity {
});
}
+ /**
+ * Sends a confirm email
+ * @param user The User object which the mail needs to be send to
+ */
protected void sendConfirmEmail(FirebaseUser user) {
user.sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener() {
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 8f500bc..97fe34d 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
@@ -1,18 +1,23 @@
package nl.myhyvesbookplus.tagram;
+import android.app.FragmentManager;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
-import android.widget.TextView;
+import android.view.View;
-import com.google.firebase.database.DatabaseReference;
-import com.google.firebase.database.FirebaseDatabase;
+import com.google.firebase.auth.FirebaseAuth;
-public class MainActivity extends AppCompatActivity {
+public class MainActivity extends AppCompatActivity implements CameraFragment.OnFragmentInteractionListener {
+ final static private String TAG = "MainScreen";
+
+ FirebaseAuth mAuth;
+ CameraFragment cameraFragment;
- private TextView mTextMessage;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@@ -20,14 +25,11 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
- case nl.myhyvesbookplus.tagram.R.id.navigation_home:
- mTextMessage.setText(nl.myhyvesbookplus.tagram.R.string.title_home);
+ case nl.myhyvesbookplus.tagram.R.id.navigation_timeline:
return true;
- case nl.myhyvesbookplus.tagram.R.id.navigation_dashboard:
- mTextMessage.setText(nl.myhyvesbookplus.tagram.R.string.title_dashboard);
+ case nl.myhyvesbookplus.tagram.R.id.navigation_camera:
return true;
- case nl.myhyvesbookplus.tagram.R.id.navigation_notifications:
- mTextMessage.setText(nl.myhyvesbookplus.tagram.R.string.title_notifications);
+ case nl.myhyvesbookplus.tagram.R.id.navigation_profile:
return true;
}
return false;
@@ -40,13 +42,38 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(nl.myhyvesbookplus.tagram.R.layout.activity_main);
- mTextMessage = (TextView) findViewById(nl.myhyvesbookplus.tagram.R.id.message);
BottomNavigationView navigation = (BottomNavigationView) findViewById(nl.myhyvesbookplus.tagram.R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
- FirebaseDatabase database = FirebaseDatabase.getInstance();
- DatabaseReference ref = database.getReference();
-// ref.setValue("Hello, Wold!");
- ref.child("Messages").child("child?").setValue("Hallo!");
+
+ FragmentManager fragmentManager = getFragmentManager();
+// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+
+ mAuth = FirebaseAuth.getInstance();
+ if (mAuth.getCurrentUser() == null) {
+ goToLogin();
+ }
+
}
+ @Override
+ public void onBackPressed() {
+// super.onBackPressed();
+ finish();
+ }
+
+ @Override
+ public void onFragmentInteraction(Uri uri) {
+
+ }
+
+ public void logOutOnClick(View view) {
+ FirebaseAuth.getInstance().signOut();
+ goToLogin();
+ this.finish();
+ }
+
+ protected void goToLogin() {
+ Intent goToLogIn = new Intent(this, LoginActivity.class);
+ startActivity(goToLogIn);
+ }
}
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
new file mode 100644
index 0000000..d63c1ed
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java
@@ -0,0 +1,108 @@
+package nl.myhyvesbookplus.tagram;
+
+import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+
+/**
+ * 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 {
+ // TODO: Rename parameter arguments, choose names that match
+ // 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;
+
+ public ProfileFragment() {
+ // 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 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
+ 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) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_profile, container, false);
+ }
+
+ // 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;
+ }
+
+ /**
+ * 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/TimelineFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java
new file mode 100644
index 0000000..4c387cd
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java
@@ -0,0 +1,108 @@
+package nl.myhyvesbookplus.tagram;
+
+import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Activities that contain this fragment must implement the
+ * {@link TimelineFragment.OnFragmentInteractionListener} interface
+ * to handle interaction events.
+ * Use the {@link TimelineFragment#newInstance} factory method to
+ * create an instance of this fragment.
+ */
+public class TimelineFragment extends Fragment {
+ // TODO: Rename parameter arguments, choose names that match
+ // 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;
+
+ public TimelineFragment() {
+ // 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 TimelineFragment.
+ */
+ // TODO: Rename and change types and number of parameters
+ public static TimelineFragment newInstance(String param1, String param2) {
+ TimelineFragment fragment = new TimelineFragment();
+ 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) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_timeline, container, false);
+ }
+
+ // 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;
+ }
+
+ /**
+ * 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/res/layout/activity_login.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/activity_login.xml
index 2235670..f903f24 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/activity_login.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/activity_login.xml
@@ -1,4 +1,4 @@
-
+
+ android:labelFor="@+id/email"
+ android:text="@string/email" />
+ android:labelFor="@+id/password"
+ android:text="@string/password" />
@@ -70,7 +72,7 @@
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:onClick="logInOnClick"
- android:text="Login" />
+ android:text="@string/login_button" />
+ android:text="@string/register" />
-
\ No newline at end of file
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/activity_main.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/activity_main.xml
index de89029..9b9037e 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/activity_main.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/activity_main.xml
@@ -14,16 +14,12 @@
android:layout_height="0dp"
android:layout_weight="1">
-
-
+ android:layout_height="match_parent"
+ tools:layout="@layout/fragment_camera" />
+
+
+
+
+
+
+
+
+
+
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml
new file mode 100644
index 0000000..5394adc
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_timeline.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_timeline.xml
new file mode 100644
index 0000000..629607b
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_timeline.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/menu/navigation.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/menu/navigation.xml
index f4de4f8..83e937f 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/menu/navigation.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/menu/navigation.xml
@@ -2,17 +2,17 @@