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

Feat/stats page UI #21

Merged
merged 16 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

11 changes: 11 additions & 0 deletions .idea/misc.xml

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

15 changes: 15 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ plugins {
}
apply plugin: 'com.google.gms.google-services'

jacoco {
toolVersion = "0.8.7"
}

android {
compileSdk 31

Expand Down Expand Up @@ -54,6 +58,17 @@ dependencies {
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-firestore-ktx'
}

configurations.all{
resolutionStrategy {
eachDependency { details ->
if ('org.jacoco' == details.requested.group) {
details.useVersion "0.8.7"
}
}
}
}

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
android:supportsRtl="true"
android:theme="@style/Theme.RockPaperScissors">
<activity
android:name=".DisplayGreeting"
android:parentActivityName=".MainActivity"
android:name=".MatchDetail"
android:exported="false" />
<activity
android:name=".PersonalStats"
android:exported="false" />
<activity
android:name=".DisplayGreeting"
android:exported="false"
android:parentActivityName=".MainActivity" />
<activity
android:name=".MainActivity"
android:exported="true">
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/ch/epfl/sweng/rps/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ class MainActivity : AppCompatActivity() {
startActivity(intent)
}

fun displayPersonalStats(view: View){
val intent = Intent(this, PersonalStats::class.java)
startActivity(intent)

}

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

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class MatchDetail : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_match_detail)
val matchUuid = intent.getStringExtra("matchUuid")
println(matchUuid)
val actionbar = supportActionBar
actionbar?.setDisplayHomeAsUpEnabled(true)
}
override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}
}
80 changes: 80 additions & 0 deletions app/src/main/java/ch/epfl/sweng/rps/PersonalStats.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package ch.epfl.sweng.rps

import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.widget.TableLayout
import android.widget.TableRow
import android.widget.TableRow.LayoutParams
import android.widget.TableRow.LayoutParams.WRAP_CONTENT
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.setPadding


class PersonalStats : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_personal_stats)
val actionbar = supportActionBar
actionbar?.setDisplayHomeAsUpEnabled(true)
addNewRow("0b9d5384-9f1f-11ec-b909-0242ac120002","2022-03-09","test","12", "4:8")
addNewRow("12345","2022-03-10","Jinglun Pan", "3", "2:1")
}
override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}


private fun addNewRow(uuid: String, date:String, opponent:String, mode:String, score: String ) {
val sizeInDp = 5
val statsTable = findViewById<TableLayout>(R.id.statsTable)
val row = TableRow(this)
row.setBackgroundColor(
Color.parseColor("#F0F7F7"))
val scale = resources.displayMetrics.density
val dpAsPixels = (sizeInDp * scale + 0.5f)
row.isClickable
row.setPadding(dpAsPixels.toInt())
row.tag = uuid
row.setOnClickListener {
val intent = Intent(this, MatchDetail::class.java)
intent.putExtra("matchUuid", row.tag as String)
startActivity(intent)

}
val params = LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1f)
val dateBlank = TextView(this)
val opponentBlank = TextView(this)
val modeBlank = TextView(this)
val scoreBlank = TextView(this)
dateBlank.text = date
opponentBlank.text = opponent
modeBlank.text = mode
scoreBlank.text = score
dateBlank.layoutParams = params
opponentBlank.layoutParams = params
modeBlank.layoutParams = params
scoreBlank.layoutParams = params

row.addView(dateBlank)
row.addView(opponentBlank)
row.addView(modeBlank)
row.addView(scoreBlank)
statsTable.addView(row)

}

fun displayMatchDetail(view: View) {
when(view.id) {
R.id.first_row_uuid -> {
println("good")

}
}

}
}

11 changes: 11 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,15 @@
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/StatsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="1dp"
android:onClick="displayPersonalStats"
android:text="STATS"
app:layout_constraintEnd_toEndOf="@+id/greetingButton"
app:layout_constraintTop_toBottomOf="@+id/greetingButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
111 changes: 111 additions & 0 deletions app/src/main/res/layout/activity_match_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<TableLayout 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:layout_marginTop="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:id="@+id/matchDetailTable"
tools:context=".MatchDetail">

<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Match Detail"
android:textSize="20dp"
android:textStyle="bold">

</TextView>


<TableRow
android:background="#51B435"
android:padding="10dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Player" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Opponent" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Outcome" />
</TableRow>

<TableRow
android:background="#F0F7F7"
android:padding="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="1" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="✋" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="👊" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="🏆" />
</TableRow>

<TableRow
android:background="#F0F7F7"
android:padding="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="2" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="👊" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="✌" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="😞" />

</TableRow>

</TableLayout>
Loading