Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-Adding Friend Page features after reset #43

Merged
merged 26 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
34dc8b1
Re-Adding Friend Page features after reset
bhvrgav Mar 24, 2022
5bf2ed8
Implemented Button Clickability
bhvrgav Mar 29, 2022
5c2857d
Merge branch 'main' into feat/friendspage
bhvrgav Mar 29, 2022
5b71e18
Merge branch 'main' into feat/friendspage
bhvrgav Mar 31, 2022
ece49de
Add Friends Page to bottom navigation
bhvrgav Mar 31, 2022
703a9a3
Attempt to write tests
bhvrgav Mar 31, 2022
63bfe88
Merge branch 'main' into feat/friendspage
bhvrgav Apr 2, 2022
34a7cea
Added PlayerInfo Fragment & Navigations
bhvrgav Apr 2, 2022
8706c33
Created DataObject to pass dummy info
bhvrgav Apr 2, 2022
7a4694f
Create Data Object for Mock Data & Wrote some tests
bhvrgav Apr 2, 2022
bb67074
Connected InfoPage, Added navigation and wrote tests
bhvrgav Apr 4, 2022
7469ed7
Merge with main
bhvrgav Apr 4, 2022
8f9c6bb
Revert "Merge with main"
bhvrgav Apr 4, 2022
4ba4d52
Revert "Revert "Merge with main""
bhvrgav Apr 4, 2022
b5c17e1
Removed an unnecessary fragment
bhvrgav Apr 4, 2022
a7d7c5a
Merge branch 'main' into feat/friendspage
bhvrgav Apr 6, 2022
6f93947
Small edit in tests
bhvrgav Apr 6, 2022
70d5aab
Merge branch 'main' into feat/friendspage
bhvrgav Apr 6, 2022
573be61
Fixed git issue
bhvrgav Apr 6, 2022
4512f66
minor addition
bhvrgav Apr 7, 2022
2e56644
Merge branch 'main' into feat/friendspage
gaetschwartz Apr 7, 2022
77c0d6a
Fix for navigation error
bhvrgav Apr 7, 2022
c9c12e4
Changed location of FriendsInfo data file
bhvrgav Apr 7, 2022
695c7ec
Merge branch 'main' into feat/friendspage
bhvrgav Apr 7, 2022
12fd236
Fixed build for bar
leonardopennino Apr 7, 2022
3227ad9
Remove checkBackHome test
bhvrgav Apr 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions app/src/main/java/ch/epfl/sweng/rps/ui/friends/FriendList.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package ch.epfl.sweng.rps.ui.friends

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import ch.epfl.sweng.rps.FriendListAdapter
import ch.epfl.sweng.rps.R

class FriendList : Fragment() {

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_friend_list, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val friends = listOf(
FriendsInfo("RPSKing88", 120, 76, 63.3, true),
FriendsInfo("Meliodas19", 220, 110, 50.0, true),
FriendsInfo("Urtrash", 86, 32, 37.2, true),
FriendsInfo("Ben10", 14, 12, 85.7, true),
FriendsInfo("JustGary", 455, 343, 75.4, false),
FriendsInfo("RockFirst", 141, 118, 83.7, false),
FriendsInfo("ulose", 63, 28, 44.4, false),
FriendsInfo("GameMstr", 90, 12, 13.3, false),
FriendsInfo("Narut0", 312, 211, 67.6, false),
FriendsInfo("Insomnix", 166, 65, 39.2, false)
)
val recyclerView = view.findViewById<RecyclerView>(R.id.friendListRecyclerView)

recyclerView.layoutManager = LinearLayoutManager(activity)
recyclerView.adapter = FriendListAdapter(friends)

}

}
12 changes: 12 additions & 0 deletions app/src/main/java/ch/epfl/sweng/rps/ui/friends/FriendsInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ch.epfl.sweng.rps.ui.friends

data class FriendsInfo(
val username : String,
val gamesPlayed : Int,
val gamesWon : Int,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit weird to me to have this class here. But I am not sure. Maybe this could be in models??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, let me move that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will also work on changing to UI in the next sprint to match the rest of the application. Didn't have enough time for that this week

val winRate : Double,
val isOnline : Boolean
)



Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package ch.epfl.sweng.rps

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import ch.epfl.sweng.rps.ui.friends.FriendsInfo

class FriendListAdapter(private val friends : List<FriendsInfo>) : RecyclerView.Adapter<FriendListAdapter.CardViewHolder>(){


class CardViewHolder(val view : View) : RecyclerView.ViewHolder(view) {
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CardViewHolder {
return CardViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.friend_card2, parent, false)
)
}

@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: CardViewHolder, position: Int) {
val friend = friends[position]

holder.view.findViewById<TextView>(R.id.friendName).text = friend.username
holder.view.findViewById<TextView>(R.id.winRateText).text = "Win Rate: " + friend.winRate + "%"
holder.view.findViewById<TextView>(R.id.gamesPlayedText).text = "Games Played: " + friend.gamesPlayed
holder.view.findViewById<TextView>(R.id.gamesWonText).text = "Games Won: " + friend.gamesWon
holder.view.findViewById<ImageView>(R.id.onlineImage).visibility = if(friend.isOnline) View.VISIBLE else View.INVISIBLE
holder.view.findViewById<ImageView>(R.id.offlineImage).visibility = if(friend.isOnline) View.INVISIBLE else View.VISIBLE


}

override fun getItemCount(): Int {
return friends.size
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/challenge_vector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="35dp" android:tint="#C84B31"
android:viewportHeight="24" android:viewportWidth="24"
android:width="35dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M21.58,16.09l-1.09,-7.66C20.21,6.46 18.52,5 16.53,5H7.47C5.48,5 3.79,6.46 3.51,8.43l-1.09,7.66C2.2,17.63 3.39,19 4.94,19h0c0.68,0 1.32,-0.27 1.8,-0.75L9,16h6l2.25,2.25c0.48,0.48 1.13,0.75 1.8,0.75h0C20.61,19 21.8,17.63 21.58,16.09zM11,11H9v2H8v-2H6v-1h2V8h1v2h2V11zM15,10c-0.55,0 -1,-0.45 -1,-1c0,-0.55 0.45,-1 1,-1s1,0.45 1,1C16,9.55 15.55,10 15,10zM17,13c-0.55,0 -1,-0.45 -1,-1c0,-0.55 0.45,-1 1,-1s1,0.45 1,1C18,12.55 17.55,13 17,13z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_friends_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M16,11c1.66,0 2.99,-1.34 2.99,-3S17.66,5 16,5c-1.66,0 -3,1.34 -3,3s1.34,3 3,3zM8,11c1.66,0 2.99,-1.34 2.99,-3S9.66,5 8,5C6.34,5 5,6.34 5,8s1.34,3 3,3zM8,13c-2.33,0 -7,1.17 -7,3.5L1,19h14v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5zM16,13c-0.29,0 -0.62,0.02 -0.97,0.05 1.16,0.84 1.97,1.97 1.97,3.45L17,19h6v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/info_vector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="32dp" android:tint="#C84B31"
android:viewportHeight="24" android:viewportWidth="24"
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/menu_vector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="30dp" android:tint="#ECDBBA"
android:viewportHeight="24" android:viewportWidth="24"
android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
</vector>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/offline_vector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<vector android:height="30dp" android:tint="#8A8887"
android:viewportHeight="24" android:viewportWidth="24"
android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M15.5,9.5m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0"/>
<path android:fillColor="@android:color/white" android:pathData="M8.5,9.5m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0"/>
<path android:fillColor="@android:color/white" android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8zM12,16.5c0.73,0 1.39,0.19 1.97,0.53 0.12,-0.14 0.86,-0.98 1.01,-1.14 -0.85,-0.56 -1.87,-0.89 -2.98,-0.89 -1.11,0 -2.13,0.33 -2.99,0.88 0.97,1.09 0.01,0.02 1.01,1.14 0.59,-0.33 1.25,-0.52 1.98,-0.52z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/online_vector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="30dp" android:tint="#80CB35"
android:viewportHeight="24" android:viewportWidth="24"
android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8zM15.5,11c0.83,0 1.5,-0.67 1.5,-1.5S16.33,8 15.5,8 14,8.67 14,9.5s0.67,1.5 1.5,1.5zM8.5,11c0.83,0 1.5,-0.67 1.5,-1.5S9.33,8 8.5,8 7,8.67 7,9.5 7.67,11 8.5,11zM12,17.5c2.33,0 4.31,-1.46 5.11,-3.5L6.89,14c0.8,2.04 2.78,3.5 5.11,3.5z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/plus_vector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="30dp" android:tint="#0B2D39"
android:viewportHeight="24" android:viewportWidth="24"
android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/rounded_corners.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="12dp"/>
</shape>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/search_vector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="30dp" android:tint="#ECDBBA"
android:viewportHeight="24" android:viewportWidth="24"
android:width="30dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>
72 changes: 72 additions & 0 deletions app/src/main/res/layout/fragment_friend_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primary"
tools:context=".ui.friends.FriendList">

<ImageButton
android:id="@+id/addButton"
android:layout_width="73dp"
android:layout_height="54dp"
android:layout_marginStart="3dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="5dp"
android:background="@drawable/rounded_corners"
android:backgroundTint="@color/secondary"
android:src="@drawable/search_vector"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/myFriends"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="SpeakableTextPresentCheck" />

<TextView
android:id="@+id/myFriends"
android:layout_width="216dp"
android:layout_height="54dp"
android:layout_marginTop="3dp"
android:background="@drawable/rounded_corners"
android:backgroundTint="@color/tertiary2"
android:gravity="center"
android:text="@string/friends"
android:textColor="@color/secondary"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/addButton"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/menuButton"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/menuButton"
android:layout_width="73dp"
android:layout_height="54dp"
android:layout_marginStart="5dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="3dp"
android:background="@drawable/rounded_corners"
android:backgroundTint="@color/secondary"
android:src="@drawable/menu_vector"
app:layout_constraintEnd_toStartOf="@+id/myFriends"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="SpeakableTextPresentCheck,SpeakableTextPresentCheck" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/friendListRecyclerView"
tools:listitem="@layout/friend_card2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:layout_marginTop="60dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/myFriends" />


</androidx.constraintlayout.widget.ConstraintLayout>
130 changes: 130 additions & 0 deletions app/src/main/res/layout/friend_card2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">

<androidx.cardview.widget.CardView
android:id="@+id/friendCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="15dp"
app:cardBackgroundColor="@color/secondary"
app:cardCornerRadius="12sp"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="10dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cardConstraint"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/friendName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:text="RPSKing88"
android:textColor="@color/tertiary2"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/onlineImage"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/onlineImage"
android:layout_width="39dp"
android:layout_height="42dp"
android:layout_marginStart="5dp"
android:src="@drawable/online_vector"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/offlineImage"
android:layout_width="39dp"
android:layout_height="42dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/friendName"
app:layout_constraintHorizontal_bias="0.545"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/offline_vector" />

<ImageButton
android:id="@+id/playButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/rounded_corners"
android:backgroundTint="@color/tertiary2"
android:src="@drawable/challenge_vector"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageButton
android:id="@+id/infoButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/rounded_corners"
android:backgroundTint="@color/tertiary2"
android:src="@drawable/info_vector"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/playButton"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/winRateText"
android:layout_width="100dp"
android:layout_height="18dp"
android:layout_marginBottom="10dp"
android:lines="3"
android:maxLines="3"
android:text="Win Rate: 63.3%"
android:textColor="@color/tertiary2"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/infoButton"
app:layout_constraintTop_toBottomOf="@+id/gamesWonText" />

<TextView
android:id="@+id/gamesPlayedText"
android:layout_width="100dp"
android:layout_height="18dp"
android:layout_marginTop="10dp"
android:lines="3"
android:maxLines="3"
android:text="Games Played: 120"
android:textColor="@color/tertiary2"
android:textSize="10sp"
app:layout_constraintBottom_toTopOf="@+id/gamesWonText"
app:layout_constraintEnd_toStartOf="@+id/infoButton"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/gamesWonText"
android:layout_width="100dp"
android:layout_height="18dp"
android:lines="3"
android:maxLines="3"
android:text="Games Won: 76"
android:textColor="@color/tertiary2"
android:textSize="10sp"
app:layout_constraintBottom_toTopOf="@+id/winRateText"
app:layout_constraintEnd_toStartOf="@+id/infoButton"
app:layout_constraintTop_toBottomOf="@+id/gamesPlayedText" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
Loading