Merge branch 'paul-profile' into 'master'
Paul profile See merge request !6
@@ -26,11 +26,14 @@ dependencies {
|
|||||||
})
|
})
|
||||||
compile 'com.android.support:appcompat-v7:25.3.1'
|
compile 'com.android.support:appcompat-v7:25.3.1'
|
||||||
compile 'com.android.support:design:25.3.1'
|
compile 'com.android.support:design:25.3.1'
|
||||||
compile 'com.google.firebase:firebase-database:10.0.1'
|
compile 'com.google.firebase:firebase-database:11.0.1'
|
||||||
compile 'com.google.firebase:firebase-auth:10.0.1'
|
compile 'com.google.firebase:firebase-auth:11.0.1'
|
||||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||||
compile 'com.android.support:support-v4:25.3.1'
|
compile 'com.android.support:support-v4:25.3.1'
|
||||||
compile 'com.google.firebase:firebase-storage:10.0.1'
|
compile 'com.google.firebase:firebase-storage:11.0.1'
|
||||||
|
|
||||||
|
// FirebaseUI Storage only
|
||||||
|
compile 'com.firebaseui:firebase-ui-storage:2.0.1'
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Make modular for use with Profile fragment.
|
||||||
/**
|
/**
|
||||||
* Saves the Username to Firebase
|
* Saves the Username to Firebase
|
||||||
* @param user The User object that needs to be updated
|
* @param user The User object that needs to be updated
|
||||||
|
|||||||
@@ -1,13 +1,33 @@
|
|||||||
package nl.myhyvesbookplus.tagram;
|
package nl.myhyvesbookplus.tagram;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
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.Button;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.firebase.ui.storage.images.FirebaseImageLoader;
|
||||||
|
import com.google.android.gms.tasks.OnCompleteListener;
|
||||||
|
import com.google.android.gms.tasks.Task;
|
||||||
|
import com.google.firebase.auth.FirebaseAuth;
|
||||||
|
import com.google.firebase.auth.FirebaseUser;
|
||||||
|
import com.google.firebase.storage.FirebaseStorage;
|
||||||
|
import com.google.firebase.storage.StorageReference;
|
||||||
|
|
||||||
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
@@ -17,7 +37,7 @@ import android.view.ViewGroup;
|
|||||||
* Use the {@link ProfileFragment#newInstance} factory method to
|
* Use the {@link ProfileFragment#newInstance} factory method to
|
||||||
* create an instance of this fragment.
|
* create an instance of this fragment.
|
||||||
*/
|
*/
|
||||||
public class ProfileFragment extends Fragment {
|
public class ProfileFragment extends Fragment implements View.OnClickListener {
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
// TODO: Rename parameter arguments, choose names that match
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||||
private static final String ARG_PARAM1 = "param1";
|
private static final String ARG_PARAM1 = "param1";
|
||||||
@@ -27,11 +47,21 @@ public class ProfileFragment extends Fragment {
|
|||||||
private String mParam1;
|
private String mParam1;
|
||||||
private String mParam2;
|
private String mParam2;
|
||||||
|
|
||||||
private OnFragmentInteractionListener mListener;
|
/// Views ///
|
||||||
|
|
||||||
|
protected Button changePwdButton;
|
||||||
|
protected ImageButton profilePicButton;
|
||||||
|
protected StorageReference httpsReference;
|
||||||
|
protected TextView profileName;
|
||||||
|
protected ImageView profilePicture;
|
||||||
|
|
||||||
|
private OnFragmentInteractionListener mListener;
|
||||||
|
protected FirebaseUser user;
|
||||||
|
|
||||||
|
/// Required empty public constructor ///
|
||||||
|
|
||||||
|
public ProfileFragment() {}
|
||||||
|
|
||||||
public ProfileFragment() {
|
|
||||||
// Required empty public constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this factory method to create a new instance of
|
* Use this factory method to create a new instance of
|
||||||
@@ -58,13 +88,48 @@ public class ProfileFragment extends Fragment {
|
|||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user = FirebaseAuth.getInstance().getCurrentUser();
|
||||||
|
if (user != null && user.getPhotoUrl() != null) {
|
||||||
|
httpsReference = FirebaseStorage.getInstance().getReferenceFromUrl(user.getPhotoUrl().toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigns all views.
|
||||||
|
*/
|
||||||
|
protected void findViews(View view) {
|
||||||
|
profilePicButton = (ImageButton) view.findViewById(R.id.profile_pic_button);
|
||||||
|
profilePicture = (ImageView) view.findViewById(R.id.imageView_profile_picture);
|
||||||
|
profileName = (TextView) view.findViewById(R.id.profile_name);
|
||||||
|
changePwdButton = (Button) view.findViewById(R.id.change_psw_button);
|
||||||
|
bindOnClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void bindOnClick() {
|
||||||
|
profilePicButton.setOnClickListener(this);
|
||||||
|
changePwdButton.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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
|
// Inflate the layout for this fragment
|
||||||
return inflater.inflate(R.layout.fragment_profile, container, false);
|
View view = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||||
|
findViews(view);
|
||||||
|
|
||||||
|
if (httpsReference != null) {
|
||||||
|
Glide.with(this).using(new FirebaseImageLoader()).load(httpsReference).into(profilePicture);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Remove check for getDisplayName if all users are required to enter a displayName anyways.
|
||||||
|
if (user != null && user.getDisplayName() != null) {
|
||||||
|
profileName.setText(user.getDisplayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Rename method, update argument and hook method into UI event
|
// TODO: Rename method, update argument and hook method into UI event
|
||||||
@@ -74,6 +139,56 @@ public class ProfileFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a view has been clicked.
|
||||||
|
*
|
||||||
|
* @param v The view that was clicked.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.profile_pic_button:
|
||||||
|
profilePicOnClick();
|
||||||
|
break;
|
||||||
|
case R.id.change_psw_button:
|
||||||
|
changePwdOnClick();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Make this function into its own class for modularity.
|
||||||
|
/**
|
||||||
|
* Performs password reset action.
|
||||||
|
*/
|
||||||
|
public void changePwdOnClick() {
|
||||||
|
if (user != null && user.getEmail() != null) {
|
||||||
|
FirebaseAuth.getInstance().sendPasswordResetEmail(user.getEmail())
|
||||||
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
|
Toast.makeText(getActivity(), task.isSuccessful()
|
||||||
|
? "An e-mail was sent, please follow its instructions."
|
||||||
|
: "An error occurred, please check internet connection.",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 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
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
@@ -85,6 +200,9 @@ public class ProfileFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obligatory onDetach function included in fragments.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDetach() {
|
public void onDetach() {
|
||||||
super.onDetach();
|
super.onDetach();
|
||||||
@@ -96,10 +214,8 @@ public class ProfileFragment extends Fragment {
|
|||||||
* fragment to allow an interaction in this fragment to be communicated
|
* fragment to allow an interaction in this fragment to be communicated
|
||||||
* to the activity and potentially other fragments contained in that
|
* to the activity and potentially other fragments contained in that
|
||||||
* activity.
|
* activity.
|
||||||
* <p>
|
* See the Android Training lesson http://developer.android.com/training/basics/fragments/communicating.html
|
||||||
* See the Android Training lesson <a href=
|
* for more information.
|
||||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
|
||||||
* >Communicating with Other Fragments</a> for more information.
|
|
||||||
*/
|
*/
|
||||||
public interface OnFragmentInteractionListener {
|
public interface OnFragmentInteractionListener {
|
||||||
// TODO: Update argument type and name
|
// TODO: Update argument type and name
|
||||||
|
|||||||
|
After Width: | Height: | Size: 98 KiB |
@@ -14,11 +14,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/hello_camera" />
|
android:text="@string/hello_camera" />
|
||||||
|
|
||||||
<Button
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:onClick="logOutOnClick"
|
|
||||||
android:text="LogOut" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- TODO: Update blank fragment layout -->
|
<!-- TODO: Update blank fragment layout -->
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,81 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="nl.myhyvesbookplus.tagram.ProfileFragment">
|
tools:context="nl.myhyvesbookplus.tagram.ProfileFragment">
|
||||||
|
|
||||||
<!-- TODO: Update blank fragment layout -->
|
<ScrollView
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:text="@string/hello_blank_fragment" />
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="5dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/profile_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="Name:"
|
||||||
|
android:textSize="25sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="10dp" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/profile_pic_button"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginStart="110dp"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:elevation="1dp"
|
||||||
|
app:srcCompat="@android:drawable/ic_menu_camera" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageView_profile_picture"
|
||||||
|
android:contentDescription="@string/profile_picture_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="300dp"
|
||||||
|
app:srcCompat="@drawable/avatar_standard"
|
||||||
|
android:layout_marginTop="-70dp"/>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="25dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/change_psw_button"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:text="@string/change_psw_button"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="20dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/logout_button"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:onClick="logOutOnClick"
|
||||||
|
android:text="@string/logout_button"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 19 KiB |
@@ -13,5 +13,9 @@
|
|||||||
<string name="username">Gebruikersnaam</string>
|
<string name="username">Gebruikersnaam</string>
|
||||||
<string name="confirm_password_hint">bevestig wachtwoord</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="profile_picture_button">Wijzig Profiel Foto</string>
|
||||||
|
<string name="profile_picture_description">profiel foto</string>
|
||||||
|
<string name="change_psw_button">Wachtwoord wijzigen</string>
|
||||||
<string name="please_wait">Wacht a.u.b.</string>
|
<string name="please_wait">Wacht a.u.b.</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -16,5 +16,9 @@
|
|||||||
<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="profile_picture_button">Change Profile Picture</string>
|
||||||
|
<string name="profile_picture_description">profile picture</string>
|
||||||
|
<string name="change_psw_button">Change Password</string>
|
||||||
<string name="please_wait">Please Wait</string>
|
<string name="please_wait">Please Wait</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||