Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into stamps
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/main/java/com/example/drp25/MatchActivity.kt
  • Loading branch information
hettysymes committed Jun 13, 2023
2 parents a29c12b + 60f4ec2 commit c86f7ca
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 73 deletions.
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.drp25">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
Expand All @@ -14,6 +13,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.DRP25"
tools:targetApi="31">
<activity
android:name=".StampActivity"
android:exported="false" />
<activity
android:name=".UserActivity"
android:exported="true">
Expand Down
57 changes: 57 additions & 0 deletions app/src/main/java/com/example/drp25/StampActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.example.drp25

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener

class StampActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_stamp)

val selectedMatchName:String? = intent.getStringExtra("selectedMatchName")

/* Functionality for SEND button -> takes user to chat page. */
val sendBtn = findViewById<Button>(R.id.match_send_button)
sendBtn.setOnClickListener { view ->
val intent = Intent(this, ChatActivity::class.java)
intent.putExtra("fromMatch", true)
intent.putExtra("matchedName", selectedMatchName)
startActivity(intent)
}

// Set up stamps
val stamp1 = findViewById<ImageView>(R.id.stamp_option_1)
val stamp2 = findViewById<ImageView>(R.id.stamp_option_2)
val stamp3 = findViewById<ImageView>(R.id.stamp_option_3)

val nationalityRef = FirebaseDatabase.getInstance().reference.child("universities")
.child(UNI_ID).child("users").child(USER_ID).child("nationality")

nationalityRef.addValueEventListener(object: ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
val nationality = snapshot.value as String
if (nationality == "Chinese") {
stamp1.setImageResource(R.drawable.china_flag_stamp)
stamp2.setImageResource(R.drawable.china_tourist_stamp)
stamp3.setImageResource(R.drawable.china_food_stamp)
} else if (nationality == "British") {
stamp1.setImageResource(R.drawable.britain_flag_stamp)
stamp2.setImageResource(R.drawable.britain_tourist_stamp)
stamp3.setImageResource(R.drawable.britain_food_stamp)
}
}

override fun onCancelled(error: DatabaseError) {
TODO("Not yet implemented")
}

})
}
}
74 changes: 3 additions & 71 deletions app/src/main/res/layout/activity_match.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
android:contentDescription="@string/matches_descr"
app:layout_constraintTop_toBottomOf="@id/match_caption"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_percent="0.4"
app:layout_constraintVertical_bias="0.1"
app:layout_constraintHeight_percent="0.65"
app:layout_constraintVertical_bias="0.35"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintWidth_percent="0.6">
app:layout_constraintWidth_percent="0.65">

<LinearLayout
android:id="@+id/match_matches"
Expand Down Expand Up @@ -73,72 +73,4 @@
<!-- app:layout_constraintBottom_toBottomOf="@id/matches_scroll_view"-->
<!-- app:layout_constraintStart_toEndOf="@id/matches_scroll_view" />-->

<TextView
android:id="@+id/match_prompt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/match_prompt"
android:textAlignment="center"
android:textSize="24sp"
android:layout_margin="@dimen/text_margin_32"
app:layout_constraintTop_toBottomOf="@id/matches_scroll_view" />

<!-- Stamp Display -->

<ImageView
android:id="@+id/stamp_option_1"
android:layout_width="125dp"
android:layout_height="125dp"
android:scaleType="centerCrop"
android:layout_margin="@dimen/margin_16"
android:contentDescription="@string/profile_picture_descr"
android:scaleX="0.75"
android:scaleY="0.75"
android:src="@drawable/stream_ui_picture_placeholder"
app:layout_constraintTop_toBottomOf="@id/match_prompt"
app:layout_constraintBottom_toTopOf="@+id/match_send_button"
app:layout_constraintStart_toStartOf="parent"/>

<ImageView
android:id="@+id/stamp_option_2"
android:layout_width="125dp"
android:layout_height="125dp"
android:scaleType="centerCrop"
android:layout_margin="@dimen/margin_16"
android:contentDescription="@string/profile_picture_descr"
android:scaleX="0.75"
android:scaleY="0.75"
android:src="@drawable/stream_ui_picture_placeholder"
app:layout_constraintTop_toBottomOf="@id/match_prompt"
app:layout_constraintBottom_toTopOf="@id/match_send_button"
app:layout_constraintStart_toEndOf="@id/stamp_option_1"
app:layout_constraintEnd_toStartOf="@id/stamp_option_3"/>

<ImageView
android:id="@+id/stamp_option_3"
android:layout_width="125dp"
android:layout_height="125dp"
android:scaleType="centerCrop"
android:layout_margin="@dimen/margin_16"
android:contentDescription="@string/profile_picture_descr"
android:scaleX="0.75"
android:scaleY="0.75"
android:src="@drawable/stream_ui_picture_placeholder"
app:layout_constraintTop_toBottomOf="@id/match_prompt"
app:layout_constraintBottom_toTopOf="@id/match_send_button"
app:layout_constraintEnd_toEndOf="parent"/>

<!-- Send Button -->

<Button
android:id="@+id/match_send_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="@dimen/button_send"
android:text="@string/match_send_button"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
112 changes: 112 additions & 0 deletions app/src/main/res/layout/activity_stamp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?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"
tools:context=".StampActivity">

<TextView
android:id="@+id/match_prompt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/match_prompt"
android:textAlignment="center"
android:textSize="24sp"
android:layout_margin="@dimen/text_margin_32"
app:layout_constraintTop_toTopOf="parent" />

<!-- Stamp Display -->

<!--
<ImageView
android:id="@+id/stamp_option_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_16"
android:contentDescription="@string/profile_picture_descr"
android:scaleX="0.75"
android:scaleY="0.75"
android:src="@drawable/stream_ui_picture_placeholder"
app:layout_constraintTop_toBottomOf="@id/match_prompt"
app:layout_constraintBottom_toTopOf="@+id/match_send_button"
app:layout_constraintStart_toStartOf="parent"/>
<ImageView
android:id="@+id/stamp_option_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_16"
android:contentDescription="@string/profile_picture_descr"
android:scaleX="0.75"
android:scaleY="0.75"
android:src="@drawable/stream_ui_picture_placeholder"
app:layout_constraintTop_toBottomOf="@id/match_prompt"
app:layout_constraintBottom_toTopOf="@id/match_send_button"
app:layout_constraintStart_toEndOf="@id/stamp_option_1"
app:layout_constraintEnd_toStartOf="@id/stamp_option_3"/>
<ImageView
android:id="@+id/stamp_option_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_16"
android:contentDescription="@string/profile_picture_descr"
android:scaleX="0.75"
android:scaleY="0.75"
android:src="@drawable/stream_ui_picture_placeholder"
app:layout_constraintTop_toBottomOf="@id/match_prompt"
app:layout_constraintBottom_toTopOf="@id/match_send_button"
app:layout_constraintEnd_toEndOf="parent"/>
-->

<ImageView
android:id="@+id/stamp_option_1"
android:layout_width="125dp"
android:layout_height="125dp"
android:scaleType="centerCrop"
android:contentDescription="@string/profile_picture_descr"
android:src="@drawable/stream_ui_picture_placeholder"
app:layout_constraintTop_toBottomOf="@id/match_prompt"
app:layout_constraintBottom_toTopOf="@id/stamp_option_2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<ImageView
android:id="@+id/stamp_option_2"
android:layout_width="125dp"
android:layout_height="125dp"
android:scaleType="centerCrop"
android:contentDescription="@string/profile_picture_descr"
android:src="@drawable/stream_ui_picture_placeholder"
app:layout_constraintTop_toBottomOf="@id/stamp_option_1"
app:layout_constraintBottom_toTopOf="@id/stamp_option_3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<ImageView
android:id="@+id/stamp_option_3"
android:layout_width="125dp"
android:layout_height="125dp"
android:scaleType="centerCrop"
android:contentDescription="@string/profile_picture_descr"
android:src="@drawable/stream_ui_picture_placeholder"
app:layout_constraintTop_toBottomOf="@id/stamp_option_2"
app:layout_constraintBottom_toTopOf="@id/match_send_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<!-- Send Button -->

<Button
android:id="@+id/match_send_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="@dimen/button_send"
android:text="@string/match_send_button"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit c86f7ca

Please sign in to comment.