-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into stamps
# Conflicts: # app/src/main/java/com/example/drp25/MatchActivity.kt
- Loading branch information
Showing
4 changed files
with
176 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
|
||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |